diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-04 21:20:19 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-04 21:20:19 +0200 |
commit | ac898bb35afde34a383f72726c2818d082933e8d (patch) | |
tree | 9cd3a320bc9d11a0b4e29e52296590b98314d058 | |
parent | de7ecc571b9ea81d5cad97e339e84f8084352741 (diff) |
tun: print automatically assigned interface name to stdout
This way scripts know what process they just started.
-rw-r--r-- | tun_darwin.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tun_darwin.go b/tun_darwin.go index 4d9b06d..5514563 100644 --- a/tun_darwin.go +++ b/tun_darwin.go @@ -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) { |