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)
downloadgnunet-862d43bb260b87ec5cd3072a8b486c90eaab3519.tar.gz
gnunet-862d43bb260b87ec5cd3072a8b486c90eaab3519.zip
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 3eff02c5c..f477c1369 100644
--- a/src/util/resolver_api.c
+++ b/src/util/resolver_api.c
@@ -171,8 +171,11 @@ struct GNUNET_RESOLVER_RequestHandle
171/** 171/**
172 * Check that the resolver service runs on localhost 172 * Check that the resolver service runs on localhost
173 * (or equivalent). 173 * (or equivalent).
174 *
175 * @return #GNUNET_OK if the resolver is properly configured,
176 * #GNUNET_SYSERR otherwise.
174 */ 177 */
175static void 178static int
176check_config () 179check_config ()
177{ 180{
178 char *hostname; 181 char *hostname;
@@ -197,32 +200,32 @@ check_config ()
197 "HOSTNAME", 200 "HOSTNAME",
198 &hostname)) 201 &hostname))
199 { 202 {
200 LOG (GNUNET_ERROR_TYPE_ERROR, 203 LOG (GNUNET_ERROR_TYPE_INFO,
201 _("Must specify `%s' for `%s' in configuration!\n"), 204 _("Missing `%s' for `%s' in configuration, DNS resolution will be unavailable.\n"),
202 "HOSTNAME", 205 "HOSTNAME",
203 "resolver"); 206 "resolver");
204 GNUNET_assert (0); 207 return GNUNET_SYSERR;
205 } 208 }
206 if ((1 != inet_pton (AF_INET, hostname, &v4)) || 209 if ((1 != inet_pton (AF_INET, hostname, &v4)) ||
207 (1 != inet_pton (AF_INET6, hostname, &v6))) 210 (1 != inet_pton (AF_INET6, hostname, &v6)))
208 { 211 {
209 GNUNET_free (hostname); 212 GNUNET_free (hostname);
210 return; 213 return GNUNET_SYSERR;
211 } 214 }
212 i = 0; 215 i = 0;
213 while (NULL != loopback[i]) 216 while (NULL != loopback[i])
214 if (0 == strcasecmp (loopback[i++], hostname)) 217 if (0 == strcasecmp (loopback[i++], hostname))
215 { 218 {
216 GNUNET_free (hostname); 219 GNUNET_free (hostname);
217 return; 220 return GNUNET_OK;
218 } 221 }
219 LOG (GNUNET_ERROR_TYPE_ERROR, 222 LOG (GNUNET_ERROR_TYPE_INFO,
220 _("Must specify `%s' or numeric IP address for `%s' of `%s' in configuration!\n"), 223 _("Missing `%s' or numeric IP address for `%s' of `%s' in configuration, DNS resolution will be unavailable.\n"),
221 "localhost", 224 "localhost",
222 "HOSTNAME", 225 "HOSTNAME",
223 "resolver"); 226 "resolver");
224 GNUNET_free (hostname); 227 GNUNET_free (hostname);
225 GNUNET_assert (0); 228 return GNUNET_SYSERR;
226} 229}
227 230
228 231
@@ -237,7 +240,7 @@ GNUNET_RESOLVER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
237 GNUNET_assert (NULL != cfg); 240 GNUNET_assert (NULL != cfg);
238 backoff = GNUNET_TIME_UNIT_MILLISECONDS; 241 backoff = GNUNET_TIME_UNIT_MILLISECONDS;
239 resolver_cfg = cfg; 242 resolver_cfg = cfg;
240 check_config (); 243 (void) check_config ();
241} 244}
242 245
243 246
@@ -951,7 +954,13 @@ GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa,
951 size_t ip_len; 954 size_t ip_len;
952 const void *ip; 955 const void *ip;
953 956
954 check_config (); 957 if (GNUNET_OK != check_config ())
958 {
959 LOG (GNUNET_ERROR_TYPE_ERROR,
960 _("Resolver not configured correctly.\n"));
961 return NULL;
962 }
963
955 switch (sa->sa_family) 964 switch (sa->sa_family)
956 { 965 {
957 case AF_INET: 966 case AF_INET: