Cleanup
This commit is contained in:
parent
6e7a2456b2
commit
232681fac6
@ -306,15 +306,14 @@ type stateClient struct {
|
|||||||
ack ackPacket
|
ack ackPacket
|
||||||
|
|
||||||
probes map[uint64]netip.AddrPort
|
probes map[uint64]netip.AddrPort
|
||||||
localDiscoveryAddr chan netip.AddrPort
|
localDiscoveryAddr netip.AddrPort
|
||||||
}
|
}
|
||||||
|
|
||||||
func enterStateClient(s *peerStateData) peerState {
|
func enterStateClient(s *peerStateData) peerState {
|
||||||
s.client = true
|
s.client = true
|
||||||
ss := &stateClient{
|
ss := &stateClient{
|
||||||
stateDisconnected: &stateDisconnected{s},
|
stateDisconnected: &stateDisconnected{s},
|
||||||
probes: map[uint64]netip.AddrPort{},
|
probes: map[uint64]netip.AddrPort{},
|
||||||
localDiscoveryAddr: make(chan netip.AddrPort, 1),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.syn = synPacket{
|
ss.syn = synPacket{
|
||||||
@ -386,14 +385,7 @@ func (s *stateClient) OnLocalDiscovery(msg controlMsg[localDiscoveryPacket]) {
|
|||||||
//
|
//
|
||||||
// The source port will be the multicast port, so we'll have to
|
// The source port will be the multicast port, so we'll have to
|
||||||
// construct the correct address using the peer's listed port.
|
// construct the correct address using the peer's listed port.
|
||||||
addr := netip.AddrPortFrom(msg.SrcAddr.Addr(), s.peer.Port)
|
s.localDiscoveryAddr = netip.AddrPortFrom(msg.SrcAddr.Addr(), s.peer.Port)
|
||||||
|
|
||||||
select {
|
|
||||||
case s.localDiscoveryAddr <- addr:
|
|
||||||
// OK.
|
|
||||||
default:
|
|
||||||
log.Printf("Local discovery packet dropped.")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *stateClient) OnPingTimer() peerState {
|
func (s *stateClient) OnPingTimer() peerState {
|
||||||
@ -418,11 +410,9 @@ func (s *stateClient) OnPingTimer() peerState {
|
|||||||
s.sendProbeTo(addr)
|
s.sendProbeTo(addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
if s.localDiscoveryAddr.IsValid() {
|
||||||
case addr := <-s.localDiscoveryAddr:
|
s.sendProbeTo(s.localDiscoveryAddr)
|
||||||
s.sendProbeTo(addr)
|
s.localDiscoveryAddr = netip.AddrPort{}
|
||||||
default:
|
|
||||||
// Nothing to do.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user