aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-03-16 08:39:00 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-03-16 08:39:00 +0000
commit82e1974e76ae1c4a0002dfc2b81d3b3f07d50637 (patch)
treec87ab048480669993b61ff753449f32fefbd10fe /src
parentbb96d65cd41acd46e8f82070ecd1408e93a1e1a1 (diff)
downloadgnunet-82e1974e76ae1c4a0002dfc2b81d3b3f07d50637.tar.gz
gnunet-82e1974e76ae1c4a0002dfc2b81d3b3f07d50637.zip
-fixes
Diffstat (limited to 'src')
-rw-r--r--src/gns/gnunet-service-gns.c41
-rw-r--r--src/gns/gnunet-service-gns_resolver.c36
-rw-r--r--src/gns/gnunet-service-gns_resolver.h11
-rw-r--r--src/gns/test_gns_dht_delegated_lookup.c2
-rw-r--r--src/gns/test_gns_simple_delegated_lookup.c2
-rw-r--r--src/gns/test_gns_simple_lookup.c2
-rw-r--r--src/gns/test_gns_simple_shorten.c2
7 files changed, 59 insertions, 37 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 5c7c8b150..182655005 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -108,7 +108,7 @@ struct ClientLookupHandle
108/** 108/**
109 * Our handle to the DHT 109 * Our handle to the DHT
110 */ 110 */
111struct GNUNET_DHT_Handle *dht_handle; 111static struct GNUNET_DHT_Handle *dht_handle;
112 112
113/** 113/**
114 * Our zone's private key 114 * Our zone's private key
@@ -760,23 +760,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
760 &zone_hash); 760 &zone_hash);
761 GNUNET_free(keyfile); 761 GNUNET_free(keyfile);
762 762
763
764 if (GNUNET_YES ==
765 GNUNET_CONFIGURATION_get_value_yesno (c, "gns",
766 "HIJACK_DNS"))
767 {
768 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
769 "DNS hijacking enabled... connecting to service.\n");
770
771 if (gns_interceptor_init(zone_hash, c) == GNUNET_SYSERR)
772 {
773 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
774 "Failed to enable the dns interceptor!\n");
775 }
776 }
777
778
779
780 /** 763 /**
781 * handle to our local namestore 764 * handle to our local namestore
782 */ 765 */
@@ -801,6 +784,28 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
801 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Could not connect to DHT!\n"); 784 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Could not connect to DHT!\n");
802 } 785 }
803 786
787 if (gns_resolver_init(namestore_handle, dht_handle) == GNUNET_SYSERR)
788 {
789 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
790 "Unable to initialize resolver!\n");
791 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
792 return;
793 }
794
795 if (GNUNET_YES ==
796 GNUNET_CONFIGURATION_get_value_yesno (c, "gns",
797 "HIJACK_DNS"))
798 {
799 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
800 "DNS hijacking enabled... connecting to service.\n");
801
802 if (gns_interceptor_init(zone_hash, c) == GNUNET_SYSERR)
803 {
804 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
805 "Failed to enable the dns interceptor!\n");
806 }
807 }
808
804 //put_some_records(); //FIXME for testing 809 //put_some_records(); //FIXME for testing
805 810
806 /** 811 /**
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 9b83794f5..a46a2fd61 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -47,22 +47,29 @@
47/** 47/**
48 * Our handle to the namestore service 48 * Our handle to the namestore service
49 */ 49 */
50struct GNUNET_NAMESTORE_Handle *namestore_handle; 50static struct GNUNET_NAMESTORE_Handle *namestore_handle;
51 51
52/** 52/**
53 * Resolver handle to the dht 53 * Resolver handle to the dht
54 */ 54 */
55struct GNUNET_DHT_Handle *dht_handle; 55static struct GNUNET_DHT_Handle *dht_handle;
56 56
57/** 57/**
58 * Connects resolver to the dht 58 * Initialize the resolver
59 * 59 */
60static void 60int
61connect_to_dht() 61gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh,
62 struct GNUNET_DHT_Handle *dh)
62{ 63{
63 //FIXME 64 namestore_handle = nh;
65 dht_handle = dh;
66 if ((namestore_handle != NULL) && (dht_handle != NULL))
67 {
68 return GNUNET_OK;
69 }
70 return GNUNET_SYSERR;
64} 71}
65*/ 72
66 73
67/** 74/**
68 * Helper function to free resolver handle 75 * Helper function to free resolver handle
@@ -274,7 +281,7 @@ resolve_record_dht(struct ResolverHandle *rh)
274 GNUNET_HashCode lookup_key; 281 GNUNET_HashCode lookup_key;
275 struct GNUNET_CRYPTO_HashAsciiEncoded lookup_key_string; 282 struct GNUNET_CRYPTO_HashAsciiEncoded lookup_key_string;
276 struct RecordLookupHandle *rlh = (struct RecordLookupHandle *)rh->proc_cls; 283 struct RecordLookupHandle *rlh = (struct RecordLookupHandle *)rh->proc_cls;
277 284
278 GNUNET_CRYPTO_hash(rh->name, strlen(rh->name), &name_hash); 285 GNUNET_CRYPTO_hash(rh->name, strlen(rh->name), &name_hash);
279 GNUNET_CRYPTO_hash_xor(&name_hash, &rh->authority, &lookup_key); 286 GNUNET_CRYPTO_hash_xor(&name_hash, &rh->authority, &lookup_key);
280 GNUNET_CRYPTO_hash_to_enc (&lookup_key, &lookup_key_string); 287 GNUNET_CRYPTO_hash_to_enc (&lookup_key, &lookup_key_string);
@@ -597,12 +604,11 @@ process_delegation_result_dht(void* cls,
597 resolve_delegation_dht(rh); 604 resolve_delegation_dht(rh);
598 return; 605 return;
599 } 606 }
600 607
601 /** 608 /**
602 * should never get here unless false dht key/put 609 * No pkey but name exists
603 * block plugin should handle this 610 */
604 **/ 611 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DHT authority lookup found no match!\n");
605 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "DHT authority lookup found no match!\n");
606 rh->proc(rh->proc_cls, rh, 0, NULL); 612 rh->proc(rh->proc_cls, rh, 0, NULL);
607} 613}
608 614
@@ -808,7 +814,7 @@ resolve_delegation_dht(struct ResolverHandle *rh)
808 uint32_t xquery; 814 uint32_t xquery;
809 GNUNET_HashCode name_hash; 815 GNUNET_HashCode name_hash;
810 GNUNET_HashCode lookup_key; 816 GNUNET_HashCode lookup_key;
811 817
812 GNUNET_CRYPTO_hash(rh->authority_name, 818 GNUNET_CRYPTO_hash(rh->authority_name,
813 strlen(rh->authority_name), 819 strlen(rh->authority_name),
814 &name_hash); 820 &name_hash);
diff --git a/src/gns/gnunet-service-gns_resolver.h b/src/gns/gnunet-service-gns_resolver.h
index 2b0c4755d..79e916015 100644
--- a/src/gns/gnunet-service-gns_resolver.h
+++ b/src/gns/gnunet-service-gns_resolver.h
@@ -2,6 +2,7 @@
2#define GNS_RESOLVER_H 2#define GNS_RESOLVER_H
3 3
4#include "gns.h" 4#include "gns.h"
5#include "gnunet_dht_service.h"
5 6
6#define DHT_OPERATION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) 7#define DHT_OPERATION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
7#define DHT_LOOKUP_TIMEOUT DHT_OPERATION_TIMEOUT 8#define DHT_LOOKUP_TIMEOUT DHT_OPERATION_TIMEOUT
@@ -185,6 +186,16 @@ struct GetNameAuthorityHandle
185 186
186}; 187};
187 188
189/**
190 * Initialize the resolver
191 *
192 * @param nh handle to the namestore
193 * @param dh handle to the dht
194 * @returns GNUNET_OK on success
195 */
196int
197gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh,
198 struct GNUNET_DHT_Handle *dh);
188 199
189/** 200/**
190 * Lookup of a record in a specific zone 201 * Lookup of a record in a specific zone
diff --git a/src/gns/test_gns_dht_delegated_lookup.c b/src/gns/test_gns_dht_delegated_lookup.c
index de393fa08..469ae36be 100644
--- a/src/gns/test_gns_dht_delegated_lookup.c
+++ b/src/gns/test_gns_dht_delegated_lookup.c
@@ -51,7 +51,7 @@
51#define VERBOSE GNUNET_YES 51#define VERBOSE GNUNET_YES
52 52
53/* Timeout for entire testcase */ 53/* Timeout for entire testcase */
54#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) 54#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
55 55
56/* If number of peers not in config file, use this number */ 56/* If number of peers not in config file, use this number */
57#define DEFAULT_NUM_PEERS 2 57#define DEFAULT_NUM_PEERS 2
diff --git a/src/gns/test_gns_simple_delegated_lookup.c b/src/gns/test_gns_simple_delegated_lookup.c
index 6a12ecfe0..2bbc87584 100644
--- a/src/gns/test_gns_simple_delegated_lookup.c
+++ b/src/gns/test_gns_simple_delegated_lookup.c
@@ -50,7 +50,7 @@
50#define VERBOSE GNUNET_YES 50#define VERBOSE GNUNET_YES
51 51
52/* Timeout for entire testcase */ 52/* Timeout for entire testcase */
53#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) 53#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
54 54
55/* If number of peers not in config file, use this number */ 55/* If number of peers not in config file, use this number */
56#define DEFAULT_NUM_PEERS 2 56#define DEFAULT_NUM_PEERS 2
diff --git a/src/gns/test_gns_simple_lookup.c b/src/gns/test_gns_simple_lookup.c
index 76f7efece..8bd33fc47 100644
--- a/src/gns/test_gns_simple_lookup.c
+++ b/src/gns/test_gns_simple_lookup.c
@@ -49,7 +49,7 @@
49#define VERBOSE GNUNET_YES 49#define VERBOSE GNUNET_YES
50 50
51/* Timeout for entire testcase */ 51/* Timeout for entire testcase */
52#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) 52#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
53 53
54/* If number of peers not in config file, use this number */ 54/* If number of peers not in config file, use this number */
55#define DEFAULT_NUM_PEERS 2 55#define DEFAULT_NUM_PEERS 2
diff --git a/src/gns/test_gns_simple_shorten.c b/src/gns/test_gns_simple_shorten.c
index c9989dd17..c444dfe87 100644
--- a/src/gns/test_gns_simple_shorten.c
+++ b/src/gns/test_gns_simple_shorten.c
@@ -36,7 +36,7 @@
36#define VERBOSE GNUNET_YES 36#define VERBOSE GNUNET_YES
37 37
38/* Timeout for entire testcase */ 38/* Timeout for entire testcase */
39#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) 39#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
40 40
41/* If number of peers not in config file, use this number */ 41/* If number of peers not in config file, use this number */
42#define DEFAULT_NUM_PEERS 2 42#define DEFAULT_NUM_PEERS 2