mirror of
https://git.zx2c4.com/wireguard-go
synced 2025-11-01 20:32:34 +08:00
tun: allow darwin to auto assign names
This commit is contained in:
@@ -46,9 +46,11 @@ var sockaddrCtlSize uintptr = 32
|
||||
|
||||
func CreateTUN(name string) (TUNDevice, error) {
|
||||
ifIndex := -1
|
||||
fmt.Sscanf(name, "utun%d", &ifIndex)
|
||||
if ifIndex < 0 {
|
||||
return nil, fmt.Errorf("error parsing interface name %s, must be utun[0-9]+", name)
|
||||
if (name != "utun") {
|
||||
fmt.Sscanf(name, "utun%d", &ifIndex)
|
||||
if ifIndex < 0 {
|
||||
return nil, fmt.Errorf("Interface name must be utun[0-9]*")
|
||||
}
|
||||
}
|
||||
|
||||
fd, err := unix.Socket(unix.AF_SYSTEM, unix.SOCK_DGRAM, 2)
|
||||
|
Reference in New Issue
Block a user