summaryrefslogtreecommitdiffhomepage
path: root/src/send.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/send.go')
-rw-r--r--src/send.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/send.go b/src/send.go
index fdbc676..7cdb806 100644
--- a/src/send.go
+++ b/src/send.go
@@ -313,17 +313,15 @@ func (device *Device) RoutineEncryption() {
elem.packet = append(elem.packet, 0)
}
- // encrypt content
+ // encrypt content (append to header)
binary.LittleEndian.PutUint64(nonce[4:], elem.nonce)
elem.packet = elem.keyPair.send.Seal(
- elem.packet[:0],
+ header,
nonce[:],
elem.packet,
nil,
)
- length := MessageTransportHeaderSize + len(elem.packet)
- elem.packet = elem.buffer[:length]
elem.mutex.Unlock()
// refresh key if necessary
@@ -381,7 +379,8 @@ func (peer *Peer) RoutineSequentialSender() {
if err != nil {
return
}
- atomic.AddUint64(&peer.txBytes, uint64(len(elem.packet)))
+
+ atomic.AddUint64(&peer.stats.txBytes, uint64(len(elem.packet)))
peer.TimerResetKeepalive()
}()