|
@ -38,11 +38,11 @@ const ( |
|
|
func splitHostPort(addr string) (host string, port int) { |
|
|
func splitHostPort(addr string) (host string, port int) { |
|
|
host, portStr, err := net.SplitHostPort(addr) |
|
|
host, portStr, err := net.SplitHostPort(addr) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
cmn.PanicSanity(err) |
|
|
|
|
|
|
|
|
panic(err) |
|
|
} |
|
|
} |
|
|
port, err = strconv.Atoi(portStr) |
|
|
port, err = strconv.Atoi(portStr) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
cmn.PanicSanity(err) |
|
|
|
|
|
|
|
|
panic(err) |
|
|
} |
|
|
} |
|
|
return host, port |
|
|
return host, port |
|
|
} |
|
|
} |
|
@ -64,7 +64,7 @@ func NewDefaultListener(protocol string, lAddr string, skipUPNP bool, logger log |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
cmn.PanicCrisis(err) |
|
|
|
|
|
|
|
|
panic(err) |
|
|
} |
|
|
} |
|
|
// Actual listener local IP & port
|
|
|
// Actual listener local IP & port
|
|
|
listenerIP, listenerPort := splitHostPort(listener.Addr().String()) |
|
|
listenerIP, listenerPort := splitHostPort(listener.Addr().String()) |
|
@ -74,7 +74,7 @@ func NewDefaultListener(protocol string, lAddr string, skipUPNP bool, logger log |
|
|
var intAddr *NetAddress |
|
|
var intAddr *NetAddress |
|
|
intAddr, err = NewNetAddressString(lAddr) |
|
|
intAddr, err = NewNetAddressString(lAddr) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
cmn.PanicCrisis(err) |
|
|
|
|
|
|
|
|
panic(err) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Determine external address...
|
|
|
// Determine external address...
|
|
@ -90,7 +90,7 @@ func NewDefaultListener(protocol string, lAddr string, skipUPNP bool, logger log |
|
|
extAddr = getNaiveExternalAddress(listenerPort, false, logger) |
|
|
extAddr = getNaiveExternalAddress(listenerPort, false, logger) |
|
|
} |
|
|
} |
|
|
if extAddr == nil { |
|
|
if extAddr == nil { |
|
|
cmn.PanicCrisis("Could not determine external address!") |
|
|
|
|
|
|
|
|
panic("Could not determine external address!") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
dl := &DefaultListener{ |
|
|
dl := &DefaultListener{ |
|
@ -132,7 +132,7 @@ func (l *DefaultListener) listenRoutine() { |
|
|
// listener wasn't stopped,
|
|
|
// listener wasn't stopped,
|
|
|
// yet we encountered an error.
|
|
|
// yet we encountered an error.
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
cmn.PanicCrisis(err) |
|
|
|
|
|
|
|
|
panic(err) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
l.connections <- conn |
|
|
l.connections <- conn |
|
@ -205,7 +205,7 @@ func getUPNPExternalAddress(externalPort, internalPort int, logger log.Logger) * |
|
|
func getNaiveExternalAddress(port int, settleForLocal bool, logger log.Logger) *NetAddress { |
|
|
func getNaiveExternalAddress(port int, settleForLocal bool, logger log.Logger) *NetAddress { |
|
|
addrs, err := net.InterfaceAddrs() |
|
|
addrs, err := net.InterfaceAddrs() |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
cmn.PanicCrisis(cmn.Fmt("Could not fetch interface addresses: %v", err)) |
|
|
|
|
|
|
|
|
panic(cmn.Fmt("Could not fetch interface addresses: %v", err)) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for _, a := range addrs { |
|
|
for _, a := range addrs { |
|
|