aboutsummaryrefslogtreecommitdiffstats
path: root/tun/tun.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-02-27 01:06:43 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-02-27 01:34:11 +0100
commitab0f442dafba417c3a13d883a447e882d7983690 (patch)
tree4ee549ee9f666b4c4a401c1d3ac34d922b120f0e /tun/tun.go
parentRearrange imports (diff)
downloadwireguard-go-ab0f442dafba417c3a13d883a447e882d7983690.tar.xz
wireguard-go-ab0f442dafba417c3a13d883a447e882d7983690.zip
tun: use sysconn instead of .Fd with Go 1.12
Diffstat (limited to 'tun/tun.go')
-rw-r--r--tun/tun.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/tun/tun.go b/tun/tun.go
index baf6fbb..d9c3c15 100644
--- a/tun/tun.go
+++ b/tun/tun.go
@@ -5,7 +5,10 @@
package tun
-import "os"
+import (
+ "fmt"
+ "os"
+)
type TUNEvent int
@@ -24,3 +27,15 @@ type TUNDevice interface {
Events() chan TUNEvent // returns a constant channel of events related to the device
Close() error // stops the device and closes the event channel
}
+
+func (tun *nativeTun) operateOnFd(fn func(fd uintptr)) {
+ sysconn, err := tun.tunFile.SyscallConn()
+ if err != nil {
+ tun.errors <- fmt.Errorf("unable to find sysconn for tunfile: %s", err.Error())
+ return
+ }
+ err = sysconn.Control(fn)
+ if err != nil {
+ tun.errors <- fmt.Errorf("unable to control sysconn for tunfile: %s", err.Error())
+ }
+} \ No newline at end of file