-fix, add config
authorMartin Schanzenbach <mschanzenbach@posteo.de>
Wed, 28 Mar 2012 10:03:22 +0000 (10:03 +0000)
committerMartin Schanzenbach <mschanzenbach@posteo.de>
Wed, 28 Mar 2012 10:03:22 +0000 (10:03 +0000)
src/gns/gns.conf.in
src/gns/gnunet-service-gns.c
src/gns/gnunet-service-gns_resolver.c
src/gns/gnunet-service-gns_resolver.h
src/gns/testdb/sqlite-alice.db
src/gns/testdb/sqlite-bob.db
src/gns/testdb/sqlite-dave.db

index 85401cdde9e1053f2b1bb72b4635b7c27f6c0bb5..960e13a94a5eba6e6e813fd3694fe9f3c08f602b 100644 (file)
@@ -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
 
index b88971b3974720d3638cd4422b7499dd97b83e85..970e001c98b7df91bc9a1b2ab3e167be9728d40a 100644 (file)
@@ -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,
index 436465a2d9494689c5d94e0348fd242696dfbdc7..591aed031dfd9e7c66efb6d3baff9a04c836b576 100644 (file)
@@ -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",
index 2da9bff1d7e83cbac783dd68c463770fb37c3551..f8c662bc22a4f78b5943d0493ac03cc4c78820b1 100644 (file)
@@ -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
index efc27b9a30238beaa3840b076e07654c13c32350..b3379dedb7b94785a6a3b60636e6f28c13e3b6aa 100644 (file)
Binary files a/src/gns/testdb/sqlite-alice.db and b/src/gns/testdb/sqlite-alice.db differ
index 884d58035848a74b81c469dc12ea6afd4fc223d6..c7c10534ea2707d9342ee3340b009f0f6aa7ae6c 100644 (file)
Binary files a/src/gns/testdb/sqlite-bob.db and b/src/gns/testdb/sqlite-bob.db differ
index c071b5d08872a8f11a3a9787465fe57edd59e163..bc164987b6503b3892f9c069417d76a8c5a127ac 100644 (file)
Binary files a/src/gns/testdb/sqlite-dave.db and b/src/gns/testdb/sqlite-dave.db differ