mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
Delete receiver key if sender is not present and not waiting Fixes #39
This commit is contained in:
parent
9c6d672272
commit
f8505caa27
2 changed files with 7 additions and 1 deletions
|
@ -253,8 +253,10 @@ func (c *Connection) runClient() error {
|
||||||
} else {
|
} else {
|
||||||
logger.Debugf("telling relay: %s", "r."+c.Code)
|
logger.Debugf("telling relay: %s", "r."+c.Code)
|
||||||
if c.Wait {
|
if c.Wait {
|
||||||
|
// tell server to wait for sender
|
||||||
sendMessage("r."+c.HashedCode+".0.0.0", connection)
|
sendMessage("r."+c.HashedCode+".0.0.0", connection)
|
||||||
} else {
|
} else {
|
||||||
|
// tell server to cancel if sender doesn't exist
|
||||||
sendMessage("c."+c.HashedCode+".0.0.0", connection)
|
sendMessage("c."+c.HashedCode+".0.0.0", connection)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -371,7 +373,7 @@ func (c *Connection) runClient() error {
|
||||||
fmt.Println("\nFile sent.")
|
fmt.Println("\nFile sent.")
|
||||||
} else { // Is a Receiver
|
} else { // Is a Receiver
|
||||||
if notPresent {
|
if notPresent {
|
||||||
fmt.Println("Sender/Code not present")
|
fmt.Println("Sender is not ready. Use -wait to wait until sender connects.")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if !gotOK {
|
if !gotOK {
|
||||||
|
|
4
relay.go
4
relay.go
|
@ -205,6 +205,10 @@ func (r *Relay) clientCommuncation(id int, connection net.Conn) {
|
||||||
r.connections.RUnlock()
|
r.connections.RUnlock()
|
||||||
if connectionType == "c" {
|
if connectionType == "c" {
|
||||||
sendMessage("0-0-0-0.0.0.0", connection)
|
sendMessage("0-0-0-0.0.0.0", connection)
|
||||||
|
// sender is not ready so delete connection
|
||||||
|
r.connections.Lock()
|
||||||
|
delete(r.connections.potentialReceivers, key)
|
||||||
|
r.connections.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue