Changeset

5810:99ad8d42d0c9

util.net: Fix s2sout on Windows (return 0.0.0.0 and :: instead of an empty list)
author Kim Alvefur <zash@zash.se>
date Fri, 30 Aug 2013 16:14:31 +0200
parents 5804:bb27ba619932
children 5811:27ae988f5b70
files util-src/net.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/util-src/net.c	Sat Aug 24 23:15:24 2013 +0100
+++ b/util-src/net.c	Fri Aug 30 16:14:31 2013 +0200
@@ -42,8 +42,8 @@
 	const long ip4_linklocal = htonl(0xa9fe0000); /* 169.254.0.0 */
 	const long ip4_mask      = htonl(0xffff0000);
 	struct ifaddrs *addr = NULL, *a;
+#endif
 	int n = 1;
-#endif
 	int type = luaL_checkoption(L, 1, "both", type_strings);
 	const char link_local = lua_toboolean(L, 2); /* defaults to 0 (false) */
 	const char ipv4 = (type == 0 || type == 1);
@@ -92,6 +92,15 @@
 	}
 
 	freeifaddrs(addr);
+#else
+	if (ipv4) {
+		lua_pushstring(L, "0.0.0.0");
+		lua_rawseti(L, -2, n++);
+	}
+	if (ipv6) {
+		lua_pushstring(L, "::");
+		lua_rawseti(L, -2, n++);
+	}
 #endif
 	return 1;
 }