multi: Added Tor support

This commit adds Tor support. Users can set the --TorSocks flag
to specify which port Tor's SOCKS5 proxy is listening on so that
lnd can connect to it. When this flag is set, ALL traffic gets
routed over Tor including DNS traffic. Special functions for
DNS lookups were added, and since Tor doesn't natively support
SRV requests, the proxySRV function routes connects us to
a DNS server via Tor and SRV requests can be issued directly
to the DNS server.

Co-authored-by: MeshCollider <dobsonsa68@gmail.com>
This commit is contained in:
nsa
2017-10-20 17:45:23 -04:00
committed by Olaoluwa Osuntokun
parent 18741831dd
commit e2142c778f
8 changed files with 314 additions and 27 deletions

View File

@@ -65,6 +65,12 @@ var (
// channel closure. This key should be accessed from within the
// sub-bucket of a target channel, identified by its channel point.
revocationLogBucket = []byte("revocation-log-key")
// resolveTCP is a resolver that is used to resolve nodes'
// publicly advertised addresses. It is set to net.ResolveTCPAddr
// initially, but the SetResolver function can be used to change this
// to a Tor-specific resolver.
resolveTCP = net.ResolveTCPAddr
)
var (
@@ -389,6 +395,12 @@ type OpenChannel struct {
sync.RWMutex
}
// SetResolver sets resolveTCP to a resolver other than the default
// net.ResolveTCPAddr resolver function.
func SetResolver(resolver func(string, string) (*net.TCPAddr, error)) {
resolveTCP = resolver
}
// FullSync serializes, and writes to disk the *full* channel state, using
// both the active channel bucket to store the prefixed column fields, and the
// remote node's ID to store the remainder of the channel state.