tun: allow darwin to auto assign names
This commit is contained in:
parent
0f322f83f5
commit
de7ecc571b
2 changed files with 20 additions and 10 deletions
22
main.go
22
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue