diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-10-27 00:57:58 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-10-27 01:03:28 +0200 |
commit | 95fefbdb39dfdac91567c6454e74a354203ef03f (patch) | |
tree | 161174e725a7273c15c0e3685a46cef18b0e547c /wireguard-go-bridge/src/tun | |
parent | bridge: go get requires arch paths (diff) | |
download | wireguard-apple-95fefbdb39dfdac91567c6454e74a354203ef03f.tar.xz wireguard-apple-95fefbdb39dfdac91567c6454e74a354203ef03f.zip |
Allow customizing MTU
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'wireguard-go-bridge/src/tun')
-rw-r--r-- | wireguard-go-bridge/src/tun/tun_ios.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/wireguard-go-bridge/src/tun/tun_ios.go b/wireguard-go-bridge/src/tun/tun_ios.go index 93a0503..cafe33b 100644 --- a/wireguard-go-bridge/src/tun/tun_ios.go +++ b/wireguard-go-bridge/src/tun/tun_ios.go @@ -26,10 +26,17 @@ type nativeTun struct { ctx unsafe.Pointer } -func CreateTUN(mtu int, readFn unsafe.Pointer, writeFn unsafe.Pointer, ctx unsafe.Pointer) TUNDevice { +func CreateTUN(mtu uint16, readFn unsafe.Pointer, writeFn unsafe.Pointer, ctx unsafe.Pointer) TUNDevice { + if mtu == 0 { + /* 0 means automatic MTU, which iOS makes outerMTU-80-15. The 80 is for + * WireGuard and the 15 ensures our padding will work. Therefore, it's + * safe to have this code assume a massive MTU. + */ + mtu = ^mtu + } tun := &nativeTun{ events: make(chan TUNEvent, 10), - mtu: mtu, + mtu: int(mtu), readFn: readFn, writeFn: writeFn, ctx: ctx, |