From 9c9e7e2724340280d0ca4ff29c067f2d144562c0 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 9 Dec 2021 17:55:50 +0100 Subject: global: apply gofumpt Signed-off-by: Jason A. Donenfeld --- tun/netstack/tun.go | 7 +++++-- tun/tun_darwin.go | 5 +---- tun/tun_linux.go | 2 -- tun/tun_openbsd.go | 5 +---- tun/tun_windows.go | 6 ++++-- 5 files changed, 11 insertions(+), 14 deletions(-) (limited to 'tun') diff --git a/tun/netstack/tun.go b/tun/netstack/tun.go index f1c03f4..fb7f07d 100644 --- a/tun/netstack/tun.go +++ b/tun/netstack/tun.go @@ -42,8 +42,11 @@ type netTun struct { dnsServers []netip.Addr hasV4, hasV6 bool } -type endpoint netTun -type Net netTun + +type ( + endpoint netTun + Net netTun +) func (e *endpoint) Attach(dispatcher stack.NetworkDispatcher) { e.dispatcher = dispatcher diff --git a/tun/tun_darwin.go b/tun/tun_darwin.go index 35d3085..94bbfa6 100644 --- a/tun/tun_darwin.go +++ b/tun/tun_darwin.go @@ -141,7 +141,7 @@ func CreateTUN(name string, mtu int) (Device, error) { if err == nil && name == "utun" { fname := os.Getenv("WG_TUN_NAME_FILE") if fname != "" { - os.WriteFile(fname, []byte(tun.(*NativeTun).name+"\n"), 0400) + os.WriteFile(fname, []byte(tun.(*NativeTun).name+"\n"), 0o400) } } @@ -232,7 +232,6 @@ func (tun *NativeTun) Read(buff []byte, offset int) (int, error) { } func (tun *NativeTun) Write(buff []byte, offset int) (int, error) { - // reserve space for header buff = buff[offset-4:] @@ -282,7 +281,6 @@ func (tun *NativeTun) setMTU(n int) error { unix.SOCK_DGRAM, 0, ) - if err != nil { return err } @@ -306,7 +304,6 @@ func (tun *NativeTun) MTU() (int, error) { unix.SOCK_DGRAM, 0, ) - if err != nil { return 0, err } diff --git a/tun/tun_linux.go b/tun/tun_linux.go index 1cc84cb..89b716d 100644 --- a/tun/tun_linux.go +++ b/tun/tun_linux.go @@ -232,7 +232,6 @@ func (tun *NativeTun) setMTU(n int) error { unix.SOCK_DGRAM, 0, ) - if err != nil { return err } @@ -269,7 +268,6 @@ func (tun *NativeTun) MTU() (int, error) { unix.SOCK_DGRAM, 0, ) - if err != nil { return 0, err } diff --git a/tun/tun_openbsd.go b/tun/tun_openbsd.go index 7ef62f4..ff845bc 100644 --- a/tun/tun_openbsd.go +++ b/tun/tun_openbsd.go @@ -133,7 +133,7 @@ func CreateTUN(name string, mtu int) (Device, error) { if err == nil && name == "tun" { fname := os.Getenv("WG_TUN_NAME_FILE") if fname != "" { - os.WriteFile(fname, []byte(tun.(*NativeTun).name+"\n"), 0400) + os.WriteFile(fname, []byte(tun.(*NativeTun).name+"\n"), 0o400) } } @@ -219,7 +219,6 @@ func (tun *NativeTun) Read(buff []byte, offset int) (int, error) { } func (tun *NativeTun) Write(buff []byte, offset int) (int, error) { - // reserve space for header buff = buff[offset-4:] @@ -274,7 +273,6 @@ func (tun *NativeTun) setMTU(n int) error { unix.SOCK_DGRAM, 0, ) - if err != nil { return err } @@ -309,7 +307,6 @@ func (tun *NativeTun) MTU() (int, error) { unix.SOCK_DGRAM, 0, ) - if err != nil { return 0, err } diff --git a/tun/tun_windows.go b/tun/tun_windows.go index 3101ed9..d057150 100644 --- a/tun/tun_windows.go +++ b/tun/tun_windows.go @@ -46,8 +46,10 @@ type NativeTun struct { forcedMTU int } -var WintunTunnelType = "WireGuard" -var WintunStaticRequestedGUID *windows.GUID +var ( + WintunTunnelType = "WireGuard" + WintunStaticRequestedGUID *windows.GUID +) //go:linkname procyield runtime.procyield func procyield(cycles uint32) -- cgit v1.2.3-54-g00ecf