From 7fd8fda1076c5e0c12e103acd97a85214fc3789a Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Wed, 15 Jul 2020 10:47:56 -0700 Subject: [PATCH] default to port 9009 if port is lost during discovery fixes #222 --- src/croc/croc.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/croc/croc.go b/src/croc/croc.go index 520128b27..006d202d4 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -434,9 +434,13 @@ func (c *Client) Receive() (err error) { continue } log.Debug("switching to local") + portToUse := string(bytes.TrimPrefix(discoveries[0].Payload, []byte("croc"))) + if portToUse == "" { + portToUse = "9009" + } c.Options.RelayAddress = fmt.Sprintf("%s:%s", discoveries[0].Address, - bytes.TrimPrefix(discoveries[0].Payload, []byte("croc")), + portToUse, ) c.ExternalIPConnected = c.Options.RelayAddress usingLocal = true