-test fixed, modified shorten
authorMartin Schanzenbach <mschanzenbach@posteo.de>
Mon, 11 Jun 2012 16:07:12 +0000 (16:07 +0000)
committerMartin Schanzenbach <mschanzenbach@posteo.de>
Mon, 11 Jun 2012 16:07:12 +0000 (16:07 +0000)
src/gns/gnunet-service-gns_resolver.c
src/gns/test_gns_dht_delegated_lookup.c
src/gns/test_gns_dht_threepeer.c
src/gns/test_gns_max_queries.c
src/gns/test_gns_pseu_shorten.c
src/gns/test_gns_simple_delegated_lookup.c
src/gns/test_gns_simple_lookup.c
src/gns/test_gns_simple_mx_lookup.c
src/gns/test_gns_simple_zkey_lookup.c

index 9883f7c451dfb16b5e182f83f0e5594c8cd30981..15b959fc0d81701418c4bb928c53558e55ca32c6 100644 (file)
@@ -80,6 +80,31 @@ static struct GNUNET_CRYPTO_ShortHashCode local_zone;
  */
 static unsigned long long rid = 0;
 
+
+/**
+ * Determine if this name is canonical.
+ * i.e.
+ * a.b.gnunet  = not canonical
+ * a           = canonical
+ *
+ * @param name the name to test
+ * @return 1 if canonical
+ */
+static int
+is_canonical(char* name)
+{
+  uint32_t len = strlen(name);
+  int i;
+
+  for (i=0; i<len; i++)
+  {
+    if (*(name+i) == '.')
+      return 0;
+  }
+  return 1;
+}
+
+
 /**
  * Namestore calls this function if we have record for this name.
  * (or with rd_count=0 to indicate no matches)
@@ -1228,7 +1253,7 @@ process_delegation_result_dht(void* cls,
                                      auth);
 
         /** try to import pkey if private key available */
-        if (rh->priv_key)
+        if (rh->priv_key && is_canonical (rh->name))
           process_discovered_authority(name, auth->zone,
                                        rh->authority_chain_tail->zone,
                                        rh->priv_key);
@@ -1535,29 +1560,6 @@ handle_record_ns(void* cls, struct ResolverHandle *rh,
 }
 
 
-/**
- * Determine if this name is canonical.
- * i.e.
- * a.b.gnunet  = not canonical
- * a           = canonical
- *
- * @param name the name to test
- * @return 1 if canonical
- */
-static int
-is_canonical(char* name)
-{
-  uint32_t len = strlen(name);
-  int i;
-
-  for (i=0; i<len; i++)
-  {
-    if (*(name+i) == '.')
-      return 0;
-  }
-  return 1;
-}
-
 /**
  * Move one level up in the domain hierarchy and return the
  * passed top level domain.
@@ -2001,7 +2003,7 @@ process_delegation_result_ns(void* cls,
     /** try to import pkey if private key available
      * TODO: Only import last one?
      */
-    if (rh->priv_key && (name != NULL))
+    if (rh->priv_key && (name != NULL) && is_canonical (rh->name))
       process_discovered_authority((char*)name, auth->zone,
                                    rh->authority_chain_tail->zone,
                                    rh->priv_key);
index 882bb7e5e739e21d9e2c56aad3525195ce1ec3ef..0ab1c1ecb2a3e4757baae3e901462364d90a3da6 100644 (file)
@@ -163,6 +163,7 @@ commence_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   }
 
   GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A,
+                    GNUNET_NO,
                     &on_lookup_result, TEST_DOMAIN);
 }
 
index ed9600f5edd591a0330851d7b139ea897690eafc..c001d54e20b4af1e08c344ec883814e9c433c0e4 100644 (file)
@@ -204,6 +204,7 @@ commence_testing(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   gh = GNUNET_GNS_connect(alice_cfg);
 
   GNUNET_GNS_lookup(gh, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A,
+                    GNUNET_NO,
                     &on_lookup_result, TEST_DOMAIN);
   die_task =
     GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from lookup");
index ad1743c67d7884feee298dad7ebd8c5291b844f4..88d43dd7813ef55dff6bc251a1af345d47165919 100644 (file)
@@ -179,10 +179,12 @@ commence_testing (void *cls, int32_t success, const char *emsg)
                     MAX_DNS_NAME_LENGTH,
                     "www.doesnotexist-%d.bob.gnunet", i);
     GNUNET_GNS_lookup(gns_handle, lookup_name, GNUNET_GNS_RECORD_TYPE_A,
+                      GNUNET_NO,
                       &on_lookup_result_dummy, NULL);
   }
 
   GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A,
+                    GNUNET_NO,
                     &on_lookup_result, TEST_DOMAIN);
 }
 
index c6fd288846fb0ae1c40b96d916c718068a982a2d..d5e0cee7823295dfbfd506984d2029ef8d5ddddb 100644 (file)
@@ -237,6 +237,7 @@ commence_testing (void *cls, int success)
   GNUNET_GNS_lookup_zone (gns_handle, TEST_DOMAIN,
                           &our_zone, &our_zone,
                           GNUNET_GNS_RECORD_TYPE_A,
+                          GNUNET_NO,
                     &on_lookup_result, TEST_DOMAIN);
 }
 
index 36fb9691570c9d126706b8331fbda380e5b9ee11..3f89b7d91348c458b52d312d00c0e1c4b3ce8a70 100644 (file)
@@ -164,6 +164,7 @@ commence_testing (void *cls, int32_t success, const char *emsg)
   }
 
   GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A,
+                    GNUNET_NO,
                     &on_lookup_result, TEST_DOMAIN);
 }
 
index 89a9aefee9818fd7a8a7413465d8710a2d5d8e34..46ce3084e82d3744d8b57f99a0a7e62dc3f31ebd 100644 (file)
@@ -149,6 +149,7 @@ commence_testing (void *cls, int32_t success, const char *emsg)
   }
 
   GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A,
+                    GNUNET_YES,
                     &on_lookup_result, TEST_DOMAIN);
 }
 
index fdc639a729bc0bd539539c830ac95751e0b5f310..57531c4eba6532a80d8a1198eb3d5580a7a4258a 100644 (file)
@@ -181,6 +181,7 @@ commence_testing (void *cls, int32_t success, const char *emsg)
   }
 
   GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_MX,
+                    GNUNET_NO,
                     &on_lookup_result, TEST_DOMAIN);
 }
 
index 8b9b78befb9318520efaa286b8b20cb8f838da82..66bca0917a5fc1ec9fc59dba593ae247932f1155 100644 (file)
@@ -168,6 +168,7 @@ commence_testing (void *cls, int32_t success, const char *emsg)
   strcpy(pos, GNUNET_GNS_TLD_ZKEY);
 
   GNUNET_GNS_lookup(gns_handle, name, GNUNET_GNS_RECORD_TYPE_A,
+                    GNUNET_NO,
                     &on_lookup_result, NULL);
 }