mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
support socks proxy in peer url and decouple explicit tor/i2p routing
This commit is contained in:
parent
769b058004
commit
7756891510
5 changed files with 74 additions and 61 deletions
|
@ -66,6 +66,26 @@ func (iface *tcpInterface) listener() {
|
|||
}
|
||||
}
|
||||
|
||||
func (iface *tcpInterface) callWithConn(conn net.Conn) {
|
||||
go func() {
|
||||
raddr := conn.RemoteAddr().String()
|
||||
iface.mutex.Lock()
|
||||
_, isIn := iface.calls[raddr]
|
||||
iface.mutex.Unlock()
|
||||
if !isIn {
|
||||
iface.mutex.Lock()
|
||||
iface.calls[raddr] = struct{}{}
|
||||
iface.mutex.Unlock()
|
||||
defer func() {
|
||||
iface.mutex.Lock()
|
||||
delete(iface.calls, raddr)
|
||||
iface.mutex.Unlock()
|
||||
}()
|
||||
iface.handler(conn)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (iface *tcpInterface) call(saddr string) {
|
||||
go func() {
|
||||
quit := false
|
||||
|
@ -82,7 +102,7 @@ func (iface *tcpInterface) call(saddr string) {
|
|||
}
|
||||
iface.mutex.Unlock()
|
||||
if !quit {
|
||||
conn, err := iface.core.Dialer.Dial("tcp", saddr)
|
||||
conn, err := net.Dial("tcp", saddr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue