Breaking change: new packet formats.
This commit is contained in:
parent
2bdd76e689
commit
970490b17b
@ -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)
|
||||||
}
|
}
|
||||||
|
@ -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]) {
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,21 +144,21 @@ func (s *peerStateData) logf(format string, args ...any) {
|
|||||||
b.WriteString(fmt.Sprintf("%30s: ", s.peer.Name))
|
b.WriteString(fmt.Sprintf("%30s: ", s.peer.Name))
|
||||||
|
|
||||||
if s.client {
|
if s.client {
|
||||||
b.WriteString("CLIENT|")
|
b.WriteString("CLIENT | ")
|
||||||
} else {
|
} else {
|
||||||
b.WriteString("SERVER|")
|
b.WriteString("SERVER | ")
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.staged.Direct {
|
if s.staged.Direct {
|
||||||
b.WriteString("DIRECT |")
|
b.WriteString("DIRECT | ")
|
||||||
} else {
|
} else {
|
||||||
b.WriteString("RELAYED|")
|
b.WriteString("RELAYED | ")
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.staged.Up {
|
if s.staged.Up {
|
||||||
b.WriteString("UP |")
|
b.WriteString("UP | ")
|
||||||
} else {
|
} else {
|
||||||
b.WriteString("DOWN|")
|
b.WriteString("DOWN | ")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf(b.String()+format, args...)
|
log.Printf(b.String()+format, args...)
|
||||||
@ -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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user