mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-22 15:20:30 +00:00
Track proxy addr and real peer addr in SOCKS mode
This commit is contained in:
parent
fbf59184ee
commit
58345ac198
@ -61,6 +61,7 @@ type tcpOptions struct {
|
|||||||
linkOptions
|
linkOptions
|
||||||
upgrade *TcpUpgrade
|
upgrade *TcpUpgrade
|
||||||
socksProxyAddr string
|
socksProxyAddr string
|
||||||
|
socksPeerAddr string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *TcpListener) Stop() {
|
func (l *TcpListener) Stop() {
|
||||||
@ -290,6 +291,7 @@ func (t *tcp) call(saddr string, options tcpOptions, sintf string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
t.waitgroup.Add(1)
|
t.waitgroup.Add(1)
|
||||||
|
options.socksPeerAddr = saddr
|
||||||
t.handler(conn, false, options)
|
t.handler(conn, false, options)
|
||||||
} else {
|
} else {
|
||||||
dst, err := net.ResolveTCPAddr("tcp", saddr)
|
dst, err := net.ResolveTCPAddr("tcp", saddr)
|
||||||
@ -379,10 +381,10 @@ func (t *tcp) handler(sock net.Conn, incoming bool, options tcpOptions) {
|
|||||||
stream.init(sock)
|
stream.init(sock)
|
||||||
var name, proto, local, remote string
|
var name, proto, local, remote string
|
||||||
if options.socksProxyAddr != "" {
|
if options.socksProxyAddr != "" {
|
||||||
name = "socks://" + sock.RemoteAddr().String() + "/" + options.socksProxyAddr
|
name = "socks://" + sock.RemoteAddr().String() + "/" + options.socksPeerAddr
|
||||||
proto = "socks"
|
proto = "socks"
|
||||||
local, _, _ = net.SplitHostPort(sock.LocalAddr().String())
|
local, _, _ = net.SplitHostPort(sock.LocalAddr().String())
|
||||||
remote, _, _ = net.SplitHostPort(options.socksProxyAddr)
|
remote, _, _ = net.SplitHostPort(options.socksPeerAddr)
|
||||||
} else {
|
} else {
|
||||||
if upgraded {
|
if upgraded {
|
||||||
proto = options.upgrade.name
|
proto = options.upgrade.name
|
||||||
|
Loading…
Reference in New Issue
Block a user