-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add User/Pass Authentication to Sock5 Dialer with Tests #189
feat: add User/Pass Authentication to Sock5 Dialer with Tests #189
Conversation
This reverts commit e793764.
@fortuna I will create a separate PR for config package changes to accept config URL with username/password for socks5 after this PR is merged otherwise the config package PR breaks the build. |
transport/socks5/stream_dialer.go
Outdated
} | ||
|
||
// SetUsername sets the username field, ensuring it doesn't exceed 255 bytes in length and is at least 1 byte. | ||
func (c *Credentials) SetUsername(username string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's nave a NewCredentials(username, password) (Credentials, error)
instead. It's easier to use.
transport/socks5/stream_dialer.go
Outdated
// +----+--------+ | ||
// | 1 | 1 | | ||
// +----+--------+ | ||
var subNegotiation [2]byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reuse buffer
transport/socks5/stream_dialer.go
Outdated
return nil, fmt.Errorf("invalid protocol version %v. Expected 5", methodResponse[0]) | ||
} | ||
if methodResponse[1] == 2 { | ||
// 2. Read sub-negotiation version and status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sub-negotiation is a bad name.
Use authentication response/reply instead.
transport/socks5/stream_dialer.go
Outdated
// +----+-----+-------+------+----------+----------+ | ||
// | 1 | 1 | X'00' | 1 | Variable | 2 | | ||
// +----+-----+-------+------+----------+----------+ | ||
var connectResponse [4]byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reuse buffer
Co-authored-by: Vinicius Fortuna <[email protected]>
@fortuna Thanks again for the feedback! I applied your comments; Could you please review this again for me? Btw, |
@fortuna also windows build failed again but I recall you mentioned it is due to some race condition. It sometimes pass for me and sometimes fail even though I am not making any breaking changes... |
Co-authored-by: Vinicius Fortuna <[email protected]>
Co-authored-by: Vinicius Fortuna <[email protected]>
Co-authored-by: Vinicius Fortuna <[email protected]>
Co-authored-by: Vinicius Fortuna <[email protected]>
Co-authored-by: Vinicius Fortuna <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one minor thing
transport/socks5/stream_dialer.go
Outdated
@@ -23,26 +23,54 @@ import ( | |||
"github.com/Jigsaw-Code/outline-sdk/transport" | |||
) | |||
|
|||
// https://datatracker.ietf.org/doc/html/rfc1929 | |||
// Credentials can be nil, and that means no authentication. | |||
type Credentials struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it private
This PR adds username/password authentication to Socks5 dialer. Changes to config package will come in a separate PR to avoid breaking build checks. The config URL for socks5 with authentication would like this:
For testing I am currently using this socks5 server implementation.
TODO