aboutsummaryrefslogtreecommitdiffstats
path: root/tun
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-12-09 17:55:50 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-12-09 23:15:55 +0100
commit9c9e7e2724340280d0ca4ff29c067f2d144562c0 (patch)
tree239826ccafe70e5cee73936d9bcea8989dd33899 /tun
parentdevice: handle peer post config on blank line (diff)
downloadwireguard-go-9c9e7e2724340280d0ca4ff29c067f2d144562c0.tar.xz
wireguard-go-9c9e7e2724340280d0ca4ff29c067f2d144562c0.zip
global: apply gofumpt
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'tun')
-rw-r--r--tun/netstack/tun.go7
-rw-r--r--tun/tun_darwin.go5
-rw-r--r--tun/tun_linux.go2
-rw-r--r--tun/tun_openbsd.go5
-rw-r--r--tun/tun_windows.go6
5 files changed, 11 insertions, 14 deletions
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)