aboutsummaryrefslogtreecommitdiffstats
path: root/tun_linux.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-04-19 15:54:33 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-04-19 16:00:20 +0200
commit676bb9143461ae25304c414fb19595fef9c310db (patch)
treea58dd5aa8e8d84d6f274f3d63b96593d638a7526 /tun_linux.go
parentDo not hard code MTU default (diff)
downloadwireguard-go-676bb9143461ae25304c414fb19595fef9c310db.tar.xz
wireguard-go-676bb9143461ae25304c414fb19595fef9c310db.zip
We can determine the interface name ourselves
Diffstat (limited to '')
-rw-r--r--tun_linux.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/tun_linux.go b/tun_linux.go
index 06b5af4..ac9824f 100644
--- a/tun_linux.go
+++ b/tun_linux.go
@@ -308,18 +308,22 @@ func (tun *NativeTun) Close() error {
return tun.fd.Close()
}
-func CreateTUNFromFile(name string, fd *os.File) (TUNDevice, error) {
+func CreateTUNFromFile(fd *os.File) (TUNDevice, error) {
device := &NativeTun{
fd: fd,
- name: name,
events: make(chan TUNEvent, 5),
errors: make(chan error, 5),
nopi: false,
}
+ var err error
+
+ _, err = device.Name()
+ if err != nil {
+ return nil, err
+ }
// start event listener
- var err error
device.index, err = getIFIndex(device.name)
if err != nil {
return nil, err