]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
tun: print automatically assigned interface name to stdout
authorJason A. Donenfeld <Jason@zx2c4.com>
Fri, 4 May 2018 19:20:19 +0000 (21:20 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 4 May 2018 19:20:19 +0000 (21:20 +0200)
This way scripts know what process they just started.

tun_darwin.go

index 4d9b06d92327eecd765400e82f22706348961ed4..55145639ae04569e8fe22a753515f17ffc598468 100644 (file)
@@ -98,7 +98,13 @@ func CreateTUN(name string) (TUNDevice, error) {
                return nil, fmt.Errorf("SYS_CONNECT: %v", errno)
        }
 
-       return CreateTUNFromFile(os.NewFile(uintptr(fd), ""))
+       tun, err := CreateTUNFromFile(os.NewFile(uintptr(fd), ""))
+
+       if err == nil && name == "utun" {
+               fmt.Printf("OS assigned interface: %s\n", tun.(*NativeTun).name)
+       }
+
+       return tun, err
 }
 
 func CreateTUNFromFile(file *os.File) (TUNDevice, error) {