mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-26 00:11:36 +00:00
Add SOCKS proxy auth (closes #423)
This commit is contained in:
parent
58345ac198
commit
8b180e941a
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/yggdrasil-network/yggdrasil-go/src/address"
|
"github.com/yggdrasil-network/yggdrasil-go/src/address"
|
||||||
"github.com/yggdrasil-network/yggdrasil-go/src/crypto"
|
"github.com/yggdrasil-network/yggdrasil-go/src/crypto"
|
||||||
"github.com/yggdrasil-network/yggdrasil-go/src/util"
|
"github.com/yggdrasil-network/yggdrasil-go/src/util"
|
||||||
|
"golang.org/x/net/proxy"
|
||||||
|
|
||||||
"github.com/Arceliar/phony"
|
"github.com/Arceliar/phony"
|
||||||
)
|
)
|
||||||
@ -127,6 +128,11 @@ func (l *link) call(uri string, sintf string) error {
|
|||||||
l.tcp.call(u.Host, tcpOpts, sintf)
|
l.tcp.call(u.Host, tcpOpts, sintf)
|
||||||
case "socks":
|
case "socks":
|
||||||
tcpOpts.socksProxyAddr = u.Host
|
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)
|
l.tcp.call(pathtokens[0], tcpOpts, sintf)
|
||||||
case "tls":
|
case "tls":
|
||||||
tcpOpts.upgrade = l.tcp.tls.forDialer
|
tcpOpts.upgrade = l.tcp.tls.forDialer
|
||||||
|
@ -61,6 +61,7 @@ type tcpOptions struct {
|
|||||||
linkOptions
|
linkOptions
|
||||||
upgrade *TcpUpgrade
|
upgrade *TcpUpgrade
|
||||||
socksProxyAddr string
|
socksProxyAddr string
|
||||||
|
socksProxyAuth *proxy.Auth
|
||||||
socksPeerAddr string
|
socksPeerAddr string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,7 +283,7 @@ func (t *tcp) call(saddr string, options tcpOptions, sintf string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
var dialer proxy.Dialer
|
var dialer proxy.Dialer
|
||||||
dialer, err = proxy.SOCKS5("tcp", dialerdst.String(), nil, proxy.Direct)
|
dialer, err = proxy.SOCKS5("tcp", dialerdst.String(), options.socksProxyAuth, proxy.Direct)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user