diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-05-25 20:59:29 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-05-25 20:59:29 +0000 |
commit | a1aee7611781a9991c31dbaa36d38c95ad5d5300 (patch) | |
tree | 76fa1711815f47f559fbdf02fffb9c5792837d26 /src | |
parent | 33a7282c26b14f838ad6f1016b90b710cec5f93f (diff) | |
download | gnunet-a1aee7611781a9991c31dbaa36d38c95ad5d5300.tar.gz gnunet-a1aee7611781a9991c31dbaa36d38c95ad5d5300.zip |
-comments, doxygen, indentation, style fixes, working on test_gns_vpn
Diffstat (limited to 'src')
-rw-r--r-- | src/exit/gnunet-daemon-exit.c | 7 | ||||
-rw-r--r-- | src/gns/gns.conf.in | 3 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns.c | 3 | ||||
-rw-r--r-- | src/gns/test_gns_proxy.conf | 2 | ||||
-rw-r--r-- | src/include/gnunet_testing_lib.h | 34 | ||||
-rw-r--r-- | src/pt/Makefile.am | 3 | ||||
-rw-r--r-- | src/pt/test_gns_vpn.c | 294 | ||||
-rw-r--r-- | src/pt/test_gns_vpn.conf | 11 |
8 files changed, 262 insertions, 95 deletions
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c index 1afa29200..2a4d12651 100644 --- a/src/exit/gnunet-daemon-exit.c +++ b/src/exit/gnunet-daemon-exit.c | |||
@@ -3394,7 +3394,8 @@ add_services (int proto, | |||
3394 | * @param section name of section in config, equal to hostname | 3394 | * @param section name of section in config, equal to hostname |
3395 | */ | 3395 | */ |
3396 | static void | 3396 | static void |
3397 | read_service_conf (void *cls, const char *section) | 3397 | read_service_conf (void *cls, |
3398 | const char *section) | ||
3398 | { | 3399 | { |
3399 | char *cpy; | 3400 | char *cpy; |
3400 | 3401 | ||
@@ -3402,7 +3403,9 @@ read_service_conf (void *cls, const char *section) | |||
3402 | (0 != strcmp (".gnunet.", section + (strlen (section) - 8)))) | 3403 | (0 != strcmp (".gnunet.", section + (strlen (section) - 8)))) |
3403 | return; | 3404 | return; |
3404 | if (GNUNET_OK == | 3405 | if (GNUNET_OK == |
3405 | GNUNET_CONFIGURATION_get_value_string (cfg, section, "UDP_REDIRECTS", | 3406 | GNUNET_CONFIGURATION_get_value_string (cfg, |
3407 | section, | ||
3408 | "UDP_REDIRECTS", | ||
3406 | &cpy)) | 3409 | &cpy)) |
3407 | { | 3410 | { |
3408 | add_services (IPPROTO_UDP, cpy, section); | 3411 | add_services (IPPROTO_UDP, cpy, section); |
diff --git a/src/gns/gns.conf.in b/src/gns/gns.conf.in index 34eda3ac5..7fbd572ab 100644 --- a/src/gns/gns.conf.in +++ b/src/gns/gns.conf.in | |||
@@ -25,6 +25,9 @@ ZONE_PUBLISH_TIME_WINDOW = 4 h | |||
25 | 25 | ||
26 | # PREFIX = valgrind --leak-check=full --track-origins=yes | 26 | # PREFIX = valgrind --leak-check=full --track-origins=yes |
27 | 27 | ||
28 | # Setting this option enables hijacking DNS queries using iptables. | ||
29 | # DNS_ROOT = KEY | ||
30 | |||
28 | [gns-proxy] | 31 | [gns-proxy] |
29 | BINARY = gnunet-gns-proxy | 32 | BINARY = gnunet-gns-proxy |
30 | AUTOSTART = NO | 33 | AUTOSTART = NO |
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 092da3577..60c277561 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -917,7 +917,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
917 | &dns_root)) | 917 | &dns_root)) |
918 | { | 918 | { |
919 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, | 919 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, |
920 | "gns", "DNS_ROOT", | 920 | "gns", |
921 | "DNS_ROOT", | ||
921 | _("valid public key required")); | 922 | _("valid public key required")); |
922 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 923 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
923 | GNUNET_free (dns_root_name); | 924 | GNUNET_free (dns_root_name); |
diff --git a/src/gns/test_gns_proxy.conf b/src/gns/test_gns_proxy.conf index 973c0257e..fb1b0c7c8 100644 --- a/src/gns/test_gns_proxy.conf +++ b/src/gns/test_gns_proxy.conf | |||
@@ -14,7 +14,7 @@ HOSTKEYSFILE = ${DATADIR}/testing_hostkeys.dat | |||
14 | 14 | ||
15 | [gns] | 15 | [gns] |
16 | AUTOSTART = YES | 16 | AUTOSTART = YES |
17 | ZONEKEY = $GNUNET_TEST_HOME/.hostkey | 17 | ZONEKEY = $GNUNET_TEST_HOME/.zonekey |
18 | HIJACK_DNS = YES | 18 | HIJACK_DNS = YES |
19 | 19 | ||
20 | [gns-proxy] | 20 | [gns-proxy] |
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h index 4cb518dc3..04975d077 100644 --- a/src/include/gnunet_testing_lib.h +++ b/src/include/gnunet_testing_lib.h | |||
@@ -226,7 +226,8 @@ GNUNET_TESTING_release_port (struct GNUNET_TESTING_System *system, | |||
226 | * | 226 | * |
227 | * @param system system to use to coordinate resource usage | 227 | * @param system system to use to coordinate resource usage |
228 | * @param cfg template configuration to update | 228 | * @param cfg template configuration to update |
229 | * @return GNUNET_OK on success, GNUNET_SYSERR on error - the configuration will | 229 | * @return #GNUNET_OK on success, |
230 | * #GNUNET_SYSERR on error - the configuration will | ||
230 | * be incomplete and should not be used there upon | 231 | * be incomplete and should not be used there upon |
231 | */ | 232 | */ |
232 | int | 233 | int |
@@ -271,7 +272,8 @@ GNUNET_TESTING_peer_get_identity (struct GNUNET_TESTING_Peer *peer, | |||
271 | * Start the peer. | 272 | * Start the peer. |
272 | * | 273 | * |
273 | * @param peer peer to start | 274 | * @param peer peer to start |
274 | * @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. peer already running) | 275 | * @return #GNUNET_OK on success, |
276 | * #GNUNET_SYSERR on error (i.e. peer already running) | ||
275 | */ | 277 | */ |
276 | int | 278 | int |
277 | GNUNET_TESTING_peer_start (struct GNUNET_TESTING_Peer *peer); | 279 | GNUNET_TESTING_peer_start (struct GNUNET_TESTING_Peer *peer); |
@@ -283,7 +285,8 @@ GNUNET_TESTING_peer_start (struct GNUNET_TESTING_Peer *peer); | |||
283 | * GNUNET_TESTING_peer_stop_async(). | 285 | * GNUNET_TESTING_peer_stop_async(). |
284 | * | 286 | * |
285 | * @param peer peer to stop | 287 | * @param peer peer to stop |
286 | * @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. peer not running) | 288 | * @return #GNUNET_OK on success, |
289 | * #GNUNET_SYSERR on error (i.e. peer not running) | ||
287 | */ | 290 | */ |
288 | int | 291 | int |
289 | GNUNET_TESTING_peer_stop (struct GNUNET_TESTING_Peer *peer); | 292 | GNUNET_TESTING_peer_stop (struct GNUNET_TESTING_Peer *peer); |
@@ -304,7 +307,7 @@ GNUNET_TESTING_peer_destroy (struct GNUNET_TESTING_Peer *peer); | |||
304 | * Sends SIGTERM to the peer's main process | 307 | * Sends SIGTERM to the peer's main process |
305 | * | 308 | * |
306 | * @param peer the handle to the peer | 309 | * @param peer the handle to the peer |
307 | * @return GNUNET_OK if successful; GNUNET_SYSERR if the main process is NULL | 310 | * @return #GNUNET_OK if successful; #GNUNET_SYSERR if the main process is NULL |
308 | * or upon any error while sending SIGTERM | 311 | * or upon any error while sending SIGTERM |
309 | */ | 312 | */ |
310 | int | 313 | int |
@@ -315,7 +318,7 @@ GNUNET_TESTING_peer_kill (struct GNUNET_TESTING_Peer *peer); | |||
315 | * Waits for a peer to terminate. The peer's main process will also be destroyed. | 318 | * Waits for a peer to terminate. The peer's main process will also be destroyed. |
316 | * | 319 | * |
317 | * @param peer the handle to the peer | 320 | * @param peer the handle to the peer |
318 | * @return GNUNET_OK if successful; GNUNET_SYSERR if the main process is NULL | 321 | * @return #GNUNET_OK if successful; #GNUNET_SYSERR if the main process is NULL |
319 | * or upon any error while waiting | 322 | * or upon any error while waiting |
320 | */ | 323 | */ |
321 | int | 324 | int |
@@ -327,13 +330,13 @@ GNUNET_TESTING_peer_wait (struct GNUNET_TESTING_Peer *peer); | |||
327 | * | 330 | * |
328 | * @param cls the closure given to GNUNET_TESTING_peer_stop_async() | 331 | * @param cls the closure given to GNUNET_TESTING_peer_stop_async() |
329 | * @param peer the respective peer whose status is being reported | 332 | * @param peer the respective peer whose status is being reported |
330 | * @param success GNUNET_YES if the peer is stopped; GNUNET_SYSERR upon any | 333 | * @param success #GNUNET_YES if the peer is stopped; #GNUNET_SYSERR upon any |
331 | * error | 334 | * error |
332 | */ | 335 | */ |
333 | typedef void (*GNUNET_TESTING_PeerStopCallback) (void *cls, | 336 | typedef void |
334 | struct GNUNET_TESTING_Peer * | 337 | (*GNUNET_TESTING_PeerStopCallback) (void *cls, |
335 | peer, | 338 | struct GNUNET_TESTING_Peer *peer, |
336 | int success); | 339 | int success); |
337 | 340 | ||
338 | 341 | ||
339 | /** | 342 | /** |
@@ -368,15 +371,16 @@ GNUNET_TESTING_peer_stop_async_cancel (struct GNUNET_TESTING_Peer *peer); | |||
368 | 371 | ||
369 | /** | 372 | /** |
370 | * Signature of the 'main' function for a (single-peer) testcase that | 373 | * Signature of the 'main' function for a (single-peer) testcase that |
371 | * is run using 'GNUNET_TESTING_peer_run'. | 374 | * is run using #GNUNET_TESTING_peer_run(). |
372 | * | 375 | * |
373 | * @param cls closure | 376 | * @param cls closure |
374 | * @param cfg configuration of the peer that was started | 377 | * @param cfg configuration of the peer that was started |
375 | * @param peer identity of the peer that was created | 378 | * @param peer identity of the peer that was created |
376 | */ | 379 | */ |
377 | typedef void (*GNUNET_TESTING_TestMain) (void *cls, | 380 | typedef void |
378 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 381 | (*GNUNET_TESTING_TestMain) (void *cls, |
379 | struct GNUNET_TESTING_Peer *peer); | 382 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
383 | struct GNUNET_TESTING_Peer *peer); | ||
380 | 384 | ||
381 | 385 | ||
382 | /** | 386 | /** |
@@ -420,7 +424,7 @@ GNUNET_TESTING_peer_run (const char *testdir, | |||
420 | * @param cfgfilename name of the configuration file to use; | 424 | * @param cfgfilename name of the configuration file to use; |
421 | * use NULL to only run with defaults | 425 | * use NULL to only run with defaults |
422 | * @param tm main function of the testcase | 426 | * @param tm main function of the testcase |
423 | * @param tm_cls closure for 'tm' | 427 | * @param tm_cls closure for @a tm |
424 | * @return 0 on success, 1 on error | 428 | * @return 0 on success, 1 on error |
425 | */ | 429 | */ |
426 | int | 430 | int |
diff --git a/src/pt/Makefile.am b/src/pt/Makefile.am index 7ce3f182f..e56990f08 100644 --- a/src/pt/Makefile.am +++ b/src/pt/Makefile.am | |||
@@ -96,6 +96,7 @@ test_gns_vpn_SOURCES = \ | |||
96 | test_gns_vpn.c | 96 | test_gns_vpn.c |
97 | test_gns_vpn_LDADD = -lmicrohttpd $(LIB_GNURL) \ | 97 | test_gns_vpn_LDADD = -lmicrohttpd $(LIB_GNURL) \ |
98 | $(top_builddir)/src/namestore/libgnunetnamestore.la \ | 98 | $(top_builddir)/src/namestore/libgnunetnamestore.la \ |
99 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
99 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 100 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
100 | $(top_builddir)/src/testing/libgnunettesting.la \ | 101 | $(top_builddir)/src/testing/libgnunettesting.la \ |
101 | $(top_builddir)/src/util/libgnunetutil.la | 102 | $(top_builddir)/src/util/libgnunetutil.la |
@@ -137,5 +138,3 @@ test_gnunet_vpn_6_to_4_LDADD = -lmicrohttpd $(LIB_GNURL) \ | |||
137 | $(top_builddir)/src/util/libgnunetutil.la | 138 | $(top_builddir)/src/util/libgnunetutil.la |
138 | test_gnunet_vpn_6_to_4_CPPFLAGS = \ | 139 | test_gnunet_vpn_6_to_4_CPPFLAGS = \ |
139 | $(CPP_GNURL) $(AM_CPPFLAGS) | 140 | $(CPP_GNURL) $(AM_CPPFLAGS) |
140 | |||
141 | |||
diff --git a/src/pt/test_gns_vpn.c b/src/pt/test_gns_vpn.c index 3661b2ed6..c426aa43c 100644 --- a/src/pt/test_gns_vpn.c +++ b/src/pt/test_gns_vpn.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include <curl/curl.h> | 27 | #include <curl/curl.h> |
28 | #include <microhttpd.h> | 28 | #include <microhttpd.h> |
29 | #include "gnunet_identity_service.h" | ||
29 | #include "gnunet_namestore_service.h" | 30 | #include "gnunet_namestore_service.h" |
30 | #include "gnunet_gnsrecord_lib.h" | 31 | #include "gnunet_gnsrecord_lib.h" |
31 | #include "gnunet_gns_service.h" | 32 | #include "gnunet_gns_service.h" |
@@ -45,9 +46,13 @@ static struct GNUNET_NAMESTORE_Handle *namestore; | |||
45 | 46 | ||
46 | static struct MHD_Daemon *mhd; | 47 | static struct MHD_Daemon *mhd; |
47 | 48 | ||
48 | static struct GNUNET_SCHEDULER_Task * mhd_task_id; | 49 | static struct GNUNET_SCHEDULER_Task *mhd_task_id; |
49 | 50 | ||
50 | static struct GNUNET_SCHEDULER_Task * curl_task_id; | 51 | static struct GNUNET_SCHEDULER_Task *curl_task_id; |
52 | |||
53 | static struct GNUNET_IDENTITY_Handle *identity; | ||
54 | |||
55 | static struct GNUNET_NAMESTORE_QueueEntry *qe; | ||
51 | 56 | ||
52 | static CURL *curl; | 57 | static CURL *curl; |
53 | 58 | ||
@@ -55,6 +60,8 @@ static CURLM *multi; | |||
55 | 60 | ||
56 | static char *url; | 61 | static char *url; |
57 | 62 | ||
63 | static struct GNUNET_PeerIdentity id; | ||
64 | |||
58 | /** | 65 | /** |
59 | * IP address of the ultimate destination. | 66 | * IP address of the ultimate destination. |
60 | */ | 67 | */ |
@@ -129,7 +136,8 @@ mhd_ahc (void *cls, | |||
129 | 136 | ||
130 | 137 | ||
131 | static void | 138 | static void |
132 | do_shutdown () | 139 | do_shutdown (void *cls, |
140 | const struct GNUNET_SCHEDULER_TaskContext *c) | ||
133 | { | 141 | { |
134 | if (mhd_task_id != NULL) | 142 | if (mhd_task_id != NULL) |
135 | { | 143 | { |
@@ -146,6 +154,16 @@ do_shutdown () | |||
146 | MHD_stop_daemon (mhd); | 154 | MHD_stop_daemon (mhd); |
147 | mhd = NULL; | 155 | mhd = NULL; |
148 | } | 156 | } |
157 | if (NULL != identity) | ||
158 | { | ||
159 | GNUNET_IDENTITY_disconnect (identity); | ||
160 | identity = NULL; | ||
161 | } | ||
162 | if (NULL != qe) | ||
163 | { | ||
164 | GNUNET_NAMESTORE_cancel (qe); | ||
165 | qe = NULL; | ||
166 | } | ||
149 | GNUNET_free_non_null (url); | 167 | GNUNET_free_non_null (url); |
150 | url = NULL; | 168 | url = NULL; |
151 | } | 169 | } |
@@ -217,7 +235,7 @@ curl_main () | |||
217 | global_ret = 3; | 235 | global_ret = 3; |
218 | } | 236 | } |
219 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download complete, shutting down!\n"); | 237 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download complete, shutting down!\n"); |
220 | do_shutdown (); | 238 | GNUNET_SCHEDULER_shutdown (); |
221 | return; | 239 | return; |
222 | } | 240 | } |
223 | GNUNET_assert (CURLM_OK == curl_multi_fdset (multi, &rs, &ws, &es, &max)); | 241 | GNUNET_assert (CURLM_OK == curl_multi_fdset (multi, &rs, &ws, &es, &max)); |
@@ -253,13 +271,15 @@ start_curl (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
253 | curl_easy_setopt (curl, CURLOPT_WRITEDATA, &cbc); | 271 | curl_easy_setopt (curl, CURLOPT_WRITEDATA, &cbc); |
254 | curl_easy_setopt (curl, CURLOPT_FAILONERROR, 1); | 272 | curl_easy_setopt (curl, CURLOPT_FAILONERROR, 1); |
255 | curl_easy_setopt (curl, CURLOPT_TIMEOUT, 150L); | 273 | curl_easy_setopt (curl, CURLOPT_TIMEOUT, 150L); |
256 | curl_easy_setopt (curl, CURLOPT_CONNECTTIMEOUT, 15L); | 274 | curl_easy_setopt (curl, CURLOPT_CONNECTTIMEOUT, 150L); |
257 | curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1); | 275 | curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1); |
258 | 276 | ||
259 | multi = curl_multi_init (); | 277 | multi = curl_multi_init (); |
260 | GNUNET_assert (multi != NULL); | 278 | GNUNET_assert (multi != NULL); |
261 | GNUNET_assert (CURLM_OK == curl_multi_add_handle (multi, curl)); | 279 | GNUNET_assert (CURLM_OK == curl_multi_add_handle (multi, curl)); |
262 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Beginning HTTP download from `%s'\n", url); | 280 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
281 | "Beginning HTTP download from `%s'\n", | ||
282 | url); | ||
263 | curl_main (); | 283 | curl_main (); |
264 | } | 284 | } |
265 | 285 | ||
@@ -292,11 +312,15 @@ commence_testing (void *cls, int32_t success, const char *emsg) | |||
292 | if ((emsg != NULL) && (GNUNET_YES != success)) | 312 | if ((emsg != NULL) && (GNUNET_YES != success)) |
293 | { | 313 | { |
294 | fprintf (stderr, | 314 | fprintf (stderr, |
295 | "NS failed to create record %s\n", emsg); | 315 | "NS failed to create record %s\n", |
316 | emsg); | ||
296 | GNUNET_SCHEDULER_shutdown (); | 317 | GNUNET_SCHEDULER_shutdown (); |
297 | return; | 318 | return; |
298 | } | 319 | } |
299 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), &start_curl, NULL); | 320 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
321 | (GNUNET_TIME_UNIT_SECONDS, 10), | ||
322 | &start_curl, | ||
323 | NULL); | ||
300 | } | 324 | } |
301 | 325 | ||
302 | 326 | ||
@@ -356,70 +380,6 @@ mhd_main () | |||
356 | } | 380 | } |
357 | 381 | ||
358 | 382 | ||
359 | static void | ||
360 | run (void *cls, | ||
361 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
362 | struct GNUNET_TESTING_Peer *peer) | ||
363 | { | ||
364 | enum MHD_FLAG flags; | ||
365 | struct GNUNET_PeerIdentity id; | ||
366 | char *peername; | ||
367 | struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key; | ||
368 | struct GNUNET_GNSRECORD_Data rd; | ||
369 | char *rd_string; | ||
370 | char *zone_keyfile; | ||
371 | |||
372 | GNUNET_TESTING_peer_get_identity (peer, &id); | ||
373 | peername = GNUNET_strdup (GNUNET_i2s_full (&id)); | ||
374 | |||
375 | namestore = GNUNET_NAMESTORE_connect (cfg); | ||
376 | GNUNET_assert (NULL != namestore); | ||
377 | flags = MHD_USE_DEBUG; | ||
378 | if (GNUNET_YES == use_v6) | ||
379 | flags |= MHD_USE_IPv6; | ||
380 | mhd = MHD_start_daemon (flags, | ||
381 | PORT, | ||
382 | NULL, NULL, | ||
383 | &mhd_ahc, NULL, | ||
384 | MHD_OPTION_END); | ||
385 | GNUNET_assert (NULL != mhd); | ||
386 | mhd_main (); | ||
387 | |||
388 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", | ||
389 | "ZONEKEY", | ||
390 | &zone_keyfile)) | ||
391 | { | ||
392 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
393 | "Failed to get key from cfg\n"); | ||
394 | GNUNET_free (peername); | ||
395 | return; | ||
396 | } | ||
397 | |||
398 | zone_key = GNUNET_CRYPTO_ecdsa_key_create_from_file (zone_keyfile); | ||
399 | rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; | ||
400 | GNUNET_asprintf (&rd_string, | ||
401 | "6 %s %s", | ||
402 | peername, | ||
403 | "www.gnu."); | ||
404 | GNUNET_free (peername); | ||
405 | GNUNET_assert (GNUNET_OK == | ||
406 | GNUNET_GNSRECORD_string_to_value (GNUNET_GNSRECORD_TYPE_VPN, | ||
407 | rd_string, | ||
408 | (void**) &rd.data, | ||
409 | &rd.data_size)); | ||
410 | rd.record_type = GNUNET_GNSRECORD_TYPE_VPN; | ||
411 | |||
412 | GNUNET_NAMESTORE_records_store (namestore, | ||
413 | zone_key, | ||
414 | "www", | ||
415 | 1, &rd, | ||
416 | &commence_testing, | ||
417 | NULL); | ||
418 | GNUNET_free ((void**)rd.data); | ||
419 | GNUNET_free (rd_string); | ||
420 | GNUNET_free (zone_keyfile); | ||
421 | GNUNET_free (zone_key); | ||
422 | } | ||
423 | 383 | ||
424 | 384 | ||
425 | /** | 385 | /** |
@@ -505,6 +465,194 @@ fork_and_exec (const char *file, | |||
505 | return 0; | 465 | return 0; |
506 | } | 466 | } |
507 | 467 | ||
468 | |||
469 | |||
470 | /** | ||
471 | * Method called to inform about the egos of this peer. | ||
472 | * | ||
473 | * When used with #GNUNET_IDENTITY_connect, this function is | ||
474 | * initially called for all egos and then again whenever a | ||
475 | * ego's name changes or if it is deleted. At the end of | ||
476 | * the initial pass over all egos, the function is once called | ||
477 | * with 'NULL' for @a ego. That does NOT mean that the callback won't | ||
478 | * be invoked in the future or that there was an error. | ||
479 | * | ||
480 | * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get, | ||
481 | * this function is only called ONCE, and 'NULL' being passed in | ||
482 | * @a ego does indicate an error (i.e. name is taken or no default | ||
483 | * value is known). If @a ego is non-NULL and if '*ctx' | ||
484 | * is set in those callbacks, the value WILL be passed to a subsequent | ||
485 | * call to the identity callback of #GNUNET_IDENTITY_connect (if | ||
486 | * that one was not NULL). | ||
487 | * | ||
488 | * When an identity is renamed, this function is called with the | ||
489 | * (known) @a ego but the NEW @a name. | ||
490 | * | ||
491 | * When an identity is deleted, this function is called with the | ||
492 | * (known) ego and "NULL" for the @a name. In this case, | ||
493 | * the @a ego is henceforth invalid (and the @a ctx should also be | ||
494 | * cleaned up). | ||
495 | * | ||
496 | * @param cls closure | ||
497 | * @param ego ego handle | ||
498 | * @param ctx context for application to store data for this ego | ||
499 | * (during the lifetime of this process, initially NULL) | ||
500 | * @param name name assigned by the user for this ego, | ||
501 | * NULL if the user just deleted the ego and it | ||
502 | * must thus no longer be used | ||
503 | */ | ||
504 | static void | ||
505 | identity_cb (void *cls, | ||
506 | struct GNUNET_IDENTITY_Ego *ego, | ||
507 | void **ctx, | ||
508 | const char *name) | ||
509 | { | ||
510 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key; | ||
511 | struct GNUNET_GNSRECORD_Data rd; | ||
512 | char *rd_string; | ||
513 | char *peername; | ||
514 | |||
515 | if (NULL == name) | ||
516 | return; | ||
517 | if (NULL == ego) | ||
518 | { | ||
519 | if (NULL == qe) | ||
520 | { | ||
521 | fprintf (stderr, | ||
522 | "Failed to find master-zone ego\n"); | ||
523 | GNUNET_SCHEDULER_shutdown (); | ||
524 | return; | ||
525 | } | ||
526 | GNUNET_IDENTITY_disconnect (identity); | ||
527 | identity = NULL; | ||
528 | return; | ||
529 | } | ||
530 | GNUNET_assert (NULL != name); | ||
531 | if (0 != strcmp (name, | ||
532 | "master-zone")) | ||
533 | { | ||
534 | fprintf (stderr, | ||
535 | "Unexpected name %s\n", | ||
536 | name); | ||
537 | return; | ||
538 | } | ||
539 | /* FIXME: we somehow need to get this zone-key into | ||
540 | the 'DNS_ROOT' option of the 'gns' service. This | ||
541 | is currently why the test fails... */ | ||
542 | zone_key = GNUNET_IDENTITY_ego_get_private_key (ego); | ||
543 | rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; | ||
544 | peername = GNUNET_strdup (GNUNET_i2s_full (&id)); | ||
545 | GNUNET_asprintf (&rd_string, | ||
546 | "6 %s %s", | ||
547 | peername, | ||
548 | "www.gnu."); | ||
549 | GNUNET_free (peername); | ||
550 | GNUNET_assert (GNUNET_OK == | ||
551 | GNUNET_GNSRECORD_string_to_value (GNUNET_GNSRECORD_TYPE_VPN, | ||
552 | rd_string, | ||
553 | (void**) &rd.data, | ||
554 | &rd.data_size)); | ||
555 | rd.record_type = GNUNET_GNSRECORD_TYPE_VPN; | ||
556 | |||
557 | qe = GNUNET_NAMESTORE_records_store (namestore, | ||
558 | zone_key, | ||
559 | "www", | ||
560 | 1, &rd, | ||
561 | &commence_testing, | ||
562 | NULL); | ||
563 | GNUNET_free ((void**)rd.data); | ||
564 | GNUNET_free (rd_string); | ||
565 | } | ||
566 | |||
567 | |||
568 | static void | ||
569 | run (void *cls, | ||
570 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
571 | struct GNUNET_TESTING_Peer *peer) | ||
572 | { | ||
573 | enum MHD_FLAG flags; | ||
574 | |||
575 | char *bin; | ||
576 | char *bin_identity; | ||
577 | char *config; | ||
578 | |||
579 | if (GNUNET_OK != | ||
580 | GNUNET_CONFIGURATION_get_value_string (cfg, | ||
581 | "arm", | ||
582 | "CONFIG", | ||
583 | &config)) | ||
584 | { | ||
585 | fprintf (stderr, | ||
586 | "Failed to locate configuration file. Skipping test.\n"); | ||
587 | GNUNET_SCHEDULER_shutdown (); | ||
588 | return; | ||
589 | } | ||
590 | |||
591 | char *const identity_args[] = | ||
592 | { | ||
593 | "gnunet-identity", | ||
594 | "-C", "master-zone", | ||
595 | "-c", config, | ||
596 | NULL | ||
597 | }; | ||
598 | char *const identity2_args[] = | ||
599 | { | ||
600 | "gnunet-identity", | ||
601 | "-e", "master-zone", | ||
602 | "-s", "gns-master", | ||
603 | "-c", config, | ||
604 | NULL | ||
605 | }; | ||
606 | GNUNET_TESTING_peer_get_identity (peer, &id); | ||
607 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, | ||
608 | &do_shutdown, | ||
609 | NULL); | ||
610 | bin = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_BINDIR); | ||
611 | GNUNET_asprintf (&bin_identity, | ||
612 | "%s/%s", | ||
613 | bin, | ||
614 | "gnunet-identity"); | ||
615 | GNUNET_free (bin); | ||
616 | if (0 != fork_and_exec (bin_identity, identity_args)) | ||
617 | { | ||
618 | fprintf (stderr, | ||
619 | "Failed to run `gnunet-identity -C. Skipping test.\n"); | ||
620 | GNUNET_SCHEDULER_shutdown (); | ||
621 | GNUNET_free (bin_identity); | ||
622 | GNUNET_free (config); | ||
623 | return; | ||
624 | } | ||
625 | if (0 != fork_and_exec (bin_identity, identity2_args)) | ||
626 | { | ||
627 | fprintf (stderr, | ||
628 | "Failed to run `gnunet-identity -e. Skipping test.\n"); | ||
629 | GNUNET_SCHEDULER_shutdown (); | ||
630 | GNUNET_free (bin_identity); | ||
631 | GNUNET_free (config); | ||
632 | return; | ||
633 | } | ||
634 | GNUNET_free (bin_identity); | ||
635 | GNUNET_free (config); | ||
636 | |||
637 | namestore = GNUNET_NAMESTORE_connect (cfg); | ||
638 | GNUNET_assert (NULL != namestore); | ||
639 | flags = MHD_USE_DEBUG; | ||
640 | if (GNUNET_YES == use_v6) | ||
641 | flags |= MHD_USE_IPv6; | ||
642 | mhd = MHD_start_daemon (flags, | ||
643 | PORT, | ||
644 | NULL, NULL, | ||
645 | &mhd_ahc, NULL, | ||
646 | MHD_OPTION_END); | ||
647 | GNUNET_assert (NULL != mhd); | ||
648 | mhd_main (); | ||
649 | |||
650 | identity = GNUNET_IDENTITY_connect (cfg, | ||
651 | &identity_cb, | ||
652 | NULL); | ||
653 | } | ||
654 | |||
655 | |||
508 | int | 656 | int |
509 | main (int argc, char *const *argv) | 657 | main (int argc, char *const *argv) |
510 | { | 658 | { |
@@ -591,6 +739,8 @@ main (int argc, char *const *argv) | |||
591 | fprintf (stderr, "failed to initialize curl\n"); | 739 | fprintf (stderr, "failed to initialize curl\n"); |
592 | return 2; | 740 | return 2; |
593 | } | 741 | } |
742 | |||
743 | |||
594 | if (0 != GNUNET_TESTING_peer_run ("test-gnunet-vpn", | 744 | if (0 != GNUNET_TESTING_peer_run ("test-gnunet-vpn", |
595 | "test_gns_vpn.conf", | 745 | "test_gns_vpn.conf", |
596 | &run, NULL)) | 746 | &run, NULL)) |
diff --git a/src/pt/test_gns_vpn.conf b/src/pt/test_gns_vpn.conf index b0ed23176..78dbdc700 100644 --- a/src/pt/test_gns_vpn.conf +++ b/src/pt/test_gns_vpn.conf | |||
@@ -7,6 +7,8 @@ PLUGINS = tcp | |||
7 | [arm] | 7 | [arm] |
8 | PORT = 0 | 8 | PORT = 0 |
9 | ALLOW_SHUTDOWN = YES | 9 | ALLOW_SHUTDOWN = YES |
10 | SYSTEM_ONLY = NO | ||
11 | USER_ONLY = NO | ||
10 | 12 | ||
11 | [exit] | 13 | [exit] |
12 | FORCESTART = YES | 14 | FORCESTART = YES |
@@ -23,6 +25,11 @@ EXIT_IFNAME = eth1 | |||
23 | 25 | ||
24 | [dns] | 26 | [dns] |
25 | DNS_EXIT = 8.8.8.8 | 27 | DNS_EXIT = 8.8.8.8 |
28 | FORCESTART = YES | ||
29 | |||
30 | [identity] | ||
31 | AUTOSTART = YES | ||
32 | FORCESTART = YES | ||
26 | 33 | ||
27 | [hostlist] | 34 | [hostlist] |
28 | AUTOSTART = NO | 35 | AUTOSTART = NO |
@@ -46,8 +53,8 @@ TTL = 3600000 | |||
46 | 53 | ||
47 | [gns] | 54 | [gns] |
48 | AUTOSTART = YES | 55 | AUTOSTART = YES |
49 | ZONEKEY = $GNUNET_TEST_HOME/.hostkey | 56 | ZONEKEY = $GNUNET_TEST_HOME/.zonekey |
50 | HIJACK_DNS = YES | 57 | DNS_ROOT = FIXME |
51 | 58 | ||
52 | [namestore] | 59 | [namestore] |
53 | AUTOSTART = YES | 60 | AUTOSTART = YES |