From c164ecb84e1b98ebcdade7b9250bb3e051156842 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Wed, 21 Mar 2012 13:47:51 +0000 Subject: [PATCH] -fixes, auto_import_pkey imlpl --- src/gns/gnunet-service-gns.c | 33 +++++++++++++++++++++---- src/gns/gnunet-service-gns_resolver.c | 9 ++++--- src/gns/test_gns_dht_delegated_lookup.c | 18 ++------------ src/gns/test_gns_simple_lookup.conf | 2 +- 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index bc1a713b6..736bff4bf 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c @@ -152,6 +152,9 @@ static struct GNUNET_TIME_Relative dht_update_interval; /* zone update task */ GNUNET_SCHEDULER_TaskIdentifier zone_update_taskid = GNUNET_SCHEDULER_NO_TASK; +/* automatic pkey import for name shortening */ +static int auto_import_pkey; + /** * Task run during shutdown. * @@ -716,9 +719,18 @@ handle_lookup(void *cls, clh->unique_id = sh_msg->id; clh->type = ntohl(sh_msg->type); - gns_resolver_lookup_record(zone_hash, clh->type, name, - zone_key, - &send_lookup_response, clh); + if (GNUNET_YES == auto_import_pkey) + { + gns_resolver_lookup_record(zone_hash, clh->type, name, + zone_key, + &send_lookup_response, clh); + } + else + { + gns_resolver_lookup_record(zone_hash, clh->type, name, + NULL, + &send_lookup_response, clh); + } } @@ -790,7 +802,18 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Could not connect to DHT!\n"); } - if (gns_resolver_init(namestore_handle, dht_handle) == GNUNET_SYSERR) + 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; + + } + + if (gns_resolver_init(namestore_handle, dht_handle) + == GNUNET_SYSERR) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Unable to initialize resolver!\n"); @@ -811,7 +834,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, "Failed to enable the dns interceptor!\n"); } } - + //put_some_records(); //FIXME for testing /** diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index ca7a5ea85..e95030db6 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c @@ -337,9 +337,10 @@ process_zone_to_name_discover(void *cls, * @param zone the authority * @param the private key of our authority */ -static void process_discovered_authority(char* name, struct GNUNET_CRYPTO_ShortHashCode zone, - struct GNUNET_CRYPTO_ShortHashCode our_zone, - struct GNUNET_CRYPTO_RsaPrivateKey *key) +static void process_discovered_authority(char* name, + struct GNUNET_CRYPTO_ShortHashCode zone, + struct GNUNET_CRYPTO_ShortHashCode our_zone, + struct GNUNET_CRYPTO_RsaPrivateKey *key) { struct GetPseuAuthorityHandle *gph; size_t namelen; @@ -878,7 +879,7 @@ process_delegation_result_dht(void* cls, rh->authority_chain_tail, auth); - /** call process new authority */ + /** try to import pkey if private key available */ if (rh->priv_key) process_discovered_authority(name, auth->zone, rh->authority_chain_tail->zone, diff --git a/src/gns/test_gns_dht_delegated_lookup.c b/src/gns/test_gns_dht_delegated_lookup.c index 2a541e4eb..b15bc3f49 100644 --- a/src/gns/test_gns_dht_delegated_lookup.c +++ b/src/gns/test_gns_dht_delegated_lookup.c @@ -18,23 +18,9 @@ Boston, MA 02111-1307, USA. */ /** - * @file gns/test_gns_twopeer.c - * @brief base testcase for testing DHT service with - * two running peers. + * @file gns/test_gns_dht_delegated_lookup.c + * @brief test for record lookup via DHT * - * This testcase starts peers using the GNUNET_TESTING_daemons_start - * function call. On peer start, connects to the peers DHT service - * by calling GNUNET_DHT_connected. Once notified about all peers - * being started (by the peers_started_callback function), calls - * GNUNET_TESTING_connect_topology, which connects the peers in a - * "straight line" topology. On notification that all peers have - * been properly connected, calls the do_get function which initiates - * a GNUNET_DHT_get from the *second* peer. Once the GNUNET_DHT_get - * function starts, runs the do_put function to insert data at the first peer. - * If the GET is successful, schedules finish_testing - * to stop the test and shut down peers. If GET is unsuccessful - * after GET_TIMEOUT seconds, prints an error message and shuts down - * the peers. */ #include "platform.h" #include "gnunet_testing_lib.h" diff --git a/src/gns/test_gns_simple_lookup.conf b/src/gns/test_gns_simple_lookup.conf index 0ce47ccec..bdb233b3d 100644 --- a/src/gns/test_gns_simple_lookup.conf +++ b/src/gns/test_gns_simple_lookup.conf @@ -79,7 +79,7 @@ HIJACK_DNS = NO UNIXPATH = /tmp/gnunet-service-gns.sock HOME = $SERVICEHOME CONFIG = $DEFAULTCONFIG - +AUTO_IMPORT_PKEY = YES [nse] -- 2.25.1