Sun, 25 Sep 2022 00:19:58 -0500
Remove unused port mapping tables
Nothing ever adds anything to the port mapping tables, and nothing ever calls
the removal function either (except this one last thing removed here.)
Testing Done:
Compile only
Reviewed at https://reviews.imfreedom.org/r/1514/
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
1 | /* purple |
| 8231 | 2 | * |
| 15884 | 3 | * Purple is the legal property of its developers, whose names are too numerous |
| 8231 | 4 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 5 | * source distribution. | |
| 6 | * | |
| 7 | * This program is free software; you can redistribute it and/or modify | |
| 8 | * it under the terms of the GNU General Public License as published by | |
| 9 | * the Free Software Foundation; either version 2 of the License, or | |
| 10 | * (at your option) any later version. | |
| 11 | * | |
| 12 | * This program is distributed in the hope that it will be useful, | |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | * GNU General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU General Public License | |
| 18 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19832
diff
changeset
|
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 8231 | 20 | */ |
| 21 | ||
|
8245
c1397ca0a619
[gaim-migrate @ 8968]
Herman Bloggs <herman@bluedigits.com>
parents:
8240
diff
changeset
|
22 | #include "internal.h" |
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40264
diff
changeset
|
23 | #include "purpleprivate.h" |
| 8231 | 24 | |
|
37450
703722d83214
Update network.c for the dns code removal
Gary Kramlich <grim@reaperworld.com>
parents:
36031
diff
changeset
|
25 | #include <gio/gio.h> |
|
703722d83214
Update network.c for the dns code removal
Gary Kramlich <grim@reaperworld.com>
parents:
36031
diff
changeset
|
26 | |
|
41682
289867067994
Clean up a bunch of stuff in internal.h
Gary Kramlich <grim@reaperworld.com>
parents:
41153
diff
changeset
|
27 | #include <fcntl.h> |
|
289867067994
Clean up a bunch of stuff in internal.h
Gary Kramlich <grim@reaperworld.com>
parents:
41153
diff
changeset
|
28 | |
|
13156
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
29 | #ifndef _WIN32 |
|
23352
9714223ca7a7
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
23185
diff
changeset
|
30 | #include <arpa/nameser.h> |
| 14864 | 31 | #include <resolv.h> |
| 32 | #include <netinet/in.h> | |
|
13156
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
33 | #include <net/if.h> |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
34 | #else |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
35 | #include <nspapi.h> |
|
13156
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
36 | #endif |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
37 | |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
38 | /* Solaris */ |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
39 | #if defined (__SVR4) && defined (__sun) |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
40 | #include <sys/sockio.h> |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
41 | #endif |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
42 | |
| 8231 | 43 | #include "debug.h" |
| 44 | #include "account.h" | |
|
16035
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
45 | #include "nat-pmp.h" |
| 8231 | 46 | #include "network.h" |
| 47 | #include "prefs.h" | |
|
11411
b74834586187
[gaim-migrate @ 13648]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11391
diff
changeset
|
48 | #include "stun.h" |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11033
diff
changeset
|
49 | #include "upnp.h" |
| 8231 | 50 | |
|
37488
88afe246144e
First stab at replacing network-manager with gio, this probably breaks win32, need to test and see
Gary Kramlich <grim@reaperworld.com>
parents:
37466
diff
changeset
|
51 | static gboolean force_online = FALSE; |
|
24999
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
52 | |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
53 | /* Cached IP addresses for STUN and TURN servers (set globally in prefs) */ |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
54 | static gchar *stun_ip = NULL; |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
55 | static gchar *turn_ip = NULL; |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
56 | |
| 8231 | 57 | void |
| 15884 | 58 | purple_network_set_public_ip(const char *ip) |
| 8231 | 59 | { |
| 60 | g_return_if_fail(ip != NULL); | |
| 61 | ||
|
8838
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
62 | /* XXX - Ensure the IP address is valid */ |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
63 | |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
64 | purple_prefs_set_string("/purple/network/public_ip", ip); |
| 8231 | 65 | } |
| 66 | ||
| 67 | const char * | |
| 15884 | 68 | purple_network_get_public_ip(void) |
| 8231 | 69 | { |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
70 | return purple_prefs_get_string("/purple/network/public_ip"); |
| 8231 | 71 | } |
| 72 | ||
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
73 | static gchar * |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
74 | purple_network_get_local_system_ip_from_gio(GSocketConnection *sockconn) |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
75 | { |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
76 | GSocketAddress *addr; |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
77 | GInetSocketAddress *inetsockaddr; |
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
78 | gchar *ip; |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
79 | |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
80 | addr = g_socket_connection_get_local_address(sockconn, NULL); |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
81 | if ((inetsockaddr = G_INET_SOCKET_ADDRESS(addr)) != NULL) { |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
82 | GInetAddress *inetaddr = |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
83 | g_inet_socket_address_get_address(inetsockaddr); |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
84 | if (g_inet_address_get_family(inetaddr) == G_SOCKET_FAMILY_IPV4 && |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
85 | !g_inet_address_get_is_loopback(inetaddr)) { |
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
86 | ip = g_inet_address_to_string(inetaddr); |
|
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
87 | g_object_unref(addr); |
|
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
88 | return ip; |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
89 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
90 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
91 | g_object_unref(addr); |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
92 | |
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
93 | return g_strdup("0.0.0.0"); |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
94 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
95 | |
|
35462
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
96 | /* |
|
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
97 | * purple_network_is_ipv4: |
|
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
98 | * @hostname: The hostname to be verified. |
|
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
99 | * |
|
33894
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
100 | * Checks, if specified hostname is valid ipv4 address. |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
101 | * |
|
35462
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
102 | * Returns: TRUE, if the hostname is valid. |
|
33894
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
103 | */ |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
104 | static gboolean |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
105 | purple_network_is_ipv4(const gchar *hostname) |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
106 | { |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
107 | g_return_val_if_fail(hostname != NULL, FALSE); |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
108 | |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
109 | /* We don't accept ipv6 here. */ |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
110 | if (strchr(hostname, ':') != NULL) |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
111 | return FALSE; |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
112 | |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
113 | return g_hostname_is_ip_address(hostname); |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
114 | } |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
115 | |
|
40663
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
116 | void |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
117 | purple_network_discover_my_ip(void) |
| 8231 | 118 | { |
|
12686
ec3e7c4ff045
[gaim-migrate @ 15029]
Richard Laager <rlaager@pidgin.im>
parents:
11424
diff
changeset
|
119 | const char *ip = NULL; |
| 15884 | 120 | PurpleStunNatDiscovery *stun; |
|
8834
0a798e3d2b84
[gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents:
8251
diff
changeset
|
121 | |
|
0a798e3d2b84
[gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents:
8251
diff
changeset
|
122 | /* Check if the user specified an IP manually */ |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
123 | if (!purple_prefs_get_bool("/purple/network/auto_ip")) { |
| 15884 | 124 | ip = purple_network_get_public_ip(); |
|
15116
037b787407ba
[gaim-migrate @ 17838]
Mark Doliner <markdoliner@pidgin.im>
parents:
14959
diff
changeset
|
125 | /* Make sure the IP address entered by the user is valid */ |
|
40663
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
126 | if (ip != NULL && purple_network_is_ipv4(ip)) { |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
127 | return; |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
128 | } |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
129 | } |
|
11424
b0f8535daa74
[gaim-migrate @ 13661]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11411
diff
changeset
|
130 | |
|
40663
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
131 | /* Check if STUN discovery was already done */ |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
132 | stun = purple_stun_discover(NULL); |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
133 | if (stun != NULL && stun->status == PURPLE_STUN_STATUS_DISCOVERED) { |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
134 | return; |
|
21810
0b5181178201
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.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
135 | } |
|
15708
979f43512119
Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
15502
diff
changeset
|
136 | |
|
40663
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
137 | /* Attempt to get the IP from a NAT device using UPnP */ |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
138 | ip = purple_upnp_get_public_ip(); |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
139 | if (ip != NULL) { |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
140 | return; |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
141 | } |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
142 | |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
143 | /* Attempt to get the IP from a NAT device using NAT-PMP */ |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
144 | ip = purple_pmp_get_public_ip(); |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
145 | if (ip != NULL) { |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
146 | return; |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
147 | } |
| 8231 | 148 | } |
| 149 | ||
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
150 | gchar * |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
151 | purple_network_get_my_ip_from_gio(GSocketConnection *sockconn) |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
152 | { |
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
153 | const gchar *ip = NULL; |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
154 | PurpleStunNatDiscovery *stun; |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
155 | |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
156 | /* Check if the user specified an IP manually */ |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
157 | if (!purple_prefs_get_bool("/purple/network/auto_ip")) { |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
158 | ip = purple_network_get_public_ip(); |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
159 | /* Make sure the IP address entered by the user is valid */ |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
160 | if ((ip != NULL) && (purple_network_is_ipv4(ip))) { |
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
161 | return g_strdup(ip); |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
162 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
163 | } else { |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
164 | /* Check if STUN discovery was already done */ |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
165 | stun = purple_stun_discover(NULL); |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
166 | if ((stun != NULL) && (stun->status == PURPLE_STUN_STATUS_DISCOVERED)) { |
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
167 | return g_strdup(stun->publicip); |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
168 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
169 | |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
170 | /* Attempt to get the IP from a NAT device using UPnP */ |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
171 | ip = purple_upnp_get_public_ip(); |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
172 | if (ip != NULL) { |
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
173 | return g_strdup(ip); |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
174 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
175 | |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
176 | /* Attempt to get the IP from a NAT device using NAT-PMP */ |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
177 | ip = purple_pmp_get_public_ip(); |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
178 | if (ip != NULL) { |
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
179 | return g_strdup(ip); |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
180 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
181 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
182 | |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
183 | /* Just fetch the IP of the local system */ |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
184 | return purple_network_get_local_system_ip_from_gio(sockconn); |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
185 | } |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11336
diff
changeset
|
186 | |
| 14758 | 187 | gboolean |
| 15884 | 188 | purple_network_is_available(void) |
| 14758 | 189 | { |
|
37488
88afe246144e
First stab at replacing network-manager with gio, this probably breaks win32, need to test and see
Gary Kramlich <grim@reaperworld.com>
parents:
37466
diff
changeset
|
190 | if(force_online) { |
|
24999
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
191 | return TRUE; |
|
23041
58661da65e36
Changes suggested by QuLogic to fix my broken changes to the NetworkManager
Richard Laager <rlaager@pidgin.im>
parents:
23040
diff
changeset
|
192 | } |
|
24519
d4af3d043211
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents:
24044
diff
changeset
|
193 | |
|
37488
88afe246144e
First stab at replacing network-manager with gio, this probably breaks win32, need to test and see
Gary Kramlich <grim@reaperworld.com>
parents:
37466
diff
changeset
|
194 | return g_network_monitor_get_network_available(g_network_monitor_get_default()); |
| 14758 | 195 | } |
| 196 | ||
|
24999
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
197 | void |
|
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
198 | purple_network_force_online() |
|
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
199 | { |
|
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
200 | force_online = TRUE; |
| 14758 | 201 | } |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
202 | |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
203 | static void |
|
37464
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
204 | purple_network_ip_lookup_cb(GObject *sender, GAsyncResult *result, gpointer data) { |
|
37450
703722d83214
Update network.c for the dns code removal
Gary Kramlich <grim@reaperworld.com>
parents:
36031
diff
changeset
|
205 | GError *error = NULL; |
|
37464
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
206 | GList *addresses = NULL; |
|
37450
703722d83214
Update network.c for the dns code removal
Gary Kramlich <grim@reaperworld.com>
parents:
36031
diff
changeset
|
207 | GInetAddress *address = NULL; |
|
37464
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
208 | const gchar **ip_address = (const gchar **)data; |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
209 | |
|
37517
a67be31f9c7e
Use the GResolver which was passed to g_resolver_lookup_*_async()
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
210 | addresses = g_resolver_lookup_by_name_finish(G_RESOLVER(sender), |
|
a67be31f9c7e
Use the GResolver which was passed to g_resolver_lookup_*_async()
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
211 | result, &error); |
|
37464
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
212 | if(error) { |
|
37450
703722d83214
Update network.c for the dns code removal
Gary Kramlich <grim@reaperworld.com>
parents:
36031
diff
changeset
|
213 | purple_debug_info("network", "lookup of IP address failed: %s\n", error->message); |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
214 | |
|
37450
703722d83214
Update network.c for the dns code removal
Gary Kramlich <grim@reaperworld.com>
parents:
36031
diff
changeset
|
215 | g_error_free(error); |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
216 | |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
217 | return; |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
218 | } |
|
26262
1ad96aa2e92a
Removed some extra tabs on blank lines
Marcus Lundblad <malu@pidgin.im>
parents:
26261
diff
changeset
|
219 | |
|
37464
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
220 | address = G_INET_ADDRESS(addresses->data); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31191
diff
changeset
|
221 | |
|
37464
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
222 | *ip_address = g_inet_address_to_string(address); |
|
26262
1ad96aa2e92a
Removed some extra tabs on blank lines
Marcus Lundblad <malu@pidgin.im>
parents:
26261
diff
changeset
|
223 | |
|
37450
703722d83214
Update network.c for the dns code removal
Gary Kramlich <grim@reaperworld.com>
parents:
36031
diff
changeset
|
224 | g_resolver_free_addresses(addresses); |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
225 | } |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
226 | |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
227 | void |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
228 | purple_network_set_stun_server(const gchar *stun_server) |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
229 | { |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
230 | if (stun_server && stun_server[0] != '\0') { |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
231 | if (purple_network_is_available()) { |
|
37518
53c9ebedf2b7
Plug g_resolver_get_default() leaks
Mike Ruprecht <cmaiku@gmail.com>
parents:
37517
diff
changeset
|
232 | GResolver *resolver = g_resolver_get_default(); |
|
53c9ebedf2b7
Plug g_resolver_get_default() leaks
Mike Ruprecht <cmaiku@gmail.com>
parents:
37517
diff
changeset
|
233 | g_resolver_lookup_by_name_async(resolver, |
|
37464
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
234 | stun_server, |
|
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
235 | NULL, |
|
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
236 | purple_network_ip_lookup_cb, |
|
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
237 | &stun_ip); |
|
37518
53c9ebedf2b7
Plug g_resolver_get_default() leaks
Mike Ruprecht <cmaiku@gmail.com>
parents:
37517
diff
changeset
|
238 | g_object_unref(resolver); |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
239 | } else { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31191
diff
changeset
|
240 | purple_debug_info("network", |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
241 | "network is unavailable, don't try to update STUN IP"); |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
242 | } |
|
37426
6fd4989b77e4
The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents:
36031
diff
changeset
|
243 | } else { |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
244 | g_free(stun_ip); |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
245 | stun_ip = NULL; |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
246 | } |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
247 | } |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
248 | |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
249 | void |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
250 | purple_network_set_turn_server(const gchar *turn_server) |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
251 | { |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
252 | if (turn_server && turn_server[0] != '\0') { |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
253 | if (purple_network_is_available()) { |
|
37518
53c9ebedf2b7
Plug g_resolver_get_default() leaks
Mike Ruprecht <cmaiku@gmail.com>
parents:
37517
diff
changeset
|
254 | GResolver *resolver = g_resolver_get_default(); |
|
53c9ebedf2b7
Plug g_resolver_get_default() leaks
Mike Ruprecht <cmaiku@gmail.com>
parents:
37517
diff
changeset
|
255 | g_resolver_lookup_by_name_async(resolver, |
|
37464
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
256 | turn_server, |
|
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
257 | NULL, |
|
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
258 | purple_network_ip_lookup_cb, |
|
40264
d253f767f6cc
fix various memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents:
40110
diff
changeset
|
259 | &turn_ip); |
|
37518
53c9ebedf2b7
Plug g_resolver_get_default() leaks
Mike Ruprecht <cmaiku@gmail.com>
parents:
37517
diff
changeset
|
260 | g_object_unref(resolver); |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
261 | } else { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31191
diff
changeset
|
262 | purple_debug_info("network", |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
263 | "network is unavailable, don't try to update TURN IP"); |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
264 | } |
|
37426
6fd4989b77e4
The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents:
36031
diff
changeset
|
265 | } else { |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
266 | g_free(turn_ip); |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
267 | turn_ip = NULL; |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
268 | } |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
269 | } |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
270 | |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
271 | |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
272 | const gchar * |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
273 | purple_network_get_stun_ip(void) |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
274 | { |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
275 | return stun_ip; |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
276 | } |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
277 | |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
278 | const gchar * |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
279 | purple_network_get_turn_ip(void) |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
280 | { |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
281 | return turn_ip; |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
282 | } |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
283 | |
|
36028
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
284 | gboolean |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
285 | _purple_network_set_common_socket_flags(int fd) |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
286 | { |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
287 | int flags; |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
288 | gboolean succ = TRUE; |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
289 | |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
290 | g_return_val_if_fail(fd >= 0, FALSE); |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
291 | |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
292 | flags = fcntl(fd, F_GETFL); |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
293 | |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
294 | if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) != 0) { |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
295 | purple_debug_warning("network", |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
296 | "Couldn't set O_NONBLOCK flag\n"); |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
297 | succ = FALSE; |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
298 | } |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
299 | |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
300 | #ifndef _WIN32 |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
301 | if (fcntl(fd, F_SETFD, FD_CLOEXEC) != 0) { |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
302 | purple_debug_warning("network", |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
303 | "Couldn't set FD_CLOEXEC flag\n"); |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
304 | succ = FALSE; |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
305 | } |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
306 | #endif |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
307 | |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
308 | return succ; |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
309 | } |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
310 | |
| 8231 | 311 | void |
| 15884 | 312 | purple_network_init(void) |
| 8231 | 313 | { |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
314 | purple_prefs_add_none ("/purple/network"); |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
315 | purple_prefs_add_string("/purple/network/stun_server", ""); |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
316 | purple_prefs_add_string("/purple/network/turn_server", ""); |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
317 | purple_prefs_add_int ("/purple/network/turn_port", 3478); |
|
31831
c3778a69ecee
Add support for using TCP relaying with TURN
Marcus Lundblad <malu@pidgin.im>
parents:
31680
diff
changeset
|
318 | purple_prefs_add_int ("/purple/network/turn_port_tcp", 3478); |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
319 | purple_prefs_add_string("/purple/network/turn_username", ""); |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
320 | purple_prefs_add_string("/purple/network/turn_password", ""); |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
321 | purple_prefs_add_bool ("/purple/network/auto_ip", TRUE); |
|
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
322 | purple_prefs_add_string("/purple/network/public_ip", ""); |
|
21810
0b5181178201
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.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
323 | purple_prefs_add_bool ("/purple/network/map_ports", TRUE); |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
324 | purple_prefs_add_bool ("/purple/network/ports_range_use", FALSE); |
|
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
325 | purple_prefs_add_int ("/purple/network/ports_range_start", 1024); |
|
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
326 | purple_prefs_add_int ("/purple/network/ports_range_end", 2048); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
327 | |
|
21810
0b5181178201
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.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
328 | if(purple_prefs_get_bool("/purple/network/map_ports") || purple_prefs_get_bool("/purple/network/auto_ip")) |
|
0b5181178201
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.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
329 | purple_upnp_discover(NULL, NULL); |
| 14758 | 330 | |
|
16035
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
331 | purple_pmp_init(); |
|
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
332 | purple_upnp_init(); |
|
31191
163f03d8d1d2
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <markdoliner@pidgin.im>
parents:
30792
diff
changeset
|
333 | |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
334 | purple_network_set_stun_server( |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
335 | purple_prefs_get_string("/purple/network/stun_server")); |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
336 | purple_network_set_turn_server( |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
337 | purple_prefs_get_string("/purple/network/turn_server")); |
| 8231 | 338 | } |
| 14758 | 339 | |
| 340 | void | |
| 15884 | 341 | purple_network_uninit(void) |
| 14758 | 342 | { |
|
37426
6fd4989b77e4
The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents:
36031
diff
changeset
|
343 | g_free(stun_ip); |
|
40264
d253f767f6cc
fix various memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents:
40110
diff
changeset
|
344 | g_free(turn_ip); |
|
27332
8240ab259385
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <malu@pidgin.im>
parents:
27116
diff
changeset
|
345 | |
|
31191
163f03d8d1d2
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <markdoliner@pidgin.im>
parents:
30792
diff
changeset
|
346 | /* TODO: clean up remaining port mappings, note calling |
|
27332
8240ab259385
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <malu@pidgin.im>
parents:
27116
diff
changeset
|
347 | purple_upnp_remove_port_mapping from here doesn't quite work... */ |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39291
diff
changeset
|
348 | |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39291
diff
changeset
|
349 | purple_upnp_uninit(); |
| 14758 | 350 | } |