From 85c5bc61ac39169f96b9c853d63e165823a014e1 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sun, 24 Nov 2019 21:03:02 +0000 Subject: [PATCH] TUN_OFFSET_BYTES per platform --- src/tuntap/iface.go | 2 -- src/tuntap/tun_bsd.go | 2 ++ src/tuntap/tun_darwin.go | 2 ++ src/tuntap/tun_linux.go | 2 ++ src/tuntap/tun_other.go | 2 ++ src/tuntap/tun_windows.go | 4 +++- 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/tuntap/iface.go b/src/tuntap/iface.go index f1ca0add..633903da 100644 --- a/src/tuntap/iface.go +++ b/src/tuntap/iface.go @@ -9,8 +9,6 @@ import ( "github.com/Arceliar/phony" ) -const TUN_OFFSET_BYTES = 4 - type tunWriter struct { phony.Inbox tun *TunAdapter diff --git a/src/tuntap/tun_bsd.go b/src/tuntap/tun_bsd.go index 219e3485..79184cb9 100644 --- a/src/tuntap/tun_bsd.go +++ b/src/tuntap/tun_bsd.go @@ -15,6 +15,8 @@ import ( wgtun "golang.zx2c4.com/wireguard/tun" ) +const TUN_OFFSET_BYTES = 0 + const SIOCSIFADDR_IN6 = (0x80000000) | ((288 & 0x1fff) << 16) | uint32(byte('i'))<<8 | 12 type in6_addrlifetime struct { diff --git a/src/tuntap/tun_darwin.go b/src/tuntap/tun_darwin.go index cf2fbfb4..4dab6f31 100644 --- a/src/tuntap/tun_darwin.go +++ b/src/tuntap/tun_darwin.go @@ -15,6 +15,8 @@ import ( wgtun "golang.zx2c4.com/wireguard/tun" ) +const TUN_OFFSET_BYTES = 0 + // Configures the "utun" adapter with the correct IPv6 address and MTU. func (tun *TunAdapter) setup(ifname string, addr string, mtu int) error { if ifname == "auto" { diff --git a/src/tuntap/tun_linux.go b/src/tuntap/tun_linux.go index 4206b26a..ca402522 100644 --- a/src/tuntap/tun_linux.go +++ b/src/tuntap/tun_linux.go @@ -9,6 +9,8 @@ import ( wgtun "golang.zx2c4.com/wireguard/tun" ) +const TUN_OFFSET_BYTES = 0 + // Configures the TUN adapter with the correct IPv6 address and MTU. func (tun *TunAdapter) setup(ifname string, addr string, mtu int) error { if ifname == "auto" { diff --git a/src/tuntap/tun_other.go b/src/tuntap/tun_other.go index 8a27f57b..85934f39 100644 --- a/src/tuntap/tun_other.go +++ b/src/tuntap/tun_other.go @@ -9,6 +9,8 @@ import ( wgtun "golang.zx2c4.com/wireguard/tun" ) +const TUN_OFFSET_BYTES = 0 + // Configures the TUN adapter with the correct IPv6 address and MTU. func (tun *TunAdapter) setup(ifname string, addr string, mtu int) error { iface, err := wgtun.CreateTUN(ifname, mtu) diff --git a/src/tuntap/tun_windows.go b/src/tuntap/tun_windows.go index 9b5f7b0c..e611af76 100644 --- a/src/tuntap/tun_windows.go +++ b/src/tuntap/tun_windows.go @@ -2,6 +2,8 @@ package tuntap +// This is to catch Windows platforms + import ( "bytes" "errors" @@ -16,7 +18,7 @@ import ( "golang.zx2c4.com/wireguard/windows/tunnel/winipcfg" ) -// This is to catch Windows platforms +const TUN_OFFSET_BYTES = 4 // Configures the TUN adapter with the correct IPv6 address and MTU. func (tun *TunAdapter) setup(ifname string, addr string, mtu int) error {