im.pidgin.pidgin: cf97e20583ba14a840946c79a5d5182fb4a6648f

datallah at pidgin.im datallah at pidgin.im
Fri Nov 30 18:30:57 EST 2007


-----------------------------------------------------------------
Revision: cf97e20583ba14a840946c79a5d5182fb4a6648f
Ancestor: 7595eff42168a97a13aec5a68f05916a862b22df
Author: datallah at pidgin.im
Date: 2007-11-30T23:25:28
Branch: im.pidgin.pidgin

Modified files:
        libpurple/network.c pidgin/gtkprefs.c

ChangeLog: 

Allow UPnP and NAT-PMP port mapping to be disabled via a pref.  This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.

-------------- next part --------------
============================================================
--- libpurple/network.c	e365eb68b6e415d5b1f5e046cb7d2ba04be39a95
+++ libpurple/network.c	d9468ae658f1afdb9339b3827ddcef4b8cbe0cc4
@@ -182,23 +182,23 @@ purple_network_get_my_ip(int fd)
 		/* Make sure the IP address entered by the user is valid */
 		if ((ip != NULL) && (purple_network_ip_atoi(ip) != NULL))
 			return ip;
-	}
+	} else {
+		/* Check if STUN discovery was already done */
+		stun = purple_stun_discover(NULL);
+		if ((stun != NULL) && (stun->status == PURPLE_STUN_STATUS_DISCOVERED))
+			return stun->publicip;
 
-	/* Check if STUN discovery was already done */
-	stun = purple_stun_discover(NULL);
-	if ((stun != NULL) && (stun->status == PURPLE_STUN_STATUS_DISCOVERED))
-		return stun->publicip;
+		/* Attempt to get the IP from a NAT device using UPnP */
+		ip = purple_upnp_get_public_ip();
+		if (ip != NULL)
+			return ip;
 
-	/* Attempt to get the IP from a NAT device using UPnP */
-	ip = purple_upnp_get_public_ip();
-	if (ip != NULL)
-	  return ip;
+		/* Attempt to get the IP from a NAT device using NAT-PMP */
+		ip = purple_pmp_get_public_ip();
+		if (ip != NULL)
+			return ip;
+	}
 
-	/* Attempt to get the IP from a NAT device using NAT-PMP */
-	ip = purple_pmp_get_public_ip();
-	if (ip != NULL)
-		return ip;
-
 	/* Just fetch the IP of the local system */
 	return purple_network_get_local_system_ip(fd);
 }
@@ -362,7 +362,7 @@ purple_network_do_listen(unsigned short 
 	listen_data->cb_data = cb_data;
 	listen_data->socket_type = socket_type;
 
-	if (!listen_map_external)
+	if (!listen_map_external || !purple_prefs_get_bool("/purple/network/map_ports"))
 	{
 		purple_debug_info("network", "Skipping external port mapping.\n");
 		/* The pmp_map_cb does what we want to do */
@@ -677,11 +677,13 @@ purple_network_init(void)
 	purple_prefs_add_none  ("/purple/network");
 	purple_prefs_add_bool  ("/purple/network/auto_ip", TRUE);
 	purple_prefs_add_string("/purple/network/public_ip", "");
+	purple_prefs_add_bool  ("/purple/network/map_ports", TRUE);
 	purple_prefs_add_bool  ("/purple/network/ports_range_use", FALSE);
 	purple_prefs_add_int   ("/purple/network/ports_range_start", 1024);
 	purple_prefs_add_int   ("/purple/network/ports_range_end", 2048);
 
-	purple_upnp_discover(NULL, NULL);
+	if(purple_prefs_get_bool("/purple/network/map_ports") || purple_prefs_get_bool("/purple/network/auto_ip"))
+		purple_upnp_discover(NULL, NULL);
 
 #ifdef HAVE_LIBNM
 	nm_context = libnm_glib_init();
============================================================
--- pidgin/gtkprefs.c	e0a1cd00c0db951892e6368bb105bfd3d11acb5d
+++ pidgin/gtkprefs.c	09fa7d574b51fe2acc2f151c7fd39fa4861d3f68
@@ -1211,6 +1211,9 @@ network_page()
 	vbox = pidgin_make_frame (ret, _("Ports"));
 	sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
 
+	pidgin_prefs_checkbox(_("_Enable automatic router port forwarding"),
+			"/purple/network/map_ports", vbox);
+
 	ports_checkbox = pidgin_prefs_checkbox(_("_Manually specify range of ports to listen on"),
 			"/purple/network/ports_range_use", vbox);
 


More information about the Commits mailing list