Add SOCKS proxy auth (closes #423)

This commit is contained in:
Neil Alexander 2020-05-09 11:24:32 +01:00
parent 58345ac198
commit 8b180e941a
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 8 additions and 1 deletions

View file

@ -17,6 +17,7 @@ import (
"github.com/yggdrasil-network/yggdrasil-go/src/address"
"github.com/yggdrasil-network/yggdrasil-go/src/crypto"
"github.com/yggdrasil-network/yggdrasil-go/src/util"
"golang.org/x/net/proxy"
"github.com/Arceliar/phony"
)
@ -127,6 +128,11 @@ func (l *link) call(uri string, sintf string) error {
l.tcp.call(u.Host, tcpOpts, sintf)
case "socks":
tcpOpts.socksProxyAddr = u.Host
if u.User != nil {
tcpOpts.socksProxyAuth = &proxy.Auth{}
tcpOpts.socksProxyAuth.User = u.User.Username()
tcpOpts.socksProxyAuth.Password, _ = u.User.Password()
}
l.tcp.call(pathtokens[0], tcpOpts, sintf)
case "tls":
tcpOpts.upgrade = l.tcp.tls.forDialer