diff options
Diffstat (limited to 'src/dns')
-rw-r--r-- | src/dns/Makefile.am | 3 | ||||
-rw-r--r-- | src/dns/dns_api.c | 2 | ||||
-rw-r--r-- | src/dns/gnunet-dns-monitor.c | 23 | ||||
-rw-r--r-- | src/dns/gnunet-dns-redirector.c | 24 | ||||
-rw-r--r-- | src/dns/gnunet-helper-dns.c | 4 | ||||
-rw-r--r-- | src/dns/gnunet-service-dns.c | 7 | ||||
-rw-r--r-- | src/dns/plugin_block_dns.c | 82 |
7 files changed, 111 insertions, 34 deletions
diff --git a/src/dns/Makefile.am b/src/dns/Makefile.am index f5fcf3782..5af228121 100644 --- a/src/dns/Makefile.am +++ b/src/dns/Makefile.am | |||
@@ -106,13 +106,14 @@ libgnunetdns_la_LDFLAGS = \ | |||
106 | libgnunet_plugin_block_dns_la_SOURCES = \ | 106 | libgnunet_plugin_block_dns_la_SOURCES = \ |
107 | plugin_block_dns.c | 107 | plugin_block_dns.c |
108 | libgnunet_plugin_block_dns_la_LIBADD = \ | 108 | libgnunet_plugin_block_dns_la_LIBADD = \ |
109 | $(top_builddir)/src/block/libgnunetblockgroup.la \ | ||
109 | $(top_builddir)/src/util/libgnunetutil.la | 110 | $(top_builddir)/src/util/libgnunetutil.la |
110 | libgnunet_plugin_block_dns_la_LDFLAGS = \ | 111 | libgnunet_plugin_block_dns_la_LDFLAGS = \ |
111 | $(top_builddir)/src/block/$(GN_PLUGIN_LDFLAGS) | 112 | $(top_builddir)/src/block/$(GN_PLUGIN_LDFLAGS) |
112 | 113 | ||
113 | 114 | ||
114 | if ENABLE_TEST_RUN | 115 | if ENABLE_TEST_RUN |
115 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH; | 116 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; |
116 | TESTS = $(check_PROGRAMS) $(check_SCRIPTS) | 117 | TESTS = $(check_PROGRAMS) $(check_SCRIPTS) |
117 | endif | 118 | endif |
118 | 119 | ||
diff --git a/src/dns/dns_api.c b/src/dns/dns_api.c index e7450a1d4..9f0dee9a9 100644 --- a/src/dns/dns_api.c +++ b/src/dns/dns_api.c | |||
@@ -317,7 +317,7 @@ GNUNET_DNS_request_answer (struct GNUNET_DNS_RequestHandle *rh, | |||
317 | return; | 317 | return; |
318 | } | 318 | } |
319 | if (reply_length + sizeof (struct GNUNET_DNS_Response) | 319 | if (reply_length + sizeof (struct GNUNET_DNS_Response) |
320 | >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 320 | >= GNUNET_MAX_MESSAGE_SIZE) |
321 | { | 321 | { |
322 | GNUNET_break (0); | 322 | GNUNET_break (0); |
323 | GNUNET_free (rh); | 323 | GNUNET_free (rh); |
diff --git a/src/dns/gnunet-dns-monitor.c b/src/dns/gnunet-dns-monitor.c index 5e6f90555..fb5c768ac 100644 --- a/src/dns/gnunet-dns-monitor.c +++ b/src/dns/gnunet-dns-monitor.c | |||
@@ -52,7 +52,7 @@ static int ret; | |||
52 | /** | 52 | /** |
53 | * Selected level of verbosity. | 53 | * Selected level of verbosity. |
54 | */ | 54 | */ |
55 | static int verbosity; | 55 | static unsigned int verbosity; |
56 | 56 | ||
57 | 57 | ||
58 | /** | 58 | /** |
@@ -346,14 +346,19 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
346 | int | 346 | int |
347 | main (int argc, char *const *argv) | 347 | main (int argc, char *const *argv) |
348 | { | 348 | { |
349 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 349 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
350 | {'i', "inbound-only", NULL, | 350 | |
351 | gettext_noop ("only monitor DNS queries"), | 351 | GNUNET_GETOPT_option_flag ('i', |
352 | 0, &GNUNET_GETOPT_set_one, &inbound_only}, | 352 | "inbound-only", |
353 | {'o', "outbound-only", NULL, | 353 | gettext_noop ("only monitor DNS queries"), |
354 | gettext_noop ("only monitor DNS replies"), | 354 | &inbound_only), |
355 | 0, &GNUNET_GETOPT_set_one, &outbound_only}, | 355 | |
356 | GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), | 356 | GNUNET_GETOPT_option_flag ('o', |
357 | "outbound-only", | ||
358 | gettext_noop ("only monitor DNS queries"), | ||
359 | &outbound_only), | ||
360 | |||
361 | GNUNET_GETOPT_option_verbose (&verbosity), | ||
357 | GNUNET_GETOPT_OPTION_END | 362 | GNUNET_GETOPT_OPTION_END |
358 | }; | 363 | }; |
359 | 364 | ||
diff --git a/src/dns/gnunet-dns-redirector.c b/src/dns/gnunet-dns-redirector.c index 89929815a..44d3d0b6c 100644 --- a/src/dns/gnunet-dns-redirector.c +++ b/src/dns/gnunet-dns-redirector.c | |||
@@ -52,7 +52,7 @@ static int ret; | |||
52 | /** | 52 | /** |
53 | * Selected level of verbosity. | 53 | * Selected level of verbosity. |
54 | */ | 54 | */ |
55 | static int verbosity; | 55 | static unsigned int verbosity; |
56 | 56 | ||
57 | 57 | ||
58 | /** | 58 | /** |
@@ -230,14 +230,20 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
230 | int | 230 | int |
231 | main (int argc, char *const *argv) | 231 | main (int argc, char *const *argv) |
232 | { | 232 | { |
233 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 233 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
234 | {'4', "ipv4", "IPV4", | 234 | GNUNET_GETOPT_option_string ('4', |
235 | gettext_noop ("set A records"), | 235 | "ipv4", |
236 | 1, &GNUNET_GETOPT_set_string, &n4}, | 236 | "IPV4", |
237 | {'6', "ipv4", "IPV6", | 237 | gettext_noop ("set A records"), |
238 | gettext_noop ("set AAAA records"), | 238 | &n4), |
239 | 1, &GNUNET_GETOPT_set_string, &n6}, | 239 | |
240 | GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), | 240 | GNUNET_GETOPT_option_string ('6', |
241 | "ipv4", | ||
242 | "IPV6", | ||
243 | gettext_noop ("set AAAA records"), | ||
244 | &n6), | ||
245 | |||
246 | GNUNET_GETOPT_option_verbose (&verbosity), | ||
241 | GNUNET_GETOPT_OPTION_END | 247 | GNUNET_GETOPT_OPTION_END |
242 | }; | 248 | }; |
243 | 249 | ||
diff --git a/src/dns/gnunet-helper-dns.c b/src/dns/gnunet-helper-dns.c index 1c5744002..5cf1967f5 100644 --- a/src/dns/gnunet-helper-dns.c +++ b/src/dns/gnunet-helper-dns.c | |||
@@ -79,7 +79,7 @@ | |||
79 | #include "gnunet_protocols.h" | 79 | #include "gnunet_protocols.h" |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE) | 82 | * Maximum size of a GNUnet message (GNUNET_MAX_MESSAGE_SIZE) |
83 | */ | 83 | */ |
84 | #define MAX_SIZE 65536 | 84 | #define MAX_SIZE 65536 |
85 | 85 | ||
@@ -794,6 +794,8 @@ main (int argc, char *const*argv) | |||
794 | sbin_ip = "/sbin/ip"; | 794 | sbin_ip = "/sbin/ip"; |
795 | else if (0 == access ("/usr/sbin/ip", X_OK)) | 795 | else if (0 == access ("/usr/sbin/ip", X_OK)) |
796 | sbin_ip = "/usr/sbin/ip"; | 796 | sbin_ip = "/usr/sbin/ip"; |
797 | else if (0 == access ("/bin/ip", X_OK)) /* gentoo has it there */ | ||
798 | sbin_ip = "/bin/ip"; | ||
797 | else | 799 | else |
798 | { | 800 | { |
799 | fprintf (stderr, | 801 | fprintf (stderr, |
diff --git a/src/dns/gnunet-service-dns.c b/src/dns/gnunet-service-dns.c index 74f595c5e..ffc94afb7 100644 --- a/src/dns/gnunet-service-dns.c +++ b/src/dns/gnunet-service-dns.c | |||
@@ -347,7 +347,7 @@ request_done (struct RequestRecord *rr) | |||
347 | } | 347 | } |
348 | reply_len += sizeof (struct GNUNET_TUN_UdpHeader); | 348 | reply_len += sizeof (struct GNUNET_TUN_UdpHeader); |
349 | reply_len += rr->payload_length; | 349 | reply_len += rr->payload_length; |
350 | if (reply_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 350 | if (reply_len >= GNUNET_MAX_MESSAGE_SIZE) |
351 | { | 351 | { |
352 | /* response too big, drop */ | 352 | /* response too big, drop */ |
353 | GNUNET_break (0); /* how can this be? */ | 353 | GNUNET_break (0); /* how can this be? */ |
@@ -481,7 +481,7 @@ send_request_to_client (struct RequestRecord *rr, | |||
481 | struct GNUNET_MQ_Envelope *env; | 481 | struct GNUNET_MQ_Envelope *env; |
482 | struct GNUNET_DNS_Request *req; | 482 | struct GNUNET_DNS_Request *req; |
483 | 483 | ||
484 | if (sizeof (struct GNUNET_DNS_Request) + rr->payload_length >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 484 | if (sizeof (struct GNUNET_DNS_Request) + rr->payload_length >= GNUNET_MAX_MESSAGE_SIZE) |
485 | { | 485 | { |
486 | GNUNET_break (0); | 486 | GNUNET_break (0); |
487 | cleanup_rr (rr); | 487 | cleanup_rr (rr); |
@@ -882,11 +882,10 @@ handle_client_response (void *cls, | |||
882 | * message is received by the tokenizer from the DNS hijack process. | 882 | * message is received by the tokenizer from the DNS hijack process. |
883 | * | 883 | * |
884 | * @param cls closure | 884 | * @param cls closure |
885 | * @param client identification of the client | ||
886 | * @param message the actual message, a DNS request we should handle | 885 | * @param message the actual message, a DNS request we should handle |
887 | */ | 886 | */ |
888 | static int | 887 | static int |
889 | process_helper_messages (void *cls GNUNET_UNUSED, void *client, | 888 | process_helper_messages (void *cls, |
890 | const struct GNUNET_MessageHeader *message) | 889 | const struct GNUNET_MessageHeader *message) |
891 | { | 890 | { |
892 | uint16_t msize; | 891 | uint16_t msize; |
diff --git a/src/dns/plugin_block_dns.c b/src/dns/plugin_block_dns.c index dc339dd25..ca6ea84c4 100644 --- a/src/dns/plugin_block_dns.c +++ b/src/dns/plugin_block_dns.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2013 GNUnet e.V. | 3 | Copyright (C) 2013, 2017 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -31,6 +31,61 @@ | |||
31 | #include "gnunet_block_plugin.h" | 31 | #include "gnunet_block_plugin.h" |
32 | #include "block_dns.h" | 32 | #include "block_dns.h" |
33 | #include "gnunet_signatures.h" | 33 | #include "gnunet_signatures.h" |
34 | #include "gnunet_block_group_lib.h" | ||
35 | |||
36 | |||
37 | /** | ||
38 | * Number of bits we set per entry in the bloomfilter. | ||
39 | * Do not change! | ||
40 | */ | ||
41 | #define BLOOMFILTER_K 16 | ||
42 | |||
43 | |||
44 | /** | ||
45 | * Create a new block group. | ||
46 | * | ||
47 | * @param ctx block context in which the block group is created | ||
48 | * @param type type of the block for which we are creating the group | ||
49 | * @param nonce random value used to seed the group creation | ||
50 | * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh | ||
51 | * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh | ||
52 | * @param va variable arguments specific to @a type | ||
53 | * @return block group handle, NULL if block groups are not supported | ||
54 | * by this @a type of block (this is not an error) | ||
55 | */ | ||
56 | static struct GNUNET_BLOCK_Group * | ||
57 | block_plugin_dns_create_group (void *cls, | ||
58 | enum GNUNET_BLOCK_Type type, | ||
59 | uint32_t nonce, | ||
60 | const void *raw_data, | ||
61 | size_t raw_data_size, | ||
62 | va_list va) | ||
63 | { | ||
64 | unsigned int bf_size; | ||
65 | const char *guard; | ||
66 | |||
67 | guard = va_arg (va, const char *); | ||
68 | if (0 == strcmp (guard, | ||
69 | "seen-set-size")) | ||
70 | bf_size = GNUNET_BLOCK_GROUP_compute_bloomfilter_size (va_arg (va, unsigned int), | ||
71 | BLOOMFILTER_K); | ||
72 | else if (0 == strcmp (guard, | ||
73 | "filter-size")) | ||
74 | bf_size = va_arg (va, unsigned int); | ||
75 | else | ||
76 | { | ||
77 | GNUNET_break (0); | ||
78 | bf_size = 8; | ||
79 | } | ||
80 | GNUNET_break (NULL == va_arg (va, const char *)); | ||
81 | return GNUNET_BLOCK_GROUP_bf_create (cls, | ||
82 | bf_size, | ||
83 | BLOOMFILTER_K, | ||
84 | type, | ||
85 | nonce, | ||
86 | raw_data, | ||
87 | raw_data_size); | ||
88 | } | ||
34 | 89 | ||
35 | 90 | ||
36 | /** | 91 | /** |
@@ -38,11 +93,11 @@ | |||
38 | * request evaluation, simply pass "NULL" for the reply_block. | 93 | * request evaluation, simply pass "NULL" for the reply_block. |
39 | * | 94 | * |
40 | * @param cls closure | 95 | * @param cls closure |
96 | * @param ctx block context | ||
41 | * @param type block type | 97 | * @param type block type |
98 | * @param bg group to evaluate against | ||
42 | * @param eo control flags | 99 | * @param eo control flags |
43 | * @param query original query (hash) | 100 | * @param query original query (hash) |
44 | * @param bf pointer to bloom filter associated with query; possibly updated (!) | ||
45 | * @param bf_mutator mutation value for bf | ||
46 | * @param xquery extended query data (can be NULL, depending on type) | 101 | * @param xquery extended query data (can be NULL, depending on type) |
47 | * @param xquery_size number of bytes in @a xquery | 102 | * @param xquery_size number of bytes in @a xquery |
48 | * @param reply_block response to validate | 103 | * @param reply_block response to validate |
@@ -51,17 +106,18 @@ | |||
51 | */ | 106 | */ |
52 | static enum GNUNET_BLOCK_EvaluationResult | 107 | static enum GNUNET_BLOCK_EvaluationResult |
53 | block_plugin_dns_evaluate (void *cls, | 108 | block_plugin_dns_evaluate (void *cls, |
109 | struct GNUNET_BLOCK_Context *ctx, | ||
54 | enum GNUNET_BLOCK_Type type, | 110 | enum GNUNET_BLOCK_Type type, |
111 | struct GNUNET_BLOCK_Group *bg, | ||
55 | enum GNUNET_BLOCK_EvaluationOptions eo, | 112 | enum GNUNET_BLOCK_EvaluationOptions eo, |
56 | const struct GNUNET_HashCode * query, | 113 | const struct GNUNET_HashCode * query, |
57 | struct GNUNET_CONTAINER_BloomFilter **bf, | ||
58 | int32_t bf_mutator, | ||
59 | const void *xquery, | 114 | const void *xquery, |
60 | size_t xquery_size, | 115 | size_t xquery_size, |
61 | const void *reply_block, | 116 | const void *reply_block, |
62 | size_t reply_block_size) | 117 | size_t reply_block_size) |
63 | { | 118 | { |
64 | const struct GNUNET_DNS_Advertisement *ad; | 119 | const struct GNUNET_DNS_Advertisement *ad; |
120 | struct GNUNET_HashCode phash; | ||
65 | 121 | ||
66 | switch (type) | 122 | switch (type) |
67 | { | 123 | { |
@@ -69,7 +125,7 @@ block_plugin_dns_evaluate (void *cls, | |||
69 | if (0 != xquery_size) | 125 | if (0 != xquery_size) |
70 | return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; | 126 | return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; |
71 | 127 | ||
72 | if (0 == reply_block_size) | 128 | if (NULL == reply_block) |
73 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | 129 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; |
74 | 130 | ||
75 | if (sizeof (struct GNUNET_DNS_Advertisement) != reply_block_size) | 131 | if (sizeof (struct GNUNET_DNS_Advertisement) != reply_block_size) |
@@ -96,13 +152,20 @@ block_plugin_dns_evaluate (void *cls, | |||
96 | } | 152 | } |
97 | if (GNUNET_OK != | 153 | if (GNUNET_OK != |
98 | GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_DNS_RECORD, | 154 | GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_DNS_RECORD, |
99 | &ad->purpose, | 155 | &ad->purpose, |
100 | &ad->signature, | 156 | &ad->signature, |
101 | &ad->peer.public_key)) | 157 | &ad->peer.public_key)) |
102 | { | 158 | { |
103 | GNUNET_break_op (0); | 159 | GNUNET_break_op (0); |
104 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | 160 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
105 | } | 161 | } |
162 | GNUNET_CRYPTO_hash (reply_block, | ||
163 | reply_block_size, | ||
164 | &phash); | ||
165 | if (GNUNET_YES == | ||
166 | GNUNET_BLOCK_GROUP_bf_test_and_set (bg, | ||
167 | &phash)) | ||
168 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; | ||
106 | return GNUNET_BLOCK_EVALUATION_OK_MORE; | 169 | return GNUNET_BLOCK_EVALUATION_OK_MORE; |
107 | default: | 170 | default: |
108 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | 171 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; |
@@ -149,6 +212,7 @@ libgnunet_plugin_block_dns_init (void *cls) | |||
149 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); | 212 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); |
150 | api->evaluate = &block_plugin_dns_evaluate; | 213 | api->evaluate = &block_plugin_dns_evaluate; |
151 | api->get_key = &block_plugin_dns_get_key; | 214 | api->get_key = &block_plugin_dns_get_key; |
215 | api->create_group = &block_plugin_dns_create_group; | ||
152 | api->types = types; | 216 | api->types = types; |
153 | return api; | 217 | return api; |
154 | } | 218 | } |