summaryrefslogtreecommitdiffhomepage
path: root/main.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-05-04 21:11:38 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-05-04 21:11:51 +0200
commitde7ecc571b9ea81d5cad97e339e84f8084352741 (patch)
tree14d4bda7780e6d42812db460ede5ff8b483682bf /main.go
parent0f322f83f5a920f89a9293e4dc48efc27e4acbac (diff)
tun: allow darwin to auto assign names
Diffstat (limited to 'main.go')
-rw-r--r--main.go22
1 files changed, 15 insertions, 7 deletions
diff --git a/main.go b/main.go
index 41231bf..8562bf6 100644
--- a/main.go
+++ b/main.go
@@ -115,13 +115,6 @@ func main() {
return LogLevelInfo
}()
- logger := NewLogger(
- logLevel,
- fmt.Sprintf("(%s) ", interfaceName),
- )
-
- logger.Debug.Println("Debug log enabled")
-
// open TUN device (or use supplied fd)
tun, err := func() (TUNDevice, error) {
@@ -141,6 +134,21 @@ func main() {
return CreateTUNFromFile(file)
}()
+ if err == nil {
+ realInterfaceName, err2 := tun.Name()
+ if err2 == nil {
+ interfaceName = realInterfaceName
+ }
+ }
+
+ logger := NewLogger(
+ logLevel,
+ fmt.Sprintf("(%s) ", interfaceName),
+ )
+
+ logger.Debug.Println("Debug log enabled")
+
+
if err != nil {
logger.Error.Println("Failed to create TUN device:", err)
os.Exit(ExitSetupFailed)