Skip to content

Commit

Permalink
Update config
Browse files Browse the repository at this point in the history
  • Loading branch information
fortuna committed Nov 6, 2024
1 parent 3354513 commit 404aa65
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
4 changes: 2 additions & 2 deletions x/configurl/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ These strategies manipulate packets to bypass SNI-based blocking.
Stream split transport (streams only, package [github.com/Jigsaw-Code/outline-sdk/transport/split])
It takes the length of the prefix. The stream will be split when PREFIX_LENGTH bytes are first written.
It takes a list of count*length pairs meaning splitting the sequence in count segments of the given length. If you omit "[COUNT]*", it's assumed to be 1.
split:[PREFIX_LENGTH]
split:[COUNT1]*[LENGTH1],[COUNT2]*[LENGTH2],...
TLS fragmentation (streams only, package [github.com/Jigsaw-Code/outline-sdk/transport/tlsfrag]).
Expand Down
33 changes: 28 additions & 5 deletions x/configurl/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"fmt"
"strconv"
"strings"

"github.com/Jigsaw-Code/outline-sdk/transport"
"github.com/Jigsaw-Code/outline-sdk/transport/split"
Expand All @@ -29,11 +30,33 @@ func registerSplitStreamDialer(r TypeRegistry[transport.StreamDialer], typeID st
if err != nil {
return nil, err
}
prefixBytesStr := config.URL.Opaque
prefixBytes, err := strconv.Atoi(prefixBytesStr)
if err != nil {
return nil, fmt.Errorf("prefixBytes is not a number: %v. Split config should be in split:<number> format", prefixBytesStr)
configText := config.URL.Opaque
splits := make([]split.RepeatedSplit, 0)
for _, part := range strings.Split(configText, ",") {
var count int
var bytes int64
subparts := strings.Split(strings.TrimSpace(part), "*")
switch len(subparts) {
case 1:
count = 1
bytes, err = strconv.ParseInt(subparts[0], 10, 64)
if err != nil {
return nil, fmt.Errorf("bytes is not a number: %v", subparts[0])
}
case 2:
count, err = strconv.Atoi(subparts[0])
if err != nil {
return nil, fmt.Errorf("count is not a number: %v", subparts[0])
}
bytes, err = strconv.ParseInt(subparts[1], 10, 64)
if err != nil {
return nil, fmt.Errorf("bytes is not a number: %v", subparts[0])
}
default:
return nil, fmt.Errorf("split format must be a comma-separated list of '[$COUNT*]$BYTES' (e.g. '100,5*2'). Got %v", part)
}
splits = append(splits, split.RepeatedSplit{Count: count, Bytes: bytes})
}
return split.NewStreamDialer(sd, split.NewFixedSplitIterator(int64(prefixBytes)))
return split.NewStreamDialer(sd, split.NewRepeatedSplitIterator(splits...))
})
}
2 changes: 1 addition & 1 deletion x/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/Jigsaw-Code/outline-sdk/x
go 1.22

require (
github.com/Jigsaw-Code/outline-sdk v0.0.18-0.20241105230628-4801a034fbaf
github.com/Jigsaw-Code/outline-sdk v0.0.18-0.20241106003301-3354513b85f8
// Use github.com/Psiphon-Labs/psiphon-tunnel-core@staging-client as per
// https://github.com/Psiphon-Labs/psiphon-tunnel-core/?tab=readme-ov-file#using-psiphon-with-go-modules
github.com/Psiphon-Labs/psiphon-tunnel-core v1.0.11-0.20240619172145-03cade11f647
Expand Down
4 changes: 2 additions & 2 deletions x/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/AndreasBriese/bbloom v0.0.0-20170702084017-28f7e881ca57 h1:CVuXDbdzPW
github.com/AndreasBriese/bbloom v0.0.0-20170702084017-28f7e881ca57/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/Jigsaw-Code/outline-sdk v0.0.18-0.20241105230628-4801a034fbaf h1:nJFLb0ukT/K4zyQod4vXLqimWq9ekzgC7i5Q+J3x6Rg=
github.com/Jigsaw-Code/outline-sdk v0.0.18-0.20241105230628-4801a034fbaf/go.mod h1:CFDKyGZA4zatKE4vMLe8TyQpZCyINOeRFbMAmYHxodw=
github.com/Jigsaw-Code/outline-sdk v0.0.18-0.20241106003301-3354513b85f8 h1:3bdohee2xFJmsXYdAB/p1zZRdrKMQlp1kiyNJgCE1OY=
github.com/Jigsaw-Code/outline-sdk v0.0.18-0.20241106003301-3354513b85f8/go.mod h1:CFDKyGZA4zatKE4vMLe8TyQpZCyINOeRFbMAmYHxodw=
github.com/Psiphon-Inc/rotate-safe-writer v0.0.0-20210303140923-464a7a37606e h1:NPfqIbzmijrl0VclX2t8eO5EPBhqe47LLGKpRrcVjXk=
github.com/Psiphon-Inc/rotate-safe-writer v0.0.0-20210303140923-464a7a37606e/go.mod h1:ZdY5pBfat/WVzw3eXbIf7N1nZN0XD5H5+X8ZMDWbCs4=
github.com/Psiphon-Labs/bolt v0.0.0-20200624191537-23cedaef7ad7 h1:Hx/NCZTnvoKZuIBwSmxE58KKoNLXIGG6hBJYN7pj9Ag=
Expand Down

0 comments on commit 404aa65

Please sign in to comment.