-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding username/password parameters to Socks5 config URL (#204)
- Loading branch information
1 parent
7fa9a1d
commit d0c350c
Showing
5 changed files
with
46 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package config | ||
|
||
import ( | ||
"net/url" | ||
|
||
"github.com/Jigsaw-Code/outline-sdk/transport" | ||
"github.com/Jigsaw-Code/outline-sdk/transport/socks5" | ||
) | ||
|
||
func newSOCKS5StreamDialerFromURL(innerDialer transport.StreamDialer, configURL *url.URL) (transport.StreamDialer, error) { | ||
endpoint := transport.StreamDialerEndpoint{Dialer: innerDialer, Address: configURL.Host} | ||
dialer, err := socks5.NewStreamDialer(&endpoint) | ||
if err != nil { | ||
return nil, err | ||
} | ||
userInfo := configURL.User | ||
if userInfo != nil { | ||
username := userInfo.Username() | ||
password, _ := userInfo.Password() | ||
err := dialer.SetCredentials([]byte(username), []byte(password)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
return dialer, nil | ||
} |
This file contains 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
This file contains 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