Add receiver side reconnect

This commit is contained in:
Josh Deprez 2024-04-23 17:05:06 +10:00
parent a932d9a35f
commit f7071fa59e
Signed by: josh
SSH key fingerprint: SHA256:zZji7w1Ilh2RuUpbQcqkLPrqmRwpiCSycbF2EfKm6Kw

View file

@ -106,7 +106,7 @@ func (p *Peer) Handle(ctx context.Context) error {
lastReconnect := time.Now() lastReconnect := time.Now()
lastHeardFrom := time.Now() lastHeardFrom := time.Now()
lastSend := time.Now() lastSend := time.Now() // TODO: clarify use of lastSend / sendRetries
lastUpdate := time.Now() lastUpdate := time.Now()
sendRetries := 0 sendRetries := 0
@ -434,6 +434,19 @@ func (p *Peer) Handle(ctx context.Context) error {
// TODO: Continue sending next RI-Rsp (streamed)? // TODO: Continue sending next RI-Rsp (streamed)?
if rstate == rsUnconnected {
// Receiver is unconnected, but their receiver sent us an
// RI-Ack for something
// Try to reconnect?
lastSend = time.Now()
sendRetries = 0
if _, err := p.Send(p.Transport.NewOpenReqPacket(nil)); err != nil {
log.Printf("AURP Peer: Couldn't send Open-Req packet: %v", err)
return err
}
rstate = rsWaitForOpenRsp
}
case *aurp.RIUpdPacket: case *aurp.RIUpdPacket:
// TODO: Integrate info into route table // TODO: Integrate info into route table
for _, et := range pkt.Events { for _, et := range pkt.Events {