-fixes
authorMartin Schanzenbach <mschanzenbach@posteo.de>
Fri, 16 Mar 2012 08:39:00 +0000 (08:39 +0000)
committerMartin Schanzenbach <mschanzenbach@posteo.de>
Fri, 16 Mar 2012 08:39:00 +0000 (08:39 +0000)
src/gns/gnunet-service-gns.c
src/gns/gnunet-service-gns_resolver.c
src/gns/gnunet-service-gns_resolver.h
src/gns/test_gns_dht_delegated_lookup.c
src/gns/test_gns_simple_delegated_lookup.c
src/gns/test_gns_simple_lookup.c
src/gns/test_gns_simple_shorten.c

index 5c7c8b150b1cfff6c4d84cf0fcf2fd354bb8180f..182655005029889325f85f7eb7ea1df16150c82e 100644 (file)
@@ -108,7 +108,7 @@ struct ClientLookupHandle
 /**
  * Our handle to the DHT
  */
-struct GNUNET_DHT_Handle *dht_handle;
+static struct GNUNET_DHT_Handle *dht_handle;
 
 /**
  * Our zone's private key
@@ -760,23 +760,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
                      &zone_hash);
   GNUNET_free(keyfile);
   
-
-  if (GNUNET_YES ==
-      GNUNET_CONFIGURATION_get_value_yesno (c, "gns",
-                                            "HIJACK_DNS"))
-  {
-    GNUNET_log(GNUNET_ERROR_TYPE_INFO,
-               "DNS hijacking enabled... connecting to service.\n");
-
-    if (gns_interceptor_init(zone_hash, c) == GNUNET_SYSERR)
-    {
-      GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
-               "Failed to enable the dns interceptor!\n");
-    }
-  }
-
-  
-
   /**
    * handle to our local namestore
    */
@@ -801,6 +784,28 @@ 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)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+               "Unable to initialize resolver!\n");
+    GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+    return;
+  }
+
+  if (GNUNET_YES ==
+      GNUNET_CONFIGURATION_get_value_yesno (c, "gns",
+                                            "HIJACK_DNS"))
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+               "DNS hijacking enabled... connecting to service.\n");
+
+    if (gns_interceptor_init(zone_hash, c) == GNUNET_SYSERR)
+    {
+      GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+               "Failed to enable the dns interceptor!\n");
+    }
+  }
+
   //put_some_records(); //FIXME for testing
   
   /**
index 9b83794f5554e962ba2afa6919db5a6db765831a..a46a2fd617e6fba468e3ac17882d5f19de2d52b8 100644 (file)
 /**
  * Our handle to the namestore service
  */
-struct GNUNET_NAMESTORE_Handle *namestore_handle;
+static struct GNUNET_NAMESTORE_Handle *namestore_handle;
 
 /**
  * Resolver handle to the dht
  */
-struct GNUNET_DHT_Handle *dht_handle;
+static struct GNUNET_DHT_Handle *dht_handle;
 
 /**
- * Connects resolver to the dht
- *
-static void
-connect_to_dht()
+ * Initialize the resolver
+ */
+int
+gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh,
+                  struct GNUNET_DHT_Handle *dh)
 {
-  //FIXME
+  namestore_handle = nh;
+  dht_handle = dh;
+  if ((namestore_handle != NULL) && (dht_handle != NULL))
+  {
+    return GNUNET_OK;
+  }
+  return GNUNET_SYSERR;
 }
-*/
+
 
 /**
  * Helper function to free resolver handle
@@ -274,7 +281,7 @@ resolve_record_dht(struct ResolverHandle *rh)
   GNUNET_HashCode lookup_key;
   struct GNUNET_CRYPTO_HashAsciiEncoded lookup_key_string;
   struct RecordLookupHandle *rlh = (struct RecordLookupHandle *)rh->proc_cls;
-
+  
   GNUNET_CRYPTO_hash(rh->name, strlen(rh->name), &name_hash);
   GNUNET_CRYPTO_hash_xor(&name_hash, &rh->authority, &lookup_key);
   GNUNET_CRYPTO_hash_to_enc (&lookup_key, &lookup_key_string);
@@ -597,12 +604,11 @@ process_delegation_result_dht(void* cls,
       resolve_delegation_dht(rh);
     return;
   }
-
+  
   /**
-   * should never get here unless false dht key/put
-   * block plugin should handle this
-   **/
-  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "DHT authority lookup found no match!\n");
+   * No pkey but name exists
+   */
+  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DHT authority lookup found no match!\n");
   rh->proc(rh->proc_cls, rh, 0, NULL);
 }
 
@@ -808,7 +814,7 @@ resolve_delegation_dht(struct ResolverHandle *rh)
   uint32_t xquery;
   GNUNET_HashCode name_hash;
   GNUNET_HashCode lookup_key;
-
+  
   GNUNET_CRYPTO_hash(rh->authority_name,
                      strlen(rh->authority_name),
                      &name_hash);
index 2b0c4755d7a1d061ec4bb6bd52c87636466f2065..79e916015e9a50395ecd6c3927f150015af082fc 100644 (file)
@@ -2,6 +2,7 @@
 #define GNS_RESOLVER_H
 
 #include "gns.h"
+#include "gnunet_dht_service.h"
 
 #define DHT_OPERATION_TIMEOUT  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
 #define DHT_LOOKUP_TIMEOUT DHT_OPERATION_TIMEOUT
@@ -185,6 +186,16 @@ struct GetNameAuthorityHandle
 
 };
 
+/**
+ * Initialize the resolver
+ *
+ * @param nh handle to the namestore
+ * @param dh handle to the dht
+ * @returns GNUNET_OK on success
+ */
+int
+gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh,
+                  struct GNUNET_DHT_Handle *dh);
 
 /**
  * Lookup of a record in a specific zone
index de393fa08e820f7ed8ee228bca7a7b8fd22bba4f..469ae36be22b9172aacc12df629609c9d74b0b7e 100644 (file)
@@ -51,7 +51,7 @@
 #define VERBOSE GNUNET_YES
 
 /* Timeout for entire testcase */
-#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10)
+#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
 
 /* If number of peers not in config file, use this number */
 #define DEFAULT_NUM_PEERS 2
index 6a12ecfe050671af748f3bca7c69e4944cb9a434..2bbc875846fe294eb87da013f027735019adb564 100644 (file)
@@ -50,7 +50,7 @@
 #define VERBOSE GNUNET_YES
 
 /* Timeout for entire testcase */
-#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10)
+#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
 
 /* If number of peers not in config file, use this number */
 #define DEFAULT_NUM_PEERS 2
index 76f7efececb30ba0d6c1aa7c1076c1ce65ffb2a4..8bd33fc472999732e41a75f3069027556d0bc4ee 100644 (file)
@@ -49,7 +49,7 @@
 #define VERBOSE GNUNET_YES
 
 /* Timeout for entire testcase */
-#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10)
+#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
 
 /* If number of peers not in config file, use this number */
 #define DEFAULT_NUM_PEERS 2
index c9989dd177be633302d6e5aa94ab25cf5d476562..c444dfe875b3672655b1eea907311c4749cccb59 100644 (file)
@@ -36,7 +36,7 @@
 #define VERBOSE GNUNET_YES
 
 /* Timeout for entire testcase */
-#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10)
+#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
 
 /* If number of peers not in config file, use this number */
 #define DEFAULT_NUM_PEERS 2