interfaces: Skip special interfaces on Apple OSes
authorOle André Vadla Ravnås <oleavr@gmail.com>
Mon, 19 Apr 2021 19:05:51 +0000 (21:05 +0200)
committerOlivier Crête <olivier.crete@ocrete.ca>
Tue, 20 Apr 2021 00:26:07 +0000 (00:26 +0000)
Including unused utun devices.

agent/interfaces.c

index e33ffc6..ba48644 100644 (file)
@@ -405,6 +405,12 @@ nice_interfaces_get_local_ips (gboolean include_loopback)
         ifa->ifa_addr->sa_family != AF_INET6)
       continue;
 
+#ifdef __APPLE__
+    if (g_str_has_prefix (ifa->ifa_name, "awdl") ||
+        g_str_has_prefix (ifa->ifa_name, "llw"))
+      continue;
+#endif
+
     /* Convert to a string. */
     addr_string = sockaddr_to_string (ifa->ifa_addr);
     if (addr_string == NULL) {
@@ -413,6 +419,18 @@ nice_interfaces_get_local_ips (gboolean include_loopback)
       continue;
     }
 
+#ifdef __APPLE__
+    {
+      gboolean is_unused_utun_device =
+          g_str_has_prefix (ifa->ifa_name, "utun") &&
+          g_str_has_prefix (addr_string, "fe80::");
+      if (is_unused_utun_device) {
+        g_free (addr_string);
+        continue;
+      }
+    }
+#endif
+
     nice_debug ("Interface:  %s", ifa->ifa_name);
     nice_debug ("IP Address: %s", addr_string);
     if ((ifa->ifa_flags & IFF_LOOPBACK) == IFF_LOOPBACK) {