tun: Automatically attempt to use utun on mac

Once /dev/tunX has been tried without success
This commit is contained in:
Erik Ekman 2021-01-21 17:39:54 +01:00
parent 39356163d9
commit a9045705ba

View File

@ -453,6 +453,17 @@ open_tun(const char *tun_device)
break;
}
#ifdef DARWIN
fprintf(stderr, "No tun devices found, trying utun\n");
for (i = 0; i < TUN_MAX_TRY; i++) {
snprintf(tun_name, sizeof(tun_name), "utun%d", i);
tun_fd = open_utun(tun_device);
if (tun_fd >= 0) {
return tun_fd;
}
}
#endif
warn("open_tun: Failed to open tunneling device");
}