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 }) {
|
func (s *peerStateData) sendControlPacket(pkt interface{ Marshal([]byte) []byte }) {
|
||||||
s.limiter.Limit()
|
s._sendControlPacket(pkt, s.staged)
|
||||||
_sendControlPacket(pkt, s.staged, s.buf1, s.buf2)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *peerStateData) sendControlPacketTo(
|
func (s *peerStateData) sendControlPacketTo(pkt interface{ Marshal([]byte) []byte }, addr netip.AddrPort) {
|
||||||
pkt interface{ Marshal([]byte) []byte },
|
|
||||||
addr netip.AddrPort,
|
|
||||||
) {
|
|
||||||
if !addr.IsValid() {
|
if !addr.IsValid() {
|
||||||
s.logf("ERROR: Attepted to send packet to invalid address: %v", addr)
|
s.logf("ERROR: Attepted to send packet to invalid address: %v", addr)
|
||||||
return
|
return
|
||||||
@ -122,7 +118,14 @@ func (s *peerStateData) sendControlPacketTo(
|
|||||||
route := s.staged
|
route := s.staged
|
||||||
route.Direct = true
|
route.Direct = true
|
||||||
route.RemoteAddr = addr
|
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)
|
_sendControlPacket(pkt, route, s.buf1, s.buf2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user