go-socks5
go-socks5 copied to clipboard
User/Pass authentication not working, can you give example code?
When trying to use the socks5 proxy (with Chrome on a Mac), it fails with this error message:
[ERR] socks: Failed to authenticate: No supported authentication mechanism
I had set the System Preferences on the Mac to use the SOCKS Proxy, and I provided the user and password. The proxy was clearly being contacted, but the authentication step was failing.
Here is the code that attempts to configure socks5 to use the UserPassAuthenticator
.
package main
import socks5 "github.com/armon/go-socks5"
func main() {
cred := socks5.StaticCredentials{"user": "pass"}
conf := &socks5.Config{Credentials: cred}
server, err := socks5.New(conf)
if err != nil {
panic(err)
}
err = server.ListenAndServe("tcp", "127.0.0.1:8000")
if err != nil {
panic(err)
}
}
Can anyone give a simple example showing how UserPassAuthenticator can be used with Chrome/Safari browsers on a Mac?
Chrome does not support authentication with socks5.
https://bugs.chromium.org/p/chromium/issues/detail?id=256785
on mac os socks proxy
auth.go:122 method == NoAuth == uint8(0)
[ERR] socks: Failed to authenticate: No supported authentication mechanism
by safari
If people are still struggling to get it working then here is the solution
func main() {
cred := socks5.StaticCredentials{
"user": "pass",
}
conf := &socks5.Config{
AuthMethods: []socks5.Authenticator{socks5.UserPassAuthenticator{Credentials: cred}},
}
server, err := socks5.New(conf)
if err != nil {
panic(err)
}
err = server.ListenAndServe("tcp", "127.0.0.1:8000")
if err != nil {
panic(err)
}
}