diff options
Diffstat (limited to 'src/nat/gnunet-nat.c')
-rw-r--r-- | src/nat/gnunet-nat.c | 67 |
1 files changed, 37 insertions, 30 deletions
diff --git a/src/nat/gnunet-nat.c b/src/nat/gnunet-nat.c index 0574f4355..ff326fe0c 100644 --- a/src/nat/gnunet-nat.c +++ b/src/nat/gnunet-nat.c | |||
@@ -176,34 +176,38 @@ auto_config_cb (void *cls, | |||
176 | ah = NULL; | 176 | ah = NULL; |
177 | switch (type) | 177 | switch (type) |
178 | { | 178 | { |
179 | case GNUNET_NAT_TYPE_NO_NAT: | 179 | case GNUNET_NAT_TYPE_NO_NAT: |
180 | nat_type = "NO NAT"; | 180 | nat_type = "NO NAT"; |
181 | break; | 181 | break; |
182 | case GNUNET_NAT_TYPE_UNREACHABLE_NAT: | 182 | case GNUNET_NAT_TYPE_UNREACHABLE_NAT: |
183 | nat_type = "NAT but we can traverse"; | 183 | nat_type = "NAT but we can traverse"; |
184 | break; | 184 | break; |
185 | case GNUNET_NAT_TYPE_STUN_PUNCHED_NAT: | 185 | case GNUNET_NAT_TYPE_STUN_PUNCHED_NAT: |
186 | nat_type = "NAT but STUN is able to identify the correct information"; | 186 | nat_type = "NAT but STUN is able to identify the correct information"; |
187 | break; | 187 | break; |
188 | case GNUNET_NAT_TYPE_UPNP_NAT: | 188 | case GNUNET_NAT_TYPE_UPNP_NAT: |
189 | nat_type = "NAT but UPNP opened the ports"; | 189 | nat_type = "NAT but UPNP opened the ports"; |
190 | break; | 190 | break; |
191 | default: | 191 | default: |
192 | SPRINTF (unknown_type, | 192 | SPRINTF (unknown_type, |
193 | "NAT unknown, type %u", | 193 | "NAT unknown, type %u", |
194 | type); | 194 | type); |
195 | nat_type = unknown_type; | 195 | nat_type = unknown_type; |
196 | break; | ||
196 | } | 197 | } |
197 | 198 | ||
198 | PRINTF ("NAT status: %s/%s\n", | 199 | PRINTF ("NAT status: %s/%s\n", |
199 | GNUNET_NAT_status2string (result), | 200 | GNUNET_NAT_status2string (result), |
200 | nat_type); | 201 | nat_type); |
201 | 202 | ||
202 | PRINTF ("SUGGESTED CHANGES:\n"); | 203 | if (NULL != diff) |
203 | GNUNET_CONFIGURATION_iterate_section_values (diff, | 204 | { |
204 | "nat", | 205 | PRINTF ("SUGGESTED CHANGES:\n"); |
205 | &auto_conf_iter, | 206 | GNUNET_CONFIGURATION_iterate_section_values (diff, |
206 | NULL); | 207 | "nat", |
208 | &auto_conf_iter, | ||
209 | NULL); | ||
210 | } | ||
207 | // FIXME: have option to save config | 211 | // FIXME: have option to save config |
208 | test_finished (); | 212 | test_finished (); |
209 | } | 213 | } |
@@ -396,8 +400,18 @@ run (void *cls, | |||
396 | proto = IPPROTO_TCP; | 400 | proto = IPPROTO_TCP; |
397 | if (use_udp) | 401 | if (use_udp) |
398 | proto = IPPROTO_UDP; | 402 | proto = IPPROTO_UDP; |
403 | |||
404 | if (do_auto) | ||
405 | { | ||
406 | ah = GNUNET_NAT_autoconfig_start (c, | ||
407 | &auto_config_cb, | ||
408 | NULL); | ||
409 | } | ||
410 | |||
399 | if (0 == proto) | 411 | if (0 == proto) |
400 | { | 412 | { |
413 | if (do_auto) | ||
414 | return; /* all good, we just run auto config */ | ||
401 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 415 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, |
402 | "Must specify either TCP or UDP\n"); | 416 | "Must specify either TCP or UDP\n"); |
403 | global_ret = 1; | 417 | global_ret = 1; |
@@ -530,13 +544,6 @@ run (void *cls, | |||
530 | } | 544 | } |
531 | } | 545 | } |
532 | 546 | ||
533 | if (do_auto) | ||
534 | { | ||
535 | ah = GNUNET_NAT_autoconfig_start (c, | ||
536 | &auto_config_cb, | ||
537 | NULL); | ||
538 | } | ||
539 | |||
540 | if (do_stun) | 547 | if (do_stun) |
541 | { | 548 | { |
542 | if (NULL == local_addr) | 549 | if (NULL == local_addr) |