Mercurial > pidgin
comparison src/network.c @ 11336:7d7dd22215ec
[gaim-migrate @ 13549]
STUN NAT discovery from gaim_network_get_public_ip
committer: Tailor Script <tailor@pidgin.im>
| author | Thomas Butter <tbutter> |
|---|---|
| date | Wed, 24 Aug 2005 20:45:20 +0000 |
| parents | bb0d7b719af2 |
| children | d3755a7ddd82 |
comparison
equal
deleted
inserted
replaced
| 11335:59aa7080eb2d | 11336:7d7dd22215ec |
|---|---|
| 27 | 27 |
| 28 #include "debug.h" | 28 #include "debug.h" |
| 29 #include "account.h" | 29 #include "account.h" |
| 30 #include "network.h" | 30 #include "network.h" |
| 31 #include "prefs.h" | 31 #include "prefs.h" |
| 32 #include "stun.h" | |
| 32 #include "upnp.h" | 33 #include "upnp.h" |
| 33 | 34 |
| 34 const unsigned char * | 35 const unsigned char * |
| 35 gaim_network_ip_atoi(const char *ip) | 36 gaim_network_ip_atoi(const char *ip) |
| 36 { | 37 { |
| 65 | 66 |
| 66 const char * | 67 const char * |
| 67 gaim_network_get_public_ip(void) | 68 gaim_network_get_public_ip(void) |
| 68 { | 69 { |
| 69 const char *ip; | 70 const char *ip; |
| 70 | 71 struct stun_nattype *stun; |
| 72 | |
| 71 ip = gaim_prefs_get_string("/core/network/public_ip"); | 73 ip = gaim_prefs_get_string("/core/network/public_ip"); |
| 72 | 74 |
| 73 if (ip == NULL || *ip == '\0') | 75 if (ip == NULL || *ip == '\0') { |
| 74 return NULL; | 76 /* Check if STUN discovery was already done */ |
| 77 stun = gaim_stun_discover(NULL); | |
| 78 if(stun && stun->status>1) | |
| 79 return stun->publicip; | |
| 80 return NULL; | |
| 81 } | |
| 75 | 82 |
| 76 return ip; | 83 return ip; |
| 77 } | 84 } |
| 78 | 85 |
| 79 static const char * | 86 static const char * |
