get local IP

This commit is contained in:
Zack Scholl 2019-05-02 17:14:24 -07:00
parent 38e7cae977
commit 3e6a554532
1 changed files with 5 additions and 1 deletions

View File

@ -333,6 +333,7 @@ func (c *Client) Receive() (err error) {
if err == nil && len(discoveries) > 0 {
log.Debug("switching to local")
c.Options.RelayAddress = fmt.Sprintf("%s:%s", discoveries[0].Address, discoveries[0].Payload)
c.ExternalIPConnected = c.Options.RelayAddress
}
log.Debugf("discoveries: %+v", discoveries)
log.Debug("establishing connection")
@ -494,7 +495,10 @@ func (c *Client) processMessage(payload []byte) (done bool, err error) {
if err != nil {
return true, err
}
c.ExternalIPConnected = m.Message
if c.ExternalIPConnected == "" {
// it can be preset by the local relay
c.ExternalIPConnected = m.Message
}
log.Debugf("connected as %s -> %s", c.ExternalIP, c.ExternalIPConnected)
c.Step1ChannelSecured = true
case "error":