Breaking change: new packet formats.

This commit is contained in:
jdl 2025-01-13 16:41:01 +01:00
parent 2bdd76e689
commit 970490b17b
3 changed files with 19 additions and 12 deletions

View File

@ -26,6 +26,10 @@ func (store *pubAddrStore) Store(add netip.AddrPort) {
return
}
if !add.IsValid() {
return
}
if _, exists := store.lastSeen[add]; !exists {
store.addrList = append(store.addrList, add)
}

View File

@ -68,7 +68,7 @@ var (
}()
// Messages for the supervisor.
messages = make(chan any, 512)
messages = make(chan any, 1024)
// Global routing table.
routingTable [256]*atomic.Pointer[peerRoute] = func() (out [256]*atomic.Pointer[peerRoute]) {

View File

@ -102,6 +102,8 @@ type peerStateData struct {
// For logging. Set per-state.
client bool
// We rate limit per remote endpoint because if we don't we tend to lose
// packets.
limiter *ratelimiter.Limiter
}
@ -142,21 +144,21 @@ func (s *peerStateData) logf(format string, args ...any) {
b.WriteString(fmt.Sprintf("%30s: ", s.peer.Name))
if s.client {
b.WriteString("CLIENT|")
b.WriteString("CLIENT | ")
} else {
b.WriteString("SERVER|")
b.WriteString("SERVER | ")
}
if s.staged.Direct {
b.WriteString("DIRECT |")
b.WriteString("DIRECT | ")
} else {
b.WriteString("RELAYED|")
b.WriteString("RELAYED | ")
}
if s.staged.Up {
b.WriteString("UP |")
b.WriteString("UP | ")
} else {
b.WriteString("DOWN|")
b.WriteString("DOWN | ")
}
log.Printf(b.String()+format, args...)
@ -270,9 +272,10 @@ func (s *stateServer) OnSyn(msg controlMsg[synPacket]) {
// Not direct => send probes.
for _, addr := range p.PossibleAddrs {
if addr.IsValid() {
s.sendControlPacketTo(probePacket{TraceID: newTraceID()}, addr)
if !addr.IsValid() {
break
}
s.sendControlPacketTo(probePacket{TraceID: newTraceID()}, addr)
}
}
@ -410,11 +413,11 @@ func (s *stateClient) OnPingTimer() peerState {
}
clear(s.probes)
for _, ip := range publicAddrs.Get() {
if !ip.IsValid() {
for _, addr := range s.ack.PossibleAddrs {
if !addr.IsValid() {
break
}
s.sendProbeTo(ip)
s.sendProbeTo(addr)
}
select {