#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
-#define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util", syscall, filename)
+
/**
* Load configuration (starts with defaults, then loads
* system-specific configuration).
const char *filename)
{
char *baseconfig;
- char *ipath;
- ipath = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
- if (NULL == ipath)
- return GNUNET_SYSERR;
- baseconfig = NULL;
- GNUNET_asprintf (&baseconfig, "%s%s", ipath, "config.d");
- GNUNET_free (ipath);
+ if (NULL != (baseconfig = getenv ("GNUNET_BASE_CONFIG")))
+ {
+ baseconfig = GNUNET_strdup (baseconfig);
+ }
+ else
+ {
+ char *ipath;
+
+ ipath = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
+ if (NULL == ipath)
+ return GNUNET_SYSERR;
+ GNUNET_asprintf (&baseconfig, "%s%s", ipath, "config.d");
+ GNUNET_free (ipath);
+ }
if (GNUNET_SYSERR ==
GNUNET_CONFIGURATION_load_from (cfg,
/**
* 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;
"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;
}
GNUNET_assert (NULL != cfg);
backoff = GNUNET_TIME_UNIT_MILLISECONDS;
resolver_cfg = cfg;
- check_config ();
+ (void) check_config ();
}
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: