From 677e5592e5c2818385715ccb1b4e0421c8395413 Mon Sep 17 00:00:00 2001 From: Josh Deprez Date: Fri, 19 Apr 2024 17:10:00 +1000 Subject: [PATCH] RI-Ack for RI-Upd --- main.go | 2 ++ router/peer.go | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/main.go b/main.go index dd7b23e..d2ca872 100644 --- a/main.go +++ b/main.go @@ -170,6 +170,7 @@ func main() { RecieveCh: make(chan aurp.Packet, 1024), RoutingTable: routes, ZoneTable: zones, + Reconnect: true, } aurp.Inc(&nextConnID) peers[udpAddrFromNet(raddr)] = peer @@ -439,6 +440,7 @@ func main() { RecieveCh: make(chan aurp.Packet, 1024), RoutingTable: routes, ZoneTable: zones, + Reconnect: false, } aurp.Inc(&nextConnID) peers[ra] = pr diff --git a/router/peer.go b/router/peer.go index 9198016..12d461f 100644 --- a/router/peer.go +++ b/router/peer.go @@ -33,6 +33,7 @@ const ( tickleRetryLimit = 10 sendRetryTimer = 10 * time.Second sendRetryLimit = 5 + reconnectTimer = 10 * time.Minute ) type receiverState int @@ -83,6 +84,7 @@ type Peer struct { RecieveCh chan aurp.Packet RoutingTable *RoutingTable ZoneTable *ZoneTable + Reconnect bool } // Send encodes and sends pkt to the remote host. @@ -202,6 +204,9 @@ func (p *Peer) Handle(ctx context.Context) error { case rsUnconnected: // TODO: periodically try to reconnect, // if this peer is in the config file + + // TODO: if sstate != ssUnconnected, send a null RI-Upd to check + // that the sender side is also unconnected } case pkt := <-p.RecieveCh: @@ -357,6 +362,11 @@ func (p *Peer) Handle(ctx context.Context) error { log.Printf("AURP Peer: RI-Upd event %v", et) } + if _, err := p.Send(p.Transport.NewRIAckPacket(pkt.ConnectionID, pkt.Sequence, 0)); err != nil { + log.Printf("AURP Peer: Couldn't send RI-Ack: %v", err) + return err + } + case *aurp.RDPacket: if rstate == rsUnconnected || rstate == rsWaitForOpenRsp { log.Printf("AURP Peer: Received RD but was not expecting one (receiver state was %v)", rstate)