AUDIT changes

This commit is contained in:
jdl
2026-06-13 00:10:21 +02:00
parent 11f6f2fc75
commit cd5442f3bf
6 changed files with 10 additions and 10 deletions

View File

@@ -260,7 +260,7 @@ func (a *App) _adminPasswordSubmit(s *api.Session, w http.ResponseWriter, r *htt
return err 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 { func (a *App) _peerInit(peer *api.Peer, w http.ResponseWriter, r *http.Request) error {

View File

@@ -44,7 +44,7 @@ func broadcastInner(selfVPNIP netip.Addr, pubKey wgtypes.Key, wgPort uint16, sig
// dropped by receivers' freshness gate. // dropped by receivers' freshness gate.
send := func() error { send := func() error {
packet.Timestamp = time.Now().Unix() packet.Timestamp = time.Now().Unix()
payload := packet.Marshal(buf, signKey) payload := packet.marshal(buf, signKey)
_, err := conn.WriteToUDP(payload, addr) _, err := conn.WriteToUDP(payload, addr)
return err return err
} }

View File

@@ -29,8 +29,8 @@ type Packet struct {
Signed []byte // Raw signed message for verification (incoming packet). Signed []byte // Raw signed message for verification (incoming packet).
} }
// Marshal the packet into a buffer with prefixed signature. // marshal the packet into a buffer with prefixed signature.
func (p Packet) Marshal(buf []byte, signKey *[64]byte) []byte { func (p Packet) marshal(buf []byte, signKey *[64]byte) []byte {
buf[0] = p.PeerIP buf[0] = p.PeerIP
copy(buf[1:33], p.WGPubKey[:]) copy(buf[1:33], p.WGPubKey[:])
binary.BigEndian.PutUint16(buf[33:35], p.WGPort) binary.BigEndian.PutUint16(buf[33:35], p.WGPort)
@@ -43,7 +43,7 @@ func (p Packet) Verify(buf []byte, pubKey *[32]byte) bool {
return ok return ok
} }
func Unmarshal(signed []byte) (p Packet) { func unmarshal(signed []byte) (p Packet) {
buf := signed[signSize:] buf := signed[signSize:]
p.PeerIP = buf[0] p.PeerIP = buf[0]
copy(p.WGPubKey[:], buf[1:33]) copy(p.WGPubKey[:], buf[1:33])

View File

@@ -21,12 +21,12 @@ func TestPacket(t *testing.T) {
} }
buf := make([]byte, BufferSize) buf := make([]byte, BufferSize)
signed := p.Marshal(buf, priv) signed := p.marshal(buf, priv)
if len(signed) != SignedPacketSize { if len(signed) != SignedPacketSize {
t.Fatalf("signed length = %d, want %d", 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 || if got.PeerIP != p.PeerIP || got.WGPubKey != p.WGPubKey ||
got.WGPort != p.WGPort || got.Timestamp != p.Timestamp { got.WGPort != p.WGPort || got.Timestamp != p.Timestamp {
t.Fatalf("round-trip mismatch:\n got %+v\nwant %+v", got, p) t.Fatalf("round-trip mismatch:\n got %+v\nwant %+v", got, p)

View File

@@ -27,7 +27,7 @@ func receiver(vpnNet netip.Prefix, selfVPNIP netip.Addr, ch chan<- Packet) error
} }
defer conn.Close() defer conn.Close()
buf := make([]byte, BufferSize+1) // +1 to detect oversized packets buf := make([]byte, SignedPacketSize+1) // +1 to detect oversized packets
for { for {
conn.SetReadDeadline(time.Now().Add(32 * time.Second)) 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 continue
} }
packet := Unmarshal(buf[:n]) packet := unmarshal(buf[:n])
if packet.PeerIP == selfIP { if packet.PeerIP == selfIP {
continue continue

View File

@@ -16,7 +16,7 @@ func (a *App) onTick() {
for _, wgPeer := range wgPeers { for _, wgPeer := range wgPeers {
p, ok := a.peersByKey[wgPeer.PublicKey] p, ok := a.peersByKey[wgPeer.PublicKey]
if !ok { 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}) a.devRemove(&Peer{wgPeer: wgPeer})
continue continue
} }