mirror of
https://git.zx2c4.com/wireguard-go
synced 2025-10-26 01:40:23 +08:00
device: update transfer counters correctly
The rule is to always update them to the full packet size minus UDP/IP encapsulation for all authenticated packet types.
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -140,7 +141,11 @@ func (peer *Peer) SendBuffer(buffer []byte) error {
|
||||
return errors.New("no known endpoint for peer")
|
||||
}
|
||||
|
||||
return peer.device.net.bind.Send(buffer, peer.endpoint)
|
||||
err := peer.device.net.bind.Send(buffer, peer.endpoint)
|
||||
if err == nil {
|
||||
atomic.AddUint64(&peer.stats.txBytes, uint64(len(buffer)))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (peer *Peer) String() string {
|
||||
|
||||
Reference in New Issue
Block a user