global: apply gofumpt
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user