-initialize GNS DNS interception in testcase, so that curl will actually get GNS...
[oweals/gnunet.git] / src / pt / test_gns_vpn.c
1 /*
2      This file is part of GNUnet
3      Copyright (C) 2007, 2009, 2011, 2012, 2015 Christian Grothoff
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file test_gns_vpn.c
23  * @brief testcase for accessing VPN services via GNS
24  * @author Martin Schanzenbach
25  */
26 #include "platform.h"
27 #include <curl/curl.h>
28 #include <microhttpd.h>
29 #include "gnunet_identity_service.h"
30 #include "gnunet_namestore_service.h"
31 #include "gnunet_gnsrecord_lib.h"
32 #include "gnunet_gns_service.h"
33 #include "gnunet_testing_lib.h"
34
35 #define PORT 8080
36 #define TEST_DOMAIN "www.gnu"
37
38 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
39
40 /**
41  * Return value for #main().
42  */
43 static int global_ret;
44
45 static struct GNUNET_NAMESTORE_Handle *namestore;
46
47 static struct MHD_Daemon *mhd;
48
49 static struct GNUNET_SCHEDULER_Task *mhd_task_id;
50
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;
56
57 static CURL *curl;
58
59 static CURLM *multi;
60
61 static char *url;
62
63 static struct GNUNET_PeerIdentity id;
64
65 /**
66  * IP address of the ultimate destination.
67  */
68 static const char *dest_ip;
69
70 /**
71  * Address family of the dest_ip.
72  */
73 static int dest_af;
74
75 /**
76  * Address family to use by the curl client.
77  */
78 static int src_af;
79
80 static int use_v6;
81
82
83 struct CBC
84 {
85   char buf[1024];
86   size_t pos;
87 };
88
89 static struct CBC cbc;
90
91
92 static size_t
93 copy_buffer (void *ptr, size_t size, size_t nmemb, void *ctx)
94 {
95   struct CBC *cbc = ctx;
96
97   if (cbc->pos + size * nmemb > sizeof(cbc->buf))
98     return 0;                   /* overflow */
99   memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb);
100   cbc->pos += size * nmemb;
101   return size * nmemb;
102 }
103
104
105 static int
106 mhd_ahc (void *cls,
107           struct MHD_Connection *connection,
108           const char *url,
109           const char *method,
110           const char *version,
111           const char *upload_data, size_t *upload_data_size,
112           void **unused)
113 {
114   static int ptr;
115   struct MHD_Response *response;
116   int ret;
117
118   if (0 != strcmp ("GET", method))
119     return MHD_NO;              /* unexpected method */
120   if (&ptr != *unused)
121   {
122     *unused = &ptr;
123     return MHD_YES;
124   }
125   *unused = NULL;
126   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MHD sends respose for request to URL `%s'\n", url);
127   response = MHD_create_response_from_buffer (strlen (url),
128                                               (void *) url,
129                                               MHD_RESPMEM_MUST_COPY);
130   ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
131   MHD_destroy_response (response);
132   if (ret == MHD_NO)
133     abort ();
134   return ret;
135 }
136
137
138 static void
139 do_shutdown (void *cls,
140              const struct GNUNET_SCHEDULER_TaskContext *c)
141 {
142   if (mhd_task_id != NULL)
143   {
144     GNUNET_SCHEDULER_cancel (mhd_task_id);
145     mhd_task_id = NULL;
146   }
147   if (curl_task_id != NULL)
148   {
149     GNUNET_SCHEDULER_cancel (curl_task_id);
150     curl_task_id = NULL;
151   }
152   if (NULL != mhd)
153   {
154     MHD_stop_daemon (mhd);
155     mhd = NULL;
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   }
167   GNUNET_free_non_null (url);
168   url = NULL;
169 }
170
171
172 /**
173  * Function to run the HTTP client.
174  */
175 static void
176 curl_main (void);
177
178
179 static void
180 curl_task (void *cls,
181           const struct GNUNET_SCHEDULER_TaskContext *tc)
182 {
183   curl_task_id = NULL;
184   curl_main ();
185 }
186
187
188 static void
189 curl_main ()
190 {
191   fd_set rs;
192   fd_set ws;
193   fd_set es;
194   int max;
195   struct GNUNET_NETWORK_FDSet nrs;
196   struct GNUNET_NETWORK_FDSet nws;
197   struct GNUNET_TIME_Relative delay;
198   long timeout;
199   int running;
200   struct CURLMsg *msg;
201
202   max = 0;
203   FD_ZERO (&rs);
204   FD_ZERO (&ws);
205   FD_ZERO (&es);
206   curl_multi_perform (multi, &running);
207   if (running == 0)
208   {
209     GNUNET_assert (NULL != (msg = curl_multi_info_read (multi, &running)));
210     if (msg->msg == CURLMSG_DONE)
211     {
212       if (msg->data.result != CURLE_OK)
213       {
214         fprintf (stderr,
215                  "%s failed at %s:%d: `%s'\n",
216                  "curl_multi_perform",
217                 __FILE__,
218                 __LINE__, curl_easy_strerror (msg->data.result));
219         global_ret = 1;
220       }
221     }
222     curl_multi_remove_handle (multi, curl);
223     curl_multi_cleanup (multi);
224     curl_easy_cleanup (curl);
225     curl = NULL;
226     multi = NULL;
227     if (cbc.pos != strlen ("/hello_world"))
228     {
229       GNUNET_break (0);
230       global_ret = 2;
231     }
232     if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
233     {
234       GNUNET_break (0);
235       global_ret = 3;
236     }
237     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download complete, shutting down!\n");
238     GNUNET_SCHEDULER_shutdown ();
239     return;
240   }
241   GNUNET_assert (CURLM_OK == curl_multi_fdset (multi, &rs, &ws, &es, &max));
242   if ( (CURLM_OK != curl_multi_timeout (multi, &timeout)) ||
243        (-1 == timeout) )
244     delay = GNUNET_TIME_UNIT_SECONDS;
245   else
246     delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, (unsigned int) timeout);
247   GNUNET_NETWORK_fdset_copy_native (&nrs,
248                                     &rs,
249                                     max + 1);
250   GNUNET_NETWORK_fdset_copy_native (&nws,
251                                     &ws,
252                                     max + 1);
253   curl_task_id = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
254                                               delay,
255                                               &nrs,
256                                               &nws,
257                                               &curl_task,
258                                               NULL);
259 }
260
261
262 static void
263 start_curl (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
264 {
265   GNUNET_asprintf (&url,
266                    "http://%s/hello_world",
267                    TEST_DOMAIN);
268   curl = curl_easy_init ();
269   curl_easy_setopt (curl, CURLOPT_URL, url);
270   curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, &copy_buffer);
271   curl_easy_setopt (curl, CURLOPT_WRITEDATA, &cbc);
272   curl_easy_setopt (curl, CURLOPT_FAILONERROR, 1);
273   curl_easy_setopt (curl, CURLOPT_TIMEOUT, 150L);
274   curl_easy_setopt (curl, CURLOPT_CONNECTTIMEOUT, 150L);
275   curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1);
276
277   multi = curl_multi_init ();
278   GNUNET_assert (multi != NULL);
279   GNUNET_assert (CURLM_OK == curl_multi_add_handle (multi, curl));
280   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
281               "Beginning HTTP download from `%s'\n",
282               url);
283   curl_main ();
284 }
285
286
287 static void
288 disco_ns (void* cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
289 {
290   GNUNET_NAMESTORE_disconnect (namestore);
291   namestore = NULL;
292 }
293
294
295 /**
296  * Callback invoked from the namestore service once record is
297  * created.
298  *
299  * @param cls closure
300  * @param af address family, AF_INET or AF_INET6; AF_UNSPEC on error;
301  *                will match 'result_af' from the request
302  * @param address IP address (struct in_addr or struct in_addr6, depending on 'af')
303  *                that the VPN allocated for the redirection;
304  *                traffic to this IP will now be redirected to the
305  *                specified target peer; NULL on error
306  */
307 static void
308 commence_testing (void *cls, int32_t success, const char *emsg)
309 {
310   GNUNET_SCHEDULER_add_now (&disco_ns, NULL);
311
312   if ((emsg != NULL) && (GNUNET_YES != success))
313   {
314     fprintf (stderr,
315              "NS failed to create record %s\n",
316              emsg);
317     GNUNET_SCHEDULER_shutdown ();
318     return;
319   }
320   GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
321                                 (GNUNET_TIME_UNIT_SECONDS, 10),
322                                 &start_curl,
323                                 NULL);
324 }
325
326
327 /**
328  * Function to keep the HTTP server running.
329  */
330 static void
331 mhd_main (void);
332
333
334 static void
335 mhd_task (void *cls,
336           const struct GNUNET_SCHEDULER_TaskContext *tc)
337 {
338   mhd_task_id = NULL;
339   MHD_run (mhd);
340   mhd_main ();
341 }
342
343
344 static void
345 mhd_main ()
346 {
347   struct GNUNET_NETWORK_FDSet nrs;
348   struct GNUNET_NETWORK_FDSet nws;
349   fd_set rs;
350   fd_set ws;
351   fd_set es;
352   int max_fd;
353   unsigned MHD_LONG_LONG timeout;
354   struct GNUNET_TIME_Relative delay;
355
356   GNUNET_assert (NULL == mhd_task_id);
357   FD_ZERO (&rs);
358   FD_ZERO (&ws);
359   FD_ZERO (&es);
360   max_fd = -1;
361   GNUNET_assert (MHD_YES ==
362                  MHD_get_fdset (mhd, &rs, &ws, &es, &max_fd));
363   if (MHD_YES == MHD_get_timeout (mhd, &timeout))
364     delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
365                                            (unsigned int) timeout);
366   else
367     delay = GNUNET_TIME_UNIT_FOREVER_REL;
368   GNUNET_NETWORK_fdset_copy_native (&nrs,
369                                     &rs,
370                                     max_fd + 1);
371   GNUNET_NETWORK_fdset_copy_native (&nws,
372                                     &ws,
373                                     max_fd + 1);
374   mhd_task_id = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
375                                              delay,
376                                              &nrs,
377                                              &nws,
378                                              &mhd_task,
379                                              NULL);
380 }
381
382
383
384
385 /**
386  * Open '/dev/null' and make the result the given
387  * file descriptor.
388  *
389  * @param target_fd desired FD to point to /dev/null
390  * @param flags open flags (O_RDONLY, O_WRONLY)
391  */
392 static void
393 open_dev_null (int target_fd,
394                int flags)
395 {
396   int fd;
397
398   fd = open ("/dev/null", flags);
399   if (-1 == fd)
400     abort ();
401   if (fd == target_fd)
402     return;
403   if (-1 == dup2 (fd, target_fd))
404   {
405     (void) close (fd);
406     abort ();
407   }
408   (void) close (fd);
409 }
410
411
412 /**
413  * Run the given command and wait for it to complete.
414  *
415  * @param file name of the binary to run
416  * @param cmd command line arguments (as given to 'execv')
417  * @return 0 on success, 1 on any error
418  */
419 static int
420 fork_and_exec (const char *file,
421                char *const cmd[])
422 {
423   int status;
424   pid_t pid;
425   pid_t ret;
426
427   pid = fork ();
428   if (-1 == pid)
429   {
430     fprintf (stderr,
431              "fork failed: %s\n",
432              strerror (errno));
433     return 1;
434   }
435   if (0 == pid)
436   {
437     /* we are the child process */
438     /* close stdin/stdout to not cause interference
439        with the helper's main protocol! */
440     (void) close (0);
441     open_dev_null (0, O_RDONLY);
442     (void) close (1);
443     open_dev_null (1, O_WRONLY);
444     (void) execv (file, cmd);
445     /* can only get here on error */
446     fprintf (stderr,
447              "exec `%s' failed: %s\n",
448              file,
449              strerror (errno));
450     _exit (1);
451   }
452   /* keep running waitpid as long as the only error we get is 'EINTR' */
453   while ( (-1 == (ret = waitpid (pid, &status, 0))) &&
454           (errno == EINTR) );
455   if (-1 == ret)
456   {
457     fprintf (stderr,
458              "waitpid failed: %s\n",
459              strerror (errno));
460     return 1;
461   }
462   if (! (WIFEXITED (status) && (0 == WEXITSTATUS (status))))
463     return 1;
464   /* child process completed and returned success, we're happy */
465   return 0;
466 }
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   zone_key = GNUNET_IDENTITY_ego_get_private_key (ego);
540   rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
541   peername = GNUNET_strdup (GNUNET_i2s_full (&id));
542   GNUNET_asprintf (&rd_string,
543                    "6 %s %s",
544                    peername,
545                    "www.gnu.");
546   GNUNET_free (peername);
547   GNUNET_assert (GNUNET_OK ==
548                  GNUNET_GNSRECORD_string_to_value (GNUNET_GNSRECORD_TYPE_VPN,
549                                                    rd_string,
550                                                    (void**) &rd.data,
551                                                    &rd.data_size));
552   rd.record_type = GNUNET_GNSRECORD_TYPE_VPN;
553
554   qe = GNUNET_NAMESTORE_records_store (namestore,
555                                        zone_key,
556                                        "www",
557                                        1, &rd,
558                                        &commence_testing,
559                                        NULL);
560   GNUNET_free ((void**)rd.data);
561   GNUNET_free (rd_string);
562 }
563
564
565 static void
566 run (void *cls,
567      const struct GNUNET_CONFIGURATION_Handle *cfg,
568      struct GNUNET_TESTING_Peer *peer)
569 {
570   enum MHD_FLAG flags;
571
572   char *bin;
573   char *bin_identity;
574   char *config;
575
576   if (GNUNET_OK !=
577       GNUNET_CONFIGURATION_get_value_string (cfg,
578                                              "arm",
579                                              "CONFIG",
580                                              &config))
581   {
582     fprintf (stderr,
583              "Failed to locate configuration file. Skipping test.\n");
584     GNUNET_SCHEDULER_shutdown ();
585     return;
586   }
587
588   char *const identity_args[] =
589   {
590     "gnunet-identity",
591     "-C", "master-zone",
592     "-c", config,
593     NULL
594   };
595   char *const identity2_args[] =
596   {
597     "gnunet-identity",
598     "-e", "master-zone",
599     "-s", "gns-master",
600     "-c", config,
601     NULL
602   };
603   char *const identity3_args[] =
604   {
605     "gnunet-identity",
606     "-e", "master-zone",
607     "-s", "gns-intercept",
608     "-c", config,
609     NULL
610   };
611   GNUNET_TESTING_peer_get_identity (peer, &id);
612   GNUNET_SCHEDULER_add_delayed (TIMEOUT,
613                                 &do_shutdown,
614                                 NULL);
615   bin = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_BINDIR);
616   GNUNET_asprintf (&bin_identity,
617                    "%s/%s",
618                    bin,
619                    "gnunet-identity");
620   GNUNET_free (bin);
621   if (0 != fork_and_exec (bin_identity, identity_args))
622   {
623     fprintf (stderr,
624              "Failed to run `gnunet-identity -C. Skipping test.\n");
625     GNUNET_SCHEDULER_shutdown ();
626     GNUNET_free (bin_identity);
627     GNUNET_free (config);
628     return;
629   }
630   if (0 != fork_and_exec (bin_identity, identity2_args))
631   {
632     fprintf (stderr,
633              "Failed to run `gnunet-identity -e. Skipping test.\n");
634     GNUNET_SCHEDULER_shutdown ();
635     GNUNET_free (bin_identity);
636     GNUNET_free (config);
637     return;
638   }
639   if (0 != fork_and_exec (bin_identity, identity3_args))
640   {
641     fprintf (stderr,
642              "Failed to run `gnunet-identity -e. Skipping test.\n");
643     GNUNET_SCHEDULER_shutdown ();
644     GNUNET_free (bin_identity);
645     GNUNET_free (config);
646     return;
647   }
648   GNUNET_free (bin_identity);
649   GNUNET_free (config);
650
651   namestore = GNUNET_NAMESTORE_connect (cfg);
652   GNUNET_assert (NULL != namestore);
653   flags = MHD_USE_DEBUG;
654   if (GNUNET_YES == use_v6)
655     flags |= MHD_USE_IPv6;
656   mhd = MHD_start_daemon (flags,
657                           PORT,
658                           NULL, NULL,
659                           &mhd_ahc, NULL,
660                           MHD_OPTION_END);
661   GNUNET_assert (NULL != mhd);
662   mhd_main ();
663
664   identity = GNUNET_IDENTITY_connect (cfg,
665                                       &identity_cb,
666                                       NULL);
667 }
668
669
670 int
671 main (int argc, char *const *argv)
672 {
673   char *sbin_iptables;
674   char *bin_vpn;
675   char *bin_exit;
676   char *bin_dns;
677   char *const iptables_args[] =
678   {
679     "iptables", "-t", "mangle", "-L", "-v", NULL
680   };
681
682   if (0 == access ("/sbin/iptables", X_OK))
683     sbin_iptables = "/sbin/iptables";
684   else if (0 == access ("/usr/sbin/iptables", X_OK))
685     sbin_iptables = "/usr/sbin/iptables";
686   else
687   {
688     fprintf (stderr,
689              "Executable iptables not found in approved directories: %s, skipping\n",
690              strerror (errno));
691     return 0;
692   }
693
694   if (0 != fork_and_exec (sbin_iptables, iptables_args))
695   {
696     fprintf (stderr,
697              "Failed to run `iptables -t mangle -L -v'. Skipping test.\n");
698     return 0;
699   }
700
701   if (0 != ACCESS ("/dev/net/tun", R_OK))
702   {
703     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
704                               "access",
705                               "/dev/net/tun");
706     fprintf (stderr,
707              "WARNING: System unable to run test, skipping.\n");
708     return 0;
709   }
710
711   bin_vpn = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-vpn");
712   bin_exit = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit");
713   bin_dns = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-dns");
714   if ( (0 != geteuid ()) &&
715        ( (GNUNET_YES !=
716           GNUNET_OS_check_helper_binary (bin_vpn, GNUNET_YES, "-d gnunet-vpn - - 169.1.3.3.7 255.255.255.0")) || //ipv4 only please!
717          (GNUNET_YES !=
718           GNUNET_OS_check_helper_binary (bin_exit, GNUNET_YES, "-d gnunet-vpn - - - 169.1.3.3.7 255.255.255.0")) || //no nat, ipv4 only
719          (GNUNET_YES !=
720           GNUNET_OS_check_helper_binary (bin_dns, GNUNET_YES, NULL))) ) // TODO: once we have a windows-testcase, add test parameters here
721   {
722     fprintf (stderr,
723              "WARNING: gnunet-helper-{exit,vpn,dns} binaries in $PATH are not SUID, refusing to run test (as it would have to fail).\n");
724     fprintf (stderr,
725              "Change $PATH ('.' in $PATH before $GNUNET_PREFIX/bin is problematic) or permissions (run 'make install' as root) to fix this!\n");
726     GNUNET_free (bin_vpn);
727     GNUNET_free (bin_exit);
728     GNUNET_free (bin_dns);
729     return 0;
730   }
731   GNUNET_free (bin_vpn);
732   GNUNET_free (bin_exit);
733   GNUNET_free (bin_dns);
734
735   dest_ip = "169.254.86.1";
736   dest_af = AF_INET;
737   src_af = AF_INET;
738
739   if (GNUNET_OK == GNUNET_NETWORK_test_pf (PF_INET6))
740     use_v6 = GNUNET_YES;
741   else
742     use_v6 = GNUNET_NO;
743
744   if ( (GNUNET_OK != GNUNET_NETWORK_test_pf (src_af)) ||
745        (GNUNET_OK != GNUNET_NETWORK_test_pf (dest_af)) )
746   {
747     fprintf (stderr,
748              "Required address families not supported by this system, skipping test.\n");
749     return 0;
750   }
751   if (0 != curl_global_init (CURL_GLOBAL_WIN32))
752   {
753     fprintf (stderr, "failed to initialize curl\n");
754     return 2;
755   }
756
757
758   if (0 != GNUNET_TESTING_peer_run ("test-gnunet-vpn",
759                                     "test_gns_vpn.conf",
760                                     &run, NULL))
761     return 1;
762   GNUNET_DISK_directory_remove ("/tmp/gnunet-test-vpn");
763   return global_ret;
764 }
765
766 /* end of test_gns_vpn.c */