From 5181a063044f2929d66ff80aba96d4c60c1712e6 Mon Sep 17 00:00:00 2001 From: snow flurry Date: Mon, 21 Mar 2022 19:37:56 -0700 Subject: [PATCH] fix whitespace mismatch --- tun/tun_netbsd.go | 80 +++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/tun/tun_netbsd.go b/tun/tun_netbsd.go index cc2004a..f95bfce 100644 --- a/tun/tun_netbsd.go +++ b/tun/tun_netbsd.go @@ -6,12 +6,12 @@ package tun import ( - "errors" + "errors" "fmt" "io/ioutil" "net" "os" - "sync" + "sync" "syscall" "unsafe" @@ -27,18 +27,18 @@ type ifreq_mtu struct { } const ( - _TUNGIFHEAD = 0x40047441 - _TUNSIFMODE = 0x80047458 - _TUNSIFHEAD = 0x80047442 + _TUNGIFHEAD = 0x40047441 + _TUNSIFMODE = 0x80047458 + _TUNSIFHEAD = 0x80047442 ) type NativeTun struct { - name string - tunFile *os.File - events chan Event - errors chan error + name string + tunFile *os.File + events chan Event + errors chan error routeSocket int - closeOnce sync.Once + closeOnce sync.Once } func (tun *NativeTun) routineRouteListener(tunIfindex int) { @@ -148,29 +148,29 @@ func CreateTUN(name string, mtu int) (Device, error) { // Enable ifhead mode, otherwise tun will complain if it gets a non-AF_INET packet ifheadmode := 1 var errno syscall.Errno - _, _, errno = unix.Syscall( - unix.SYS_IOCTL, - tunfile.Fd(), - uintptr(_TUNSIFHEAD), - uintptr(unsafe.Pointer(&ifheadmode)), - ) + _, _, errno = unix.Syscall( + unix.SYS_IOCTL, + tunfile.Fd(), + uintptr(_TUNSIFHEAD), + uintptr(unsafe.Pointer(&ifheadmode)), + ) - if errno != 0 { - tunfile.Close() - return nil, fmt.Errorf("Unable to put into IFHEAD mode: %v", errno) - } + if errno != 0 { + tunfile.Close() + return nil, fmt.Errorf("Unable to put into IFHEAD mode: %v", errno) + } - _, _, errno = unix.Syscall( - unix.SYS_IOCTL, - tunfile.Fd(), - uintptr(_TUNGIFHEAD), - uintptr(unsafe.Pointer(&ifheadmode)), - ) + _, _, errno = unix.Syscall( + unix.SYS_IOCTL, + tunfile.Fd(), + uintptr(_TUNGIFHEAD), + uintptr(unsafe.Pointer(&ifheadmode)), + ) - if errno != 0 || ifheadmode == 0 { - tunfile.Close() - return nil, fmt.Errorf("Unable to validate IFHEAD mode: %v (ifheadmode = %d)", errno, ifheadmode) - } + if errno != 0 || ifheadmode == 0 { + tunfile.Close() + return nil, fmt.Errorf("Unable to validate IFHEAD mode: %v (ifheadmode = %d)", errno, ifheadmode) + } if err == nil && name == "tun" { fname := os.Getenv("WG_TUN_NAME_FILE") @@ -289,16 +289,16 @@ func (tun *NativeTun) Flush() error { func (tun *NativeTun) Close() error { var err1, err2 error - tun.closeOnce.Do(func () { - err1 = tun.tunFile.Close() - if tun.routeSocket != -1 { - unix.Shutdown(tun.routeSocket, unix.SHUT_RDWR) - err2 = unix.Close(tun.routeSocket) - tun.routeSocket = -1 - } else if tun.events != nil { - close(tun.events) - } - }) + tun.closeOnce.Do(func () { + err1 = tun.tunFile.Close() + if tun.routeSocket != -1 { + unix.Shutdown(tun.routeSocket, unix.SHUT_RDWR) + err2 = unix.Close(tun.routeSocket) + tun.routeSocket = -1 + } else if tun.events != nil { + close(tun.events) + } + }) if err1 != nil { return err1 }