aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-03-28 10:03:22 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-03-28 10:03:22 +0000
commite7526f97264417497e9d7d89d53a7dac4d832083 (patch)
treed4e59a40428166d36846c7eacf4f3677db971005 /src/gns
parent550d63adf0451a1413a0597109623fa7c801d7cd (diff)
downloadgnunet-e7526f97264417497e9d7d89d53a7dac4d832083.tar.gz
gnunet-e7526f97264417497e9d7d89d53a7dac4d832083.zip
-fix, add config
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/gns.conf.in1
-rw-r--r--src/gns/gnunet-service-gns.c36
-rw-r--r--src/gns/gnunet-service-gns_resolver.c25
-rw-r--r--src/gns/gnunet-service-gns_resolver.h5
-rw-r--r--src/gns/testdb/sqlite-alice.dbbin17408 -> 17408 bytes
-rw-r--r--src/gns/testdb/sqlite-bob.dbbin14336 -> 14336 bytes
-rw-r--r--src/gns/testdb/sqlite-dave.dbbin17408 -> 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
8ZONEKEY = $SERVICEHOME/gns/zonekey.zkey 8ZONEKEY = $SERVICEHOME/gns/zonekey.zkey
9HIJACK_DNS = YES 9HIJACK_DNS = YES
10AUTO_IMPORT_PKEY = YES 10AUTO_IMPORT_PKEY = YES
11AUTO_IMPORT_CONFIRMATION_REQ = NO
11MAX_PARALLEL_BACKGROUND_QUERIES = 25 12MAX_PARALLEL_BACKGROUND_QUERIES = 25
12DEFAULT_LOOKUP_TIMEOUT = 10 13DEFAULT_LOOKUP_TIMEOUT = 10
13 14
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,
763 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; 763 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey;
764 unsigned long long max_parallel_bg_queries = 0; 764 unsigned long long max_parallel_bg_queries = 0;
765 unsigned long long default_lookup_timeout_secs = 0; 765 unsigned long long default_lookup_timeout_secs = 0;
766 int ignore_pending = GNUNET_NO;
766 767
767 static const struct GNUNET_SERVER_MessageHandler handlers[] = { 768 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
768 {&handle_shorten, NULL, GNUNET_MESSAGE_TYPE_GNS_SHORTEN, 0}, 769 {&handle_shorten, NULL, GNUNET_MESSAGE_TYPE_GNS_SHORTEN, 0},
@@ -804,15 +805,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
804 return; 805 return;
805 } 806 }
806 807
807 /** 808
808 * handle to the dht
809 */
810 dht_handle = GNUNET_DHT_connect(c, 1); //FIXME get ht_len from cfg
811
812 if (NULL == dht_handle)
813 {
814 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Could not connect to DHT!\n");
815 }
816 809
817 auto_import_pkey = GNUNET_NO; 810 auto_import_pkey = GNUNET_NO;
818 811
@@ -827,7 +820,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
827 } 820 }
828 821
829 if (GNUNET_OK == 822 if (GNUNET_OK ==
830 GNUNET_CONFIGURATION_get_value_number(c, "gns", 823 GNUNET_CONFIGURATION_get_value_number (c, "gns",
831 "MAX_PARALLEL_BACKGROUND_QUERIES", 824 "MAX_PARALLEL_BACKGROUND_QUERIES",
832 &max_parallel_bg_queries)) 825 &max_parallel_bg_queries))
833 { 826 {
@@ -836,6 +829,15 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
836 max_parallel_bg_queries); 829 max_parallel_bg_queries);
837 } 830 }
838 831
832 if (GNUNET_YES ==
833 GNUNET_CONFIGURATION_get_value_yesno (c, "gns",
834 "AUTO_IMPORT_CONFIRMATION_REQ"))
835 {
836 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
837 "Auto import requires user confirmation\n");
838 ignore_pending = GNUNET_YES;
839 }
840
839 if (GNUNET_OK == 841 if (GNUNET_OK ==
840 GNUNET_CONFIGURATION_get_value_number(c, "gns", 842 GNUNET_CONFIGURATION_get_value_number(c, "gns",
841 "DEFAULT_LOOKUP_TIMEOUT", 843 "DEFAULT_LOOKUP_TIMEOUT",
@@ -848,8 +850,20 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
848 default_lookup_timeout_secs); 850 default_lookup_timeout_secs);
849 } 851 }
850 852
853 /**
854 * handle to the dht
855 */
856 dht_handle = GNUNET_DHT_connect(c,
857 max_parallel_bg_queries); //FIXME get ht_len from cfg
858
859 if (NULL == dht_handle)
860 {
861 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Could not connect to DHT!\n");
862 }
863
851 if (gns_resolver_init(namestore_handle, dht_handle, zone_hash, 864 if (gns_resolver_init(namestore_handle, dht_handle, zone_hash,
852 max_parallel_bg_queries) 865 max_parallel_bg_queries,
866 ignore_pending)
853 == GNUNET_SYSERR) 867 == GNUNET_SYSERR)
854 { 868 {
855 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 869 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
@@ -65,6 +65,11 @@ static struct GNUNET_CONTAINER_Heap *dht_lookup_heap;
65static unsigned long long max_allowed_background_queries; 65static unsigned long long max_allowed_background_queries;
66 66
67/** 67/**
68 * Wheather or not to ignore pending records
69 */
70static int ignore_pending_records;
71
72/**
68 * Our local zone 73 * Our local zone
69 */ 74 */
70static struct GNUNET_CRYPTO_ShortHashCode local_zone; 75static struct GNUNET_CRYPTO_ShortHashCode local_zone;
@@ -118,7 +123,7 @@ process_pseu_lookup_ns(void* cls,
118 GNUNET_NAMESTORE_lookup_record(namestore_handle, 123 GNUNET_NAMESTORE_lookup_record(namestore_handle,
119 &gph->zone, 124 &gph->zone,
120 gph->new_name, 125 gph->new_name,
121 GNUNET_GNS_RECORD_PSEU, 126 GNUNET_NAMESTORE_TYPE_ANY,
122 &process_pseu_lookup_ns, 127 &process_pseu_lookup_ns,
123 gph); 128 gph);
124 return; 129 return;
@@ -439,13 +444,16 @@ static void process_discovered_authority(char* name,
439 * @param dh the dht handle 444 * @param dh the dht handle
440 * @param lz the local zone's hash 445 * @param lz the local zone's hash
441 * @param max_bg_queries maximum number of parallel background queries in dht 446 * @param max_bg_queries maximum number of parallel background queries in dht
447 * @param ignore_pending ignore records that still require user confirmation
448 * on lookup
442 * @return GNUNET_OK on success 449 * @return GNUNET_OK on success
443 */ 450 */
444int 451int
445gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh, 452gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh,
446 struct GNUNET_DHT_Handle *dh, 453 struct GNUNET_DHT_Handle *dh,
447 struct GNUNET_CRYPTO_ShortHashCode lz, 454 struct GNUNET_CRYPTO_ShortHashCode lz,
448 unsigned long long max_bg_queries) 455 unsigned long long max_bg_queries,
456 int ignore_pending)
449{ 457{
450 namestore_handle = nh; 458 namestore_handle = nh;
451 dht_handle = dh; 459 dht_handle = dh;
@@ -453,6 +461,7 @@ gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh,
453 dht_lookup_heap = 461 dht_lookup_heap =
454 GNUNET_CONTAINER_heap_create(GNUNET_CONTAINER_HEAP_ORDER_MIN); 462 GNUNET_CONTAINER_heap_create(GNUNET_CONTAINER_HEAP_ORDER_MIN);
455 max_allowed_background_queries = max_bg_queries; 463 max_allowed_background_queries = max_bg_queries;
464 ignore_pending_records = ignore_pending;
456 465
457 if ((namestore_handle != NULL) && (dht_handle != NULL)) 466 if ((namestore_handle != NULL) && (dht_handle != NULL))
458 { 467 {
@@ -944,6 +953,15 @@ process_record_result_ns(void* cls,
944 953
945 if (rd[i].record_type != rlh->record_type) 954 if (rd[i].record_type != rlh->record_type)
946 continue; 955 continue;
956
957 if (ignore_pending_records &&
958 (rd[i].flags & GNUNET_NAMESTORE_RF_PENDING))
959 {
960 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
961 "GNS_PHASE_REC-%d: Record %s is awaiting user confirmation. Skipping\n",
962 rh->id, name);
963 continue;
964 }
947 965
948 if ((GNUNET_TIME_absolute_get_remaining (rd[i].expiration)).rel_value 966 if ((GNUNET_TIME_absolute_get_remaining (rd[i].expiration)).rel_value
949 == 0) 967 == 0)
@@ -1913,7 +1931,8 @@ process_delegation_result_ns(void* cls,
1913 if (rd[i].record_type != GNUNET_GNS_RECORD_PKEY) 1931 if (rd[i].record_type != GNUNET_GNS_RECORD_PKEY)
1914 continue; 1932 continue;
1915 1933
1916 if (rd[i].flags & GNUNET_NAMESTORE_RF_PENDING) 1934 if (ignore_pending_records &&
1935 (rd[i].flags & GNUNET_NAMESTORE_RF_PENDING))
1917 { 1936 {
1918 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1937 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1919 "GNS_PHASE_DELEGATE_NS-%llu: PKEY for %s is pending user confirmation.\n", 1938 "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
255 * @param dh handle to the dht 255 * @param dh handle to the dht
256 * @param lz the local zone 256 * @param lz the local zone
257 * @param max_bg_queries maximum amount of background queries 257 * @param max_bg_queries maximum amount of background queries
258 * @param ignore_pending ignore records that still require user confirmation
259 * on lookup
258 * @returns GNUNET_OK on success 260 * @returns GNUNET_OK on success
259 */ 261 */
260int 262int
261gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh, 263gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh,
262 struct GNUNET_DHT_Handle *dh, 264 struct GNUNET_DHT_Handle *dh,
263 struct GNUNET_CRYPTO_ShortHashCode lz, 265 struct GNUNET_CRYPTO_ShortHashCode lz,
264 unsigned long long max_bg_queries); 266 unsigned long long max_bg_queries,
267 int ignore_pending);
265 268
266/** 269/**
267 * Cleanup resolver: Terminate pending lookups 270 * Cleanup resolver: Terminate pending lookups
diff --git a/src/gns/testdb/sqlite-alice.db b/src/gns/testdb/sqlite-alice.db
index efc27b9a3..b3379dedb 100644
--- a/src/gns/testdb/sqlite-alice.db
+++ b/src/gns/testdb/sqlite-alice.db
Binary files differ
diff --git a/src/gns/testdb/sqlite-bob.db b/src/gns/testdb/sqlite-bob.db
index 884d58035..c7c10534e 100644
--- a/src/gns/testdb/sqlite-bob.db
+++ b/src/gns/testdb/sqlite-bob.db
Binary files differ
diff --git a/src/gns/testdb/sqlite-dave.db b/src/gns/testdb/sqlite-dave.db
index c071b5d08..bc164987b 100644
--- a/src/gns/testdb/sqlite-dave.db
+++ b/src/gns/testdb/sqlite-dave.db
Binary files differ