Ignore interfaces in windows
authorAmi Perlmutter <amip@8e14.net>
Thu, 13 Aug 2020 11:34:50 +0000 (14:34 +0300)
committerAmi Perlmutter <amip@8e14.net>
Thu, 13 Aug 2020 11:34:50 +0000 (14:34 +0300)
agent/interfaces.c

index 6bdabdb..f75f7cf 100644 (file)
 #endif /* G_OS_UNIX */
 
 #ifdef IGNORED_IFACE_PREFIX
+#ifdef G_OS_WIN32
+#include <stdio.h>
+#endif
+
 static const gchar *ignored_iface_prefix_list[] = {
   IGNORED_IFACE_PREFIX,
   NULL
@@ -565,6 +569,11 @@ nice_interfaces_get_local_ips (gboolean include_loopback)
   IP_ADAPTER_ADDRESSES *addresses, *a;
   DWORD pref = 0;
   GList *ret = NULL;
+#ifdef IGNORED_IFACE_PREFIX
+  const gchar **prefix;
+  gboolean ignored;
+  const char output[256];
+#endif
 
   addresses = _nice_get_adapters_addresses ();
   if (!addresses)
@@ -611,6 +620,22 @@ nice_interfaces_get_local_ips (gboolean include_loopback)
       continue;
     }
 
+#ifdef IGNORED_IFACE_PREFIX
+    sprintf_s(output, 256, "%ws", a->FriendlyName);
+    ignored = FALSE;
+    for (prefix = ignored_iface_prefix_list; *prefix; prefix++) {
+      if (g_str_has_prefix (output, *prefix)) {
+        nice_debug ("Ignoring interface %s as it matches prefix %s",
+            output, *prefix);
+        ignored = TRUE;
+        break;
+      }
+    }
+
+    if (ignored)
+      continue;
+#endif
+
     /* Grab the interface’s unicast addresses. */
     for (unicast = a->FirstUnicastAddress;
          unicast != NULL; unicast = unicast->Next) {