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:
parent
41fdbf0971
commit
3371f8dac6
3 changed files with 9 additions and 4 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue