Cleanup
This commit is contained in:
parent
36172bf310
commit
55f63043ee
@ -107,14 +107,10 @@ type peerStateData struct {
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
func (s *peerStateData) sendControlPacket(pkt interface{ Marshal([]byte) []byte }) {
|
||||
s.limiter.Limit()
|
||||
_sendControlPacket(pkt, s.staged, s.buf1, s.buf2)
|
||||
s._sendControlPacket(pkt, s.staged)
|
||||
}
|
||||
|
||||
func (s *peerStateData) sendControlPacketTo(
|
||||
pkt interface{ Marshal([]byte) []byte },
|
||||
addr netip.AddrPort,
|
||||
) {
|
||||
func (s *peerStateData) sendControlPacketTo(pkt interface{ Marshal([]byte) []byte }, addr netip.AddrPort) {
|
||||
if !addr.IsValid() {
|
||||
s.logf("ERROR: Attepted to send packet to invalid address: %v", addr)
|
||||
return
|
||||
@ -122,7 +118,14 @@ func (s *peerStateData) sendControlPacketTo(
|
||||
route := s.staged
|
||||
route.Direct = true
|
||||
route.RemoteAddr = addr
|
||||
s.limiter.Limit()
|
||||
s._sendControlPacket(pkt, route)
|
||||
}
|
||||
|
||||
func (s *peerStateData) _sendControlPacket(pkt interface{ Marshal([]byte) []byte }, route peerRoute) {
|
||||
if err := s.limiter.Limit(); err != nil {
|
||||
s.logf("Not sending control packet: rate limited.") // Shouldn't happen.
|
||||
return
|
||||
}
|
||||
_sendControlPacket(pkt, route, s.buf1, s.buf2)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user