#include <microhttpd.h>
#include "gnunet_namestore_service.h"
#include "gnunet_gns_service.h"
-#include "gnunet_testing_lib-new.h"
+#include "gnunet_testing_lib.h"
#define PORT 8080
#define TEST_DOMAIN "www.gads"
disco_ns (void* cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_NAMESTORE_disconnect (namestore);
+ namestore = NULL;
}
"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);
-
+ }
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), &start_curl, NULL);
}
-
-
/**
* Function to keep the HTTP server running.
*/
enum MHD_FLAG flags;
struct GNUNET_PeerIdentity id;
struct GNUNET_CRYPTO_HashAsciiEncoded peername;
- struct GNUNET_CRYPTO_RsaPrivateKey *host_key;
+ struct GNUNET_CRYPTO_EccPrivateKey *host_key;
struct GNUNET_NAMESTORE_RecordData rd;
char *rd_string;
char *zone_keyfile;
return;
}
- host_key = GNUNET_CRYPTO_rsa_key_create_from_file (zone_keyfile);
- rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value;
+ host_key = GNUNET_CRYPTO_ecc_key_create_from_file (zone_keyfile);
+ rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
GNUNET_asprintf (&rd_string, "6 %s %s", (char*)&peername, "www.gads.");
GNUNET_assert (GNUNET_OK == GNUNET_NAMESTORE_string_to_value (GNUNET_GNS_RECORD_VPN,
rd_string,
&rd.data_size));
rd.record_type = GNUNET_GNS_RECORD_VPN;
- GNUNET_NAMESTORE_record_create (namestore,
- host_key,
- "www",
- &rd,
- &commence_testing,
- NULL);
+ GNUNET_NAMESTORE_records_store (namestore,
+ host_key,
+ "www",
+ 1, &rd,
+ &commence_testing,
+ NULL);
GNUNET_free ((void**)rd.data);
GNUNET_free (rd_string);
GNUNET_free (zone_keyfile);
- GNUNET_CRYPTO_rsa_key_free (host_key);
-}
-
-
-/**
- * Test if the given AF is supported by this system.
- *
- * @param af to test
- * @return GNUNET_OK if the AF is supported
- */
-static int
-test_af (int af)
-{
- int s;
-
- s = socket (af, SOCK_STREAM, 0);
- if (-1 == s)
- {
- if (EAFNOSUPPORT == errno)
- return GNUNET_NO;
- fprintf (stderr, "Failed to create test socket: %s\n", STRERROR (errno));
- return GNUNET_SYSERR;
- }
- close (s);
- return GNUNET_OK;
+ GNUNET_CRYPTO_ecc_key_free (host_key);
}
main (int argc, char *const *argv)
{
char *sbin_iptables;
+ char *bin_vpn;
+ char *bin_exit;
+ char *bin_dns;
char *const iptables_args[] =
{
"iptables", "-t", "mangle", "-L", "-v", NULL
return 0;
}
+ bin_vpn = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-vpn");
+ bin_exit = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit");
+ bin_dns = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-dns");
if ( (0 != geteuid ()) &&
( (GNUNET_YES !=
- GNUNET_OS_check_helper_binary ("gnunet-helper-vpn")) ||
+ GNUNET_OS_check_helper_binary (bin_vpn, GNUNET_YES, "-d gnunet-vpn - - 169.1.3.3.7 255.255.255.0")) || //ipv4 only please!
(GNUNET_YES !=
- GNUNET_OS_check_helper_binary ("gnunet-helper-exit")) ||
+ 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
(GNUNET_YES !=
- GNUNET_OS_check_helper_binary ("gnunet-helper-dns"))) )
- {
+ GNUNET_OS_check_helper_binary (bin_dns, GNUNET_YES, NULL))) ) // TODO: once we have a windows-testcase, add test parameters here
+ {
fprintf (stderr,
"WARNING: gnunet-helper-{exit,vpn,dns} binaries in $PATH are not SUID, refusing to run test (as it would have to fail).\n");
fprintf (stderr,
"Change $PATH ('.' in $PATH before $GNUNET_PREFIX/bin is problematic) or permissions (run 'make install' as root) to fix this!\n");
+ GNUNET_free (bin_vpn);
+ GNUNET_free (bin_exit);
+ GNUNET_free (bin_dns);
return 0;
}
- GNUNET_CRYPTO_setup_hostkey ("test_gns_vpn.conf");
+ GNUNET_free (bin_vpn);
+ GNUNET_free (bin_exit);
+ GNUNET_free (bin_dns);
dest_ip = "169.254.86.1";
dest_af = AF_INET;
src_af = AF_INET;
- if (GNUNET_OK == test_af (AF_INET6))
+ if (GNUNET_OK == GNUNET_NETWORK_test_pf (PF_INET6))
use_v6 = GNUNET_YES;
else
use_v6 = GNUNET_NO;
- if ( (GNUNET_OK != test_af (src_af)) ||
- (GNUNET_OK != test_af (dest_af)) )
+ if ( (GNUNET_OK != GNUNET_NETWORK_test_pf (src_af)) ||
+ (GNUNET_OK != GNUNET_NETWORK_test_pf (dest_af)) )
{
fprintf (stderr,
"Required address families not supported by this system, skipping test.\n");