diff options
Diffstat (limited to 'src/gns/gnunet-service-gns.c')
-rw-r--r-- | src/gns/gnunet-service-gns.c | 171 |
1 files changed, 17 insertions, 154 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index cec31ff48..1e8d07bc5 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -61,7 +61,7 @@ struct ClientLookupHandle | |||
61 | * We keep these in a DLL. | 61 | * We keep these in a DLL. |
62 | */ | 62 | */ |
63 | struct ClientLookupHandle *prev; | 63 | struct ClientLookupHandle *prev; |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * Client handle | 66 | * Client handle |
67 | */ | 67 | */ |
@@ -73,11 +73,6 @@ struct ClientLookupHandle | |||
73 | struct GNS_ResolverHandle *lookup; | 73 | struct GNS_ResolverHandle *lookup; |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * Active handle for a reverse lookup | ||
77 | */ | ||
78 | struct GNS_ReverserHandle *rev_lookup; | ||
79 | |||
80 | /** | ||
81 | * request id | 76 | * request id |
82 | */ | 77 | */ |
83 | uint32_t request_id; | 78 | uint32_t request_id; |
@@ -173,8 +168,6 @@ shutdown_task (void *cls) | |||
173 | identity_handle = NULL; | 168 | identity_handle = NULL; |
174 | } | 169 | } |
175 | GNS_resolver_done (); | 170 | GNS_resolver_done (); |
176 | GNS_reverse_done (); | ||
177 | GNS_shorten_done (); | ||
178 | if (NULL != statistics) | 171 | if (NULL != statistics) |
179 | { | 172 | { |
180 | GNUNET_STATISTICS_destroy (statistics, | 173 | GNUNET_STATISTICS_destroy (statistics, |
@@ -221,15 +214,13 @@ client_disconnect_cb (void *cls, | |||
221 | { | 214 | { |
222 | if (NULL != clh->lookup) | 215 | if (NULL != clh->lookup) |
223 | GNS_resolver_lookup_cancel (clh->lookup); | 216 | GNS_resolver_lookup_cancel (clh->lookup); |
224 | if (NULL != clh->rev_lookup) | ||
225 | GNS_reverse_lookup_cancel (clh->rev_lookup); | ||
226 | GNUNET_CONTAINER_DLL_remove (gc->clh_head, | 217 | GNUNET_CONTAINER_DLL_remove (gc->clh_head, |
227 | gc->clh_tail, | 218 | gc->clh_tail, |
228 | clh); | 219 | clh); |
229 | GNUNET_free (clh); | 220 | GNUNET_free (clh); |
230 | } | 221 | } |
231 | 222 | ||
232 | GNUNET_free (gc); | 223 | GNUNET_free (gc); |
233 | } | 224 | } |
234 | 225 | ||
235 | 226 | ||
@@ -288,7 +279,9 @@ send_lookup_response (void* cls, | |||
288 | (char*) &rmsg[1]); | 279 | (char*) &rmsg[1]); |
289 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(clh->gc->client), | 280 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(clh->gc->client), |
290 | env); | 281 | env); |
291 | GNUNET_CONTAINER_DLL_remove (clh->gc->clh_head, clh->gc->clh_tail, clh); | 282 | GNUNET_CONTAINER_DLL_remove (clh->gc->clh_head, |
283 | clh->gc->clh_tail, | ||
284 | clh); | ||
292 | GNUNET_free (clh); | 285 | GNUNET_free (clh); |
293 | GNUNET_STATISTICS_update (statistics, | 286 | GNUNET_STATISTICS_update (statistics, |
294 | "Completed lookups", 1, | 287 | "Completed lookups", 1, |
@@ -299,47 +292,6 @@ send_lookup_response (void* cls, | |||
299 | GNUNET_NO); | 292 | GNUNET_NO); |
300 | } | 293 | } |
301 | 294 | ||
302 | /** | ||
303 | * Reply to client with the result from our reverse lookup. | ||
304 | * | ||
305 | * @param cls the closure (our client lookup handle) | ||
306 | * @param rd_count the number of records in @a rd | ||
307 | * @param rd the record data | ||
308 | */ | ||
309 | static void | ||
310 | send_reverse_lookup_response (void* cls, | ||
311 | const char *name) | ||
312 | { | ||
313 | struct ClientLookupHandle *clh = cls; | ||
314 | struct GNUNET_MQ_Envelope *env; | ||
315 | struct ReverseLookupResultMessage *rmsg; | ||
316 | size_t len; | ||
317 | |||
318 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
319 | "Sending LOOKUP_RESULT message with %s\n", | ||
320 | name); | ||
321 | |||
322 | if (NULL == name) | ||
323 | len = 1; | ||
324 | else | ||
325 | len = strlen (name) + 1; | ||
326 | env = GNUNET_MQ_msg_extra (rmsg, | ||
327 | len, | ||
328 | GNUNET_MESSAGE_TYPE_GNS_REVERSE_LOOKUP_RESULT); | ||
329 | rmsg->id = clh->request_id; | ||
330 | if (1 < len) | ||
331 | GNUNET_memcpy ((char*) &rmsg[1], | ||
332 | name, | ||
333 | strlen (name)); | ||
334 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(clh->gc->client), | ||
335 | env); | ||
336 | GNUNET_CONTAINER_DLL_remove (clh->gc->clh_head, clh->gc->clh_tail, clh); | ||
337 | GNUNET_free (clh); | ||
338 | GNUNET_STATISTICS_update (statistics, | ||
339 | "Completed reverse lookups", 1, | ||
340 | GNUNET_NO); | ||
341 | } | ||
342 | |||
343 | 295 | ||
344 | /** | 296 | /** |
345 | * Checks a #GNUNET_MESSAGE_TYPE_GNS_LOOKUP message | 297 | * Checks a #GNUNET_MESSAGE_TYPE_GNS_LOOKUP message |
@@ -371,6 +323,7 @@ check_lookup (void *cls, | |||
371 | return GNUNET_OK; | 323 | return GNUNET_OK; |
372 | } | 324 | } |
373 | 325 | ||
326 | |||
374 | /** | 327 | /** |
375 | * Handle lookup requests from client | 328 | * Handle lookup requests from client |
376 | * | 329 | * |
@@ -387,20 +340,17 @@ handle_lookup (void *cls, | |||
387 | struct ClientLookupHandle *clh; | 340 | struct ClientLookupHandle *clh; |
388 | char *nameptr = name; | 341 | char *nameptr = name; |
389 | const char *utf_in; | 342 | const char *utf_in; |
390 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *key; | ||
391 | 343 | ||
392 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 344 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
393 | "Received LOOKUP message\n"); | 345 | "Received LOOKUP message\n"); |
394 | GNUNET_SERVICE_client_continue (gc->client); | 346 | GNUNET_SERVICE_client_continue (gc->client); |
395 | if (GNUNET_YES == ntohs (sh_msg->have_key)) | ||
396 | key = &sh_msg->shorten_key; | ||
397 | else | ||
398 | key = NULL; | ||
399 | utf_in = (const char *) &sh_msg[1]; | 347 | utf_in = (const char *) &sh_msg[1]; |
400 | GNUNET_STRINGS_utf8_tolower (utf_in, nameptr); | 348 | GNUNET_STRINGS_utf8_tolower (utf_in, nameptr); |
401 | 349 | ||
402 | clh = GNUNET_new (struct ClientLookupHandle); | 350 | clh = GNUNET_new (struct ClientLookupHandle); |
403 | GNUNET_CONTAINER_DLL_insert (gc->clh_head, gc->clh_tail, clh); | 351 | GNUNET_CONTAINER_DLL_insert (gc->clh_head, |
352 | gc->clh_tail, | ||
353 | clh); | ||
404 | clh->gc = gc; | 354 | clh->gc = gc; |
405 | clh->request_id = sh_msg->id; | 355 | clh->request_id = sh_msg->id; |
406 | if ( (GNUNET_DNSPARSER_TYPE_A == ntohl (sh_msg->type)) && | 356 | if ( (GNUNET_DNSPARSER_TYPE_A == ntohl (sh_msg->type)) && |
@@ -422,7 +372,6 @@ handle_lookup (void *cls, | |||
422 | clh->lookup = GNS_resolver_lookup (&sh_msg->zone, | 372 | clh->lookup = GNS_resolver_lookup (&sh_msg->zone, |
423 | ntohl (sh_msg->type), | 373 | ntohl (sh_msg->type), |
424 | name, | 374 | name, |
425 | key, | ||
426 | (enum GNUNET_GNS_LocalOptions) ntohs (sh_msg->options), | 375 | (enum GNUNET_GNS_LocalOptions) ntohs (sh_msg->options), |
427 | &send_lookup_response, clh); | 376 | &send_lookup_response, clh); |
428 | GNUNET_STATISTICS_update (statistics, | 377 | GNUNET_STATISTICS_update (statistics, |
@@ -430,82 +379,6 @@ handle_lookup (void *cls, | |||
430 | 1, GNUNET_NO); | 379 | 1, GNUNET_NO); |
431 | } | 380 | } |
432 | 381 | ||
433 | /** | ||
434 | * Handle reverse lookup requests from client | ||
435 | * | ||
436 | * @param cls the closure | ||
437 | * @param client the client | ||
438 | * @param message the message | ||
439 | */ | ||
440 | static void | ||
441 | handle_rev_lookup (void *cls, | ||
442 | const struct ReverseLookupMessage *sh_msg) | ||
443 | { | ||
444 | struct GnsClient *gc = cls; | ||
445 | struct ClientLookupHandle *clh; | ||
446 | |||
447 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
448 | "Received REVERSE_LOOKUP message\n"); | ||
449 | GNUNET_SERVICE_client_continue (gc->client); | ||
450 | |||
451 | clh = GNUNET_new (struct ClientLookupHandle); | ||
452 | GNUNET_CONTAINER_DLL_insert (gc->clh_head, gc->clh_tail, clh); | ||
453 | clh->gc = gc; | ||
454 | clh->request_id = sh_msg->id; | ||
455 | clh->rev_lookup = GNS_reverse_lookup (&sh_msg->zone_pkey, | ||
456 | &sh_msg->root_pkey, | ||
457 | &send_reverse_lookup_response, | ||
458 | clh); | ||
459 | GNUNET_STATISTICS_update (statistics, | ||
460 | "Reverse lookup attempts", | ||
461 | 1, GNUNET_NO); | ||
462 | } | ||
463 | |||
464 | |||
465 | /** | ||
466 | * Method called to inform about the ego to be used for the master zone | ||
467 | * for DNS interceptions. | ||
468 | * | ||
469 | * This function is only called ONCE, and 'NULL' being passed in | ||
470 | * @a ego does indicate that interception is not configured. | ||
471 | * If @a ego is non-NULL, we should start to intercept DNS queries | ||
472 | * and resolve ".gnu" queries using the given ego as the master zone. | ||
473 | * | ||
474 | * @param cls closure, our `const struct GNUNET_CONFIGURATION_Handle *c` | ||
475 | * @param ego ego handle | ||
476 | * @param ctx context for application to store data for this ego | ||
477 | * (during the lifetime of this process, initially NULL) | ||
478 | * @param name name assigned by the user for this ego, | ||
479 | * NULL if the user just deleted the ego and it | ||
480 | * must thus no longer be used | ||
481 | */ | ||
482 | static void | ||
483 | identity_reverse_cb (void *cls, | ||
484 | struct GNUNET_IDENTITY_Ego *ego, | ||
485 | void **ctx, | ||
486 | const char *name) | ||
487 | { | ||
488 | identity_op = NULL; | ||
489 | |||
490 | if (NULL == ego) | ||
491 | { | ||
492 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
493 | _("No ego configured for `%s`\n"), | ||
494 | "gns-master"); | ||
495 | |||
496 | return; | ||
497 | } | ||
498 | if (GNUNET_SYSERR == | ||
499 | GNS_reverse_init (namestore_handle, | ||
500 | GNUNET_IDENTITY_ego_get_private_key (ego), | ||
501 | name)) | ||
502 | { | ||
503 | GNUNET_break (0); | ||
504 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
505 | return; | ||
506 | } | ||
507 | } | ||
508 | |||
509 | 382 | ||
510 | /** | 383 | /** |
511 | * Method called to inform about the ego to be used for the master zone | 384 | * Method called to inform about the ego to be used for the master zone |
@@ -532,16 +405,10 @@ identity_intercept_cb (void *cls, | |||
532 | { | 405 | { |
533 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 406 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; |
534 | struct GNUNET_CRYPTO_EcdsaPublicKey dns_root; | 407 | struct GNUNET_CRYPTO_EcdsaPublicKey dns_root; |
535 | identity_op = NULL; | ||
536 | 408 | ||
409 | identity_op = NULL; | ||
537 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 410 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
538 | "Looking for gns-intercept ego\n"); | 411 | "Looking for gns-intercept ego\n"); |
539 | identity_op = GNUNET_IDENTITY_get (identity_handle, | ||
540 | "gns-reverse", | ||
541 | &identity_reverse_cb, | ||
542 | (void*)cfg); | ||
543 | |||
544 | |||
545 | if (NULL == ego) | 412 | if (NULL == ego) |
546 | { | 413 | { |
547 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 414 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -553,10 +420,12 @@ identity_intercept_cb (void *cls, | |||
553 | GNUNET_IDENTITY_ego_get_public_key (ego, | 420 | GNUNET_IDENTITY_ego_get_public_key (ego, |
554 | &dns_root); | 421 | &dns_root); |
555 | if (GNUNET_SYSERR == | 422 | if (GNUNET_SYSERR == |
556 | GNS_interceptor_init (&dns_root, cfg)) | 423 | GNS_interceptor_init (&dns_root, |
424 | cfg)) | ||
557 | { | 425 | { |
558 | GNUNET_break (0); | 426 | GNUNET_break (0); |
559 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 427 | GNUNET_SCHEDULER_add_now (&shutdown_task, |
428 | NULL); | ||
560 | return; | 429 | return; |
561 | } | 430 | } |
562 | } | 431 | } |
@@ -577,7 +446,7 @@ run (void *cls, | |||
577 | unsigned long long max_parallel_bg_queries = 16; | 446 | unsigned long long max_parallel_bg_queries = 16; |
578 | 447 | ||
579 | v6_enabled = GNUNET_NETWORK_test_pf (PF_INET6); | 448 | v6_enabled = GNUNET_NETWORK_test_pf (PF_INET6); |
580 | v4_enabled = GNUNET_NETWORK_test_pf (PF_INET); | 449 | v4_enabled = GNUNET_NETWORK_test_pf (PF_INET); |
581 | namestore_handle = GNUNET_NAMESTORE_connect (c); | 450 | namestore_handle = GNUNET_NAMESTORE_connect (c); |
582 | if (NULL == namestore_handle) | 451 | if (NULL == namestore_handle) |
583 | { | 452 | { |
@@ -635,11 +504,9 @@ run (void *cls, | |||
635 | dht_handle, | 504 | dht_handle, |
636 | c, | 505 | c, |
637 | max_parallel_bg_queries); | 506 | max_parallel_bg_queries); |
638 | GNS_shorten_init (namestore_handle, | ||
639 | namecache_handle, | ||
640 | dht_handle); | ||
641 | statistics = GNUNET_STATISTICS_create ("gns", c); | 507 | statistics = GNUNET_STATISTICS_create ("gns", c); |
642 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); | 508 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
509 | NULL); | ||
643 | } | 510 | } |
644 | 511 | ||
645 | 512 | ||
@@ -657,10 +524,6 @@ GNUNET_SERVICE_MAIN | |||
657 | GNUNET_MESSAGE_TYPE_GNS_LOOKUP, | 524 | GNUNET_MESSAGE_TYPE_GNS_LOOKUP, |
658 | struct LookupMessage, | 525 | struct LookupMessage, |
659 | NULL), | 526 | NULL), |
660 | GNUNET_MQ_hd_fixed_size (rev_lookup, | ||
661 | GNUNET_MESSAGE_TYPE_GNS_REVERSE_LOOKUP, | ||
662 | struct ReverseLookupMessage, | ||
663 | NULL), | ||
664 | GNUNET_MQ_handler_end()); | 527 | GNUNET_MQ_handler_end()); |
665 | 528 | ||
666 | 529 | ||