mirror of https://github.com/schollz/croc.git
get local IP
This commit is contained in:
parent
38e7cae977
commit
3e6a554532
|
@ -333,6 +333,7 @@ func (c *Client) Receive() (err error) {
|
||||||
if err == nil && len(discoveries) > 0 {
|
if err == nil && len(discoveries) > 0 {
|
||||||
log.Debug("switching to local")
|
log.Debug("switching to local")
|
||||||
c.Options.RelayAddress = fmt.Sprintf("%s:%s", discoveries[0].Address, discoveries[0].Payload)
|
c.Options.RelayAddress = fmt.Sprintf("%s:%s", discoveries[0].Address, discoveries[0].Payload)
|
||||||
|
c.ExternalIPConnected = c.Options.RelayAddress
|
||||||
}
|
}
|
||||||
log.Debugf("discoveries: %+v", discoveries)
|
log.Debugf("discoveries: %+v", discoveries)
|
||||||
log.Debug("establishing connection")
|
log.Debug("establishing connection")
|
||||||
|
@ -494,7 +495,10 @@ func (c *Client) processMessage(payload []byte) (done bool, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return true, err
|
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)
|
log.Debugf("connected as %s -> %s", c.ExternalIP, c.ExternalIPConnected)
|
||||||
c.Step1ChannelSecured = true
|
c.Step1ChannelSecured = true
|
||||||
case "error":
|
case "error":
|
||||||
|
|
Loading…
Reference in New Issue