From 376c09d1898d1ee51dafc5e8a21f4e1d4b4aca8e Mon Sep 17 00:00:00 2001 From: Josh Deprez Date: Sun, 5 May 2024 18:13:40 +1000 Subject: [PATCH] More cleanups --- router/rtmp.go | 11 ++++++----- router/zip.go | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/router/rtmp.go b/router/rtmp.go index d1a9752..b714e03 100644 --- a/router/rtmp.go +++ b/router/rtmp.go @@ -102,8 +102,7 @@ func (port *EtherTalkPort) HandleRTMP(ctx context.Context, pkt *ddp.ExtPacket) e } case rtmp.FunctionLoopProbe: - log.Print("RTMP: TODO: handle Loop Probes") - return nil + return fmt.Errorf("TODO: handle Loop Probes") } case ddp.ProtoRTMPResp: @@ -122,7 +121,7 @@ func (port *EtherTalkPort) HandleRTMP(ctx context.Context, pkt *ddp.ExtPacket) e for _, nt := range dataPkt.NetworkTuples { route, err := port.Router.RouteTable.UpsertEtherTalkRoute(peer, nt.Extended, nt.RangeStart, nt.RangeEnd, nt.Distance+1) if err != nil { - log.Printf("RTMP: Couldn't upsert EtherTalk route: %v", err) + return fmt.Errorf("upsert EtherTalk route: %v", err) } if len(route.ZoneNames) == 0 { noZones = append(noZones, route.NetStart) @@ -149,11 +148,13 @@ func (port *EtherTalkPort) HandleRTMP(ctx context.Context, pkt *ddp.ExtPacket) e }, Data: qryPkt, } - port.Send(ctx, outDDP) + if err := port.Send(ctx, outDDP); err != nil { + return fmt.Errorf("sending ZIP Query: %w", err) + } } default: - log.Printf("RTMP: invalid DDP type %d on socket 1", pkt.Proto) + return fmt.Errorf("invalid DDP type %d on socket 1", pkt.Proto) } return nil diff --git a/router/zip.go b/router/zip.go index c3b8875..9b668e2 100644 --- a/router/zip.go +++ b/router/zip.go @@ -52,7 +52,7 @@ func (port *EtherTalkPort) handleZIPZIP(ctx context.Context, ddpkt *ddp.ExtPacke return port.handleZIPQuery(ctx, ddpkt, zipkt) case *zip.ReplyPacket: - return port.handleZIPReply(ctx, zipkt) + return port.handleZIPReply(zipkt) case *zip.GetNetInfoPacket: return port.handleZIPGetNetInfo(ctx, ddpkt, zipkt) @@ -158,8 +158,8 @@ func (port *EtherTalkPort) handleZIPQuery(ctx context.Context, ddpkt *ddp.ExtPac return nil } -func (port *EtherTalkPort) handleZIPReply(ctx context.Context, zipkt *zip.ReplyPacket) error { - log.Printf("ZIP: Got Reply for networks %v", zipkt.Networks) +func (port *EtherTalkPort) handleZIPReply(zipkt *zip.ReplyPacket) error { + log.Printf("ZIP: Got Reply containing %v", zipkt.Networks) // Integrate new zone information into route table. for n, zs := range zipkt.Networks {