Don't bother parsing listeners if disabled.
This commit is contained in:
parent
3902a71bee
commit
c3a3fbcabf
1 changed files with 8 additions and 5 deletions
13
server.go
13
server.go
|
@ -815,12 +815,14 @@ func newServer(listenAddrs []string, db btcdb.Db, btcnet btcwire.BitcoinNet) (*s
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ipv4Addrs, ipv6Addrs, err := parseListeners(listenAddrs)
|
var listeners []net.Listener
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
listeners := make([]net.Listener, 0, len(ipv4Addrs)+len(ipv6Addrs))
|
|
||||||
if !cfg.DisableListen {
|
if !cfg.DisableListen {
|
||||||
|
ipv4Addrs, ipv6Addrs, err := parseListeners(listenAddrs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
listeners = make([]net.Listener, 0, len(ipv4Addrs)+len(ipv6Addrs))
|
||||||
|
|
||||||
for _, addr := range ipv4Addrs {
|
for _, addr := range ipv4Addrs {
|
||||||
listener, err := net.Listen("tcp4", addr)
|
listener, err := net.Listen("tcp4", addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -840,6 +842,7 @@ func newServer(listenAddrs []string, db btcdb.Db, btcnet btcwire.BitcoinNet) (*s
|
||||||
}
|
}
|
||||||
listeners = append(listeners, listener)
|
listeners = append(listeners, listener)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(listeners) == 0 {
|
if len(listeners) == 0 {
|
||||||
return nil, errors.New("No valid listen address")
|
return nil, errors.New("No valid listen address")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue