aboutsummaryrefslogtreecommitdiff
path: root/src/arm/test_gnunet_service_arm.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-02-24 08:29:02 +0100
committerChristian Grothoff <christian@grothoff.org>2019-02-24 08:29:02 +0100
commit35df06d312116e8695a038429a6e3c2fceb41fba (patch)
treec49a79742aabdc07ac14524c32c39d1fa3b5dd07 /src/arm/test_gnunet_service_arm.c
parenta69123887e250ede1cc83f7096f160e5b896f2d5 (diff)
downloadgnunet-35df06d312116e8695a038429a6e3c2fceb41fba.tar.gz
gnunet-35df06d312116e8695a038429a6e3c2fceb41fba.zip
resolve www.gnu.org instead of hostname to avoid complications of hostname as per #5578
Diffstat (limited to 'src/arm/test_gnunet_service_arm.c')
-rw-r--r--src/arm/test_gnunet_service_arm.c44
1 files changed, 12 insertions, 32 deletions
diff --git a/src/arm/test_gnunet_service_arm.c b/src/arm/test_gnunet_service_arm.c
index 700e7ca19..55903c499 100644
--- a/src/arm/test_gnunet_service_arm.c
+++ b/src/arm/test_gnunet_service_arm.c
@@ -47,6 +47,8 @@ static int asked_for_a_list;
47 47
48static struct GNUNET_ARM_Handle *arm; 48static struct GNUNET_ARM_Handle *arm;
49 49
50static const char hostname[] = "www.gnu.org"; /* any domain should do */
51
50 52
51static void 53static void
52trigger_disconnect (void *cls) 54trigger_disconnect (void *cls)
@@ -114,7 +116,7 @@ hostname_resolve_cb (void *cls,
114 if (NULL == addr) 116 if (NULL == addr)
115 { 117 {
116 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 118 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
117 "Failed to resolve our own hostname!\n"); 119 "Failed to resolve hostname!\n");
118 GNUNET_break (0); 120 GNUNET_break (0);
119 ret = 3; 121 ret = 3;
120 GNUNET_ARM_request_service_stop (arm, 122 GNUNET_ARM_request_service_stop (arm,
@@ -144,13 +146,14 @@ arm_start_cb (void *cls,
144 GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); 146 GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK);
145 GNUNET_break (result == GNUNET_ARM_RESULT_STARTING); 147 GNUNET_break (result == GNUNET_ARM_RESULT_STARTING);
146 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
147 "Trying to resolve our own hostname!\n"); 149 "Trying to resolve a hostname via the resolver service!\n");
148 /* connect to the resolver service */ 150 /* connect to the resolver service */
149 if (NULL == 151 if (NULL ==
150 GNUNET_RESOLVER_hostname_resolve (AF_UNSPEC, 152 GNUNET_RESOLVER_ip_get (hostname,
151 TIMEOUT, 153 AF_UNSPEC,
152 &hostname_resolve_cb, 154 TIMEOUT,
153 NULL)) 155 &hostname_resolve_cb,
156 NULL))
154 { 157 {
155 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 158 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
156 "Unable initiate connection to resolver service\n"); 159 "Unable initiate connection to resolver service\n");
@@ -193,30 +196,7 @@ main (int argc, char *av[])
193 static struct GNUNET_GETOPT_CommandLineOption options[] = { 196 static struct GNUNET_GETOPT_CommandLineOption options[] = {
194 GNUNET_GETOPT_OPTION_END 197 GNUNET_GETOPT_OPTION_END
195 }; 198 };
196 char hostname[GNUNET_OS_get_hostname_max_length () + 1];
197 199
198 if (0 != gethostname (hostname, sizeof (hostname) - 1))
199 {
200 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
201 "gethostname");
202 FPRINTF (stderr,
203 "%s",
204 "Failed to determine my own hostname, testcase not run.\n");
205 return 77;
206 }
207 if ( (0 == strcmp (hostname,
208 "localhost")) ||
209 (0 == strcmp (hostname,
210 "ipv6-localnet")) )
211 {
212 /* we cannot use 'localhost' as this would not trigger the
213 resolver service (see resolver_api.c); so in this case,
214 we fall back to (ab)using gnu.org. */
215 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
216 "Falling back to `www.gnu.org'\n");
217 strcpy (hostname,
218 "www.gnu.org");
219 }
220 /* trigger DNS lookup */ 200 /* trigger DNS lookup */
221#if HAVE_GETADDRINFO 201#if HAVE_GETADDRINFO
222 { 202 {
@@ -226,7 +206,7 @@ main (int argc, char *av[])
226 if (0 != (ret = getaddrinfo (hostname, NULL, NULL, &ai))) 206 if (0 != (ret = getaddrinfo (hostname, NULL, NULL, &ai)))
227 { 207 {
228 FPRINTF (stderr, 208 FPRINTF (stderr,
229 "Failed to resolve my hostname `%s', testcase not run.\n", 209 "Failed to resolve `%s', testcase not run.\n",
230 hostname); 210 hostname);
231 return 77; 211 return 77;
232 } 212 }
@@ -242,7 +222,7 @@ main (int argc, char *av[])
242 if (NULL == host) 222 if (NULL == host)
243 { 223 {
244 FPRINTF (stderr, 224 FPRINTF (stderr,
245 "Failed to resolve my hostname `%s', testcase not run.\n", 225 "Failed to resolve `%s', testcase not run.\n",
246 hostname); 226 hostname);
247 return 77; 227 return 77;
248 } 228 }
@@ -255,7 +235,7 @@ main (int argc, char *av[])
255 if (NULL == host) 235 if (NULL == host)
256 { 236 {
257 FPRINTF (stderr, 237 FPRINTF (stderr,
258 "Failed to resolve my hostname `%s', testcase not run.\n", 238 "Failed to resolve `%s', testcase not run.\n",
259 hostname); 239 hostname);
260 return 77; 240 return 77;
261 } 241 }