aboutsummaryrefslogtreecommitdiff
path: root/src/util/resolver_api.c
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-02-28 20:40:00 +0000
committerFlorian Dold <florian.dold@gmail.com>2016-02-28 20:40:00 +0000
commit862d43bb260b87ec5cd3072a8b486c90eaab3519 (patch)
tree3539f2064eb1a1b0c21e20097f6b3f1c69e8394b /src/util/resolver_api.c
parent232cf1d42677f94f5d0df487490878bb7fc792c4 (diff)
Add support for $GNUNET_BASE_CONFIG
The environment variable GNUNET_BASE_CONFIG allows specifying the directory from which all base config files will be loaded. This is useful when ARM is to be used to supervise things otherwise unrelated to GNUnet. Modifying GNUNET_PREFIX is not sufficient for this use case, since e.g. libexec files need to be under GNUNET_PREFIX, and GNUNET_BASE_CONFIG provides a way to only modify the base config directory independent of where GNUnet was installed.
Diffstat (limited to 'src/util/resolver_api.c')
-rw-r--r--src/util/resolver_api.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c
index 3eff02c5c1..f477c13693 100644
--- a/src/util/resolver_api.c
+++ b/src/util/resolver_api.c
@@ -171,8 +171,11 @@ struct GNUNET_RESOLVER_RequestHandle
/**
* Check that the resolver service runs on localhost
* (or equivalent).
+ *
+ * @return #GNUNET_OK if the resolver is properly configured,
+ * #GNUNET_SYSERR otherwise.
*/
-static void
+static int
check_config ()
{
char *hostname;
@@ -197,32 +200,32 @@ check_config ()
"HOSTNAME",
&hostname))
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Must specify `%s' for `%s' in configuration!\n"),
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ _("Missing `%s' for `%s' in configuration, DNS resolution will be unavailable.\n"),
"HOSTNAME",
"resolver");
- GNUNET_assert (0);
+ return GNUNET_SYSERR;
}
if ((1 != inet_pton (AF_INET, hostname, &v4)) ||
(1 != inet_pton (AF_INET6, hostname, &v6)))
{
GNUNET_free (hostname);
- return;
+ return GNUNET_SYSERR;
}
i = 0;
while (NULL != loopback[i])
if (0 == strcasecmp (loopback[i++], hostname))
{
GNUNET_free (hostname);
- return;
+ return GNUNET_OK;
}
- LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Must specify `%s' or numeric IP address for `%s' of `%s' in configuration!\n"),
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ _("Missing `%s' or numeric IP address for `%s' of `%s' in configuration, DNS resolution will be unavailable.\n"),
"localhost",
"HOSTNAME",
"resolver");
GNUNET_free (hostname);
- GNUNET_assert (0);
+ return GNUNET_SYSERR;
}
@@ -237,7 +240,7 @@ GNUNET_RESOLVER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
GNUNET_assert (NULL != cfg);
backoff = GNUNET_TIME_UNIT_MILLISECONDS;
resolver_cfg = cfg;
- check_config ();
+ (void) check_config ();
}
@@ -951,7 +954,13 @@ GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa,
size_t ip_len;
const void *ip;
- check_config ();
+ if (GNUNET_OK != check_config ())
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ _("Resolver not configured correctly.\n"));
+ return NULL;
+ }
+
switch (sa->sa_family)
{
case AF_INET: