support socks proxy in peer url and decouple explicit tor/i2p routing

This commit is contained in:
Jeff Becker 2018-04-26 10:23:21 -04:00
parent 769b058004
commit 7756891510
No known key found for this signature in database
GPG key ID: F357B3B42F6F9B05
5 changed files with 74 additions and 61 deletions

View file

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