default to port 9009 if port is lost during discovery

fixes #222
This commit is contained in:
Zack Scholl 2020-07-15 10:47:56 -07:00
parent 1255a79a57
commit 7fd8fda107
1 changed files with 5 additions and 1 deletions

View File

@ -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