/**
* Our handle to the DHT
*/
-struct GNUNET_DHT_Handle *dht_handle;
+static struct GNUNET_DHT_Handle *dht_handle;
/**
* Our zone's private key
&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
*/
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
/**
/**
* 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
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);
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);
}
uint32_t xquery;
GNUNET_HashCode name_hash;
GNUNET_HashCode lookup_key;
-
+
GNUNET_CRYPTO_hash(rh->authority_name,
strlen(rh->authority_name),
&name_hash);
#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
};
+/**
+ * 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
#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
#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
#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
#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