aboutsummaryrefslogtreecommitdiffstats
path: root/tun_darwin.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 /tun_darwin.go
parentwarning: put into main (diff)
downloadwireguard-go-de7ecc571b9ea81d5cad97e339e84f8084352741.tar.xz
wireguard-go-de7ecc571b9ea81d5cad97e339e84f8084352741.zip
tun: allow darwin to auto assign names
Diffstat (limited to '')
-rw-r--r--tun_darwin.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/tun_darwin.go b/tun_darwin.go
index a03347f..4d9b06d 100644
--- a/tun_darwin.go
+++ b/tun_darwin.go
@@ -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)