From a9045705ba8d9af0c73995ffce07560e94ca192e Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Thu, 21 Jan 2021 17:39:54 +0100 Subject: [PATCH] tun: Automatically attempt to use utun on mac Once /dev/tunX has been tried without success --- src/tun.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/tun.c b/src/tun.c index 05f18ad..2ac3b2d 100644 --- a/src/tun.c +++ b/src/tun.c @@ -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"); }