Cleanup
This commit is contained in:
		| @@ -306,15 +306,14 @@ type stateClient struct { | ||||
| 	ack      ackPacket | ||||
|  | ||||
| 	probes             map[uint64]netip.AddrPort | ||||
| 	localDiscoveryAddr chan netip.AddrPort | ||||
| 	localDiscoveryAddr netip.AddrPort | ||||
| } | ||||
|  | ||||
| func enterStateClient(s *peerStateData) peerState { | ||||
| 	s.client = true | ||||
| 	ss := &stateClient{ | ||||
| 		stateDisconnected:  &stateDisconnected{s}, | ||||
| 		probes:             map[uint64]netip.AddrPort{}, | ||||
| 		localDiscoveryAddr: make(chan netip.AddrPort, 1), | ||||
| 		stateDisconnected: &stateDisconnected{s}, | ||||
| 		probes:            map[uint64]netip.AddrPort{}, | ||||
| 	} | ||||
|  | ||||
| 	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 | ||||
| 	// construct the correct address using the peer's listed port. | ||||
| 	addr := netip.AddrPortFrom(msg.SrcAddr.Addr(), s.peer.Port) | ||||
|  | ||||
| 	select { | ||||
| 	case s.localDiscoveryAddr <- addr: | ||||
| 		// OK. | ||||
| 	default: | ||||
| 		log.Printf("Local discovery packet dropped.") | ||||
| 	} | ||||
| 	s.localDiscoveryAddr = netip.AddrPortFrom(msg.SrcAddr.Addr(), s.peer.Port) | ||||
| } | ||||
|  | ||||
| func (s *stateClient) OnPingTimer() peerState { | ||||
| @@ -418,11 +410,9 @@ func (s *stateClient) OnPingTimer() peerState { | ||||
| 		s.sendProbeTo(addr) | ||||
| 	} | ||||
|  | ||||
| 	select { | ||||
| 	case addr := <-s.localDiscoveryAddr: | ||||
| 		s.sendProbeTo(addr) | ||||
| 	default: | ||||
| 		// Nothing to do. | ||||
| 	if s.localDiscoveryAddr.IsValid() { | ||||
| 		s.sendProbeTo(s.localDiscoveryAddr) | ||||
| 		s.localDiscoveryAddr = netip.AddrPort{} | ||||
| 	} | ||||
|  | ||||
| 	return nil | ||||
|   | ||||
		Reference in New Issue
	
	Block a user