Mercurial > pidgin.yaz
changeset 21697:65ef019c000b
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.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Fri, 30 Nov 2007 23:25:28 +0000 |
parents | fded60f269bc |
children | a4237a2117ab |
files | libpurple/network.c pidgin/gtkprefs.c |
diffstat | 2 files changed, 21 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/network.c Fri Nov 30 21:29:18 2007 +0000 +++ b/libpurple/network.c Fri Nov 30 23:25:28 2007 +0000 @@ -182,22 +182,22 @@ /* Make sure the IP address entered by the user is valid */ if ((ip != NULL) && (purple_network_ip_atoi(ip) != NULL)) return ip; - } - - /* Check if STUN discovery was already done */ - stun = purple_stun_discover(NULL); - if ((stun != NULL) && (stun->status == PURPLE_STUN_STATUS_DISCOVERED)) - return stun->publicip; + } 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; - /* 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 @@ 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_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();
--- a/pidgin/gtkprefs.c Fri Nov 30 21:29:18 2007 +0000 +++ b/pidgin/gtkprefs.c Fri Nov 30 23:25:28 2007 +0000 @@ -1211,6 +1211,9 @@ 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);