diff --git a/src/api.go b/src/api.go index 4aefffc..b277d68 100644 --- a/src/api.go +++ b/src/api.go @@ -96,6 +96,7 @@ func (c *Croc) Send(fname string, codePhrase string) (err error) { ce.cs.channel.fileMetaData = c.cs.channel.fileMetaData ce.crocFile = c.crocFile ce.crocFileEncrypted = ce.crocFileEncrypted + ce.isLocal = true ce.cs.Unlock() c.cs.Unlock() var ri runInfo @@ -144,6 +145,7 @@ func (c *Croc) Receive(codePhrase string) (err error) { if connectTimeout == nil { log.Debug("connected") c.WebsocketAddress = "ws://" + discovered[0].Address + ":8140" + c.isLocal = true log.Debug(discovered[0].Address) codePhrase = string(discovered[0].Payload) } else { diff --git a/src/client.go b/src/client.go index e7e413a..bdd6a0c 100644 --- a/src/client.go +++ b/src/client.go @@ -223,6 +223,9 @@ func (c *Croc) processState(cd channelData) (err error) { c.cs.channel.Ports = cd.Ports c.cs.channel.EncryptedFileMetaData = cd.EncryptedFileMetaData c.cs.channel.Addresses = cd.Addresses + if c.cs.channel.Role == 0 && c.isLocal { + c.cs.channel.Addresses[0] = getLocalIP() + } c.bothConnected = cd.Addresses[0] != "" && cd.Addresses[1] != "" // update the Pake diff --git a/src/models.go b/src/models.go index 39cae48..94e8172 100644 --- a/src/models.go +++ b/src/models.go @@ -39,6 +39,12 @@ type Croc struct { Stdout bool // private variables + + // localIP address + localIP string + // is using local relay + isLocal bool + // rs relay state is only for the relay rs relayState @@ -70,7 +76,7 @@ func Init() (c *Croc) { c.rs.ips = make(map[string]string) c.cs.channel = new(channelData) c.rs.Unlock() - + c.localIP = getLocalIP() return }