Depend on libnice as farstream already pulled it in and replace purple_network_get_all_local_system_ips with nice_interfaces_get_local_ips.
Testing Done:
Compiled and ran the unit tests.
Reviewed at https://reviews.imfreedom.org/r/239/
--- a/ChangeLog.API Thu Nov 19 21:49:57 2020 -0600
+++ b/ChangeLog.API Fri Nov 20 02:10:50 2020 -0600
@@ -398,6 +398,7 @@
purple_mime_decode_field. Use the GMime library, instead.
* purple_network_convert_idn_to_ascii. Use g_hostname_to_ascii,
+ * purple_network_get_all_local_system_ips. Use libnice instead. * purple_network_listen_family. Use purple_network_listen, instead.
* purple_network_listen_map_external
* purple_network_listen_range_family. Use purple_network_listen,
--- a/libpurple/network.c Thu Nov 19 21:49:57 2020 -0600
+++ b/libpurple/network.c Fri Nov 20 02:10:50 2020 -0600
@@ -182,89 +182,6 @@
return g_strdup("0.0.0.0");
-purple_network_get_all_local_system_ips(void)
-#if defined(HAVE_GETIFADDRS) && defined(HAVE_INET_NTOP)
- struct ifaddrs *start, *ifa;
- ret = getifaddrs(&start);
- purple_debug_warning("network",
- "getifaddrs() failed: %s\n", g_strerror(errno));
- for (ifa = start; ifa; ifa = ifa->ifa_next) {
- int family = ifa->ifa_addr ? ifa->ifa_addr->sa_family : AF_UNSPEC;
- char host[INET6_ADDRSTRLEN];
- const char *tmp = NULL;
- common_sockaddr_t *addr =
- (common_sockaddr_t *)(gpointer)ifa->ifa_addr;
- if ((family != AF_INET && family != AF_INET6) || ifa->ifa_flags & IFF_LOOPBACK)
- tmp = inet_ntop(family, &addr->in.sin_addr, host, sizeof(host));
- /* Peer-peer link-local communication is a big TODO. I am not sure
- * how communicating link-local addresses is supposed to work, and
- * it seems like it would require attempting the cartesian product
- * of the local and remote interfaces to see if any match (eww).
- if (!IN6_IS_ADDR_LINKLOCAL(&addr->in6.sin6_addr))
- tmp = inet_ntop(family, &addr->in6.sin6_addr, host, sizeof(host));
- result = g_list_prepend(result, g_strdup(tmp));
- return g_list_reverse(result);
-#else /* HAVE_GETIFADDRS && HAVE_INET_NTOP */
- int source = socket(PF_INET,SOCK_STREAM, 0);
- struct ifreq buffer[100];
- ifc.ifc_len = sizeof(buffer);
- ioctl(source, SIOCGIFCONF, &ifc);
- it_end = it + ifc.ifc_len;
- char dst[INET_ADDRSTRLEN];
- /* alignment: see purple_network_get_local_system_ip */
- ifr = (struct ifreq *)(gpointer)it;
- it += HX_SIZE_OF_IFREQ(*ifr);
- if (ifr->ifr_addr.sa_family == AF_INET) {
- struct sockaddr_in *sinptr =
- (struct sockaddr_in *)(gpointer)&ifr->ifr_addr;
- inet_ntop(AF_INET, &sinptr->sin_addr, dst,
- purple_debug_info("network",
- "found local i/f with address %s on IPv4\n", dst);
- if (!purple_strequal(dst, "127.0.0.1")) {
- result = g_list_append(result, g_strdup(dst));
-#endif /* HAVE_GETIFADDRS && HAVE_INET_NTOP */
* purple_network_is_ipv4:
* @hostname: The hostname to be verified.
--- a/libpurple/network.h Thu Nov 19 21:49:57 2020 -0600
+++ b/libpurple/network.h Fri Nov 20 02:10:50 2020 -0600
@@ -90,18 +90,6 @@
const char *purple_network_get_local_system_ip(int fd);
- * purple_network_get_all_local_system_ips:
- * Returns all IP addresses of the local system.
- * Note: The caller must free this list. If libpurple was built with
- * support for it, this function also enumerates IPv6 addresses.
- * Returns: (element-type utf8) (transfer full): A list of local IP addresses.
-GList *purple_network_get_all_local_system_ips(void);
* purple_network_get_my_ip:
* @fd: The fd to use to help figure out the IP, or -1.
--- a/libpurple/protocols/bonjour/bonjour_ft.c Thu Nov 19 21:49:57 2020 -0600
+++ b/libpurple/protocols/bonjour/bonjour_ft.c Fri Nov 20 02:10:50 2020 -0600
@@ -30,6 +30,8 @@
@@ -944,7 +946,7 @@
purple_xfer_set_local_port(xfer, port);
- local_ips = purple_network_get_all_local_system_ips();
+ local_ips = nice_interfaces_get_local_ips(FALSE); port_str = g_strdup_printf("%hu", port);
--- a/libpurple/protocols/bonjour/meson.build Thu Nov 19 21:49:57 2020 -0600
+++ b/libpurple/protocols/bonjour/meson.build Fri Nov 20 02:10:50 2020 -0600
@@ -26,6 +26,6 @@
bonjour_prpl = shared_library('bonjour', BONJOURSOURCES,
link_args : bonjour_link_args,
- dependencies : [libxml, avahi, libpurple_dep, glib, ws2_32],
+ dependencies : [libxml, avahi, libpurple_dep, glib, nice, ws2_32], install : true, install_dir : PURPLE_PLUGINDIR)
--- a/libpurple/protocols/bonjour/xmpp.c Thu Nov 19 21:49:57 2020 -0600
+++ b/libpurple/protocols/bonjour/xmpp.c Fri Nov 20 02:10:50 2020 -0600
@@ -44,10 +44,6 @@
--- a/libpurple/protocols/jabber/meson.build Thu Nov 19 21:49:57 2020 -0600
+++ b/libpurple/protocols/jabber/meson.build Fri Nov 20 02:10:50 2020 -0600
@@ -111,7 +111,7 @@
jabber_prpl = shared_library('jabber', JABBERSOURCES,
link_args : jabber_link_args,
- dependencies : [gstreamer, idn, libxml, sasl, libpurple_dep, libsoup, glib, gio, math, ws2_32],
+ dependencies : [gstreamer, idn, libxml, sasl, libpurple_dep, libsoup, glib, gio, math, nice, ws2_32], install : true, install_dir : PURPLE_PLUGINDIR)
--- a/libpurple/protocols/jabber/si.c Thu Nov 19 21:49:57 2020 -0600
+++ b/libpurple/protocols/jabber/si.c Fri Nov 20 02:10:50 2020 -0600
@@ -32,6 +32,8 @@
#include <glib/gi18n-lib.h>
@@ -1039,7 +1041,7 @@
/* Include the localhost's IPs (for in-network transfers) */
- local_ips = purple_network_get_all_local_system_ips();
+ local_ips = nice_interfaces_get_local_ips(FALSE); /* Include the public IP (assuming there is a port mapped somehow) */
public_ip = purple_network_get_my_ip_from_gio(
--- a/meson.build Thu Nov 19 21:49:57 2020 -0600
+++ b/meson.build Fri Nov 20 02:10:50 2020 -0600
@@ -287,6 +287,11 @@
conf.set('ENABLE_INTROSPECTION', enable_introspection)
#######################################################################
+####################################################################### +nice = dependency('nice', version : '>=0.1.16') +####################################################################### # Check Pidgin dependencies
#######################################################################