mirror of https://github.com/schollz/croc.git
Delete receiver key if sender is not present and not waiting Fixes #39
This commit is contained in:
parent
9c6d672272
commit
f8505caa27
|
@ -253,8 +253,10 @@ func (c *Connection) runClient() error {
|
|||
} else {
|
||||
logger.Debugf("telling relay: %s", "r."+c.Code)
|
||||
if c.Wait {
|
||||
// tell server to wait for sender
|
||||
sendMessage("r."+c.HashedCode+".0.0.0", connection)
|
||||
} else {
|
||||
// tell server to cancel if sender doesn't exist
|
||||
sendMessage("c."+c.HashedCode+".0.0.0", connection)
|
||||
}
|
||||
}
|
||||
|
@ -371,7 +373,7 @@ func (c *Connection) runClient() error {
|
|||
fmt.Println("\nFile sent.")
|
||||
} else { // Is a Receiver
|
||||
if notPresent {
|
||||
fmt.Println("Sender/Code not present")
|
||||
fmt.Println("Sender is not ready. Use -wait to wait until sender connects.")
|
||||
return nil
|
||||
}
|
||||
if !gotOK {
|
||||
|
|
4
relay.go
4
relay.go
|
@ -205,6 +205,10 @@ func (r *Relay) clientCommuncation(id int, connection net.Conn) {
|
|||
r.connections.RUnlock()
|
||||
if connectionType == "c" {
|
||||
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
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
|
Loading…
Reference in New Issue