Fix SS connector error propagation and SIP002 base64 auth decoding#82
Open
juev wants to merge 1 commit intogo-gost:masterfrom
Open
Fix SS connector error propagation and SIP002 base64 auth decoding#82juev wants to merge 1 commit intogo-gost:masterfrom
juev wants to merge 1 commit intogo-gost:masterfrom
Conversation
- Return err instead of nil in SS TCP/UDP connector Init when NewClientConfig fails, preventing nil pointer dereference in WrapConn - Initialize tcpClient in UDP connector for UDP-over-TCP path - Add decodeSIP002Auth to handle ss://BASE64(method:password)@host:port URL format with RawURLEncoding and StdEncoding fallback - Update buildServiceConfig and buildNodeConfig to decode SIP002 auth for ss* schemes before falling back to standard userinfo parsing - Support RawURLEncoding in parseAuthFromCmd with StdEncoding fallback - Add tests for decodeSIP002Auth, parseAuthFromCmd, and integration tests for buildNodeConfig/buildServiceConfig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Initwas returningnilinstead oferrfromNewClientConfig, causingWrapConnto crash on a nil clientss://BASE64(method:password)@host:port) for command-line-L/-Fflags, withRawURLEncodingandStdEncodingfallbacktcpClientin UDP connector for the UDP-over-TCP code pathProblem
When using gost with a SIP002-style Shadowsocks URI:
Two issues occur:
YWVzLTI1Ni1nY206cGFzc3dvcmQ=aes-256-gcm:password) is passed as-is to the cipher, which fails silently becauseInitreturnsnilinstead of the error:separator in the raw URL), so method and password are never extractedChanges
connector/ss/connector.go,connector/ss/udp/connector.goerrinstead ofnilwhenNewClientConfigfailstcpClientin UDP connectorconfig/cmd/cmd.godecodeSIP002Auth()— detects SIP002 format (userinfo without password), decodes base64 (RawURLEncodingwithStdEncodingfallback), splits on:into method and passwordbuildServiceConfigandbuildNodeConfigto try SIP002 decoding forss*schemes before falling back to standard userinfoparseAuthFromCmdto tryRawURLEncodingbeforeStdEncodingconfig/cmd/cmd_test.go(new)decodeSIP002AuthandparseAuthFromCmdbuildNodeConfigandbuildServiceConfigwith both SIP002 and standard auth formatsTest plan
go build ./...go test -v -race -count=1 ./...gost -L :1080 -F 'ss://YWVzLTI1Ni1nY206cGFzc3dvcmQ@127.0.0.1:8388'starts without panicClosed: go-gost/gost#843