diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-12-23 14:46:33 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-12-23 14:46:33 +0000 |
commit | 06f2636a57445f48a63b61316878abe161a12fa5 (patch) | |
tree | 7bf0bf8eaf232d4a19df5db9c8f572cab436241a /src/nat/nat.c | |
parent | 85ab049726deae170d98610499ec44c0d029a425 (diff) | |
download | gnunet-06f2636a57445f48a63b61316878abe161a12fa5.tar.gz gnunet-06f2636a57445f48a63b61316878abe161a12fa5.zip |
-debug logic for NAT external IP resolution
Diffstat (limited to 'src/nat/nat.c')
-rw-r--r-- | src/nat/nat.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/nat/nat.c b/src/nat/nat.c index 2b2d1df53..0234f03c2 100644 --- a/src/nat/nat.c +++ b/src/nat/nat.c | |||
@@ -587,16 +587,26 @@ process_external_ip (void *cls, | |||
587 | { | 587 | { |
588 | h->ext_dns = NULL; | 588 | h->ext_dns = NULL; |
589 | /* Current iteration is over, remove 'old' IPs now */ | 589 | /* Current iteration is over, remove 'old' IPs now */ |
590 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
591 | "Purging old IPs for external address\n"); | ||
590 | remove_from_address_list_by_source (h, LAL_EXTERNAL_IP); | 592 | remove_from_address_list_by_source (h, LAL_EXTERNAL_IP); |
591 | if (1 == inet_pton (AF_INET, | 593 | if (1 == inet_pton (AF_INET, |
592 | h->external_address, | 594 | h->external_address, |
593 | &dummy)) | 595 | &dummy)) |
596 | { | ||
597 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
598 | "Got numeric IP for external address, not repeating lookup\n"); | ||
594 | return; /* repated lookup pointless: was numeric! */ | 599 | return; /* repated lookup pointless: was numeric! */ |
600 | } | ||
595 | h->dns_task = | 601 | h->dns_task = |
596 | GNUNET_SCHEDULER_add_delayed (h->dyndns_frequency, | 602 | GNUNET_SCHEDULER_add_delayed (h->dyndns_frequency, |
597 | &resolve_dns, h); | 603 | &resolve_dns, h); |
598 | return; | 604 | return; |
599 | } | 605 | } |
606 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
607 | "Got IP `%s' for external address `%s'\n", | ||
608 | GNUNET_a2s (addr, addrlen), | ||
609 | h->external_address); | ||
600 | add_to_address_list (h, LAL_EXTERNAL_IP, addr, addrlen); | 610 | add_to_address_list (h, LAL_EXTERNAL_IP, addr, addrlen); |
601 | } | 611 | } |
602 | 612 | ||
@@ -891,7 +901,8 @@ start_gnunet_nat_server (struct GNUNET_NAT_Handle *h) | |||
891 | (h->server_stdout = | 901 | (h->server_stdout = |
892 | GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO, GNUNET_YES)))) | 902 | GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO, GNUNET_YES)))) |
893 | { | 903 | { |
894 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting `%s' at `%s'\n", | 904 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
905 | "Starting `%s' at `%s'\n", | ||
895 | "gnunet-helper-nat-server", h->internal_address); | 906 | "gnunet-helper-nat-server", h->internal_address); |
896 | /* Start the server process */ | 907 | /* Start the server process */ |
897 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-server"); | 908 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-server"); |
@@ -982,6 +993,9 @@ resolve_dns (void *cls, | |||
982 | for (pos = h->lal_head; NULL != pos; pos = pos->next) | 993 | for (pos = h->lal_head; NULL != pos; pos = pos->next) |
983 | if (pos->source == LAL_EXTERNAL_IP) | 994 | if (pos->source == LAL_EXTERNAL_IP) |
984 | pos->source = LAL_EXTERNAL_IP_OLD; | 995 | pos->source = LAL_EXTERNAL_IP_OLD; |
996 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
997 | "Resolving external address `%s'\n", | ||
998 | h->external_address); | ||
985 | h->ext_dns = | 999 | h->ext_dns = |
986 | GNUNET_RESOLVER_ip_get (h->external_address, AF_INET, | 1000 | GNUNET_RESOLVER_ip_get (h->external_address, AF_INET, |
987 | GNUNET_TIME_UNIT_MINUTES, | 1001 | GNUNET_TIME_UNIT_MINUTES, |
@@ -1235,13 +1249,19 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1235 | h->enable_nat_server = GNUNET_NO; | 1249 | h->enable_nat_server = GNUNET_NO; |
1236 | 1250 | ||
1237 | /* Check if NAT was hole-punched */ | 1251 | /* Check if NAT was hole-punched */ |
1238 | if ((NULL != h->address_callback) && (h->external_address != NULL) && | 1252 | if ((NULL != h->address_callback) && |
1239 | (h->nat_punched == GNUNET_YES)) | 1253 | (NULL != h->external_address) && |
1254 | (GNUNET_YES == h->nat_punched)) | ||
1240 | { | 1255 | { |
1241 | h->dns_task = GNUNET_SCHEDULER_add_now (&resolve_dns, h); | 1256 | h->dns_task = GNUNET_SCHEDULER_add_now (&resolve_dns, h); |
1242 | h->enable_nat_server = GNUNET_NO; | 1257 | h->enable_nat_server = GNUNET_NO; |
1243 | h->enable_upnp = GNUNET_NO; | 1258 | h->enable_upnp = GNUNET_NO; |
1244 | } | 1259 | } |
1260 | else | ||
1261 | { | ||
1262 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1263 | "No external IP address given to add to our list of addresses\n"); | ||
1264 | } | ||
1245 | 1265 | ||
1246 | /* Test for SUID binaries */ | 1266 | /* Test for SUID binaries */ |
1247 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-server"); | 1267 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-server"); |
@@ -1251,8 +1271,7 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1251 | { | 1271 | { |
1252 | h->enable_nat_server = GNUNET_NO; | 1272 | h->enable_nat_server = GNUNET_NO; |
1253 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1273 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1254 | _ | 1274 | _("Configuration requires `%s', but binary is not installed properly (SUID bit not set). Option disabled.\n"), |
1255 | ("Configuration requires `%s', but binary is not installed properly (SUID bit not set). Option disabled.\n"), | ||
1256 | "gnunet-helper-nat-server"); | 1275 | "gnunet-helper-nat-server"); |
1257 | } | 1276 | } |
1258 | GNUNET_free (binary); | 1277 | GNUNET_free (binary); |
@@ -1296,6 +1315,8 @@ GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h) | |||
1296 | struct LocalAddressList *lal; | 1315 | struct LocalAddressList *lal; |
1297 | struct MiniList *ml; | 1316 | struct MiniList *ml; |
1298 | 1317 | ||
1318 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1319 | "NAT unregister called\n"); | ||
1299 | while (NULL != (ml = h->mini_head)) | 1320 | while (NULL != (ml = h->mini_head)) |
1300 | { | 1321 | { |
1301 | GNUNET_CONTAINER_DLL_remove (h->mini_head, h->mini_tail, ml); | 1322 | GNUNET_CONTAINER_DLL_remove (h->mini_head, h->mini_tail, ml); |