aboutsummaryrefslogtreecommitdiffstats
path: root/wireguard-go-bridge
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-02-27 06:24:56 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-02-27 06:24:56 +0100
commitb1dabf5a00a8400238ef261d31e048aa794be106 (patch)
treec0deabec4f7654f84a78c3b76c967850998afd65 /wireguard-go-bridge
parentImporting: macOS: Support importing of multiple files at a time (diff)
downloadwireguard-apple-b1dabf5a00a8400238ef261d31e048aa794be106.tar.xz
wireguard-apple-b1dabf5a00a8400238ef261d31e048aa794be106.zip
wireguard-go-bridge: update to Go 1.12
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'wireguard-go-bridge')
-rw-r--r--wireguard-go-bridge/Makefile2
-rw-r--r--wireguard-go-bridge/goruntime-boottime-over-monotonic.diff97
-rw-r--r--wireguard-go-bridge/src/api-ios.go4
-rw-r--r--wireguard-go-bridge/src/tun/api-ios.go14
4 files changed, 69 insertions, 48 deletions
diff --git a/wireguard-go-bridge/Makefile b/wireguard-go-bridge/Makefile
index 2468e870..68989490 100644
--- a/wireguard-go-bridge/Makefile
+++ b/wireguard-go-bridge/Makefile
@@ -28,7 +28,7 @@ version-header: $(DESTDIR)/wireguard-go-version.h
GOBUILDARCH := $(GOARCH_$(shell uname -m))
GOBUILDOS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
-GOBUILDVERSION := 1.11.5
+GOBUILDVERSION := 1.12
GOBUILDTARBALL := go$(GOBUILDVERSION).$(GOBUILDOS)-$(GOBUILDARCH).tar.gz
GOBUILDTARBALLURL := https://dl.google.com/go/$(GOBUILDTARBALL)
GOBUILDVERSION_NEEDED := go version go$(GOBUILDVERSION) $(GOBUILDOS)/$(GOBUILDARCH)
diff --git a/wireguard-go-bridge/goruntime-boottime-over-monotonic.diff b/wireguard-go-bridge/goruntime-boottime-over-monotonic.diff
index 5e2dd534..e449ac4e 100644
--- a/wireguard-go-bridge/goruntime-boottime-over-monotonic.diff
+++ b/wireguard-go-bridge/goruntime-boottime-over-monotonic.diff
@@ -1,7 +1,40 @@
-diff -r -u go/src/runtime/sys_darwin_386.s go-modified/src/runtime/sys_darwin_386.s
---- go/src/runtime/sys_darwin_386.s 2018-10-01 23:02:54.000000000 +0200
-+++ go-modified/src/runtime/sys_darwin_386.s 2018-11-01 23:18:04.383055355 +0100
-@@ -184,7 +184,7 @@
+From 74523c5a12d37fa792e77a252bcc569484c3d41a Mon Sep 17 00:00:00 2001
+From: "Jason A. Donenfeld" <Jason@zx2c4.com>
+Date: Wed, 27 Feb 2019 05:33:01 +0100
+Subject: [PATCH] runtime: use libc_mach_continuous_time in nanotime on Darwin
+
+This makes timers account for having expired while a computer was
+asleep, which is quite common on mobile devices. Note that
+continuous_time absolute_time, except that it takes into account
+time spent in suspend.
+
+Fixes #24595
+---
+ src/runtime/sys_darwin.go | 2 +-
+ src/runtime/sys_darwin_386.s | 2 +-
+ src/runtime/sys_darwin_amd64.s | 2 +-
+ src/runtime/sys_darwin_arm.s | 2 +-
+ src/runtime/sys_darwin_arm64.s | 2 +-
+ 5 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/runtime/sys_darwin.go b/src/runtime/sys_darwin.go
+index f34ac88352..416fcb673f 100644
+--- a/src/runtime/sys_darwin.go
++++ b/src/runtime/sys_darwin.go
+@@ -403,7 +403,7 @@ func closeonexec(fd int32) {
+ //go:cgo_import_dynamic libc_usleep usleep "/usr/lib/libSystem.B.dylib"
+
+ //go:cgo_import_dynamic libc_mach_timebase_info mach_timebase_info "/usr/lib/libSystem.B.dylib"
+-//go:cgo_import_dynamic libc_mach_absolute_time mach_absolute_time "/usr/lib/libSystem.B.dylib"
++//go:cgo_import_dynamic libc_mach_continuous_time mach_continuous_time "/usr/lib/libSystem.B.dylib"
+ //go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
+ //go:cgo_import_dynamic libc_sigaction sigaction "/usr/lib/libSystem.B.dylib"
+ //go:cgo_import_dynamic libc_pthread_sigmask pthread_sigmask "/usr/lib/libSystem.B.dylib"
+diff --git a/src/runtime/sys_darwin_386.s b/src/runtime/sys_darwin_386.s
+index 1bc1a63c28..34a3561350 100644
+--- a/src/runtime/sys_darwin_386.s
++++ b/src/runtime/sys_darwin_386.s
+@@ -184,7 +184,7 @@ TEXT runtime·nanotime_trampoline(SB),NOSPLIT,$0
PUSHL BP
MOVL SP, BP
SUBL $8+(machTimebaseInfo__size+15)/16*16, SP
@@ -10,10 +43,11 @@ diff -r -u go/src/runtime/sys_darwin_386.s go-modified/src/runtime/sys_darwin_38
MOVL 16+(machTimebaseInfo__size+15)/16*16(SP), CX
MOVL AX, 0(CX)
MOVL DX, 4(CX)
-diff -r -u go/src/runtime/sys_darwin_amd64.s go-modified/src/runtime/sys_darwin_amd64.s
---- go/src/runtime/sys_darwin_amd64.s 2018-10-01 23:02:54.000000000 +0200
-+++ go-modified/src/runtime/sys_darwin_amd64.s 2018-11-01 23:18:04.382055360 +0100
-@@ -85,7 +85,7 @@
+diff --git a/src/runtime/sys_darwin_amd64.s b/src/runtime/sys_darwin_amd64.s
+index f99cb00ab8..8b99316983 100644
+--- a/src/runtime/sys_darwin_amd64.s
++++ b/src/runtime/sys_darwin_amd64.s
+@@ -86,7 +86,7 @@ TEXT runtime·nanotime_trampoline(SB),NOSPLIT,$0
PUSHQ BP
MOVQ SP, BP
MOVQ DI, BX
@@ -22,22 +56,11 @@ diff -r -u go/src/runtime/sys_darwin_amd64.s go-modified/src/runtime/sys_darwin_
MOVQ AX, 0(BX)
MOVL timebase<>+machTimebaseInfo_numer(SB), SI
MOVL timebase<>+machTimebaseInfo_denom(SB), DI // atomic read
-diff -r -u go/src/runtime/sys_darwin_arm64.s go-modified/src/runtime/sys_darwin_arm64.s
---- go/src/runtime/sys_darwin_arm64.s 2018-10-01 23:02:54.000000000 +0200
-+++ go-modified/src/runtime/sys_darwin_arm64.s 2018-11-01 23:18:04.380055369 +0100
-@@ -110,7 +110,7 @@
-
- TEXT runtime·nanotime_trampoline(SB),NOSPLIT,$40
- MOVD R0, R19
-- BL libc_mach_absolute_time(SB)
-+ BL libc_mach_continuous_time(SB)
- MOVD R0, 0(R19)
- MOVW timebase<>+machTimebaseInfo_numer(SB), R20
- MOVD $timebase<>+machTimebaseInfo_denom(SB), R21
-diff -r -u go/src/runtime/sys_darwin_arm.s go-modified/src/runtime/sys_darwin_arm.s
---- go/src/runtime/sys_darwin_arm.s 2018-10-01 23:02:54.000000000 +0200
-+++ go-modified/src/runtime/sys_darwin_arm.s 2018-11-01 23:18:04.381055364 +0100
-@@ -118,7 +118,7 @@
+diff --git a/src/runtime/sys_darwin_arm.s b/src/runtime/sys_darwin_arm.s
+index 54c7afbf34..a4f06fdb85 100644
+--- a/src/runtime/sys_darwin_arm.s
++++ b/src/runtime/sys_darwin_arm.s
+@@ -118,7 +118,7 @@ GLOBL timebase<>(SB),NOPTR,$(machTimebaseInfo__size)
TEXT runtime·nanotime_trampoline(SB),NOSPLIT,$0
MOVW R0, R8
@@ -46,15 +69,19 @@ diff -r -u go/src/runtime/sys_darwin_arm.s go-modified/src/runtime/sys_darwin_ar
MOVW R0, 0(R8)
MOVW R1, 4(R8)
MOVW timebase<>+machTimebaseInfo_numer(SB), R6
-diff -r -u go/src/runtime/sys_darwin.go go-modified/src/runtime/sys_darwin.go
---- go/src/runtime/sys_darwin.go 2018-10-01 23:02:54.000000000 +0200
-+++ go-modified/src/runtime/sys_darwin.go 2018-11-01 23:18:04.384055350 +0100
-@@ -348,7 +348,7 @@
- //go:cgo_import_dynamic libc_usleep usleep "/usr/lib/libSystem.B.dylib"
+diff --git a/src/runtime/sys_darwin_arm64.s b/src/runtime/sys_darwin_arm64.s
+index 29951d8ad7..cdaf0a630e 100644
+--- a/src/runtime/sys_darwin_arm64.s
++++ b/src/runtime/sys_darwin_arm64.s
+@@ -113,7 +113,7 @@ GLOBL timebase<>(SB),NOPTR,$(machTimebaseInfo__size)
- //go:cgo_import_dynamic libc_mach_timebase_info mach_timebase_info "/usr/lib/libSystem.B.dylib"
--//go:cgo_import_dynamic libc_mach_absolute_time mach_absolute_time "/usr/lib/libSystem.B.dylib"
-+//go:cgo_import_dynamic libc_mach_continuous_time mach_continuous_time "/usr/lib/libSystem.B.dylib"
- //go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
- //go:cgo_import_dynamic libc_sigaction sigaction "/usr/lib/libSystem.B.dylib"
- //go:cgo_import_dynamic libc_pthread_sigmask pthread_sigmask "/usr/lib/libSystem.B.dylib"
+ TEXT runtime·nanotime_trampoline(SB),NOSPLIT,$40
+ MOVD R0, R19
+- BL libc_mach_absolute_time(SB)
++ BL libc_mach_continuous_time(SB)
+ MOVD R0, 0(R19)
+ MOVW timebase<>+machTimebaseInfo_numer(SB), R20
+ MOVD $timebase<>+machTimebaseInfo_denom(SB), R21
+--
+2.20.1
+
diff --git a/wireguard-go-bridge/src/api-ios.go b/wireguard-go-bridge/src/api-ios.go
index de730eb7..d3d92013 100644
--- a/wireguard-go-bridge/src/api-ios.go
+++ b/wireguard-go-bridge/src/api-ios.go
@@ -17,8 +17,8 @@ import (
"bufio"
"bytes"
"errors"
- "git.zx2c4.com/wireguard-go/tun"
"golang.org/x/sys/unix"
+ "golang.zx2c4.com/wireguard/tun"
"log"
"math"
"os"
@@ -61,7 +61,7 @@ func init() {
n := runtime.Stack(buf, true)
buf[n] = 0
if uintptr(loggerFunc) != 0 {
- C.callLogger(loggerFunc, 0, (*_Ctype_char)(unsafe.Pointer(&buf[0])))
+ C.callLogger(loggerFunc, 0, (*C.char)(unsafe.Pointer(&buf[0])))
}
}
}
diff --git a/wireguard-go-bridge/src/tun/api-ios.go b/wireguard-go-bridge/src/tun/api-ios.go
index 0d542cf9..8d3413ee 100644
--- a/wireguard-go-bridge/src/tun/api-ios.go
+++ b/wireguard-go-bridge/src/tun/api-ios.go
@@ -6,28 +6,24 @@
package tun
import (
- "git.zx2c4.com/wireguard-go/rwcancel"
"golang.org/x/sys/unix"
"net"
"os"
)
func CreateTUNFromFD(tunFd int) (TUNDevice, string, error) {
+ err := unix.SetNonblock(tunFd, true)
+ if err != nil {
+ return nil, "", err
+ }
file := os.NewFile(uintptr(tunFd), "/dev/tun")
tun := &nativeTun{
tunFile: file,
- fd: file.Fd(),
events: make(chan TUNEvent, 5),
errors: make(chan error, 5),
}
- var err error
- tun.rwcancel, err = rwcancel.NewRWCancel(tunFd)
- if err != nil {
- return nil, "", err
- }
name, err := tun.Name()
if err != nil {
- tun.rwcancel.Cancel()
return nil, "", err
}
tunIfindex, err := func() (int, error) {
@@ -38,12 +34,10 @@ func CreateTUNFromFD(tunFd int) (TUNDevice, string, error) {
return iface.Index, nil
}()
if err != nil {
- tun.tunFile.Close()
return nil, "", err
}
tun.routeSocket, err = unix.Socket(unix.AF_ROUTE, unix.SOCK_RAW, unix.AF_UNSPEC)
if err != nil {
- tun.tunFile.Close()
return nil, "", err
}
go tun.routineRouteListener(tunIfindex)