diff 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
line wrap: on
line diff
--- a/src/network.c	Mon Jan 02 23:07:46 2006 +0000
+++ b/src/network.c	Tue Jan 03 00:23:24 2006 +0000
@@ -69,14 +69,14 @@
 gaim_network_get_public_ip(void)
 {
 	const char *ip;
-	struct stun_nattype *stun;
+	GaimStunNatDiscovery *stun;
 
 	ip = gaim_prefs_get_string("/core/network/public_ip");
 
 	if (ip == NULL || *ip == '\0') {
 		/* Check if STUN discovery was already done */
 		stun = gaim_stun_discover(NULL);
-		if(stun && stun->status>1)
+		if (stun != NULL && stun->status == GAIM_STUN_STATUS_DISCOVERED)
 			return stun->publicip;
 		return NULL;
 	}	
@@ -142,9 +142,9 @@
 const char *
 gaim_network_get_my_ip(int fd)
 {
-  const char *ip = NULL;
-  GaimUPnPControlInfo* controlInfo = NULL;
-	struct stun_nattype *stun;
+	const char *ip = NULL;
+	GaimUPnPControlInfo* controlInfo = NULL;
+	GaimStunNatDiscovery *stun;
 
 	/* Check if the user specified an IP manually */
 	if (!gaim_prefs_get_bool("/core/network/auto_ip")) {
@@ -156,21 +156,22 @@
 	if (ip == NULL || *ip == '\0') {
 		/* Check if STUN discovery was already done */
 		stun = gaim_stun_discover(NULL);
-		if(stun && stun->status>1)
+		if (stun != NULL && stun->status == GAIM_STUN_STATUS_DISCOVERED)
 			return stun->publicip;
 	}	
 
 
-  /* attempt to get the ip from a NAT device */
-  if ((controlInfo = gaim_upnp_discover()) != NULL) {
-    ip = gaim_upnp_get_public_ip(controlInfo);
-    g_free(controlInfo->controlURL);
-    g_free(controlInfo->serviceType);
-    g_free(controlInfo);
-    if (ip != NULL) {
-      return ip;
-    }
-  }
+	/* attempt to get the ip from a NAT device */
+	if ((controlInfo = gaim_upnp_discover()) != NULL) {
+		ip = gaim_upnp_get_public_ip(controlInfo);
+
+		g_free(controlInfo->controlURL);
+		g_free(controlInfo->serviceType);
+		g_free(controlInfo);
+
+		if (ip != NULL)
+		  return ip;
+	}
 
 	/* Just fetch the IP of the local system */
 	return gaim_network_get_local_system_ip(fd);