diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2023-03-13 17:55:05 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2023-03-13 17:55:53 +0100 |
commit | 0ad14a89f5f9da577dae6a63ad196015e51a0381 (patch) | |
tree | da74ec4dd4dd79b3577236bc30b42ea999e8516b /device/send.go | |
parent | 7d327ed35aef08e2f54c12645a3002c94c6aec91 (diff) |
global: buff -> buf
This always struck me as kind of weird and non-standard.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device/send.go')
-rw-r--r-- | device/send.go | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/device/send.go b/device/send.go index b33b9f4..d22bf26 100644 --- a/device/send.go +++ b/device/send.go @@ -120,8 +120,8 @@ func (peer *Peer) SendHandshakeInitiation(isRetry bool) error { return err } - var buff [MessageInitiationSize]byte - writer := bytes.NewBuffer(buff[:0]) + var buf [MessageInitiationSize]byte + writer := bytes.NewBuffer(buf[:0]) binary.Write(writer, binary.LittleEndian, msg) packet := writer.Bytes() peer.cookieGenerator.AddMacs(packet) @@ -151,8 +151,8 @@ func (peer *Peer) SendHandshakeResponse() error { return err } - var buff [MessageResponseSize]byte - writer := bytes.NewBuffer(buff[:0]) + var buf [MessageResponseSize]byte + writer := bytes.NewBuffer(buf[:0]) binary.Write(writer, binary.LittleEndian, response) packet := writer.Bytes() peer.cookieGenerator.AddMacs(packet) @@ -185,8 +185,8 @@ func (device *Device) SendHandshakeCookie(initiatingElem *QueueHandshakeElement) return err } - var buff [MessageCookieReplySize]byte - writer := bytes.NewBuffer(buff[:0]) + var buf [MessageCookieReplySize]byte + writer := bytes.NewBuffer(buf[:0]) binary.Write(writer, binary.LittleEndian, reply) // TODO: allocation could be avoided device.net.bind.Send([][]byte{writer.Bytes()}, initiatingElem.endpoint) @@ -217,7 +217,7 @@ func (device *Device) RoutineReadFromTUN() { batchSize = device.BatchSize() readErr error elems = make([]*QueueOutboundElement, batchSize) - buffs = make([][]byte, batchSize) + bufs = make([][]byte, batchSize) elemsByPeer = make(map[*Peer]*[]*QueueOutboundElement, batchSize) count = 0 sizes = make([]int, batchSize) @@ -226,7 +226,7 @@ func (device *Device) RoutineReadFromTUN() { for i := range elems { elems[i] = device.NewOutboundElement() - buffs[i] = elems[i].buffer[:] + bufs[i] = elems[i].buffer[:] } defer func() { @@ -240,14 +240,14 @@ func (device *Device) RoutineReadFromTUN() { for { // read packets - count, readErr = device.tun.device.Read(buffs, sizes, offset) + count, readErr = device.tun.device.Read(bufs, sizes, offset) for i := 0; i < count; i++ { if sizes[i] < 1 { continue } elem := elems[i] - elem.packet = buffs[i][offset : offset+sizes[i]] + elem.packet = bufs[i][offset : offset+sizes[i]] // lookup peer var peer *Peer @@ -280,7 +280,7 @@ func (device *Device) RoutineReadFromTUN() { } *elemsForPeer = append(*elemsForPeer, elem) elems[i] = device.NewOutboundElement() - buffs[i] = elems[i].buffer[:] + bufs[i] = elems[i].buffer[:] } for peer, elemsForPeer := range elemsByPeer { @@ -483,10 +483,10 @@ func (peer *Peer) RoutineSequentialSender(maxBatchSize int) { }() device.log.Verbosef("%v - Routine: sequential sender - started", peer) - buffs := make([][]byte, 0, maxBatchSize) + bufs := make([][]byte, 0, maxBatchSize) for elems := range peer.queue.outbound.c { - buffs = buffs[:0] + bufs = bufs[:0] if elems == nil { return } @@ -510,13 +510,13 @@ func (peer *Peer) RoutineSequentialSender(maxBatchSize int) { if len(elem.packet) != MessageKeepaliveSize { dataSent = true } - buffs = append(buffs, elem.packet) + bufs = append(bufs, elem.packet) } peer.timersAnyAuthenticatedPacketTraversal() peer.timersAnyAuthenticatedPacketSent() - err := peer.SendBuffers(buffs) + err := peer.SendBuffers(bufs) if dataSent { peer.timersDataSent() } |