tor: Allow direct connections to clearnet targets

This commit is contained in:
Adrian-Stefan Mares
2021-06-20 11:14:23 +02:00
parent c733c139e9
commit be666b55b6
3 changed files with 54 additions and 15 deletions

View File

@@ -72,7 +72,7 @@ func (r *ClearNet) ResolveTCPAddr(network, address string) (*net.TCPAddr, error)
return net.ResolveTCPAddr(network, address)
}
// ProxyNet is an implementation of the Net interface that defines behaviour
// ProxyNet is an implementation of the Net interface that defines behavior
// for Tor network connections.
type ProxyNet struct {
// SOCKS is the host:port which Tor's exposed SOCKS5 proxy is listening
@@ -88,6 +88,11 @@ type ProxyNet struct {
// means that our traffic may be harder to correlate as each connection
// will now use a distinct circuit.
StreamIsolation bool
// DirectConnections allows the proxy network to use direct connections
// to non-onion service targets. If enabled, the node IP address will be
// revealed while communicating with such targets.
DirectConnections bool
}
// Dial uses the Tor Dial function in order to establish connections through
@@ -100,7 +105,9 @@ func (p *ProxyNet) Dial(network, address string,
default:
return nil, errors.New("cannot dial non-tcp network via Tor")
}
return Dial(address, p.SOCKS, p.StreamIsolation, timeout)
return Dial(
address, p.SOCKS, p.StreamIsolation, p.DirectConnections, timeout,
)
}
// LookupHost uses the Tor LookupHost function in order to resolve hosts over
@@ -116,7 +123,7 @@ func (p *ProxyNet) LookupSRV(service, proto,
return LookupSRV(
service, proto, name, p.SOCKS, p.DNS,
p.StreamIsolation, timeout,
p.StreamIsolation, p.DirectConnections, timeout,
)
}