aboutsummaryrefslogtreecommitdiff
path: root/conn
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2023-03-13 17:55:05 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2023-03-13 17:55:53 +0100
commit0ad14a89f5f9da577dae6a63ad196015e51a0381 (patch)
treeda74ec4dd4dd79b3577236bc30b42ea999e8516b /conn
parent7d327ed35aef08e2f54c12645a3002c94c6aec91 (diff)
downloadwireguard-go-0ad14a89f5f9da577dae6a63ad196015e51a0381.tar.gz
wireguard-go-0ad14a89f5f9da577dae6a63ad196015e51a0381.zip
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 'conn')
-rw-r--r--conn/bind_std.go46
-rw-r--r--conn/bind_std_test.go6
-rw-r--r--conn/bind_windows.go12
-rw-r--r--conn/bindtest/bindtest.go8
-rw-r--r--conn/conn.go6
-rw-r--r--conn/conn_test.go2
6 files changed, 40 insertions, 40 deletions
diff --git a/conn/bind_std.go b/conn/bind_std.go
index 1ee2cef..e8cf7b8 100644
--- a/conn/bind_std.go
+++ b/conn/bind_std.go
@@ -204,11 +204,11 @@ again:
}
func (s *StdNetBind) makeReceiveIPv4(pc *ipv4.PacketConn, conn *net.UDPConn) ReceiveFunc {
- return func(buffs [][]byte, sizes []int, eps []Endpoint) (n int, err error) {
+ return func(bufs [][]byte, sizes []int, eps []Endpoint) (n int, err error) {
msgs := s.ipv4MsgsPool.Get().(*[]ipv4.Message)
defer s.ipv4MsgsPool.Put(msgs)
- for i := range buffs {
- (*msgs)[i].Buffers[0] = buffs[i]
+ for i := range bufs {
+ (*msgs)[i].Buffers[0] = bufs[i]
}
var numMsgs int
if runtime.GOOS == "linux" {
@@ -237,11 +237,11 @@ func (s *StdNetBind) makeReceiveIPv4(pc *ipv4.PacketConn, conn *net.UDPConn) Rec
}
func (s *StdNetBind) makeReceiveIPv6(pc *ipv6.PacketConn, conn *net.UDPConn) ReceiveFunc {
- return func(buffs [][]byte, sizes []int, eps []Endpoint) (n int, err error) {
+ return func(bufs [][]byte, sizes []int, eps []Endpoint) (n int, err error) {
msgs := s.ipv4MsgsPool.Get().(*[]ipv6.Message)
defer s.ipv4MsgsPool.Put(msgs)
- for i := range buffs {
- (*msgs)[i].Buffers[0] = buffs[i]
+ for i := range bufs {
+ (*msgs)[i].Buffers[0] = bufs[i]
}
var numMsgs int
if runtime.GOOS == "linux" {
@@ -301,7 +301,7 @@ func (s *StdNetBind) Close() error {
return err2
}
-func (s *StdNetBind) Send(buffs [][]byte, endpoint Endpoint) error {
+func (s *StdNetBind) Send(bufs [][]byte, endpoint Endpoint) error {
s.mu.Lock()
blackhole := s.blackhole4
conn := s.ipv4
@@ -327,21 +327,21 @@ func (s *StdNetBind) Send(buffs [][]byte, endpoint Endpoint) error {
return syscall.EAFNOSUPPORT
}
if is6 {
- return s.send6(conn, pc6, endpoint, buffs)
+ return s.send6(conn, pc6, endpoint, bufs)
} else {
- return s.send4(conn, pc4, endpoint, buffs)
+ return s.send4(conn, pc4, endpoint, bufs)
}
}
-func (s *StdNetBind) send4(conn *net.UDPConn, pc *ipv4.PacketConn, ep Endpoint, buffs [][]byte) error {
+func (s *StdNetBind) send4(conn *net.UDPConn, pc *ipv4.PacketConn, ep Endpoint, bufs [][]byte) error {
ua := s.udpAddrPool.Get().(*net.UDPAddr)
as4 := ep.DstIP().As4()
copy(ua.IP, as4[:])
ua.IP = ua.IP[:4]
ua.Port = int(ep.(*StdNetEndpoint).Port())
msgs := s.ipv4MsgsPool.Get().(*[]ipv4.Message)
- for i, buff := range buffs {
- (*msgs)[i].Buffers[0] = buff
+ for i, buf := range bufs {
+ (*msgs)[i].Buffers[0] = buf
(*msgs)[i].Addr = ua
setSrcControl(&(*msgs)[i].OOB, ep.(*StdNetEndpoint))
}
@@ -352,15 +352,15 @@ func (s *StdNetBind) send4(conn *net.UDPConn, pc *ipv4.PacketConn, ep Endpoint,
)
if runtime.GOOS == "linux" {
for {
- n, err = pc.WriteBatch((*msgs)[start:len(buffs)], 0)
- if err != nil || n == len((*msgs)[start:len(buffs)]) {
+ n, err = pc.WriteBatch((*msgs)[start:len(bufs)], 0)
+ if err != nil || n == len((*msgs)[start:len(bufs)]) {
break
}
start += n
}
} else {
- for i, buff := range buffs {
- _, _, err = conn.WriteMsgUDP(buff, (*msgs)[i].OOB, ua)
+ for i, buf := range bufs {
+ _, _, err = conn.WriteMsgUDP(buf, (*msgs)[i].OOB, ua)
if err != nil {
break
}
@@ -371,15 +371,15 @@ func (s *StdNetBind) send4(conn *net.UDPConn, pc *ipv4.PacketConn, ep Endpoint,
return err
}
-func (s *StdNetBind) send6(conn *net.UDPConn, pc *ipv6.PacketConn, ep Endpoint, buffs [][]byte) error {
+func (s *StdNetBind) send6(conn *net.UDPConn, pc *ipv6.PacketConn, ep Endpoint, bufs [][]byte) error {
ua := s.udpAddrPool.Get().(*net.UDPAddr)
as16 := ep.DstIP().As16()
copy(ua.IP, as16[:])
ua.IP = ua.IP[:16]
ua.Port = int(ep.(*StdNetEndpoint).Port())
msgs := s.ipv6MsgsPool.Get().(*[]ipv6.Message)
- for i, buff := range buffs {
- (*msgs)[i].Buffers[0] = buff
+ for i, buf := range bufs {
+ (*msgs)[i].Buffers[0] = buf
(*msgs)[i].Addr = ua
setSrcControl(&(*msgs)[i].OOB, ep.(*StdNetEndpoint))
}
@@ -390,15 +390,15 @@ func (s *StdNetBind) send6(conn *net.UDPConn, pc *ipv6.PacketConn, ep Endpoint,
)
if runtime.GOOS == "linux" {
for {
- n, err = pc.WriteBatch((*msgs)[start:len(buffs)], 0)
- if err != nil || n == len((*msgs)[start:len(buffs)]) {
+ n, err = pc.WriteBatch((*msgs)[start:len(bufs)], 0)
+ if err != nil || n == len((*msgs)[start:len(bufs)]) {
break
}
start += n
}
} else {
- for i, buff := range buffs {
- _, _, err = conn.WriteMsgUDP(buff, (*msgs)[i].OOB, ua)
+ for i, buf := range bufs {
+ _, _, err = conn.WriteMsgUDP(buf, (*msgs)[i].OOB, ua)
if err != nil {
break
}
diff --git a/conn/bind_std_test.go b/conn/bind_std_test.go
index 76afa30..1e46776 100644
--- a/conn/bind_std_test.go
+++ b/conn/bind_std_test.go
@@ -9,14 +9,14 @@ func TestStdNetBindReceiveFuncAfterClose(t *testing.T) {
t.Fatal(err)
}
bind.Close()
- buffs := make([][]byte, 1)
- buffs[0] = make([]byte, 1)
+ bufs := make([][]byte, 1)
+ bufs[0] = make([]byte, 1)
sizes := make([]int, 1)
eps := make([]Endpoint, 1)
for _, fn := range fns {
// The ReceiveFuncs must not access conn-related fields on StdNetBind
// unguarded. Close() nils the conn-related fields resulting in a panic
// if they violate the mutex.
- fn(buffs, sizes, eps)
+ fn(bufs, sizes, eps)
}
}
diff --git a/conn/bind_windows.go b/conn/bind_windows.go
index e44cc7b..228167e 100644
--- a/conn/bind_windows.go
+++ b/conn/bind_windows.go
@@ -416,19 +416,19 @@ retry:
return n, &ep, nil
}
-func (bind *WinRingBind) receiveIPv4(buffs [][]byte, sizes []int, eps []Endpoint) (int, error) {
+func (bind *WinRingBind) receiveIPv4(bufs [][]byte, sizes []int, eps []Endpoint) (int, error) {
bind.mu.RLock()
defer bind.mu.RUnlock()
- n, ep, err := bind.v4.Receive(buffs[0], &bind.isOpen)
+ n, ep, err := bind.v4.Receive(bufs[0], &bind.isOpen)
sizes[0] = n
eps[0] = ep
return 1, err
}
-func (bind *WinRingBind) receiveIPv6(buffs [][]byte, sizes []int, eps []Endpoint) (int, error) {
+func (bind *WinRingBind) receiveIPv6(bufs [][]byte, sizes []int, eps []Endpoint) (int, error) {
bind.mu.RLock()
defer bind.mu.RUnlock()
- n, ep, err := bind.v6.Receive(buffs[0], &bind.isOpen)
+ n, ep, err := bind.v6.Receive(bufs[0], &bind.isOpen)
sizes[0] = n
eps[0] = ep
return 1, err
@@ -486,14 +486,14 @@ func (bind *afWinRingBind) Send(buf []byte, nend *WinRingEndpoint, isOpen *atomi
return winrio.SendEx(bind.rq, dataBuffer, 1, nil, addressBuffer, nil, nil, 0, 0)
}
-func (bind *WinRingBind) Send(buffs [][]byte, endpoint Endpoint) error {
+func (bind *WinRingBind) Send(bufs [][]byte, endpoint Endpoint) error {
nend, ok := endpoint.(*WinRingEndpoint)
if !ok {
return ErrWrongEndpointType
}
bind.mu.RLock()
defer bind.mu.RUnlock()
- for _, buf := range buffs {
+ for _, buf := range bufs {
switch nend.family {
case windows.AF_INET:
if bind.v4.blackhole {
diff --git a/conn/bindtest/bindtest.go b/conn/bindtest/bindtest.go
index b33c53d..74e7add 100644
--- a/conn/bindtest/bindtest.go
+++ b/conn/bindtest/bindtest.go
@@ -94,12 +94,12 @@ func (c *ChannelBind) BatchSize() int { return 1 }
func (c *ChannelBind) SetMark(mark uint32) error { return nil }
func (c *ChannelBind) makeReceiveFunc(ch chan []byte) conn.ReceiveFunc {
- return func(buffs [][]byte, sizes []int, eps []conn.Endpoint) (n int, err error) {
+ return func(bufs [][]byte, sizes []int, eps []conn.Endpoint) (n int, err error) {
select {
case <-c.closeSignal:
return 0, net.ErrClosed
case rx := <-ch:
- copied := copy(buffs[0], rx)
+ copied := copy(bufs[0], rx)
sizes[0] = copied
eps[0] = c.target6
return 1, nil
@@ -107,8 +107,8 @@ func (c *ChannelBind) makeReceiveFunc(ch chan []byte) conn.ReceiveFunc {
}
}
-func (c *ChannelBind) Send(buffs [][]byte, ep conn.Endpoint) error {
- for _, b := range buffs {
+func (c *ChannelBind) Send(bufs [][]byte, ep conn.Endpoint) error {
+ for _, b := range bufs {
select {
case <-c.closeSignal:
return net.ErrClosed
diff --git a/conn/conn.go b/conn/conn.go
index a9c70b5..a1f57d2 100644
--- a/conn/conn.go
+++ b/conn/conn.go
@@ -45,9 +45,9 @@ type Bind interface {
// This mark is passed to the kernel as the socket option SO_MARK.
SetMark(mark uint32) error
- // Send writes one or more packets in buffs to address ep. The length of
- // buffs must not exceed BatchSize().
- Send(buffs [][]byte, ep Endpoint) error
+ // Send writes one or more packets in bufs to address ep. The length of
+ // bufs must not exceed BatchSize().
+ Send(bufs [][]byte, ep Endpoint) error
// ParseEndpoint creates a new endpoint from a string.
ParseEndpoint(s string) (Endpoint, error)
diff --git a/conn/conn_test.go b/conn/conn_test.go
index 7a6231d..c6194ee 100644
--- a/conn/conn_test.go
+++ b/conn/conn_test.go
@@ -11,7 +11,7 @@ import (
func TestPrettyName(t *testing.T) {
var (
- recvFunc ReceiveFunc = func(buffs [][]byte, sizes []int, eps []Endpoint) (n int, err error) { return }
+ recvFunc ReceiveFunc = func(bufs [][]byte, sizes []int, eps []Endpoint) (n int, err error) { return }
)
const want = "TestPrettyName"