From e7526f97264417497e9d7d89d53a7dac4d832083 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Wed, 28 Mar 2012 10:03:22 +0000 Subject: [PATCH] -fix, add config --- src/gns/gns.conf.in | 1 + src/gns/gnunet-service-gns.c | 36 ++++++++++++++++++-------- src/gns/gnunet-service-gns_resolver.c | 25 +++++++++++++++--- src/gns/gnunet-service-gns_resolver.h | 5 +++- src/gns/testdb/sqlite-alice.db | Bin 17408 -> 17408 bytes src/gns/testdb/sqlite-bob.db | Bin 14336 -> 14336 bytes src/gns/testdb/sqlite-dave.db | Bin 17408 -> 17408 bytes 7 files changed, 52 insertions(+), 15 deletions(-) diff --git a/src/gns/gns.conf.in b/src/gns/gns.conf.in index 85401cdde..960e13a94 100644 --- a/src/gns/gns.conf.in +++ b/src/gns/gns.conf.in @@ -8,6 +8,7 @@ UNIXPATH = /tmp/gnunet-service-gns.sock ZONEKEY = $SERVICEHOME/gns/zonekey.zkey HIJACK_DNS = YES AUTO_IMPORT_PKEY = YES +AUTO_IMPORT_CONFIRMATION_REQ = NO MAX_PARALLEL_BACKGROUND_QUERIES = 25 DEFAULT_LOOKUP_TIMEOUT = 10 diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index b88971b39..970e001c9 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c @@ -763,6 +763,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, 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}, @@ -804,15 +805,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, return; } - /** - * handle to the dht - */ - dht_handle = GNUNET_DHT_connect(c, 1); //FIXME get ht_len from cfg - - if (NULL == dht_handle) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Could not connect to DHT!\n"); - } + auto_import_pkey = GNUNET_NO; @@ -827,7 +820,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, } if (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_number(c, "gns", + GNUNET_CONFIGURATION_get_value_number (c, "gns", "MAX_PARALLEL_BACKGROUND_QUERIES", &max_parallel_bg_queries)) { @@ -836,6 +829,15 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, 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", @@ -848,8 +850,20 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, default_lookup_timeout_secs); } + /** + * handle to the dht + */ + dht_handle = GNUNET_DHT_connect(c, + max_parallel_bg_queries); //FIXME get ht_len from cfg + + 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) + max_parallel_bg_queries, + ignore_pending) == GNUNET_SYSERR) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 436465a2d..591aed031 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c @@ -64,6 +64,11 @@ static struct GNUNET_CONTAINER_Heap *dht_lookup_heap; */ static unsigned long long max_allowed_background_queries; +/** + * Wheather or not to ignore pending records + */ +static int ignore_pending_records; + /** * Our local zone */ @@ -118,7 +123,7 @@ process_pseu_lookup_ns(void* cls, GNUNET_NAMESTORE_lookup_record(namestore_handle, &gph->zone, gph->new_name, - GNUNET_GNS_RECORD_PSEU, + GNUNET_NAMESTORE_TYPE_ANY, &process_pseu_lookup_ns, gph); return; @@ -439,13 +444,16 @@ static void process_discovered_authority(char* name, * @param dh the dht handle * @param lz the local zone's hash * @param max_bg_queries maximum number of parallel background queries in dht + * @param ignore_pending ignore records that still require user confirmation + * on lookup * @return GNUNET_OK on success */ int gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh, struct GNUNET_DHT_Handle *dh, struct GNUNET_CRYPTO_ShortHashCode lz, - unsigned long long max_bg_queries) + unsigned long long max_bg_queries, + int ignore_pending) { namestore_handle = nh; dht_handle = dh; @@ -453,6 +461,7 @@ gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh, dht_lookup_heap = GNUNET_CONTAINER_heap_create(GNUNET_CONTAINER_HEAP_ORDER_MIN); max_allowed_background_queries = max_bg_queries; + ignore_pending_records = ignore_pending; if ((namestore_handle != NULL) && (dht_handle != NULL)) { @@ -944,6 +953,15 @@ process_record_result_ns(void* cls, if (rd[i].record_type != rlh->record_type) continue; + + if (ignore_pending_records && + (rd[i].flags & GNUNET_NAMESTORE_RF_PENDING)) + { + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, + "GNS_PHASE_REC-%d: Record %s is awaiting user confirmation. Skipping\n", + rh->id, name); + continue; + } if ((GNUNET_TIME_absolute_get_remaining (rd[i].expiration)).rel_value == 0) @@ -1913,7 +1931,8 @@ process_delegation_result_ns(void* cls, if (rd[i].record_type != GNUNET_GNS_RECORD_PKEY) continue; - if (rd[i].flags & GNUNET_NAMESTORE_RF_PENDING) + if (ignore_pending_records && + (rd[i].flags & GNUNET_NAMESTORE_RF_PENDING)) { GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "GNS_PHASE_DELEGATE_NS-%llu: PKEY for %s is pending user confirmation.\n", diff --git a/src/gns/gnunet-service-gns_resolver.h b/src/gns/gnunet-service-gns_resolver.h index 2da9bff1d..f8c662bc2 100644 --- a/src/gns/gnunet-service-gns_resolver.h +++ b/src/gns/gnunet-service-gns_resolver.h @@ -255,13 +255,16 @@ struct GetPseuAuthorityHandle * @param dh handle to the dht * @param lz the local zone * @param max_bg_queries maximum amount of background queries + * @param ignore_pending ignore records that still require user confirmation + * on lookup * @returns GNUNET_OK on success */ int gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh, struct GNUNET_DHT_Handle *dh, struct GNUNET_CRYPTO_ShortHashCode lz, - unsigned long long max_bg_queries); + unsigned long long max_bg_queries, + int ignore_pending); /** * Cleanup resolver: Terminate pending lookups diff --git a/src/gns/testdb/sqlite-alice.db b/src/gns/testdb/sqlite-alice.db index efc27b9a30238beaa3840b076e07654c13c32350..b3379dedb7b94785a6a3b60636e6f28c13e3b6aa 100644 GIT binary patch delta 19 acmZqZU~K4MoFL7}J5k1&k#}Rl0%rg@*9E=+ delta 19 acmZqZU~K4MoFL7}JyFJ)k$Ypp0%rg@xdpla diff --git a/src/gns/testdb/sqlite-bob.db b/src/gns/testdb/sqlite-bob.db index 884d58035848a74b81c469dc12ea6afd4fc223d6..c7c10534ea2707d9342ee3340b009f0f6aa7ae6c 100644 GIT binary patch delta 17 YcmZoDXegK<&1f=F#+lJ%W5NP+05%H+&Hw-a delta 17 YcmZoDXegK<&1f`H#+lJ*W5NP+05$Ce$^ZZW diff --git a/src/gns/testdb/sqlite-dave.db b/src/gns/testdb/sqlite-dave.db index c071b5d08872a8f11a3a9787465fe57edd59e163..bc164987b6503b3892f9c069417d76a8c5a127ac 100644 GIT binary patch delta 19 acmZqZU~K4MoFL6;JyFJ)(RyRT0%rg`i3S<~ delta 19 acmZqZU~K4MoFL6;IZ?)$(Q;$L0%rg`YX%ko -- 2.25.1