diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-12-09 17:55:50 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-12-09 23:15:55 +0100 |
commit | 9c9e7e2724340280d0ca4ff29c067f2d144562c0 (patch) | |
tree | 239826ccafe70e5cee73936d9bcea8989dd33899 /conn | |
parent | 2dd424e2d808703339688ff78e32ed30cd0dfe87 (diff) |
global: apply gofumpt
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'conn')
-rw-r--r-- | conn/bind_linux.go | 19 | ||||
-rw-r--r-- | conn/bind_std.go | 6 | ||||
-rw-r--r-- | conn/bind_windows.go | 8 | ||||
-rw-r--r-- | conn/bindtest/bindtest.go | 6 | ||||
-rw-r--r-- | conn/winrio/rio_windows.go | 8 |
5 files changed, 22 insertions, 25 deletions
diff --git a/conn/bind_linux.go b/conn/bind_linux.go index da0670a..b3d755c 100644 --- a/conn/bind_linux.go +++ b/conn/bind_linux.go @@ -66,8 +66,10 @@ type LinuxSocketBind struct { func NewLinuxSocketBind() Bind { return &LinuxSocketBind{sock4: -1, sock6: -1} } func NewDefaultBind() Bind { return NewLinuxSocketBind() } -var _ Endpoint = (*LinuxSocketEndpoint)(nil) -var _ Bind = (*LinuxSocketBind)(nil) +var ( + _ Endpoint = (*LinuxSocketEndpoint)(nil) + _ Bind = (*LinuxSocketBind)(nil) +) func (*LinuxSocketBind) ParseEndpoint(s string) (Endpoint, error) { var end LinuxSocketEndpoint @@ -171,7 +173,6 @@ func (bind *LinuxSocketBind) SetMark(value uint32) error { unix.SO_MARK, int(value), ) - if err != nil { return err } @@ -184,7 +185,6 @@ func (bind *LinuxSocketBind) SetMark(value uint32) error { unix.SO_MARK, int(value), ) - if err != nil { return err } @@ -327,7 +327,6 @@ func zoneToUint32(zone string) (uint32, error) { } func create4(port uint16) (int, uint16, error) { - // create socket fd, err := unix.Socket( @@ -335,7 +334,6 @@ func create4(port uint16) (int, uint16, error) { unix.SOCK_DGRAM, 0, ) - if err != nil { return -1, 0, err } @@ -371,7 +369,6 @@ func create4(port uint16) (int, uint16, error) { } func create6(port uint16) (int, uint16, error) { - // create socket fd, err := unix.Socket( @@ -379,7 +376,6 @@ func create6(port uint16) (int, uint16, error) { unix.SOCK_DGRAM, 0, ) - if err != nil { return -1, 0, err } @@ -410,7 +406,6 @@ func create6(port uint16) (int, uint16, error) { } return unix.Bind(fd, &addr) - }(); err != nil { unix.Close(fd) return -1, 0, err @@ -425,7 +420,6 @@ func create6(port uint16) (int, uint16, error) { } func send4(sock int, end *LinuxSocketEndpoint, buff []byte) error { - // construct message header cmsg := struct { @@ -465,7 +459,6 @@ func send4(sock int, end *LinuxSocketEndpoint, buff []byte) error { } func send6(sock int, end *LinuxSocketEndpoint, buff []byte) error { - // construct message header cmsg := struct { @@ -509,7 +502,6 @@ func send6(sock int, end *LinuxSocketEndpoint, buff []byte) error { } func receive4(sock int, buff []byte, end *LinuxSocketEndpoint) (int, error) { - // construct message header var cmsg struct { @@ -518,7 +510,6 @@ func receive4(sock int, buff []byte, end *LinuxSocketEndpoint) (int, error) { } size, _, _, newDst, err := unix.Recvmsg(sock, buff, (*[unsafe.Sizeof(cmsg)]byte)(unsafe.Pointer(&cmsg))[:], 0) - if err != nil { return 0, err } @@ -541,7 +532,6 @@ func receive4(sock int, buff []byte, end *LinuxSocketEndpoint) (int, error) { } func receive6(sock int, buff []byte, end *LinuxSocketEndpoint) (int, error) { - // construct message header var cmsg struct { @@ -550,7 +540,6 @@ func receive6(sock int, buff []byte, end *LinuxSocketEndpoint) (int, error) { } size, _, _, newDst, err := unix.Recvmsg(sock, buff, (*[unsafe.Sizeof(cmsg)]byte)(unsafe.Pointer(&cmsg))[:], 0) - if err != nil { return 0, err } diff --git a/conn/bind_std.go b/conn/bind_std.go index a3cbb15..de03b10 100644 --- a/conn/bind_std.go +++ b/conn/bind_std.go @@ -30,8 +30,10 @@ func NewStdNetBind() Bind { return &StdNetBind{} } type StdNetEndpoint net.UDPAddr -var _ Bind = (*StdNetBind)(nil) -var _ Endpoint = (*StdNetEndpoint)(nil) +var ( + _ Bind = (*StdNetBind)(nil) + _ Endpoint = (*StdNetEndpoint)(nil) +) func (*StdNetBind) ParseEndpoint(s string) (Endpoint, error) { e, err := netip.ParseAddrPort(s) diff --git a/conn/bind_windows.go b/conn/bind_windows.go index 26a3af8..476e277 100644 --- a/conn/bind_windows.go +++ b/conn/bind_windows.go @@ -91,8 +91,10 @@ type WinRingEndpoint struct { data [30]byte } -var _ Bind = (*WinRingBind)(nil) -var _ Endpoint = (*WinRingEndpoint)(nil) +var ( + _ Bind = (*WinRingBind)(nil) + _ Endpoint = (*WinRingEndpoint)(nil) +) func (*WinRingBind) ParseEndpoint(s string) (Endpoint, error) { host, port, err := net.SplitHostPort(s) @@ -382,7 +384,6 @@ retry: count = winrio.DequeueCompletion(bind.rx.cq, results[:]) if count == 0 { return 0, nil, io.ErrNoProgress - } } bind.rx.Return(1) @@ -533,6 +534,7 @@ func (bind *StdNetBind) BindSocketToInterface6(interfaceIndex uint32, blackhole bind.blackhole6 = blackhole return nil } + func (bind *WinRingBind) BindSocketToInterface4(interfaceIndex uint32, blackhole bool) error { bind.mu.RLock() defer bind.mu.RUnlock() diff --git a/conn/bindtest/bindtest.go b/conn/bindtest/bindtest.go index 6a45896..6fc1972 100644 --- a/conn/bindtest/bindtest.go +++ b/conn/bindtest/bindtest.go @@ -25,8 +25,10 @@ type ChannelBind struct { type ChannelEndpoint uint16 -var _ conn.Bind = (*ChannelBind)(nil) -var _ conn.Endpoint = (*ChannelEndpoint)(nil) +var ( + _ conn.Bind = (*ChannelBind)(nil) + _ conn.Endpoint = (*ChannelEndpoint)(nil) +) func NewChannelBinds() [2]conn.Bind { arx4 := make(chan []byte, 8192) diff --git a/conn/winrio/rio_windows.go b/conn/winrio/rio_windows.go index 0a07c65..0911998 100644 --- a/conn/winrio/rio_windows.go +++ b/conn/winrio/rio_windows.go @@ -84,8 +84,10 @@ type iocpNotificationCompletion struct { overlapped *windows.Overlapped } -var initialized sync.Once -var available bool +var ( + initialized sync.Once + available bool +) func Initialize() bool { initialized.Do(func() { @@ -108,7 +110,7 @@ func Initialize() bool { return } defer windows.CloseHandle(socket) - var WSAID_MULTIPLE_RIO = &windows.GUID{0x8509e081, 0x96dd, 0x4005, [8]byte{0xb1, 0x65, 0x9e, 0x2e, 0xe8, 0xc7, 0x9e, 0x3f}} + WSAID_MULTIPLE_RIO := &windows.GUID{0x8509e081, 0x96dd, 0x4005, [8]byte{0xb1, 0x65, 0x9e, 0x2e, 0xe8, 0xc7, 0x9e, 0x3f}} const SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER = 0xc8000024 ob := uint32(0) err = windows.WSAIoctl(socket, SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER, |