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 return
} }
if !add.IsValid() {
return
}
if _, exists := store.lastSeen[add]; !exists { if _, exists := store.lastSeen[add]; !exists {
store.addrList = append(store.addrList, add) store.addrList = append(store.addrList, add)
} }

View File

@ -68,7 +68,7 @@ var (
}() }()
// Messages for the supervisor. // Messages for the supervisor.
messages = make(chan any, 512) messages = make(chan any, 1024)
// Global routing table. // Global routing table.
routingTable [256]*atomic.Pointer[peerRoute] = func() (out [256]*atomic.Pointer[peerRoute]) { 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. // For logging. Set per-state.
client bool client bool
// We rate limit per remote endpoint because if we don't we tend to lose
// packets.
limiter *ratelimiter.Limiter limiter *ratelimiter.Limiter
} }
@ -270,9 +272,10 @@ func (s *stateServer) OnSyn(msg controlMsg[synPacket]) {
// Not direct => send probes. // Not direct => send probes.
for _, addr := range p.PossibleAddrs { for _, addr := range p.PossibleAddrs {
if addr.IsValid() { if !addr.IsValid() {
s.sendControlPacketTo(probePacket{TraceID: newTraceID()}, addr) break
} }
s.sendControlPacketTo(probePacket{TraceID: newTraceID()}, addr)
} }
} }
@ -410,11 +413,11 @@ func (s *stateClient) OnPingTimer() peerState {
} }
clear(s.probes) clear(s.probes)
for _, ip := range publicAddrs.Get() { for _, addr := range s.ack.PossibleAddrs {
if !ip.IsValid() { if !addr.IsValid() {
break break
} }
s.sendProbeTo(ip) s.sendProbeTo(addr)
} }
select { select {