mirror of
https://github.com/schollz/croc.git
synced 2024-11-24 08:02:33 +03:00
use correct local ip if sending locally
This commit is contained in:
parent
a6bc4973aa
commit
22220e54a7
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user