static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer) { struct GNUNET_CRYPTO_RsaSignature signature; struct GNUNET_NAMESTORE_RecordData rd; char *hostkey_file; const char * name = "dummy.dummy.gnunet"; endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL); GNUNET_asprintf (&hostkey_file, "zonefiles%s%s", DIR_SEPARATOR_STR, "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); privkey = GNUNET_CRYPTO_rsa_key_create_from_file (hostkey_file); GNUNET_free (hostkey_file); GNUNET_assert (privkey != NULL); GNUNET_CRYPTO_rsa_key_get_public (privkey, &pubkey); GNUNET_CRYPTO_short_hash (&pubkey, sizeof (pubkey), &zone); memset (&signature, '\0', sizeof (signature)); rd.expiration_time = GNUNET_TIME_absolute_get().abs_value; rd.record_type = TEST_RECORD_TYPE; rd.data_size = TEST_RECORD_DATALEN; rd.data = GNUNET_malloc (TEST_RECORD_DATALEN); memset ((char *) rd.data, 'a', TEST_RECORD_DATALEN); nsh = GNUNET_NAMESTORE_connect (cfg); GNUNET_break (NULL != nsh); nsqe = GNUNET_NAMESTORE_record_put (nsh, &pubkey, name, GNUNET_TIME_UNIT_FOREVER_ABS, 1, &rd, &signature, &put_cont, (void*) name); GNUNET_free ((void *)rd.data); }
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer) { directory = NULL; GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "GNUNET_TEST_HOME", &directory)); GNUNET_DISK_directory_remove (directory); endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT, &endbadly, NULL); nsh = GNUNET_NAMESTORE_connect (cfg); GNUNET_break (NULL != nsh); /* first, iterate over empty namestore */ zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, NULL, &fail_cb, NULL, &empty_zone_proc, nsh, &empty_zone_end, nsh); if (NULL == zi) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n"); GNUNET_break (0); GNUNET_SCHEDULER_cancel (endbadly_task); endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); } }
static int setup_alice (const struct GNUNET_CONFIGURATION_Handle * cfg) { char* keyfile; struct GNUNET_CRYPTO_RsaPrivateKey *key; struct GNUNET_NAMESTORE_RecordData rd; cfg_handles[2] = GNUNET_CONFIGURATION_dup (cfg); GNUNET_assert (NULL != cfg); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", "ZONEKEY", &keyfile)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n"); return GNUNET_SYSERR; } key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); if (NULL == key) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n"); GNUNET_free (keyfile); return GNUNET_SYSERR; } nh[2] = GNUNET_NAMESTORE_connect (cfg_handles[2]); if (NULL == nh[2]) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to namestore\n"); GNUNET_CRYPTO_rsa_key_free (key); GNUNET_free (keyfile); return GNUNET_SYSERR; } rd.expiration_time = UINT64_MAX; rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); rd.data = &bob_hash; rd.record_type = GNUNET_GNS_RECORD_PKEY; rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; GNUNET_NAMESTORE_record_create (nh[2], key, "bob", &rd, &cont_ns, nh[2]); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up alice gns\n"); gh = GNUNET_GNS_connect (cfg_handles[2]); if (NULL == gh) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to gns\n"); GNUNET_CRYPTO_rsa_key_free (key); GNUNET_free (keyfile); return GNUNET_SYSERR; } GNUNET_CRYPTO_rsa_key_free (key); GNUNET_free (keyfile); alice_is_setup = GNUNET_YES; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up alice done\n"); return GNUNET_OK; }
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer) { char *hostkey_file; struct GNUNET_TIME_Absolute et; endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,&endbadly, NULL); GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); GNUNET_free (hostkey_file); GNUNET_assert (privkey != NULL); GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); GNUNET_CRYPTO_hash(&pubkey, sizeof (pubkey), &zone); GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); privkey2 = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); GNUNET_free (hostkey_file); GNUNET_assert (privkey2 != NULL); GNUNET_CRYPTO_rsa_key_get_public(privkey2, &pubkey2); GNUNET_CRYPTO_hash(&pubkey2, sizeof (pubkey), &zone2); nsh = GNUNET_NAMESTORE_connect (cfg); GNUNET_break (NULL != nsh); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n"); GNUNET_asprintf(&s_name_1, "dummy1"); s_rd_1 = create_record(1); et.abs_value = s_rd_1[0].expiration_time; sig_1 = GNUNET_NAMESTORE_create_signature(privkey, et, s_name_1, s_rd_1, 1); GNUNET_NAMESTORE_record_create(nsh, privkey, s_name_1, s_rd_1, &put_cont, NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n"); GNUNET_asprintf(&s_name_2, "dummy2"); s_rd_2 = create_record(1); et.abs_value = s_rd_2[0].expiration_time; sig_2 = GNUNET_NAMESTORE_create_signature(privkey, et, s_name_2, s_rd_2, 1); GNUNET_NAMESTORE_record_create(nsh, privkey, s_name_2, s_rd_2, &put_cont, NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n"); /* name in different zone */ GNUNET_asprintf(&s_name_3, "dummy3"); s_rd_3 = create_record(1); et.abs_value = s_rd_3[0].expiration_time; sig_3 = GNUNET_NAMESTORE_create_signature(privkey2, et, s_name_3, s_rd_3, 1); GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_UNIT_FOREVER_ABS, 1, s_rd_3, sig_3, &put_cont, NULL); }
static void do_check (void *cls, const struct GNUNET_CONFIGURATION_Handle *ccfg, struct GNUNET_TESTING_Peer *peer) { struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey; struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; struct GNUNET_NAMESTORE_RecordData rd; char* alice_keyfile; char* ip = TEST_IP; struct in_addr web; cfg = ccfg; die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); /* put records into namestore */ namestore_handle = GNUNET_NAMESTORE_connect(cfg); if (NULL == namestore_handle) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to connect to namestore\n"); end_badly_now (); return; } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", "ZONEKEY", &alice_keyfile)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n"); end_badly_now (); return; } alice_key = GNUNET_CRYPTO_rsa_key_create_from_file (alice_keyfile); GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); GNUNET_free (alice_keyfile); rd.expiration_time = UINT64_MAX; GNUNET_assert (1 == inet_pton (AF_INET, ip, &web)); rd.data_size = sizeof(struct in_addr); rd.data = &web; rd.record_type = GNUNET_DNSPARSER_TYPE_A; rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; nsqe = GNUNET_NAMESTORE_record_create (namestore_handle, alice_key, TEST_RECORD_NAME, &rd, &commence_testing, NULL); GNUNET_CRYPTO_rsa_key_free (alice_key); }
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_TESTING_Peer *peer) { cfg = c; GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_test, NULL); id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL); op = GNUNET_IDENTITY_create (id, "phone-ego", &phone_ego_create_cont, NULL); ns = GNUNET_NAMESTORE_connect (cfg); }
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer) { struct GNUNET_GNSRECORD_Data rd; char *hostkey_file; directory = NULL; GNUNET_CONFIGURATION_get_value_string(cfg, "PATHS", "GNUNET_TEST_HOME", &directory); GNUNET_DISK_directory_remove (directory); update_performed = GNUNET_NO; endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL); GNUNET_asprintf (&hostkey_file, "zonefiles%s%s", DIR_SEPARATOR_STR, "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file (hostkey_file); GNUNET_free (hostkey_file); GNUNET_assert (privkey != NULL); GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey); rd.flags = GNUNET_GNSRECORD_RF_NONE; rd.expiration_time = GNUNET_TIME_absolute_get().abs_value_us + 1000000000; rd.record_type = TEST_RECORD_TYPE; rd.data_size = TEST_RECORD_DATALEN; rd.data = GNUNET_malloc (TEST_RECORD_DATALEN); memset ((char *) rd.data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); nsh = GNUNET_NAMESTORE_connect (cfg); GNUNET_break (NULL != nsh); nch = GNUNET_NAMECACHE_connect (cfg); GNUNET_break (NULL != nch); nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name, 1, &rd, &put_cont, (void *) name); if (NULL == nsqe) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Namestore cannot store no block\n")); } GNUNET_free ((void *)rd.data); }
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { delete_existing_db(cfg); endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); size_t rd_ser_len; /* load privat key from file not included in zonekey dir */ privkey = GNUNET_CRYPTO_rsa_key_create_from_file("test_hostkey"); GNUNET_assert (privkey != NULL); /* get public key */ GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); /* create record */ s_name = "dummy.dummy.gnunet"; s_rd = create_record (RECORDS); rd_ser_len = GNUNET_NAMESTORE_records_get_size(RECORDS, s_rd); char rd_ser[rd_ser_len]; GNUNET_NAMESTORE_records_serialize(RECORDS, s_rd, rd_ser_len, rd_ser); /* sign */ s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_rd[0].expiration, s_name, s_rd, RECORDS); /* create random zone hash */ GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone); start_arm (cfgfile); GNUNET_assert (arm != NULL); nsh = GNUNET_NAMESTORE_connect (cfg); GNUNET_break (NULL != nsh); GNUNET_break (s_rd != NULL); GNUNET_break (s_name != NULL); GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name, GNUNET_TIME_UNIT_FOREVER_ABS, RECORDS, s_rd, s_signature, put_cont, s_name); }
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer) { char *hostkey_file; const char * name = "dummy.dummy.gnunet"; directory = NULL; GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "PATHS", "GNUNET_TEST_HOME", &directory)); GNUNET_DISK_directory_remove (directory); endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL); GNUNET_asprintf (&hostkey_file, "zonefiles%s%s", DIR_SEPARATOR_STR, "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file (hostkey_file); GNUNET_free (hostkey_file); GNUNET_assert (privkey != NULL); GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey); nsh = GNUNET_NAMESTORE_connect (cfg); GNUNET_break (NULL != nsh); nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name, 0, NULL, &put_cont, (void *) name); if (NULL == nsqe) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Namestore cannot store no block\n")); } }
/** * Main function that will be run * * @param cls closure * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL) * @param c configuration */ static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { cfg = c; //Connect to identity and namestore services ns_handle = GNUNET_NAMESTORE_connect (cfg); if (NULL == ns_handle) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "error connecting to namestore"); } identity_handle = GNUNET_IDENTITY_connect (cfg, &list_ego, NULL); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_shutdown, NULL); }
static void do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *_cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey; struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey; struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; struct GNUNET_CRYPTO_RsaPrivateKey *bob_key; struct GNUNET_CRYPTO_RsaSignature *sig; char* alice_keyfile; cfg = _cfg; GNUNET_SCHEDULER_cancel (die_task); /* put records into namestore */ namestore_handle = GNUNET_NAMESTORE_connect(cfg); if (NULL == namestore_handle) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to namestore\n"); ok = -1; return; } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", "ZONEKEY", &alice_keyfile)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n"); ok = -1; return; } alice_key = GNUNET_CRYPTO_rsa_key_create_from_file (alice_keyfile); bob_key = GNUNET_CRYPTO_rsa_key_create_from_file (KEYFILE_BOB); GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey); struct GNUNET_NAMESTORE_RecordData rd; char* ip = TEST_IP; struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr)); rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); rd.data = &bob_hash; rd.record_type = GNUNET_GNS_RECORD_PKEY; GNUNET_NAMESTORE_record_create (namestore_handle, alice_key, TEST_AUTHORITY_NAME, &rd, NULL, NULL); rd.data_size = sizeof(struct in_addr); rd.data = web; rd.record_type = GNUNET_DNSPARSER_TYPE_A; sig = GNUNET_NAMESTORE_create_signature(bob_key, GNUNET_TIME_UNIT_FOREVER_ABS, TEST_RECORD_NAME, &rd, 1); GNUNET_NAMESTORE_record_put (namestore_handle, &bob_pkey, TEST_RECORD_NAME, rd.expiration, 1, &rd, sig, &commence_testing, NULL); GNUNET_free(sig); GNUNET_CRYPTO_rsa_key_free(bob_key); GNUNET_CRYPTO_rsa_key_free(alice_key); }
/** * Process GNS requests. * * @param cls closure) * @param server the initialized server * @param c configuration to use */ static void run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Initializing GNS\n"); char* keyfile; struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; unsigned long long max_parallel_bg_queries = 0; unsigned long long default_lookup_timeout_secs = 0; int ignore_pending = GNUNET_NO; static const struct GNUNET_SERVER_MessageHandler handlers[] = { {&handle_shorten, NULL, GNUNET_MESSAGE_TYPE_GNS_SHORTEN, 0}, {&handle_lookup, NULL, GNUNET_MESSAGE_TYPE_GNS_LOOKUP, 0}, {&handle_get_authority, NULL, GNUNET_MESSAGE_TYPE_GNS_GET_AUTH, 0} }; GNS_cfg = c; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c, "gns", "ZONEKEY", &keyfile)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No private key for root zone specified!\n"); GNUNET_SCHEDULER_shutdown (); return; } GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Using keyfile %s for root zone.\n", keyfile); zone_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); GNUNET_CRYPTO_rsa_key_get_public (zone_key, &pkey); GNUNET_CRYPTO_short_hash(&pkey, sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &zone_hash); GNUNET_free(keyfile); /** * handle to our local namestore */ namestore_handle = GNUNET_NAMESTORE_connect(c); if (NULL == namestore_handle) { //FIXME do error handling; GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to the namestore!\n"); GNUNET_SCHEDULER_shutdown (); return; } auto_import_pkey = GNUNET_NO; if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (c, "gns", "AUTO_IMPORT_PKEY")) { GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Automatic PKEY import is enabled.\n"); auto_import_pkey = GNUNET_YES; } dht_max_update_interval = GNUNET_GNS_DHT_MAX_UPDATE_INTERVAL; if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (c, "gns", "ZONE_PUT_INTERVAL", &dht_max_update_interval)) { GNUNET_log(GNUNET_ERROR_TYPE_INFO, "DHT zone update interval: %d\n", dht_max_update_interval); } max_record_put_interval = 1; if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (c, "gns", "RECORD_PUT_INTERVAL", &max_record_put_interval)) { GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Record put interval: %d\n", max_record_put_interval); } if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (c, "gns", "MAX_PARALLEL_BACKGROUND_QUERIES", &max_parallel_bg_queries)) { GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Number of allowed parallel background queries: %d\n", max_parallel_bg_queries); } if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (c, "gns", "AUTO_IMPORT_CONFIRMATION_REQ")) { GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Auto import requires user confirmation\n"); ignore_pending = GNUNET_YES; } if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(c, "gns", "DEFAULT_LOOKUP_TIMEOUT", &default_lookup_timeout_secs)) { GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Default lookup timeout: %ds\n", default_lookup_timeout_secs); default_lookup_timeout = GNUNET_TIME_relative_multiply( GNUNET_TIME_UNIT_SECONDS, default_lookup_timeout_secs); } /** * handle to the dht */ dht_handle = GNUNET_DHT_connect(c, //max_parallel_bg_queries); //FIXME get ht_len from cfg 1024); if (NULL == dht_handle) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Could not connect to DHT!\n"); } if (gns_resolver_init(namestore_handle, dht_handle, zone_hash, max_parallel_bg_queries, ignore_pending) == GNUNET_SYSERR) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Unable to initialize resolver!\n"); GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); return; } if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (c, "gns", "HIJACK_DNS")) { GNUNET_log(GNUNET_ERROR_TYPE_INFO, "DNS hijacking enabled... connecting to service.\n"); if (gns_interceptor_init(zone_hash, zone_key, c) == GNUNET_SYSERR) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to enable the dns interceptor!\n"); } } /** * Schedule periodic put * for our records * We have roughly an hour for all records; */ record_put_interval = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1); zone_update_taskid = GNUNET_SCHEDULER_add_now (&update_zone_dht_start, NULL); GNUNET_SERVER_add_handlers (server, handlers); //FIXME //GNUNET_SERVER_disconnect_notify (server, // &client_disconnect_notification, // NULL); nc = GNUNET_SERVER_notification_context_create (server, 1); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); }
static int setup_dave (const struct GNUNET_CONFIGURATION_Handle * cfg) { char* keyfile; struct GNUNET_CRYPTO_RsaPrivateKey *key; struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; struct in_addr *web; struct GNUNET_NAMESTORE_RecordData rd; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up dave\n"); cfg_handles[0] = GNUNET_CONFIGURATION_dup (cfg); GNUNET_assert (NULL != cfg_handles[0]); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", "ZONEKEY", &keyfile)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n"); return GNUNET_SYSERR; } key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); if (NULL == key) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n"); GNUNET_free (keyfile); return GNUNET_SYSERR; } nh[0] = GNUNET_NAMESTORE_connect (cfg_handles[0]); if (NULL == nh[0]) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to namestore\n"); GNUNET_CRYPTO_rsa_key_free (key); GNUNET_free (keyfile); return GNUNET_SYSERR; } GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); GNUNET_CRYPTO_short_hash(&pkey, sizeof(pkey), &dave_hash); rd.expiration_time = UINT64_MAX; web = GNUNET_malloc(sizeof(struct in_addr)); GNUNET_assert(1 == inet_pton (AF_INET, TEST_IP, web)); rd.data_size = sizeof(struct in_addr); rd.data = web; rd.record_type = GNUNET_GNS_RECORD_A; rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; GNUNET_NAMESTORE_record_create (nh[0], key, "www", &rd, NULL, NULL); rd.data_size = strlen(TEST_DAVE_PSEU); rd.data = TEST_DAVE_PSEU; rd.record_type = GNUNET_GNS_RECORD_PSEU; GNUNET_NAMESTORE_record_create (nh[0], key, GNUNET_GNS_MASTERZONE_STR, &rd, &cont_ns, nh[0]); GNUNET_CRYPTO_rsa_key_free(key); GNUNET_free(keyfile); GNUNET_free(web); dave_is_setup = GNUNET_YES; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up dave done\n"); return GNUNET_OK; }
void do_check (void *cls, const struct GNUNET_CONFIGURATION_Handle *ccfg, struct GNUNET_TESTING_Peer *peer) { struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded our_pkey; struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey; struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey; struct GNUNET_CRYPTO_RsaPrivateKey *our_key; struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; struct GNUNET_CRYPTO_RsaPrivateKey *bob_key; struct GNUNET_CRYPTO_ShortHashCode bob_hash; struct GNUNET_CRYPTO_ShortHashCode alice_hash; struct GNUNET_CRYPTO_RsaSignature *sig; char* our_keyfile; cfg = ccfg; die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Running test\n"); /* put records into namestore */ namestore_handle = GNUNET_NAMESTORE_connect(cfg); if (NULL == namestore_handle) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to namestore\n"); end_badly_now(); return; } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", "ZONEKEY", &our_keyfile)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n"); end_badly_now(); return; } our_key = GNUNET_CRYPTO_rsa_key_create_from_file (our_keyfile); GNUNET_free(our_keyfile); bob_key = GNUNET_CRYPTO_rsa_key_create_from_file (KEYFILE_BOB); alice_key = GNUNET_CRYPTO_rsa_key_create_from_file (KEYFILE_ALICE); GNUNET_CRYPTO_rsa_key_get_public (our_key, &our_pkey); GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey); struct GNUNET_NAMESTORE_RecordData rd; char* ip = TEST_IP; struct in_addr *web = GNUNET_malloc (sizeof(struct in_addr)); rd.expiration_time = UINT64_MAX; GNUNET_assert (1 == inet_pton (AF_INET, ip, web)); GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); rd.data = &bob_hash; rd.record_type = GNUNET_GNS_RECORD_PKEY; rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; /* put bob into our zone */ GNUNET_NAMESTORE_record_create (namestore_handle, our_key, TEST_AUTHORITY_BOB, &rd, NULL, NULL); /* put alice into bobs zone */ GNUNET_CRYPTO_short_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash); rd.data = &alice_hash; sig = GNUNET_NAMESTORE_create_signature(bob_key, GNUNET_TIME_UNIT_FOREVER_ABS, TEST_AUTHORITY_ALICE, &rd, 1); GNUNET_NAMESTORE_record_put (namestore_handle, &bob_pkey, TEST_AUTHORITY_ALICE, GNUNET_TIME_UNIT_FOREVER_ABS, 1, &rd, sig, NULL, NULL); GNUNET_free (sig); /* put www A record and PSEU into alice's zone */ rd.data_size = sizeof(struct in_addr); rd.data = web; rd.record_type = GNUNET_DNSPARSER_TYPE_A; sig = GNUNET_NAMESTORE_create_signature(alice_key,GNUNET_TIME_UNIT_FOREVER_ABS, TEST_RECORD_NAME, &rd, 1); GNUNET_NAMESTORE_record_put (namestore_handle, &alice_pkey, TEST_RECORD_NAME, GNUNET_TIME_UNIT_FOREVER_ABS, 1, &rd, sig, NULL, NULL); rd.data_size = strlen(TEST_ALICE_PSEU); rd.data = TEST_ALICE_PSEU; rd.record_type = GNUNET_GNS_RECORD_PSEU; GNUNET_free(sig); sig = GNUNET_NAMESTORE_create_signature(alice_key,GNUNET_TIME_UNIT_FOREVER_ABS, "", &rd, 1); GNUNET_NAMESTORE_record_put (namestore_handle, &alice_pkey, "", GNUNET_TIME_UNIT_FOREVER_ABS, 1, &rd, sig, &commence_testing, NULL); GNUNET_free (web); GNUNET_free (sig); GNUNET_CRYPTO_rsa_key_free (alice_key); GNUNET_CRYPTO_rsa_key_free (bob_key); GNUNET_CRYPTO_rsa_key_free (our_key); }
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer) { enum MHD_FLAG flags; char *bin; char *bin_identity; char *bin_gns; char *config; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "arm", "CONFIG", &config)) { fprintf (stderr, "Failed to locate configuration file. Skipping test.\n"); GNUNET_SCHEDULER_shutdown (); return; } char *const identity_args[] = { "gnunet-identity", "-C", "master-zone", "-c", config, NULL }; char *const identity2_args[] = { "gnunet-identity", "-e", "master-zone", "-s", "gns-master", "-c", config, NULL }; char *const identity3_args[] = { "gnunet-identity", "-e", "master-zone", "-s", "gns-intercept", "-c", config, NULL }; char *const gns_args[] = { "gnunet-gns", "-u", "www.gns", "-c", config, NULL }; GNUNET_TESTING_peer_get_identity (peer, &id); GNUNET_SCHEDULER_add_delayed (TIMEOUT, &do_shutdown, NULL); bin = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_BINDIR); GNUNET_asprintf (&bin_identity, "%s/%s", bin, "gnunet-identity"); if (0 != fork_and_exec (bin_identity, identity_args)) { fprintf (stderr, "Failed to run `gnunet-identity -C. Skipping test.\n"); GNUNET_SCHEDULER_shutdown (); GNUNET_free (bin_identity); GNUNET_free (config); GNUNET_free (bin); return; } if (0 != fork_and_exec (bin_identity, identity2_args)) { fprintf (stderr, "Failed to run `gnunet-identity -e. Skipping test.\n"); GNUNET_SCHEDULER_shutdown (); GNUNET_free (bin_identity); GNUNET_free (config); GNUNET_free (bin); return; } if (0 != fork_and_exec (bin_identity, identity3_args)) { fprintf (stderr, "Failed to run `gnunet-identity -e. Skipping test.\n"); GNUNET_SCHEDULER_shutdown (); GNUNET_free (bin_identity); GNUNET_free (config); GNUNET_free (bin); return; } GNUNET_free (bin_identity); /* do lookup just to launch GNS service */ GNUNET_asprintf (&bin_gns, "%s/%s", bin, "gnunet-gns"); if (0 != fork_and_exec (bin_gns, gns_args)) { fprintf (stderr, "Failed to run `gnunet-gns -u. Skipping test.\n"); GNUNET_SCHEDULER_shutdown (); GNUNET_free (bin_gns); GNUNET_free (config); GNUNET_free (bin); return; } GNUNET_free (bin_gns); GNUNET_free (config); GNUNET_free (bin); namestore = GNUNET_NAMESTORE_connect (cfg); GNUNET_assert (NULL != namestore); flags = MHD_USE_DEBUG; if (GNUNET_YES == use_v6) flags |= MHD_USE_DUAL_STACK; mhd = MHD_start_daemon (flags, PORT, NULL, NULL, &mhd_ahc, NULL, MHD_OPTION_END); GNUNET_assert (NULL != mhd); mhd_main (); identity = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL); }
static void do_check (void *cls, const struct GNUNET_CONFIGURATION_Handle *ccfg, struct GNUNET_TESTING_Peer *peer) { struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey; struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey; struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; struct GNUNET_CRYPTO_RsaPrivateKey *bob_key; struct GNUNET_CRYPTO_ShortHashCode bob_hash; struct GNUNET_CRYPTO_RsaSignature *sig; char* alice_keyfile; struct srv_data *srv_data; struct GNUNET_TIME_Absolute et; cfg = ccfg; die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); /* put records into namestore */ namestore_handle = GNUNET_NAMESTORE_connect(cfg); if (NULL == namestore_handle) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to namestore\n"); end_badly_now(); return; } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", "ZONEKEY", &alice_keyfile)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n"); end_badly_now(); return; } alice_key = GNUNET_CRYPTO_rsa_key_create_from_file (alice_keyfile); bob_key = GNUNET_CRYPTO_rsa_key_create_from_file (KEYFILE_BOB); GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey); struct GNUNET_NAMESTORE_RecordData rd; char* ip = TEST_IP; struct in_addr *sipserver = GNUNET_malloc (sizeof (struct in_addr)); srv_data = GNUNET_malloc (sizeof (struct srv_data) + strlen (TEST_SRV_NAME) + 1); uint16_t srv_weight = 60; uint16_t srv_prio = 50; uint16_t srv_port = 5060; rd.expiration_time = UINT64_MAX; GNUNET_assert(1 == inet_pton (AF_INET, ip, sipserver)); GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); rd.data = &bob_hash; rd.record_type = GNUNET_GNS_RECORD_PKEY; rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; GNUNET_NAMESTORE_record_create (namestore_handle, alice_key, TEST_AUTHORITY_NAME, &rd, NULL, NULL); rd.data_size = sizeof (struct in_addr); rd.data = sipserver; rd.record_type = GNUNET_DNSPARSER_TYPE_A; sig = GNUNET_NAMESTORE_create_signature(bob_key, GNUNET_TIME_UNIT_FOREVER_ABS, TEST_RECORD_NAME, &rd, 1); et.abs_value = rd.expiration_time; GNUNET_NAMESTORE_record_put (namestore_handle, &bob_pkey, TEST_RECORD_NAME, et, 1, &rd, sig, NULL, NULL); GNUNET_free (sig); rd.data_size = sizeof (struct srv_data)+strlen(TEST_SRV_NAME)+1; srv_data->port = srv_port; srv_data->prio = srv_prio; srv_data->weight = srv_weight; strcpy((char*)&srv_data[1], TEST_SRV_NAME); rd.data = srv_data; rd.record_type = GNUNET_GNS_RECORD_SRV; sig = GNUNET_NAMESTORE_create_signature(bob_key, GNUNET_TIME_UNIT_FOREVER_ABS, TEST_RECORD_NAME_SRV, &rd, 1); et.abs_value = rd.expiration_time; GNUNET_NAMESTORE_record_put (namestore_handle, &bob_pkey, TEST_RECORD_NAME_SRV, et, 1, &rd, sig, &commence_testing, NULL); GNUNET_free (alice_keyfile); GNUNET_free (srv_data); GNUNET_free (sipserver); GNUNET_free (sig); GNUNET_CRYPTO_rsa_key_free (bob_key); GNUNET_CRYPTO_rsa_key_free (alice_key); }
/** * Function called with the result from the check if the namestore * service is actually running. If it is, we start the actual * operation. * * @param cls closure with our configuration * @param result #GNUNET_YES if the namestore service is running */ static void testservice_task (void *cls, int result) { const struct GNUNET_CONFIGURATION_Handle *cfg = cls; struct GNUNET_CRYPTO_EcdsaPublicKey pub; struct GNUNET_GNSRECORD_Data rd; if (GNUNET_YES != result) { FPRINTF (stderr, _("Service `%s' is not running\n"), "namestore"); return; } if (! (add|del|list|(NULL != nickstring)|(NULL != uri)|(NULL != reverse_pkey)) ) { /* nothing more to be done */ fprintf (stderr, _("No options given\n")); GNUNET_SCHEDULER_shutdown (); return; } GNUNET_CRYPTO_ecdsa_key_get_public (&zone_pkey, &pub); ns = GNUNET_NAMESTORE_connect (cfg); if (NULL == ns) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to connect to namestore\n")); return; } if (add) { if (NULL == name) { fprintf (stderr, _("Missing option `%s' for operation `%s'\n"), "-n", _("add")); GNUNET_SCHEDULER_shutdown (); ret = 1; return; } if (NULL == typestring) { fprintf (stderr, _("Missing option `%s' for operation `%s'\n"), "-t", _("add")); GNUNET_SCHEDULER_shutdown (); ret = 1; return; } type = GNUNET_GNSRECORD_typename_to_number (typestring); if (UINT32_MAX == type) { fprintf (stderr, _("Unsupported type `%s'\n"), typestring); GNUNET_SCHEDULER_shutdown (); ret = 1; return; } if (NULL == value) { fprintf (stderr, _("Missing option `%s' for operation `%s'\n"), "-V", _("add")); ret = 1; GNUNET_SCHEDULER_shutdown (); return; } if (GNUNET_OK != GNUNET_GNSRECORD_string_to_value (type, value, &data, &data_size)) { fprintf (stderr, _("Value `%s' invalid for record type `%s'\n"), value, typestring); GNUNET_SCHEDULER_shutdown (); ret = 1; return; } if (NULL == expirationstring) { fprintf (stderr, _("Missing option `%s' for operation `%s'\n"), "-e", _("add")); GNUNET_SCHEDULER_shutdown (); ret = 1; return; } if (0 == strcmp (expirationstring, "never")) { etime_abs = GNUNET_TIME_UNIT_FOREVER_ABS; etime_is_rel = GNUNET_NO; } else if (GNUNET_OK == GNUNET_STRINGS_fancy_time_to_relative (expirationstring, &etime_rel)) { etime_is_rel = GNUNET_YES; } else if (GNUNET_OK == GNUNET_STRINGS_fancy_time_to_absolute (expirationstring, &etime_abs)) { etime_is_rel = GNUNET_NO; } else { fprintf (stderr, _("Invalid time format `%s'\n"), expirationstring); GNUNET_SCHEDULER_shutdown (); ret = 1; return; } add_qe = GNUNET_NAMESTORE_records_lookup (ns, &zone_pkey, name, &get_existing_record, NULL ); } if (del) { if (NULL == name) { fprintf (stderr, _("Missing option `%s' for operation `%s'\n"), "-n", _("del")); GNUNET_SCHEDULER_shutdown (); ret = 1; return; } del_qe = GNUNET_NAMESTORE_records_lookup (ns, &zone_pkey, name, &del_monitor, NULL); } if (list) { list_it = GNUNET_NAMESTORE_zone_iteration_start (ns, &zone_pkey, &display_record, NULL); } if (NULL != reverse_pkey) { struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_public_key_from_string (reverse_pkey, strlen (reverse_pkey), &pubkey)) { fprintf (stderr, _("Invalid public key for reverse lookup `%s'\n"), reverse_pkey); GNUNET_SCHEDULER_shutdown (); } reverse_qe = GNUNET_NAMESTORE_zone_to_name (ns, &zone_pkey, &pubkey, &handle_reverse_lookup, NULL); } if (NULL != uri) { char sh[105]; char sname[64]; struct GNUNET_CRYPTO_EcdsaPublicKey pkey; GNUNET_STRINGS_utf8_tolower (uri, uri); if ( (2 != (sscanf (uri, "gnunet://gns/%52s/%63s", sh, sname)) ) || (GNUNET_OK != GNUNET_CRYPTO_ecdsa_public_key_from_string (sh, strlen (sh), &pkey)) ) { fprintf (stderr, _("Invalid URI `%s'\n"), uri); GNUNET_SCHEDULER_shutdown (); ret = 1; return; } memset (&rd, 0, sizeof (rd)); rd.data = &pkey; rd.data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey); rd.record_type = GNUNET_GNSRECORD_TYPE_PKEY; if (GNUNET_YES == etime_is_rel) { rd.expiration_time = etime_rel.rel_value_us; rd.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; } else if (GNUNET_NO == etime_is_rel) rd.expiration_time = etime_abs.abs_value_us; else rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; if (1 == is_shadow) rd.flags |= GNUNET_GNSRECORD_RF_SHADOW_RECORD; add_qe_uri = GNUNET_NAMESTORE_records_store (ns, &zone_pkey, sname, 1, &rd, &add_continuation, &add_qe_uri); } if (NULL != nickstring) { if (0 == strlen(nickstring)) { fprintf (stderr, _("Invalid nick `%s'\n"), nickstring); GNUNET_SCHEDULER_shutdown (); ret = 1; return; } add_qe_uri = GNUNET_NAMESTORE_set_nick(ns, &zone_pkey, nickstring, &add_continuation, &add_qe_uri); } if (monitor) { zm = GNUNET_NAMESTORE_zone_monitor_start (cfg, &zone_pkey, GNUNET_YES, &display_record, &sync_cb, NULL); } }
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer) { enum MHD_FLAG flags; struct GNUNET_CRYPTO_EcdsaPrivateKey *host_key; struct GNUNET_GNSRECORD_Data 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"); do_shutdown (); return; } proxy_proc = GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL, NULL, NULL, "gnunet-gns-proxy", "gnunet-gns-proxy", "-c", tmp_cfgfile, NULL); if (NULL == proxy_proc) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unable to start proxy\n"); do_shutdown (); return; } 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_ecdsa_key_create_from_file (zone_keyfile); rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_string_to_value (GNUNET_DNSPARSER_TYPE_A, "127.0.0.1", (void**)&rd.data, &rd.data_size)); rd.record_type = GNUNET_DNSPARSER_TYPE_A; GNUNET_NAMESTORE_record_create (namestore, host_key, "www", &rd, &commence_testing, NULL); GNUNET_free ((void**)rd.data); GNUNET_free (zone_keyfile); GNUNET_free (host_key); }
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *mycfg, struct GNUNET_TESTING_Peer *peer) { char *hostkey_file; directory = NULL; GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(mycfg, "PATHS", "GNUNET_TEST_HOME", &directory)); GNUNET_DISK_directory_remove (directory); res = 1; GNUNET_asprintf(&hostkey_file, "zonefiles%s%s", DIR_SEPARATOR_STR, "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file); GNUNET_free (hostkey_file); GNUNET_assert (privkey != NULL); cfg = mycfg; endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL); /* Connect to namestore */ nsh = GNUNET_NAMESTORE_connect (cfg); if (NULL == nsh) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Connect to namestore\n"); GNUNET_break (0); endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); return; } GNUNET_asprintf(&hostkey_file,"zonefiles%s%s", DIR_SEPARATOR_STR, "HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); privkey2 = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file); GNUNET_free (hostkey_file); GNUNET_assert (privkey2 != NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n"); /* name in different zone */ GNUNET_asprintf(&s_name_3, "dummy3"); s_rd_3 = create_record(1); GNUNET_assert (NULL != (ns_ops[2] = GNUNET_NAMESTORE_records_store (nsh, privkey2, s_name_3, 1, s_rd_3, &put_cont, s_name_3))); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n"); GNUNET_asprintf(&s_name_1, "dummy1"); s_rd_1 = create_record(1); GNUNET_assert (NULL != (ns_ops[0] = GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1, 1, s_rd_1, &put_cont, s_name_1))); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n"); GNUNET_asprintf(&s_name_2, "dummy2"); s_rd_2 = create_record(1); GNUNET_assert (NULL != (ns_ops[1] = GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_2, 1, s_rd_2, &put_cont, s_name_2))); }