Mercurial > pidgin
comparison src/network.c @ 12686:5f65a0cca87c
[gaim-migrate @ 15029]
Clean up the STUN / SRV API a bit.
I don't use this stuff, so there was no testing beyond compiling it. I think it's right, though I couldn't find where the STUN discovery status was ever set to 1 (discovering). Anyone know something about that?
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 03 Jan 2006 00:23:24 +0000 |
parents | e1ab173ef3b5 |
children | fb3b7466e3d2 |
comparison
equal
deleted
inserted
replaced
12685:e9f279f0ef02 | 12686:5f65a0cca87c |
---|---|
67 | 67 |
68 const char * | 68 const char * |
69 gaim_network_get_public_ip(void) | 69 gaim_network_get_public_ip(void) |
70 { | 70 { |
71 const char *ip; | 71 const char *ip; |
72 struct stun_nattype *stun; | 72 GaimStunNatDiscovery *stun; |
73 | 73 |
74 ip = gaim_prefs_get_string("/core/network/public_ip"); | 74 ip = gaim_prefs_get_string("/core/network/public_ip"); |
75 | 75 |
76 if (ip == NULL || *ip == '\0') { | 76 if (ip == NULL || *ip == '\0') { |
77 /* Check if STUN discovery was already done */ | 77 /* Check if STUN discovery was already done */ |
78 stun = gaim_stun_discover(NULL); | 78 stun = gaim_stun_discover(NULL); |
79 if(stun && stun->status>1) | 79 if (stun != NULL && stun->status == GAIM_STUN_STATUS_DISCOVERED) |
80 return stun->publicip; | 80 return stun->publicip; |
81 return NULL; | 81 return NULL; |
82 } | 82 } |
83 | 83 |
84 return ip; | 84 return ip; |
140 } | 140 } |
141 | 141 |
142 const char * | 142 const char * |
143 gaim_network_get_my_ip(int fd) | 143 gaim_network_get_my_ip(int fd) |
144 { | 144 { |
145 const char *ip = NULL; | 145 const char *ip = NULL; |
146 GaimUPnPControlInfo* controlInfo = NULL; | 146 GaimUPnPControlInfo* controlInfo = NULL; |
147 struct stun_nattype *stun; | 147 GaimStunNatDiscovery *stun; |
148 | 148 |
149 /* Check if the user specified an IP manually */ | 149 /* Check if the user specified an IP manually */ |
150 if (!gaim_prefs_get_bool("/core/network/auto_ip")) { | 150 if (!gaim_prefs_get_bool("/core/network/auto_ip")) { |
151 ip = gaim_network_get_public_ip(); | 151 ip = gaim_network_get_public_ip(); |
152 if (ip != NULL) | 152 if (ip != NULL) |
154 } | 154 } |
155 | 155 |
156 if (ip == NULL || *ip == '\0') { | 156 if (ip == NULL || *ip == '\0') { |
157 /* Check if STUN discovery was already done */ | 157 /* Check if STUN discovery was already done */ |
158 stun = gaim_stun_discover(NULL); | 158 stun = gaim_stun_discover(NULL); |
159 if(stun && stun->status>1) | 159 if (stun != NULL && stun->status == GAIM_STUN_STATUS_DISCOVERED) |
160 return stun->publicip; | 160 return stun->publicip; |
161 } | 161 } |
162 | 162 |
163 | 163 |
164 /* attempt to get the ip from a NAT device */ | 164 /* attempt to get the ip from a NAT device */ |
165 if ((controlInfo = gaim_upnp_discover()) != NULL) { | 165 if ((controlInfo = gaim_upnp_discover()) != NULL) { |
166 ip = gaim_upnp_get_public_ip(controlInfo); | 166 ip = gaim_upnp_get_public_ip(controlInfo); |
167 g_free(controlInfo->controlURL); | 167 |
168 g_free(controlInfo->serviceType); | 168 g_free(controlInfo->controlURL); |
169 g_free(controlInfo); | 169 g_free(controlInfo->serviceType); |
170 if (ip != NULL) { | 170 g_free(controlInfo); |
171 return ip; | 171 |
172 } | 172 if (ip != NULL) |
173 } | 173 return ip; |
174 } | |
174 | 175 |
175 /* Just fetch the IP of the local system */ | 176 /* Just fetch the IP of the local system */ |
176 return gaim_network_get_local_system_ip(fd); | 177 return gaim_network_get_local_system_ip(fd); |
177 } | 178 } |
178 | 179 |