From f7071fa59edc3c3d3acada63d1ee126609fa49a2 Mon Sep 17 00:00:00 2001 From: Josh Deprez Date: Tue, 23 Apr 2024 17:05:06 +1000 Subject: [PATCH] Add receiver side reconnect --- router/peer.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/router/peer.go b/router/peer.go index 98fb5a6..cc7a1c7 100644 --- a/router/peer.go +++ b/router/peer.go @@ -106,7 +106,7 @@ func (p *Peer) Handle(ctx context.Context) error { lastReconnect := time.Now() lastHeardFrom := time.Now() - lastSend := time.Now() + lastSend := time.Now() // TODO: clarify use of lastSend / sendRetries lastUpdate := time.Now() sendRetries := 0 @@ -434,6 +434,19 @@ func (p *Peer) Handle(ctx context.Context) error { // 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: // TODO: Integrate info into route table for _, et := range pkt.Events {