diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-08-04 16:15:53 +0200 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-08-04 16:15:53 +0200 |
commit | 8c34c4cbb3780c433148966a004f5a51aace0f64 (patch) | |
tree | a590de76c326f6dfe3c92d2e27b78ce2ab792289 /src/tun_linux.go | |
parent | 22c83f4b8d98b6b3c7dabc078e70801d0201876c (diff) | |
download | wireguard-go-8c34c4cbb3780c433148966a004f5a51aace0f64.tar.gz wireguard-go-8c34c4cbb3780c433148966a004f5a51aace0f64.zip |
First set of code review patches
Diffstat (limited to 'src/tun_linux.go')
-rw-r--r-- | src/tun_linux.go | 6 |
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 } |