From d3aa2be9ab38346787981eb012456730ffc5af90 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Thu, 22 Oct 2020 10:11:11 -0700 Subject: [PATCH] ping server from discoveries --- src/croc/croc.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/croc/croc.go b/src/croc/croc.go index 8501508f..41fe2270 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -542,12 +542,14 @@ func (c *Client) Receive() (err error) { if portToUse == "" { portToUse = "9009" } - c.Options.RelayAddress = net.JoinHostPort(discoveries[0].Address, portToUse) - c.ExternalIPConnected = c.Options.RelayAddress - c.Options.RelayAddress6 = "" - usingLocal = true - - break + address := net.JoinHostPort(discoveries[0].Address, portToUse) + if tcp.PingServer(address) == nil { + c.Options.RelayAddress = address + c.ExternalIPConnected = c.Options.RelayAddress + c.Options.RelayAddress6 = "" + usingLocal = true + break + } } } log.Debugf("discoveries: %+v", discoveries)