From 1a5afc122701558b20e95f34115145bb79180f03 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 16 Dec 2016 12:07:11 +0100 Subject: [PATCH] fix minor bugs --- src/nat/gnunet-nat.c | 67 ++++++++++++++++++++---------------- src/nat/gnunet-service-nat.c | 2 +- src/nat/nat_api.c | 2 +- 3 files changed, 39 insertions(+), 32 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, ah = NULL; switch (type) { - case GNUNET_NAT_TYPE_NO_NAT: - nat_type = "NO NAT"; - break; - case GNUNET_NAT_TYPE_UNREACHABLE_NAT: - nat_type = "NAT but we can traverse"; - break; - case GNUNET_NAT_TYPE_STUN_PUNCHED_NAT: - nat_type = "NAT but STUN is able to identify the correct information"; - break; - case GNUNET_NAT_TYPE_UPNP_NAT: - nat_type = "NAT but UPNP opened the ports"; - break; - default: - SPRINTF (unknown_type, - "NAT unknown, type %u", - type); - nat_type = unknown_type; + case GNUNET_NAT_TYPE_NO_NAT: + nat_type = "NO NAT"; + break; + case GNUNET_NAT_TYPE_UNREACHABLE_NAT: + nat_type = "NAT but we can traverse"; + break; + case GNUNET_NAT_TYPE_STUN_PUNCHED_NAT: + nat_type = "NAT but STUN is able to identify the correct information"; + break; + case GNUNET_NAT_TYPE_UPNP_NAT: + nat_type = "NAT but UPNP opened the ports"; + break; + default: + SPRINTF (unknown_type, + "NAT unknown, type %u", + type); + nat_type = unknown_type; + break; } PRINTF ("NAT status: %s/%s\n", GNUNET_NAT_status2string (result), nat_type); - - PRINTF ("SUGGESTED CHANGES:\n"); - GNUNET_CONFIGURATION_iterate_section_values (diff, - "nat", - &auto_conf_iter, - NULL); + + if (NULL != diff) + { + PRINTF ("SUGGESTED CHANGES:\n"); + GNUNET_CONFIGURATION_iterate_section_values (diff, + "nat", + &auto_conf_iter, + NULL); + } // FIXME: have option to save config test_finished (); } @@ -396,8 +400,18 @@ run (void *cls, proto = IPPROTO_TCP; if (use_udp) proto = IPPROTO_UDP; + + if (do_auto) + { + ah = GNUNET_NAT_autoconfig_start (c, + &auto_config_cb, + NULL); + } + if (0 == proto) { + if (do_auto) + return; /* all good, we just run auto config */ GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "Must specify either TCP or UDP\n"); global_ret = 1; @@ -530,13 +544,6 @@ run (void *cls, } } - if (do_auto) - { - ah = GNUNET_NAT_autoconfig_start (c, - &auto_config_cb, - NULL); - } - if (do_stun) { if (NULL == local_addr) diff --git a/src/nat/gnunet-service-nat.c b/src/nat/gnunet-service-nat.c index 1ebf75608..0da854883 100644 --- a/src/nat/gnunet-service-nat.c +++ b/src/nat/gnunet-service-nat.c @@ -351,7 +351,7 @@ match_ipv6 (const char *network, if (0 == bits) return GNUNET_YES; - GNUNET_assert (1 == inet_pton (AF_INET, + GNUNET_assert (1 == inet_pton (AF_INET6, network, &net)); memset (&mask, 0, sizeof (mask)); diff --git a/src/nat/nat_api.c b/src/nat/nat_api.c index cab2b657e..798da0ea6 100644 --- a/src/nat/nat_api.c +++ b/src/nat/nat_api.c @@ -737,7 +737,7 @@ GNUNET_NAT_status2string (enum GNUNET_NAT_StatusCode err) case GNUNET_NAT_ERROR_SUCCESS: return _ ("Operation Successful"); case GNUNET_NAT_ERROR_IPC_FAILURE: - return _ ("Internal Failure (IPC, ...)"); + return _ ("IPC failure"); case GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR: return _ ("Failure in network subsystem, check permissions."); case GNUNET_NAT_ERROR_TIMEOUT: -- 2.25.1