Skip to content

Commit 9c9e7e2

Browse files
committed
global: apply gofumpt
Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 2dd424e commit 9c9e7e2

28 files changed

+56
-71
lines changed

conn/bind_linux.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ type LinuxSocketBind struct {
6666
func NewLinuxSocketBind() Bind { return &LinuxSocketBind{sock4: -1, sock6: -1} }
6767
func NewDefaultBind() Bind { return NewLinuxSocketBind() }
6868

69-
var _ Endpoint = (*LinuxSocketEndpoint)(nil)
70-
var _ Bind = (*LinuxSocketBind)(nil)
69+
var (
70+
_ Endpoint = (*LinuxSocketEndpoint)(nil)
71+
_ Bind = (*LinuxSocketBind)(nil)
72+
)
7173

7274
func (*LinuxSocketBind) ParseEndpoint(s string) (Endpoint, error) {
7375
var end LinuxSocketEndpoint
@@ -171,7 +173,6 @@ func (bind *LinuxSocketBind) SetMark(value uint32) error {
171173
unix.SO_MARK,
172174
int(value),
173175
)
174-
175176
if err != nil {
176177
return err
177178
}
@@ -184,7 +185,6 @@ func (bind *LinuxSocketBind) SetMark(value uint32) error {
184185
unix.SO_MARK,
185186
int(value),
186187
)
187-
188188
if err != nil {
189189
return err
190190
}
@@ -327,15 +327,13 @@ func zoneToUint32(zone string) (uint32, error) {
327327
}
328328

329329
func create4(port uint16) (int, uint16, error) {
330-
331330
// create socket
332331

333332
fd, err := unix.Socket(
334333
unix.AF_INET,
335334
unix.SOCK_DGRAM,
336335
0,
337336
)
338-
339337
if err != nil {
340338
return -1, 0, err
341339
}
@@ -371,15 +369,13 @@ func create4(port uint16) (int, uint16, error) {
371369
}
372370

373371
func create6(port uint16) (int, uint16, error) {
374-
375372
// create socket
376373

377374
fd, err := unix.Socket(
378375
unix.AF_INET6,
379376
unix.SOCK_DGRAM,
380377
0,
381378
)
382-
383379
if err != nil {
384380
return -1, 0, err
385381
}
@@ -410,7 +406,6 @@ func create6(port uint16) (int, uint16, error) {
410406
}
411407

412408
return unix.Bind(fd, &addr)
413-
414409
}(); err != nil {
415410
unix.Close(fd)
416411
return -1, 0, err
@@ -425,7 +420,6 @@ func create6(port uint16) (int, uint16, error) {
425420
}
426421

427422
func send4(sock int, end *LinuxSocketEndpoint, buff []byte) error {
428-
429423
// construct message header
430424

431425
cmsg := struct {
@@ -465,7 +459,6 @@ func send4(sock int, end *LinuxSocketEndpoint, buff []byte) error {
465459
}
466460

467461
func send6(sock int, end *LinuxSocketEndpoint, buff []byte) error {
468-
469462
// construct message header
470463

471464
cmsg := struct {
@@ -509,7 +502,6 @@ func send6(sock int, end *LinuxSocketEndpoint, buff []byte) error {
509502
}
510503

511504
func receive4(sock int, buff []byte, end *LinuxSocketEndpoint) (int, error) {
512-
513505
// construct message header
514506

515507
var cmsg struct {
@@ -518,7 +510,6 @@ func receive4(sock int, buff []byte, end *LinuxSocketEndpoint) (int, error) {
518510
}
519511

520512
size, _, _, newDst, err := unix.Recvmsg(sock, buff, (*[unsafe.Sizeof(cmsg)]byte)(unsafe.Pointer(&cmsg))[:], 0)
521-
522513
if err != nil {
523514
return 0, err
524515
}
@@ -541,7 +532,6 @@ func receive4(sock int, buff []byte, end *LinuxSocketEndpoint) (int, error) {
541532
}
542533

543534
func receive6(sock int, buff []byte, end *LinuxSocketEndpoint) (int, error) {
544-
545535
// construct message header
546536

547537
var cmsg struct {
@@ -550,7 +540,6 @@ func receive6(sock int, buff []byte, end *LinuxSocketEndpoint) (int, error) {
550540
}
551541

552542
size, _, _, newDst, err := unix.Recvmsg(sock, buff, (*[unsafe.Sizeof(cmsg)]byte)(unsafe.Pointer(&cmsg))[:], 0)
553-
554543
if err != nil {
555544
return 0, err
556545
}

conn/bind_std.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ func NewStdNetBind() Bind { return &StdNetBind{} }
3030

3131
type StdNetEndpoint net.UDPAddr
3232

33-
var _ Bind = (*StdNetBind)(nil)
34-
var _ Endpoint = (*StdNetEndpoint)(nil)
33+
var (
34+
_ Bind = (*StdNetBind)(nil)
35+
_ Endpoint = (*StdNetEndpoint)(nil)
36+
)
3537

3638
func (*StdNetBind) ParseEndpoint(s string) (Endpoint, error) {
3739
e, err := netip.ParseAddrPort(s)

conn/bind_windows.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ type WinRingEndpoint struct {
9191
data [30]byte
9292
}
9393

94-
var _ Bind = (*WinRingBind)(nil)
95-
var _ Endpoint = (*WinRingEndpoint)(nil)
94+
var (
95+
_ Bind = (*WinRingBind)(nil)
96+
_ Endpoint = (*WinRingEndpoint)(nil)
97+
)
9698

9799
func (*WinRingBind) ParseEndpoint(s string) (Endpoint, error) {
98100
host, port, err := net.SplitHostPort(s)
@@ -382,7 +384,6 @@ retry:
382384
count = winrio.DequeueCompletion(bind.rx.cq, results[:])
383385
if count == 0 {
384386
return 0, nil, io.ErrNoProgress
385-
386387
}
387388
}
388389
bind.rx.Return(1)
@@ -533,6 +534,7 @@ func (bind *StdNetBind) BindSocketToInterface6(interfaceIndex uint32, blackhole
533534
bind.blackhole6 = blackhole
534535
return nil
535536
}
537+
536538
func (bind *WinRingBind) BindSocketToInterface4(interfaceIndex uint32, blackhole bool) error {
537539
bind.mu.RLock()
538540
defer bind.mu.RUnlock()

conn/bindtest/bindtest.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ type ChannelBind struct {
2525

2626
type ChannelEndpoint uint16
2727

28-
var _ conn.Bind = (*ChannelBind)(nil)
29-
var _ conn.Endpoint = (*ChannelEndpoint)(nil)
28+
var (
29+
_ conn.Bind = (*ChannelBind)(nil)
30+
_ conn.Endpoint = (*ChannelEndpoint)(nil)
31+
)
3032

3133
func NewChannelBinds() [2]conn.Bind {
3234
arx4 := make(chan []byte, 8192)

conn/winrio/rio_windows.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ type iocpNotificationCompletion struct {
8484
overlapped *windows.Overlapped
8585
}
8686

87-
var initialized sync.Once
88-
var available bool
87+
var (
88+
initialized sync.Once
89+
available bool
90+
)
8991

9092
func Initialize() bool {
9193
initialized.Do(func() {
@@ -108,7 +110,7 @@ func Initialize() bool {
108110
return
109111
}
110112
defer windows.CloseHandle(socket)
111-
var WSAID_MULTIPLE_RIO = &windows.GUID{0x8509e081, 0x96dd, 0x4005, [8]byte{0xb1, 0x65, 0x9e, 0x2e, 0xe8, 0xc7, 0x9e, 0x3f}}
113+
WSAID_MULTIPLE_RIO := &windows.GUID{0x8509e081, 0x96dd, 0x4005, [8]byte{0xb1, 0x65, 0x9e, 0x2e, 0xe8, 0xc7, 0x9e, 0x3f}}
112114
const SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER = 0xc8000024
113115
ob := uint32(0)
114116
err = windows.WSAIoctl(socket, SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER,

device/allowedips_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ type testPairCommonBits struct {
2020
}
2121

2222
func TestCommonBits(t *testing.T) {
23-
2423
tests := []testPairCommonBits{
2524
{s1: []byte{1, 4, 53, 128}, s2: []byte{0, 0, 0, 0}, match: 7},
2625
{s1: []byte{0, 4, 53, 128}, s2: []byte{0, 0, 0, 0}, match: 13},
@@ -41,7 +40,7 @@ func TestCommonBits(t *testing.T) {
4140
}
4241
}
4342

44-
func benchmarkTrie(peerNumber int, addressNumber int, addressLength int, b *testing.B) {
43+
func benchmarkTrie(peerNumber, addressNumber, addressLength int, b *testing.B) {
4544
var trie *trieEntry
4645
var peers []*Peer
4746
root := parentIndirection{&trie, 2}

device/cookie.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (st *CookieChecker) CheckMAC1(msg []byte) bool {
8383
return hmac.Equal(mac1[:], msg[smac1:smac2])
8484
}
8585

86-
func (st *CookieChecker) CheckMAC2(msg []byte, src []byte) bool {
86+
func (st *CookieChecker) CheckMAC2(msg, src []byte) bool {
8787
st.RLock()
8888
defer st.RUnlock()
8989

@@ -119,7 +119,6 @@ func (st *CookieChecker) CreateReply(
119119
recv uint32,
120120
src []byte,
121121
) (*MessageCookieReply, error) {
122-
123122
st.RLock()
124123

125124
// refresh cookie secret
@@ -204,7 +203,6 @@ func (st *CookieGenerator) ConsumeReply(msg *MessageCookieReply) bool {
204203

205204
xchapoly, _ := chacha20poly1305.NewX(st.mac2.encryptionKey[:])
206205
_, err := xchapoly.Open(cookie[:0], msg.Nonce[:], msg.Cookie[:], st.mac2.lastMAC1[:])
207-
208206
if err != nil {
209207
return false
210208
}
@@ -215,7 +213,6 @@ func (st *CookieGenerator) ConsumeReply(msg *MessageCookieReply) bool {
215213
}
216214

217215
func (st *CookieGenerator) AddMacs(msg []byte) {
218-
219216
size := len(msg)
220217

221218
smac2 := size - blake2s.Size128

device/cookie_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
)
1111

1212
func TestCookieMAC1(t *testing.T) {
13-
1413
// setup generator / checker
1514

1615
var (
@@ -132,12 +131,12 @@ func TestCookieMAC1(t *testing.T) {
132131

133132
msg[5] ^= 0x20
134133

135-
srcBad1 := []byte{192, 168, 13, 37, 40, 01}
134+
srcBad1 := []byte{192, 168, 13, 37, 40, 1}
136135
if checker.CheckMAC2(msg, srcBad1) {
137136
t.Fatal("MAC2 generation/verification failed")
138137
}
139138

140-
srcBad2 := []byte{192, 168, 13, 38, 40, 01}
139+
srcBad2 := []byte{192, 168, 13, 38, 40, 1}
141140
if checker.CheckMAC2(msg, srcBad2) {
142141
t.Fatal("MAC2 generation/verification failed")
143142
}

device/device_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func uapiCfg(cfg ...string) string {
4848

4949
// genConfigs generates a pair of configs that connect to each other.
5050
// The configs use distinct, probably-usable ports.
51-
func genConfigs(tb testing.TB) (cfgs [2]string, endpointCfgs [2]string) {
51+
func genConfigs(tb testing.TB) (cfgs, endpointCfgs [2]string) {
5252
var key1, key2 NoisePrivateKey
5353
_, err := rand.Read(key1[:])
5454
if err != nil {

device/kdf_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type KDFTest struct {
2020
t2 string
2121
}
2222

23-
func assertEquals(t *testing.T, a string, b string) {
23+
func assertEquals(t *testing.T, a, b string) {
2424
if a != b {
2525
t.Fatal("expected", a, "=", b)
2626
}

0 commit comments

Comments
 (0)