aboutsummaryrefslogtreecommitdiffstats
path: root/tun/tun_default.go
diff options
context:
space:
mode:
Diffstat (limited to 'tun/tun_default.go')
-rw-r--r--tun/tun_default.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/tun/tun_default.go b/tun/tun_default.go
new file mode 100644
index 0000000..31747a2
--- /dev/null
+++ b/tun/tun_default.go
@@ -0,0 +1,24 @@
+// +build !windows
+
+/* SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2017-2019 WireGuard LLC. All Rights Reserved.
+ */
+
+package tun
+
+import (
+ "fmt"
+)
+
+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())
+ }
+}