multi: Added a NetInterface to clean up config.go
This commit adds a new interface named NetInterface and two implementations of it: RegularNet & TorProxyNet. These two structs are used in config.go in an attempt to clean up the code and abstract away the dialer and DNS functions.
This commit is contained in:
1 parent
e132ad8433
commit
8c482f2be7
6 files changed
+99
-87
No files matched your search
+4
-4
@@ -43,11 +43,11 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
// TorDial returns a go-socks proxy dialer function that can be used to make
|
||||
// connections to peers through Tor's exposed socks proxy.
|
||||
func TorDial(socksPort string) func(string, string) (net.Conn, error) {
|
||||
// TorDial returns a connection to a remote peer via Tor's socks proxy. Only
|
||||
// TCP is supported over Tor.
|
||||
func TorDial(address, socksPort string) (net.Conn, error) {
|
||||
p := &socks.Proxy{Addr: localhost + ":" + socksPort}
|
||||
return p.Dial
|
||||
return p.Dial("tcp", address)
|
||||
}
|
||||
|
||||
// TorLookupHost performs DNS resolution on a given hostname via Tor's
|
||||
|
||||
Reference in new issue
Block a user