Include proxy address in connection messages.
This commit is contained in:
parent
5ca605dadc
commit
aad69df74b
1 changed files with 9 additions and 2 deletions
11
server.go
11
server.go
|
@ -6,6 +6,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"container/list"
|
"container/list"
|
||||||
|
"fmt"
|
||||||
"github.com/conformal/btcdb"
|
"github.com/conformal/btcdb"
|
||||||
"github.com/conformal/btcwire"
|
"github.com/conformal/btcwire"
|
||||||
"github.com/conformal/go-socks"
|
"github.com/conformal/go-socks"
|
||||||
|
@ -249,16 +250,22 @@ func (s *server) ConnectPeerAsync(addr string, persistent bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
// Select which dial method to call depending on whether or
|
||||||
|
// not a proxy is configured. Also, add proxy information to
|
||||||
|
// logged address if needed.
|
||||||
dial := net.Dial
|
dial := net.Dial
|
||||||
|
faddr := addr
|
||||||
if cfg.Proxy != "" {
|
if cfg.Proxy != "" {
|
||||||
proxy := &socks.Proxy{cfg.Proxy, cfg.ProxyUser, cfg.ProxyPass}
|
proxy := &socks.Proxy{cfg.Proxy, cfg.ProxyUser, cfg.ProxyPass}
|
||||||
dial = proxy.Dial
|
dial = proxy.Dial
|
||||||
|
faddr = fmt.Sprintf("%s via proxy %s", addr, cfg.Proxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to connect to the peer. If the connection fails and
|
// Attempt to connect to the peer. If the connection fails and
|
||||||
// this is a persistent connection, retry after the retry
|
// this is a persistent connection, retry after the retry
|
||||||
// interval.
|
// interval.
|
||||||
for !s.shutdown {
|
for !s.shutdown {
|
||||||
log.Debugf("[SRVR] Attempting to connect to %s", addr)
|
log.Debugf("[SRVR] Attempting to connect to %s", faddr)
|
||||||
conn, err := dial("tcp", addr)
|
conn, err := dial("tcp", addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("[SRVR] %v", err)
|
log.Errorf("[SRVR] %v", err)
|
||||||
|
@ -266,7 +273,7 @@ func (s *server) ConnectPeerAsync(addr string, persistent bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Infof("[SRVR] Retrying connection to %s "+
|
log.Infof("[SRVR] Retrying connection to %s "+
|
||||||
"in %s", addr, connectionRetryInterval)
|
"in %s", faddr, connectionRetryInterval)
|
||||||
time.Sleep(connectionRetryInterval)
|
time.Sleep(connectionRetryInterval)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue