+++ /dev/null
-#! /bin/sh
-
-# test_gns_proxy - temporary wrapper script for .libs/test_gns_proxy
-# Generated by libtool (GNU libtool) 2.4.2
-#
-# The test_gns_proxy program cannot be directly executed until all the libtool
-# libraries that it depends on are installed.
-#
-# This wrapper script should never be moved out of the build directory.
-# If it is, it will not operate correctly.
-
-# Sed substitution that helps us do robust quoting. It backslashifies
-# metacharacters that are still active within double-quoted strings.
-sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
- setopt NO_GLOB_SUBST
-else
- case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
-fi
-BIN_SH=xpg4; export BIN_SH # for Tru64
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-relink_command="(cd /home/schanzen/Documents/thesis/gnunet/src/gns; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=/home/schanzen/bin:/home/schanzen/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/schanzen/Documents/thesis/gnunet-install/bin:/home/schanzen/bin:/home/schanzen/Documents/thesis/gnunet-install/bin; export PATH; gcc -fno-strict-aliasing -Wall -g -O2 -o \$progdir/\$file test_gns_proxy.o -L/home/schanzen/Documents/thesis/gnunet-install/lib /home/schanzen/Documents/thesis/gnunet-install/lib/libmicrohttpd.so -lpthread /home/schanzen/Documents/thesis/gnunet-install/lib/libcurl.so -lrt -lgnutls ../../src/util/.libs/libgnunetutil.so ../../src/namestore/.libs/libgnunetnamestore.so ../../src/gns/.libs/libgnunetgns.so /home/schanzen/Documents/thesis/gnunet/src/namestore/.libs/libgnunetnamestore.so /home/schanzen/Documents/thesis/gnunet/src/statistics/.libs/libgnunetstatistics.so ../../src/testing/.libs/libgnunettesting.so /home/schanzen/Documents/thesis/gnunet/src/util/.libs/libgnunetutil.so -lgcrypt -lgpg-error -lltdl -lz -lunistring -lm -ldl -Wl,-rpath -Wl,/home/schanzen/Documents/thesis/gnunet-install/lib -Wl,-rpath -Wl,/home/schanzen/Documents/thesis/gnunet/src/util/.libs -Wl,-rpath -Wl,/home/schanzen/Documents/thesis/gnunet/src/namestore/.libs -Wl,-rpath -Wl,/home/schanzen/Documents/thesis/gnunet/src/gns/.libs -Wl,-rpath -Wl,/home/schanzen/Documents/thesis/gnunet/src/statistics/.libs -Wl,-rpath -Wl,/home/schanzen/Documents/thesis/gnunet/src/testing/.libs -Wl,-rpath -Wl,/home/schanzen/Documents/thesis/gnunet-install/lib)"
-
-# This environment variable determines our operation mode.
-if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
- # install mode needs the following variables:
- generated_by_libtool_version='2.4.2'
- notinst_deplibs=' ../../src/util/libgnunetutil.la ../../src/namestore/libgnunetnamestore.la ../../src/gns/libgnunetgns.la /home/schanzen/Documents/thesis/gnunet/src/namestore/libgnunetnamestore.la /home/schanzen/Documents/thesis/gnunet/src/statistics/libgnunetstatistics.la ../../src/testing/libgnunettesting.la /home/schanzen/Documents/thesis/gnunet/src/util/libgnunetutil.la'
-else
- # When we are sourced in execute mode, $file and $ECHO are already set.
- if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
- file="$0"
-
-# A function that is used when there is no print builtin or printf.
-func_fallback_echo ()
-{
- eval 'cat <<_LTECHO_EOF
-$1
-_LTECHO_EOF'
-}
- ECHO="printf %s\\n"
- fi
-
-# Very basic option parsing. These options are (a) specific to
-# the libtool wrapper, (b) are identical between the wrapper
-# /script/ and the wrapper /executable/ which is used only on
-# windows platforms, and (c) all begin with the string --lt-
-# (application programs are unlikely to have options which match
-# this pattern).
-#
-# There are only two supported options: --lt-debug and
-# --lt-dump-script. There is, deliberately, no --lt-help.
-#
-# The first argument to this parsing function should be the
-# script's ../../libtool value, followed by no.
-lt_option_debug=
-func_parse_lt_options ()
-{
- lt_script_arg0=$0
- shift
- for lt_opt
- do
- case "$lt_opt" in
- --lt-debug) lt_option_debug=1 ;;
- --lt-dump-script)
- lt_dump_D=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%/[^/]*$%%'`
- test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=.
- lt_dump_F=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%^.*/%%'`
- cat "$lt_dump_D/$lt_dump_F"
- exit 0
- ;;
- --lt-*)
- $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2
- exit 1
- ;;
- esac
- done
-
- # Print the debug banner immediately:
- if test -n "$lt_option_debug"; then
- echo "test_gns_proxy:test_gns_proxy:${LINENO}: libtool wrapper (GNU libtool) 2.4.2" 1>&2
- fi
-}
-
-# Used when --lt-debug. Prints its arguments to stdout
-# (redirection is the responsibility of the caller)
-func_lt_dump_args ()
-{
- lt_dump_args_N=1;
- for lt_arg
- do
- $ECHO "test_gns_proxy:test_gns_proxy:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg"
- lt_dump_args_N=`expr $lt_dump_args_N + 1`
- done
-}
-
-# Core function for launching the target application
-func_exec_program_core ()
-{
-
- if test -n "$lt_option_debug"; then
- $ECHO "test_gns_proxy:test_gns_proxy:${LINENO}: newargv[0]: $progdir/$program" 1>&2
- func_lt_dump_args ${1+"$@"} 1>&2
- fi
- exec "$progdir/$program" ${1+"$@"}
-
- $ECHO "$0: cannot exec $program $*" 1>&2
- exit 1
-}
-
-# A function to encapsulate launching the target application
-# Strips options in the --lt-* namespace from $@ and
-# launches target application with the remaining arguments.
-func_exec_program ()
-{
- case " $* " in
- *\ --lt-*)
- for lt_wr_arg
- do
- case $lt_wr_arg in
- --lt-*) ;;
- *) set x "$@" "$lt_wr_arg"; shift;;
- esac
- shift
- done ;;
- esac
- func_exec_program_core ${1+"$@"}
-}
-
- # Parse options
- func_parse_lt_options "$0" ${1+"$@"}
-
- # Find the directory that this script lives in.
- thisdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'`
- test "x$thisdir" = "x$file" && thisdir=.
-
- # Follow symbolic links until we get to the real thisdir.
- file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'`
- while test -n "$file"; do
- destdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'`
-
- # If there was a directory component, then change thisdir.
- if test "x$destdir" != "x$file"; then
- case "$destdir" in
- [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;;
- *) thisdir="$thisdir/$destdir" ;;
- esac
- fi
-
- file=`$ECHO "$file" | /bin/sed 's%^.*/%%'`
- file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'`
- done
-
- # Usually 'no', except on cygwin/mingw when embedded into
- # the cwrapper.
- WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no
- if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then
- # special case for '.'
- if test "$thisdir" = "."; then
- thisdir=`pwd`
- fi
- # remove .libs from thisdir
- case "$thisdir" in
- *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /bin/sed 's%[\\/][^\\/]*$%%'` ;;
- .libs ) thisdir=. ;;
- esac
- fi
-
- # Try to get the absolute directory name.
- absdir=`cd "$thisdir" && pwd`
- test -n "$absdir" && thisdir="$absdir"
-
- program=lt-'test_gns_proxy'
- progdir="$thisdir/.libs"
-
- if test ! -f "$progdir/$program" ||
- { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \
- test "X$file" != "X$progdir/$program"; }; then
-
- file="$$-$program"
-
- if test ! -d "$progdir"; then
- mkdir "$progdir"
- else
- rm -f "$progdir/$file"
- fi
-
- # relink executable if necessary
- if test -n "$relink_command"; then
- if relink_command_output=`eval $relink_command 2>&1`; then :
- else
- printf %s\n "$relink_command_output" >&2
- rm -f "$progdir/$file"
- exit 1
- fi
- fi
-
- mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null ||
- { rm -f "$progdir/$program";
- mv -f "$progdir/$file" "$progdir/$program"; }
- rm -f "$progdir/$file"
- fi
-
- if test -f "$progdir/$program"; then
- if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
- # Run the actual program with our arguments.
- func_exec_program ${1+"$@"}
- fi
- else
- # The program doesn't exist.
- $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2
- $ECHO "This script is just a wrapper for $program." 1>&2
- $ECHO "See the libtool documentation for more information." 1>&2
- exit 1
- fi
-fi
--- /dev/null
+/*
+ This file is part of GNUnet
+ (C) 2007, 2009, 2011, 2012 Christian Grothoff
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file test_gns_proxy.c
+ * @brief testcase for accessing SOCKS5 GNS proxy
+ * @author Martin Schanzenbach
+ */
+#include "platform.h"
+#include <curl/curl.h>
+#include <microhttpd.h>
+#include "gnunet_namestore_service.h"
+#include "gnunet_gns_service.h"
+#include "gnunet_testing_lib-new.h"
+#include "gnunet_os_lib.h"
+
+#define PORT 8080
+#define TEST_DOMAIN "www.gnunet"
+
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
+
+/**
+ * Return value for 'main'.
+ */
+static int global_ret;
+
+static struct GNUNET_NAMESTORE_Handle *namestore;
+
+static struct MHD_Daemon *mhd;
+
+static GNUNET_SCHEDULER_TaskIdentifier mhd_task_id;
+
+static GNUNET_SCHEDULER_TaskIdentifier curl_task_id;
+
+static CURL *curl;
+
+static CURLM *multi;
+
+static char *url;
+
+static struct GNUNET_OS_Process *proxy_proc;
+
+static char* tmp_cfgfile;
+
+struct CBC
+{
+ char buf[1024];
+ size_t pos;
+};
+
+static struct CBC cbc;
+
+
+static size_t
+copy_buffer (void *ptr, size_t size, size_t nmemb, void *ctx)
+{
+ struct CBC *cbc = ctx;
+
+ if (cbc->pos + size * nmemb > sizeof(cbc->buf))
+ return 0; /* overflow */
+ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb);
+ cbc->pos += size * nmemb;
+ return size * nmemb;
+}
+
+
+static int
+mhd_ahc (void *cls,
+ struct MHD_Connection *connection,
+ const char *url,
+ const char *method,
+ const char *version,
+ const char *upload_data, size_t *upload_data_size,
+ void **unused)
+{
+ static int ptr;
+ struct MHD_Response *response;
+ int ret;
+
+ if (0 != strcmp ("GET", method))
+ return MHD_NO; /* unexpected method */
+ if (&ptr != *unused)
+ {
+ *unused = &ptr;
+ return MHD_YES;
+ }
+ *unused = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MHD sends respose for request to URL `%s'\n", url);
+ response = MHD_create_response_from_buffer (strlen (url),
+ (void *) url,
+ MHD_RESPMEM_MUST_COPY);
+ ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
+ MHD_destroy_response (response);
+ if (ret == MHD_NO)
+ abort ();
+ return ret;
+}
+
+
+static void
+do_shutdown ()
+{
+ if (mhd_task_id != GNUNET_SCHEDULER_NO_TASK)
+ {
+ GNUNET_SCHEDULER_cancel (mhd_task_id);
+ mhd_task_id = GNUNET_SCHEDULER_NO_TASK;
+ }
+ if (curl_task_id != GNUNET_SCHEDULER_NO_TASK)
+ {
+ GNUNET_SCHEDULER_cancel (curl_task_id);
+ curl_task_id = GNUNET_SCHEDULER_NO_TASK;
+ }
+ if (NULL != mhd)
+ {
+ MHD_stop_daemon (mhd);
+ mhd = NULL;
+ }
+ GNUNET_free_non_null (url);
+
+ if (NULL != tmp_cfgfile)
+ remove (tmp_cfgfile);
+
+ if (NULL != proxy_proc)
+ GNUNET_OS_process_kill (proxy_proc, 9);
+ url = NULL;
+}
+
+
+/**
+ * Function to run the HTTP client.
+ */
+static void
+curl_main (void);
+
+
+static void
+curl_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ curl_task_id = GNUNET_SCHEDULER_NO_TASK;
+ curl_main ();
+}
+
+
+static void
+curl_main ()
+{
+ fd_set rs;
+ fd_set ws;
+ fd_set es;
+ int max;
+ struct GNUNET_NETWORK_FDSet nrs;
+ struct GNUNET_NETWORK_FDSet nws;
+ struct GNUNET_TIME_Relative delay;
+ long timeout;
+ int running;
+ struct CURLMsg *msg;
+
+ max = 0;
+ FD_ZERO (&rs);
+ FD_ZERO (&ws);
+ FD_ZERO (&es);
+ curl_multi_perform (multi, &running);
+ if (running == 0)
+ {
+ GNUNET_assert (NULL != (msg = curl_multi_info_read (multi, &running)));
+ if (msg->msg == CURLMSG_DONE)
+ {
+ if (msg->data.result != CURLE_OK)
+ {
+ fprintf (stderr,
+ "%s failed at %s:%d: `%s'\n",
+ "curl_multi_perform",
+ __FILE__,
+ __LINE__, curl_easy_strerror (msg->data.result));
+ global_ret = 1;
+ }
+ }
+ curl_multi_remove_handle (multi, curl);
+ curl_multi_cleanup (multi);
+ curl_easy_cleanup (curl);
+ curl = NULL;
+ multi = NULL;
+ if (cbc.pos != strlen ("/hello_world"))
+ {
+ GNUNET_break (0);
+ global_ret = 2;
+ }
+ if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
+ {
+ GNUNET_break (0);
+ global_ret = 3;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download complete, shutting down!\n");
+ do_shutdown ();
+ return;
+ }
+ GNUNET_assert (CURLM_OK == curl_multi_fdset (multi, &rs, &ws, &es, &max));
+ if ( (CURLM_OK != curl_multi_timeout (multi, &timeout)) ||
+ (-1 == timeout) )
+ delay = GNUNET_TIME_UNIT_SECONDS;
+ else
+ delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, (unsigned int) timeout);
+ GNUNET_NETWORK_fdset_copy_native (&nrs,
+ &rs,
+ max + 1);
+ GNUNET_NETWORK_fdset_copy_native (&nws,
+ &ws,
+ max + 1);
+ curl_task_id = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
+ delay,
+ &nrs,
+ &nws,
+ &curl_task,
+ NULL);
+}
+
+static void
+start_curl (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ GNUNET_asprintf (&url,
+ "http://%s:%d/hello_world",
+ TEST_DOMAIN, PORT);
+ curl = curl_easy_init ();
+ curl_easy_setopt (curl, CURLOPT_URL, url);
+ curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, ©_buffer);
+ curl_easy_setopt (curl, CURLOPT_WRITEDATA, &cbc);
+ curl_easy_setopt (curl, CURLOPT_FAILONERROR, 1);
+ curl_easy_setopt (curl, CURLOPT_TIMEOUT, 150L);
+ curl_easy_setopt (curl, CURLOPT_CONNECTTIMEOUT, 15L);
+ curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1);
+ curl_easy_setopt (curl, CURLOPT_PROXY, "socks5h://127.0.0.1:7777");
+
+ multi = curl_multi_init ();
+ GNUNET_assert (multi != NULL);
+ GNUNET_assert (CURLM_OK == curl_multi_add_handle (multi, curl));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Beginning HTTP download from `%s'\n", url);
+ curl_main ();
+}
+
+static void
+disco_ns (void* cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ GNUNET_NAMESTORE_disconnect (namestore);
+}
+
+/**
+ * Callback invoked from the namestore service once record is
+ * created.
+ *
+ * @param cls closure
+ * @param af address family, AF_INET or AF_INET6; AF_UNSPEC on error;
+ * will match 'result_af' from the request
+ * @param address IP address (struct in_addr or struct in_addr6, depending on 'af')
+ * that the VPN allocated for the redirection;
+ * traffic to this IP will now be redirected to the
+ * specified target peer; NULL on error
+ */
+static void
+commence_testing (void *cls, int32_t success, const char *emsg)
+{
+ GNUNET_SCHEDULER_add_now (&disco_ns, NULL);
+
+ if ((emsg != NULL) && (GNUNET_YES != success))
+ {
+ fprintf (stderr,
+ "NS failed to create record %s\n", emsg);
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), start_curl, NULL);
+
+}
+
+
+
+
+/**
+ * Function to keep the HTTP server running.
+ */
+static void
+mhd_main (void);
+
+
+static void
+mhd_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ mhd_task_id = GNUNET_SCHEDULER_NO_TASK;
+ MHD_run (mhd);
+ mhd_main ();
+}
+
+
+static void
+mhd_main ()
+{
+ struct GNUNET_NETWORK_FDSet nrs;
+ struct GNUNET_NETWORK_FDSet nws;
+ fd_set rs;
+ fd_set ws;
+ fd_set es;
+ int max_fd;
+ unsigned MHD_LONG_LONG timeout;
+ struct GNUNET_TIME_Relative delay;
+
+ GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == mhd_task_id);
+ FD_ZERO (&rs);
+ FD_ZERO (&ws);
+ FD_ZERO (&es);
+ max_fd = -1;
+ GNUNET_assert (MHD_YES ==
+ MHD_get_fdset (mhd, &rs, &ws, &es, &max_fd));
+ if (MHD_YES == MHD_get_timeout (mhd, &timeout))
+ delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
+ (unsigned int) timeout);
+ else
+ delay = GNUNET_TIME_UNIT_FOREVER_REL;
+ GNUNET_NETWORK_fdset_copy_native (&nrs,
+ &rs,
+ max_fd + 1);
+ GNUNET_NETWORK_fdset_copy_native (&nws,
+ &ws,
+ max_fd + 1);
+ mhd_task_id = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
+ delay,
+ &nrs,
+ &nws,
+ &mhd_task,
+ NULL);
+}
+
+static void
+run (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_TESTING_Peer *peer)
+{
+ enum MHD_FLAG flags;
+ struct GNUNET_CRYPTO_RsaPrivateKey *host_key;
+ struct GNUNET_NAMESTORE_RecordData rd;
+ char *zone_keyfile;
+
+ namestore = GNUNET_NAMESTORE_connect (cfg);
+ GNUNET_assert (NULL != namestore);
+ flags = MHD_USE_DEBUG;
+ mhd = MHD_start_daemon (flags,
+ PORT,
+ NULL, NULL,
+ &mhd_ahc, NULL,
+ MHD_OPTION_END);
+ GNUNET_assert (NULL != mhd);
+ mhd_main ();
+
+ tmp_cfgfile = GNUNET_DISK_mktemp ("test_gns_proxy_tmp.conf");
+ if (NULL == tmp_cfgfile)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to create tmp cfg!\n");
+ do_shutdown ();
+ return;
+ }
+
+ if (GNUNET_OK != GNUNET_CONFIGURATION_write ((struct GNUNET_CONFIGURATION_Handle *)cfg,
+ tmp_cfgfile))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to write tmp cfg\n");
+ return;
+ }
+
+ proxy_proc = GNUNET_OS_start_process (GNUNET_NO,
+ GNUNET_OS_INHERIT_STD_ALL,
+ NULL,
+ NULL,
+ "gnunet-gns-proxy",
+ "gnunet-gns-proxy",
+ "-c", tmp_cfgfile, NULL);
+
+ GNUNET_assert (NULL != proxy_proc);
+
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
+ "ZONEKEY",
+ &zone_keyfile))
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n");
+ return;
+ }
+
+ host_key = GNUNET_CRYPTO_rsa_key_create_from_file (zone_keyfile);
+ rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value;
+ GNUNET_assert (GNUNET_OK == GNUNET_NAMESTORE_string_to_value (GNUNET_GNS_RECORD_A,
+ "127.0.0.1",
+ (void**)&rd.data,
+ &rd.data_size));
+ rd.record_type = GNUNET_GNS_RECORD_A;
+
+ GNUNET_NAMESTORE_record_create (namestore,
+ host_key,
+ "www",
+ &rd,
+ &commence_testing,
+ NULL);
+
+ GNUNET_free ((void**)rd.data);
+ GNUNET_free (zone_keyfile);
+ GNUNET_CRYPTO_rsa_key_free (host_key);
+}
+
+int
+main (int argc, char *const *argv)
+{
+
+ GNUNET_CRYPTO_setup_hostkey ("test_gns_proxy.conf");
+
+ if (0 != curl_global_init (CURL_GLOBAL_WIN32))
+ {
+ fprintf (stderr, "failed to initialize curl\n");
+ return 2;
+ }
+ if (0 != GNUNET_TESTING_peer_run ("test-gnunet-gns-proxy",
+ "test_gns_proxy.conf",
+ &run, NULL))
+ return 1;
+ GNUNET_DISK_directory_remove ("/tmp/gnunet-test-gns-proxy");
+ return global_ret;
+}
+
+/* end of test_gns_vpn.c */
+