Connect after incoming Open-Req

This commit is contained in:
Josh Deprez 2024-03-30 18:53:31 +11:00
parent 09e2522a1a
commit f5527d6db2
Signed by: josh
SSH key fingerprint: SHA256:zZji7w1Ilh2RuUpbQcqkLPrqmRwpiCSycbF2EfKm6Kw

12
peer.go
View file

@ -194,6 +194,17 @@ func (p *peer) handle(ctx context.Context) error {
sstate = ssConnected sstate = ssConnected
} }
// If receiver is unconnected, commence connecting
if rstate == rsUnconnected {
lastSend = time.Now()
sendRetries = 0
if _, err := p.send(p.tr.NewOpenReqPacket(nil)); err != nil {
log.Printf("Couldn't send Open-Req packet: %v", err)
return err
}
rstate = rsWaitForOpenRsp
}
case *aurp.OpenRspPacket: case *aurp.OpenRspPacket:
if rstate != rsWaitForOpenRsp { if rstate != rsWaitForOpenRsp {
log.Printf("Received Open-Rsp but was not waiting for one (receiver state was %v)", rstate) log.Printf("Received Open-Rsp but was not waiting for one (receiver state was %v)", rstate)
@ -213,6 +224,7 @@ func (p *peer) handle(ctx context.Context) error {
if sstate != ssConnected { if sstate != ssConnected {
log.Printf("Received RI-Req but was not expecting one (sender state was %v)", sstate) log.Printf("Received RI-Req but was not expecting one (sender state was %v)", sstate)
} }
// TODO: Respond with RI-Rsp // TODO: Respond with RI-Rsp
case *aurp.RIRspPacket: case *aurp.RIRspPacket: