mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-24 18:44:08 +02:00
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:
@@ -32,9 +32,19 @@ var _ net.Conn = (*Conn)(nil)
|
||||
// remote peer located at address which has remotePub as its long-term static
|
||||
// public key. In the case of a handshake failure, the connection is closed and
|
||||
// a non-nil error is returned.
|
||||
func Dial(localPriv *btcec.PrivateKey, netAddr *lnwire.NetAddress) (*Conn, error) {
|
||||
func Dial(localPriv *btcec.PrivateKey, netAddr *lnwire.NetAddress,
|
||||
dialer ...func(string, string) (net.Conn, error)) (*Conn, error) {
|
||||
ipAddr := netAddr.Address.String()
|
||||
conn, err := net.Dial("tcp", ipAddr)
|
||||
var conn net.Conn
|
||||
var err error
|
||||
if dialer == nil {
|
||||
// A Tor proxy dial function WAS NOT passed in.
|
||||
conn, err = net.Dial("tcp", ipAddr)
|
||||
} else {
|
||||
// A Tor proxy dial function WAS passed in so we use it instead
|
||||
// of golang's net.Dial.
|
||||
conn, err = dialer[0]("tcp", ipAddr)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@@ -24,6 +24,8 @@ var _ net.Listener = (*Listener)(nil)
|
||||
|
||||
// NewListener returns a new net.Listener which enforces the Brontide scheme
|
||||
// during both initial connection establishment and data transfer.
|
||||
// Note: though this function uses ResolveTCPAddr, we don't need to call the
|
||||
// general lndResolveTCP function since we are resolving a local address.
|
||||
func NewListener(localStatic *btcec.PrivateKey, listenAddr string) (*Listener,
|
||||
error) {
|
||||
addr, err := net.ResolveTCPAddr("tcp", listenAddr)
|
||||
|
Reference in New Issue
Block a user