Skip to content
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

User/Pass authentication not working, can you give example code? #26

Open
dxjones opened this issue Jan 13, 2019 · 4 comments
Open

User/Pass authentication not working, can you give example code? #26

dxjones opened this issue Jan 13, 2019 · 4 comments

Comments

@dxjones
Copy link

dxjones commented Jan 13, 2019

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?

@OneOfOne
Copy link

Chrome does not support authentication with socks5.

https://bugs.chromium.org/p/chromium/issues/detail?id=256785

@514366607
Copy link

on mac os socks proxy

auth.go:122 method == NoAuth == uint8(0)

[ERR] socks: Failed to authenticate: No supported authentication mechanism

@514366607
Copy link

by safari

@packet-sent
Copy link

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)
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants