@ -131,23 +131,23 @@ func (s *Statistics) updateVirtual(b []byte, receive bool) {
s . virtual [ conn ] = cnts
s . virtual [ conn ] = cnts
}
}
// UpdateTxPhysical updates the counters for a transmitted wireguard packet
// UpdateTxPhysical updates the counters for zero or more transmitted wireguard packets.
// The src is always a Tailscale IP address, representing some remote peer.
// The src is always a Tailscale IP address, representing some remote peer.
// The dst is a remote IP address and port that corresponds
// The dst is a remote IP address and port that corresponds
// with some physical peer backing the Tailscale IP address.
// with some physical peer backing the Tailscale IP address.
func ( s * Statistics ) UpdateTxPhysical ( src netip . Addr , dst netip . AddrPort , n int ) {
func ( s * Statistics ) UpdateTxPhysical ( src netip . Addr , dst netip . AddrPort , packets, bytes int ) {
s . updatePhysical ( src , dst , n , false )
s . updatePhysical ( src , dst , packets, bytes , false )
}
}
// UpdateRxPhysical updates the counters for a received wireguard packet .
// UpdateRxPhysical updates the counters for zero or more received wireguard packets .
// The src is always a Tailscale IP address, representing some remote peer.
// The src is always a Tailscale IP address, representing some remote peer.
// The dst is a remote IP address and port that corresponds
// The dst is a remote IP address and port that corresponds
// with some physical peer backing the Tailscale IP address.
// with some physical peer backing the Tailscale IP address.
func ( s * Statistics ) UpdateRxPhysical ( src netip . Addr , dst netip . AddrPort , n int ) {
func ( s * Statistics ) UpdateRxPhysical ( src netip . Addr , dst netip . AddrPort , packets, bytes int ) {
s . updatePhysical ( src , dst , n , true )
s . updatePhysical ( src , dst , packets, bytes , true )
}
}
func ( s * Statistics ) updatePhysical ( src netip . Addr , dst netip . AddrPort , n int , receive bool ) {
func ( s * Statistics ) updatePhysical ( src netip . Addr , dst netip . AddrPort , packets, bytes int , receive bool ) {
conn := netlogtype . Connection { Src : netip . AddrPortFrom ( src , 0 ) , Dst : dst }
conn := netlogtype . Connection { Src : netip . AddrPortFrom ( src , 0 ) , Dst : dst }
s . mu . Lock ( )
s . mu . Lock ( )
@ -157,11 +157,11 @@ func (s *Statistics) updatePhysical(src netip.Addr, dst netip.AddrPort, n int, r
return
return
}
}
if receive {
if receive {
cnts . RxPackets ++
cnts . RxPackets += uint64 ( packets )
cnts . RxBytes += uint64 ( n )
cnts . RxBytes += uint64 ( bytes )
} else {
} else {
cnts . TxPackets ++
cnts . TxPackets += uint64 ( packets )
cnts . TxBytes += uint64 ( n )
cnts . TxBytes += uint64 ( bytes )
}
}
s . physical [ conn ] = cnts
s . physical [ conn ] = cnts
}
}