aboutsummaryrefslogtreecommitdiffstats
path: root/src/tun_linux.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tun_linux.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/tun_linux.go b/src/tun_linux.go
index 261d142..d0e2f47 100644
--- a/src/tun_linux.go
+++ b/src/tun_linux.go
@@ -7,6 +7,7 @@ import (
"encoding/binary"
"errors"
"golang.org/x/sys/unix"
+ "net"
"os"
"strings"
"unsafe"
@@ -19,6 +20,11 @@ type NativeTun struct {
name string
}
+func (tun *NativeTun) IsUp() (bool, error) {
+ inter, err := net.InterfaceByName(tun.name)
+ return inter.Flags&net.FlagUp != 0, err
+}
+
func (tun *NativeTun) Name() string {
return tun.name
}