From cd5442f3bf2b28fd02680aba8768f87a400346b5 Mon Sep 17 00:00:00 2001 From: jdl Date: Sat, 13 Jun 2026 00:10:21 +0200 Subject: [PATCH] AUDIT changes --- hub/handlers.go | 2 +- peer/multicast/broadcaster.go | 2 +- peer/multicast/packet.go | 6 +++--- peer/multicast/packet_test.go | 4 ++-- peer/multicast/receiver.go | 4 ++-- peer/on_tick.go | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hub/handlers.go b/hub/handlers.go index bcbe82b..818925b 100644 --- a/hub/handlers.go +++ b/hub/handlers.go @@ -260,7 +260,7 @@ func (a *App) _adminPasswordSubmit(s *api.Session, w http.ResponseWriter, r *htt return err } - return a.redirect(w, r, "/admin/config/") + return a.redirect(w, r, "/admin/network/list/") } func (a *App) _peerInit(peer *api.Peer, w http.ResponseWriter, r *http.Request) error { diff --git a/peer/multicast/broadcaster.go b/peer/multicast/broadcaster.go index c349d6b..3acfa2d 100644 --- a/peer/multicast/broadcaster.go +++ b/peer/multicast/broadcaster.go @@ -44,7 +44,7 @@ func broadcastInner(selfVPNIP netip.Addr, pubKey wgtypes.Key, wgPort uint16, sig // dropped by receivers' freshness gate. send := func() error { packet.Timestamp = time.Now().Unix() - payload := packet.Marshal(buf, signKey) + payload := packet.marshal(buf, signKey) _, err := conn.WriteToUDP(payload, addr) return err } diff --git a/peer/multicast/packet.go b/peer/multicast/packet.go index ed3db7c..11f6adb 100644 --- a/peer/multicast/packet.go +++ b/peer/multicast/packet.go @@ -29,8 +29,8 @@ type Packet struct { Signed []byte // Raw signed message for verification (incoming packet). } -// Marshal the packet into a buffer with prefixed signature. -func (p Packet) Marshal(buf []byte, signKey *[64]byte) []byte { +// marshal the packet into a buffer with prefixed signature. +func (p Packet) marshal(buf []byte, signKey *[64]byte) []byte { buf[0] = p.PeerIP copy(buf[1:33], p.WGPubKey[:]) binary.BigEndian.PutUint16(buf[33:35], p.WGPort) @@ -43,7 +43,7 @@ func (p Packet) Verify(buf []byte, pubKey *[32]byte) bool { return ok } -func Unmarshal(signed []byte) (p Packet) { +func unmarshal(signed []byte) (p Packet) { buf := signed[signSize:] p.PeerIP = buf[0] copy(p.WGPubKey[:], buf[1:33]) diff --git a/peer/multicast/packet_test.go b/peer/multicast/packet_test.go index 6aed8d9..6267594 100644 --- a/peer/multicast/packet_test.go +++ b/peer/multicast/packet_test.go @@ -21,12 +21,12 @@ func TestPacket(t *testing.T) { } buf := make([]byte, BufferSize) - signed := p.Marshal(buf, priv) + signed := p.marshal(buf, priv) if len(signed) != SignedPacketSize { t.Fatalf("signed length = %d, want %d", len(signed), SignedPacketSize) } - got := Unmarshal(signed) + got := unmarshal(signed) if got.PeerIP != p.PeerIP || got.WGPubKey != p.WGPubKey || got.WGPort != p.WGPort || got.Timestamp != p.Timestamp { t.Fatalf("round-trip mismatch:\n got %+v\nwant %+v", got, p) diff --git a/peer/multicast/receiver.go b/peer/multicast/receiver.go index 2d1bfad..4dcdf69 100644 --- a/peer/multicast/receiver.go +++ b/peer/multicast/receiver.go @@ -27,7 +27,7 @@ func receiver(vpnNet netip.Prefix, selfVPNIP netip.Addr, ch chan<- Packet) error } defer conn.Close() - buf := make([]byte, BufferSize+1) // +1 to detect oversized packets + buf := make([]byte, SignedPacketSize+1) // +1 to detect oversized packets for { conn.SetReadDeadline(time.Now().Add(32 * time.Second)) @@ -43,7 +43,7 @@ func receiver(vpnNet netip.Prefix, selfVPNIP netip.Addr, ch chan<- Packet) error continue } - packet := Unmarshal(buf[:n]) + packet := unmarshal(buf[:n]) if packet.PeerIP == selfIP { continue diff --git a/peer/on_tick.go b/peer/on_tick.go index afdd5b6..83137e0 100644 --- a/peer/on_tick.go +++ b/peer/on_tick.go @@ -16,7 +16,7 @@ func (a *App) onTick() { for _, wgPeer := range wgPeers { p, ok := a.peersByKey[wgPeer.PublicKey] if !ok { - log.Printf("Wireguard peer not in index, removing: %v", wgPeer) + log.Printf("Wireguard peer not known. Removing: %v", wgPeer.PublicKey) a.devRemove(&Peer{wgPeer: wgPeer}) continue }