Parse out ports from externalip strings if present.
If not, continue to use the default. Should fix a problem reported by Justus Ranvier on github. Closes #38 (again)
This commit is contained in:
parent
7b304515d6
commit
8310661c29
1 changed files with 23 additions and 9 deletions
32
server.go
32
server.go
|
@ -887,19 +887,33 @@ func newServer(listenAddrs []string, db btcdb.Db, btcnet btcwire.BitcoinNet) (*s
|
||||||
discover := true
|
discover := true
|
||||||
if len(cfg.ExternalIPs) != 0 {
|
if len(cfg.ExternalIPs) != 0 {
|
||||||
discover = false
|
discover = false
|
||||||
port, err :=
|
// if this fails we have real issues.
|
||||||
strconv.ParseUint(activeNetParams.listenPort,
|
port, _ := strconv.ParseUint(
|
||||||
10, 16)
|
activeNetParams.listenPort, 10, 16)
|
||||||
if err != nil {
|
|
||||||
srvrLog.Warnf("doubleewteeeff?")
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, sip := range cfg.ExternalIPs {
|
for _, sip := range cfg.ExternalIPs {
|
||||||
na, err := hostToNetAddress(sip, uint16(port),
|
eport := uint16(port)
|
||||||
|
host, portstr, err := net.SplitHostPort(sip)
|
||||||
|
if err != nil {
|
||||||
|
// no port, use default.
|
||||||
|
host = sip
|
||||||
|
} else {
|
||||||
|
port, err := strconv.ParseUint(
|
||||||
|
portstr, 10, 16)
|
||||||
|
if err != nil {
|
||||||
|
srvrLog.Warnf("Can not parse "+
|
||||||
|
"port from %s for "+
|
||||||
|
"externalip: %v", sip,
|
||||||
|
err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
eport = uint16(port)
|
||||||
|
}
|
||||||
|
na, err := hostToNetAddress(host, eport,
|
||||||
btcwire.SFNodeNetwork)
|
btcwire.SFNodeNetwork)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
srvrLog.Warnf("Not adding %s as ip: %v",
|
srvrLog.Warnf("Not adding %s as "+
|
||||||
sip, err)
|
"externalip: %v", sip, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue