Unexport and comment btcDial and btcLookup func.
These functions are at the package level and only apply within btcd, so unexport them to be consistent.
This commit is contained in:
parent
cd3084afcd
commit
d33e9b4165
5 changed files with 18 additions and 6 deletions
|
@ -774,7 +774,7 @@ func hostToNetAddress(host string, port uint16, services btcwire.ServiceFlag) (*
|
||||||
prefix := []byte{0xfd, 0x87, 0xd8, 0x7e, 0xeb, 0x43}
|
prefix := []byte{0xfd, 0x87, 0xd8, 0x7e, 0xeb, 0x43}
|
||||||
ip = net.IP(append(prefix, data...))
|
ip = net.IP(append(prefix, data...))
|
||||||
} else if ip = net.ParseIP(host); ip == nil {
|
} else if ip = net.ParseIP(host); ip == nil {
|
||||||
ips, err := BtcdLookup(host)
|
ips, err := btcdLookup(host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
16
config.go
16
config.go
|
@ -538,14 +538,26 @@ func loadConfig() (*config, []string, error) {
|
||||||
return &cfg, remainingArgs, nil
|
return &cfg, remainingArgs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func BtcdDial(network, address string) (net.Conn, error) {
|
// btcdDial connects to the address on the named network using the appropriate
|
||||||
|
// dial function depending on the address and configuration options. For
|
||||||
|
// example, .onion addresses will be dialed using the onion specific proxy if
|
||||||
|
// one was specified, but will otherwise use the normal dial function (which
|
||||||
|
// could itself use a proxy or not).
|
||||||
|
func btcdDial(network, address string) (net.Conn, error) {
|
||||||
if strings.HasSuffix(address, ".onion") {
|
if strings.HasSuffix(address, ".onion") {
|
||||||
return cfg.oniondial(network, address)
|
return cfg.oniondial(network, address)
|
||||||
}
|
}
|
||||||
return cfg.dial(network, address)
|
return cfg.dial(network, address)
|
||||||
}
|
}
|
||||||
|
|
||||||
func BtcdLookup(host string) ([]net.IP, error) {
|
// btcdLookup returns the correct DNS lookup function to use depending on the
|
||||||
|
// passed host and configuration options. For example, .onion addresses will be
|
||||||
|
// resolved using the onion specific proxy if one was specified, but will
|
||||||
|
// otherwise treat the normal proxy as tor unless --noonion was specified in
|
||||||
|
// which case the lookup will fail. Meanwhile, normal IP addresses will be
|
||||||
|
// resolved using tor if a proxy was specified unless --noonion was also
|
||||||
|
// specified in which case the normal system DNS resolver will be used.
|
||||||
|
func btcdLookup(host string) ([]net.IP, error) {
|
||||||
if strings.HasSuffix(host, ".onion") {
|
if strings.HasSuffix(host, ".onion") {
|
||||||
return cfg.onionlookup(host)
|
return cfg.onionlookup(host)
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ func torLookupIP(host, proxy string) ([]net.IP, error) {
|
||||||
// strings will be returned.
|
// strings will be returned.
|
||||||
func dnsDiscover(seeder string) []net.IP {
|
func dnsDiscover(seeder string) []net.IP {
|
||||||
discLog.Debugf("Fetching list of seeds from %v", seeder)
|
discLog.Debugf("Fetching list of seeds from %v", seeder)
|
||||||
peers, err := BtcdLookup(seeder)
|
peers, err := btcdLookup(seeder)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
discLog.Debugf("Unable to fetch dns seeds from %s: %v",
|
discLog.Debugf("Unable to fetch dns seeds from %s: %v",
|
||||||
seeder, err)
|
seeder, err)
|
||||||
|
|
2
peer.go
2
peer.go
|
@ -1551,7 +1551,7 @@ func newOutboundPeer(s *server, addr string, persistent bool) *peer {
|
||||||
// interval.
|
// interval.
|
||||||
for atomic.LoadInt32(&p.disconnect) == 0 {
|
for atomic.LoadInt32(&p.disconnect) == 0 {
|
||||||
srvrLog.Debugf("Attempting to connect to %s", addr)
|
srvrLog.Debugf("Attempting to connect to %s", addr)
|
||||||
conn, err := BtcdDial("tcp", addr)
|
conn, err := btcdDial("tcp", addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.retryCount += 1
|
p.retryCount += 1
|
||||||
srvrLog.Debugf("Failed to connect to %s: %v",
|
srvrLog.Debugf("Failed to connect to %s: %v",
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
; If the proxy is not tor the the following my be used to prevent using
|
; If the proxy is not tor the the following my be used to prevent using
|
||||||
; tor specific SOCKS queries to lookup addresses (this increases anonymity when
|
; tor specific SOCKS queries to lookup addresses (this increases anonymity when
|
||||||
; tor is used by preventing your IP being leaked via DNS).
|
; tor is used by preventing your IP being leaked via DNS).
|
||||||
;noonion=1
|
; noonion=1
|
||||||
|
|
||||||
; Use an alternative proxy to connect to .onion addresses. The proxy is assumed
|
; Use an alternative proxy to connect to .onion addresses. The proxy is assumed
|
||||||
; to be a Tor node. Non .onion addresses will be contacted with the main proxy
|
; to be a Tor node. Non .onion addresses will be contacted with the main proxy
|
||||||
|
|
Loading…
Add table
Reference in a new issue