diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-06-13 17:36:47 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-06-13 17:36:47 +0000 |
commit | 1f5326cd1032cbcc914c7809df1a64994eeebbe9 (patch) | |
tree | bd04389845d0b3096d98e3e97033040486108830 /src/gns | |
parent | a8c5598ba43fcd61a5a340f14a3bab1613adbe7c (diff) | |
download | gnunet-1f5326cd1032cbcc914c7809df1a64994eeebbe9.tar.gz gnunet-1f5326cd1032cbcc914c7809df1a64994eeebbe9.zip |
- big shorten algorithm rewrite
- API change for lookup
- tests fixed
- introduces 3 zone system: root, private and shortened
Diffstat (limited to 'src/gns')
-rw-r--r-- | src/gns/gns.conf.in | 4 | ||||
-rw-r--r-- | src/gns/gns.h | 25 | ||||
-rw-r--r-- | src/gns/gns_api.c | 65 | ||||
-rw-r--r-- | src/gns/gnunet-gns-proxy.c | 85 | ||||
-rw-r--r-- | src/gns/gnunet-gns.c | 27 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns.c | 281 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 520 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.h | 35 | ||||
-rw-r--r-- | src/gns/test_gns_dht_delegated_lookup.c | 1 | ||||
-rw-r--r-- | src/gns/test_gns_dht_threepeer.c | 1 | ||||
-rw-r--r-- | src/gns/test_gns_max_queries.c | 2 | ||||
-rw-r--r-- | src/gns/test_gns_pseu_shorten.c | 109 | ||||
-rw-r--r-- | src/gns/test_gns_simple_delegated_lookup.c | 1 | ||||
-rw-r--r-- | src/gns/test_gns_simple_lookup.c | 1 | ||||
-rw-r--r-- | src/gns/test_gns_simple_lookup.conf | 4 | ||||
-rw-r--r-- | src/gns/test_gns_simple_mx_lookup.c | 1 | ||||
-rw-r--r-- | src/gns/test_gns_simple_zkey_lookup.c | 1 |
17 files changed, 775 insertions, 388 deletions
diff --git a/src/gns/gns.conf.in b/src/gns/gns.conf.in index 8484f1810..406d59464 100644 --- a/src/gns/gns.conf.in +++ b/src/gns/gns.conf.in | |||
@@ -6,6 +6,10 @@ CONFIG = $DEFAULTCONFIG | |||
6 | BINARY = gnunet-service-gns | 6 | BINARY = gnunet-service-gns |
7 | UNIXPATH = /tmp/gnunet-service-gns.sock | 7 | UNIXPATH = /tmp/gnunet-service-gns.sock |
8 | ZONEKEY = $SERVICEHOME/gns/zonekey.zkey | 8 | ZONEKEY = $SERVICEHOME/gns/zonekey.zkey |
9 | PRIVATE_ZONE = private | ||
10 | PRIVATE_ZONEKEY = $SERVICEHOME/gns/zonekey_priv.zkey | ||
11 | SHORTEN_ZONE = short | ||
12 | SHORTEN_ZONEKEY = $SERVICEHOME/gns/zonekey_short.zkey | ||
9 | HIJACK_DNS = NO | 13 | HIJACK_DNS = NO |
10 | AUTO_IMPORT_PKEY = YES | 14 | AUTO_IMPORT_PKEY = YES |
11 | AUTO_IMPORT_ZONEKEY = $SERVICEHOME/gns/shorten_zonekey.zkey | 15 | AUTO_IMPORT_ZONEKEY = $SERVICEHOME/gns/shorten_zonekey.zkey |
diff --git a/src/gns/gns.h b/src/gns/gns.h index 686729dd7..e34d0a086 100644 --- a/src/gns/gns.h +++ b/src/gns/gns.h | |||
@@ -63,25 +63,22 @@ struct GNUNET_GNS_ClientLookupMessage | |||
63 | uint32_t use_default_zone GNUNET_PACKED; | 63 | uint32_t use_default_zone GNUNET_PACKED; |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * If use_default_zone is empty this zone is used for lookup | 66 | * Is a shorten key attached? |
67 | */ | 67 | */ |
68 | struct GNUNET_CRYPTO_ShortHashCode zone; | 68 | uint32_t have_key GNUNET_PACKED; |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * Should we use a shorten zone? | 71 | * If use_default_zone is empty this zone is used for lookup |
72 | */ | ||
73 | uint32_t use_shorten_zone GNUNET_PACKED; | ||
74 | |||
75 | /** | ||
76 | * If use_shorten_zone is set use this zone for shortening | ||
77 | */ | 72 | */ |
78 | struct GNUNET_CRYPTO_ShortHashCode shorten_zone; | 73 | struct GNUNET_CRYPTO_ShortHashCode zone; |
79 | 74 | ||
80 | /** | 75 | /** |
81 | * the type of record to look up | 76 | * the type of record to look up |
82 | */ | 77 | */ |
83 | enum GNUNET_GNS_RecordType type; | 78 | enum GNUNET_GNS_RecordType type; |
84 | 79 | ||
80 | /* Followed by the key for shorten (optional) see have_key */ | ||
81 | |||
85 | /* Followed by the name to look up */ | 82 | /* Followed by the name to look up */ |
86 | }; | 83 | }; |
87 | 84 | ||
@@ -136,16 +133,6 @@ struct GNUNET_GNS_ClientShortenMessage | |||
136 | */ | 133 | */ |
137 | struct GNUNET_CRYPTO_ShortHashCode zone; | 134 | struct GNUNET_CRYPTO_ShortHashCode zone; |
138 | 135 | ||
139 | /** | ||
140 | * Should we use a shorten zone? | ||
141 | */ | ||
142 | uint32_t use_shorten_zone GNUNET_PACKED; | ||
143 | |||
144 | /** | ||
145 | * If use_shorten_zone is set use this zone for shortening | ||
146 | */ | ||
147 | struct GNUNET_CRYPTO_ShortHashCode shorten_zone; | ||
148 | |||
149 | /* Followed by the name to shorten up */ | 136 | /* Followed by the name to shorten up */ |
150 | }; | 137 | }; |
151 | 138 | ||
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c index 2e1e9712c..9806082bc 100644 --- a/src/gns/gns_api.c +++ b/src/gns/gns_api.c | |||
@@ -640,9 +640,9 @@ get_request_id (struct GNUNET_GNS_Handle *h) | |||
640 | * @param handle handle to the GNS service | 640 | * @param handle handle to the GNS service |
641 | * @param name the name to look up | 641 | * @param name the name to look up |
642 | * @param zone the zone to start the resolution in | 642 | * @param zone the zone to start the resolution in |
643 | * @param shorten_zone the zone where to shorten names into | ||
644 | * @param type the record type to look up | 643 | * @param type the record type to look up |
645 | * @param only_cached GNUNET_NO to only check locally not DHT for performance | 644 | * @param only_cached GNUNET_NO to only check locally not DHT for performance |
645 | * @param shorten_key the private key of the shorten zone (can be NULL) | ||
646 | * @param proc processor to call on result | 646 | * @param proc processor to call on result |
647 | * @param proc_cls closure for processor | 647 | * @param proc_cls closure for processor |
648 | * @return handle to the get | 648 | * @return handle to the get |
@@ -651,9 +651,9 @@ struct GNUNET_GNS_QueueEntry * | |||
651 | GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle, | 651 | GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle, |
652 | const char * name, | 652 | const char * name, |
653 | struct GNUNET_CRYPTO_ShortHashCode *zone, | 653 | struct GNUNET_CRYPTO_ShortHashCode *zone, |
654 | struct GNUNET_CRYPTO_ShortHashCode *shorten_zone, | ||
655 | enum GNUNET_GNS_RecordType type, | 654 | enum GNUNET_GNS_RecordType type, |
656 | int only_cached, | 655 | int only_cached, |
656 | struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key, | ||
657 | GNUNET_GNS_LookupResultProcessor proc, | 657 | GNUNET_GNS_LookupResultProcessor proc, |
658 | void *proc_cls) | 658 | void *proc_cls) |
659 | { | 659 | { |
@@ -662,13 +662,24 @@ GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle, | |||
662 | struct GNUNET_GNS_QueueEntry *qe; | 662 | struct GNUNET_GNS_QueueEntry *qe; |
663 | size_t msize; | 663 | size_t msize; |
664 | struct PendingMessage *pending; | 664 | struct PendingMessage *pending; |
665 | struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *pkey_enc=NULL; | ||
666 | size_t key_len = 0; | ||
667 | char* pkey_tmp; | ||
668 | |||
669 | if (NULL != shorten_key) | ||
670 | { | ||
671 | pkey_enc = GNUNET_CRYPTO_rsa_encode_key (shorten_key); | ||
672 | GNUNET_assert (pkey_enc != NULL); | ||
673 | key_len = ntohs (pkey_enc->len); | ||
674 | } | ||
665 | 675 | ||
666 | if (NULL == name) | 676 | if (NULL == name) |
667 | { | 677 | { |
668 | return NULL; | 678 | return NULL; |
669 | } | 679 | } |
670 | 680 | ||
671 | msize = sizeof (struct GNUNET_GNS_ClientLookupMessage) + strlen(name) + 1; | 681 | msize = sizeof (struct GNUNET_GNS_ClientLookupMessage) |
682 | + key_len + strlen(name) + 1; | ||
672 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to lookup %s in GNS\n", name); | 683 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to lookup %s in GNS\n", name); |
673 | 684 | ||
674 | qe = GNUNET_malloc(sizeof (struct GNUNET_GNS_QueueEntry)); | 685 | qe = GNUNET_malloc(sizeof (struct GNUNET_GNS_QueueEntry)); |
@@ -701,26 +712,23 @@ GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle, | |||
701 | memset(&lookup_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode)); | 712 | memset(&lookup_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode)); |
702 | } | 713 | } |
703 | 714 | ||
704 | if (NULL != shorten_zone) | 715 | lookup_msg->type = htonl(type); |
716 | |||
717 | pkey_tmp = (char *) &lookup_msg[1]; | ||
718 | |||
719 | if (pkey_enc != NULL) | ||
705 | { | 720 | { |
706 | lookup_msg->use_shorten_zone = htonl(1); | 721 | lookup_msg->have_key = htonl(1); |
707 | memcpy(&lookup_msg->shorten_zone, shorten_zone, | 722 | memcpy(pkey_tmp, pkey_enc, key_len); |
708 | sizeof(struct GNUNET_CRYPTO_ShortHashCode)); | ||
709 | } | 723 | } |
710 | else | 724 | else |
711 | { | 725 | lookup_msg->have_key = htonl(0); |
712 | lookup_msg->use_shorten_zone = htonl(0); | ||
713 | memset(&lookup_msg->shorten_zone, 0, | ||
714 | sizeof(struct GNUNET_CRYPTO_ShortHashCode)); | ||
715 | } | ||
716 | |||
717 | lookup_msg->type = htonl(type); | ||
718 | 726 | ||
719 | memcpy(&lookup_msg[1], name, strlen(name)); | 727 | memcpy(&pkey_tmp[key_len], name, strlen(name)); |
720 | 728 | ||
721 | GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail, | 729 | GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail, |
722 | pending); | 730 | pending); |
723 | 731 | GNUNET_free_non_null (pkey_enc); | |
724 | process_pending_messages (handle); | 732 | process_pending_messages (handle); |
725 | return qe; | 733 | return qe; |
726 | } | 734 | } |
@@ -732,6 +740,7 @@ GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle, | |||
732 | * @param name the name to look up | 740 | * @param name the name to look up |
733 | * @param type the record type to look up | 741 | * @param type the record type to look up |
734 | * @param only_cached GNUNET_NO to only check locally not DHT for performance | 742 | * @param only_cached GNUNET_NO to only check locally not DHT for performance |
743 | * @param shorten_key the private key of the shorten zone (can be NULL) | ||
735 | * @param proc processor to call on result | 744 | * @param proc processor to call on result |
736 | * @param proc_cls closure for processor | 745 | * @param proc_cls closure for processor |
737 | * @return handle to the get | 746 | * @return handle to the get |
@@ -741,12 +750,15 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, | |||
741 | const char * name, | 750 | const char * name, |
742 | enum GNUNET_GNS_RecordType type, | 751 | enum GNUNET_GNS_RecordType type, |
743 | int only_cached, | 752 | int only_cached, |
753 | struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key, | ||
744 | GNUNET_GNS_LookupResultProcessor proc, | 754 | GNUNET_GNS_LookupResultProcessor proc, |
745 | void *proc_cls) | 755 | void *proc_cls) |
746 | { | 756 | { |
747 | return GNUNET_GNS_lookup_zone (handle, name, | 757 | return GNUNET_GNS_lookup_zone (handle, name, |
748 | NULL, NULL, | 758 | NULL, |
749 | type, only_cached, proc, proc_cls); | 759 | type, only_cached, |
760 | shorten_key, | ||
761 | proc, proc_cls); | ||
750 | } | 762 | } |
751 | 763 | ||
752 | /** | 764 | /** |
@@ -755,7 +767,6 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, | |||
755 | * @param handle handle to the GNS service | 767 | * @param handle handle to the GNS service |
756 | * @param name the name to look up | 768 | * @param name the name to look up |
757 | * @param zone the zone to start the resolution in | 769 | * @param zone the zone to start the resolution in |
758 | * @param shorten_zone the zone where to shorten names into | ||
759 | * @param proc function to call on result | 770 | * @param proc function to call on result |
760 | * @param proc_cls closure for processor | 771 | * @param proc_cls closure for processor |
761 | * @return handle to the operation | 772 | * @return handle to the operation |
@@ -764,7 +775,6 @@ struct GNUNET_GNS_QueueEntry * | |||
764 | GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle, | 775 | GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle, |
765 | const char * name, | 776 | const char * name, |
766 | struct GNUNET_CRYPTO_ShortHashCode *zone, | 777 | struct GNUNET_CRYPTO_ShortHashCode *zone, |
767 | struct GNUNET_CRYPTO_ShortHashCode *shorten_zone, | ||
768 | GNUNET_GNS_ShortenResultProcessor proc, | 778 | GNUNET_GNS_ShortenResultProcessor proc, |
769 | void *proc_cls) | 779 | void *proc_cls) |
770 | { | 780 | { |
@@ -812,19 +822,6 @@ GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle, | |||
812 | memset(&shorten_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode)); | 822 | memset(&shorten_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode)); |
813 | } | 823 | } |
814 | 824 | ||
815 | if (NULL != shorten_zone) | ||
816 | { | ||
817 | shorten_msg->use_shorten_zone = htonl(1); | ||
818 | memcpy(&shorten_msg->shorten_zone, shorten_zone, | ||
819 | sizeof(struct GNUNET_CRYPTO_ShortHashCode)); | ||
820 | } | ||
821 | else | ||
822 | { | ||
823 | shorten_msg->use_shorten_zone = htonl(0); | ||
824 | memset(&shorten_msg->shorten_zone, 0, | ||
825 | sizeof(struct GNUNET_CRYPTO_ShortHashCode)); | ||
826 | } | ||
827 | |||
828 | memcpy(&shorten_msg[1], name, strlen(name)); | 825 | memcpy(&shorten_msg[1], name, strlen(name)); |
829 | 826 | ||
830 | GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail, | 827 | GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail, |
@@ -849,7 +846,7 @@ GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle, | |||
849 | GNUNET_GNS_ShortenResultProcessor proc, | 846 | GNUNET_GNS_ShortenResultProcessor proc, |
850 | void *proc_cls) | 847 | void *proc_cls) |
851 | { | 848 | { |
852 | return GNUNET_GNS_shorten_zone (handle, name, NULL, NULL, proc, proc_cls); | 849 | return GNUNET_GNS_shorten_zone (handle, name, NULL, proc, proc_cls); |
853 | } | 850 | } |
854 | /** | 851 | /** |
855 | * Perform an authority lookup for a given name. | 852 | * Perform an authority lookup for a given name. |
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index 4effc0f04..a2c7d181e 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c | |||
@@ -292,17 +292,14 @@ static regex_t re_dotplus; | |||
292 | /* The users local GNS zone hash */ | 292 | /* The users local GNS zone hash */ |
293 | static struct GNUNET_CRYPTO_ShortHashCode local_gns_zone; | 293 | static struct GNUNET_CRYPTO_ShortHashCode local_gns_zone; |
294 | 294 | ||
295 | /* The users local shorten zone hash */ | ||
296 | static struct GNUNET_CRYPTO_ShortHashCode local_shorten_zone; | ||
297 | |||
298 | /* The CA for SSL certificate generation */ | 295 | /* The CA for SSL certificate generation */ |
299 | static struct ProxyCA proxy_ca; | 296 | static struct ProxyCA proxy_ca; |
300 | 297 | ||
301 | /* UNIX domain socket for mhd */ | 298 | /* UNIX domain socket for mhd */ |
302 | struct GNUNET_NETWORK_Handle *mhd_unix_socket; | 299 | struct GNUNET_NETWORK_Handle *mhd_unix_socket; |
303 | 300 | ||
304 | /* Shorten names? */ | 301 | /* Shorten zone private key */ |
305 | int use_shorten; | 302 | struct GNUNET_CRYPTO_RsaPrivateKey *shorten_zonekey; |
306 | 303 | ||
307 | /** | 304 | /** |
308 | * Checks if name is in tld | 305 | * Checks if name is in tld |
@@ -1110,9 +1107,9 @@ process_get_authority (void *cls, | |||
1110 | GNUNET_GNS_lookup_zone (gns_handle, | 1107 | GNUNET_GNS_lookup_zone (gns_handle, |
1111 | ctask->host, | 1108 | ctask->host, |
1112 | &local_gns_zone, | 1109 | &local_gns_zone, |
1113 | &local_shorten_zone, | ||
1114 | GNUNET_GNS_RECORD_LEHO, | 1110 | GNUNET_GNS_RECORD_LEHO, |
1115 | GNUNET_YES, //Only cached for performance | 1111 | GNUNET_YES, //Only cached for performance |
1112 | shorten_zonekey, | ||
1116 | &process_leho_lookup, | 1113 | &process_leho_lookup, |
1117 | ctask); | 1114 | ctask); |
1118 | } | 1115 | } |
@@ -2366,58 +2363,6 @@ load_local_zone_key (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
2366 | } | 2363 | } |
2367 | 2364 | ||
2368 | /** | 2365 | /** |
2369 | * Loads the users local shorten zone key | ||
2370 | * | ||
2371 | * @return GNUNET_YES on success | ||
2372 | */ | ||
2373 | static int | ||
2374 | load_local_shorten_key (const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
2375 | { | ||
2376 | char *keyfile; | ||
2377 | struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL; | ||
2378 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; | ||
2379 | struct GNUNET_CRYPTO_ShortHashCode *zone = NULL; | ||
2380 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename; | ||
2381 | |||
2382 | if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_yesno (cfg, "gns", | ||
2383 | "AUTO_IMPORT_PKEY")) | ||
2384 | { | ||
2385 | return GNUNET_NO; | ||
2386 | } | ||
2387 | |||
2388 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", | ||
2389 | "AUTO_IMPORT_ZONEKEY", | ||
2390 | &keyfile)) | ||
2391 | { | ||
2392 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2393 | "Unable to load shorten key config value! (not fatal)\n"); | ||
2394 | return GNUNET_NO; | ||
2395 | } | ||
2396 | |||
2397 | if (GNUNET_NO == GNUNET_DISK_file_test (keyfile)) | ||
2398 | { | ||
2399 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2400 | "Unable to load shorten key %s! (not fatal)\n", keyfile); | ||
2401 | GNUNET_free(keyfile); | ||
2402 | return GNUNET_NO; | ||
2403 | } | ||
2404 | |||
2405 | key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | ||
2406 | GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); | ||
2407 | GNUNET_CRYPTO_short_hash(&pkey, | ||
2408 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
2409 | &local_shorten_zone); | ||
2410 | zone = &local_gns_zone; | ||
2411 | GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename); | ||
2412 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2413 | "Using shorten zone: %s!\n", &zonename); | ||
2414 | GNUNET_CRYPTO_rsa_key_free(key); | ||
2415 | GNUNET_free(keyfile); | ||
2416 | |||
2417 | return GNUNET_YES; | ||
2418 | } | ||
2419 | |||
2420 | /** | ||
2421 | * Main function that will be run | 2366 | * Main function that will be run |
2422 | * | 2367 | * |
2423 | * @param cls closure | 2368 | * @param cls closure |
@@ -2436,6 +2381,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
2436 | char* proxy_sockfile; | 2381 | char* proxy_sockfile; |
2437 | char* cafile_cfg = NULL; | 2382 | char* cafile_cfg = NULL; |
2438 | char* cafile; | 2383 | char* cafile; |
2384 | char* shorten_keyfile; | ||
2439 | 2385 | ||
2440 | curl_multi = NULL; | 2386 | curl_multi = NULL; |
2441 | 2387 | ||
@@ -2471,7 +2417,26 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
2471 | 2417 | ||
2472 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2418 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2473 | "Loading Template\n"); | 2419 | "Loading Template\n"); |
2474 | 2420 | ||
2421 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns-proxy", | ||
2422 | "PROXY_CACERT", | ||
2423 | &shorten_keyfile)) | ||
2424 | { | ||
2425 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2426 | "Unable to load shorten zonekey config value!\n"); | ||
2427 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2428 | "No shorten key provided!\n"); | ||
2429 | return; | ||
2430 | } | ||
2431 | else | ||
2432 | { | ||
2433 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2434 | "Loading shorten zonekey %s!\n", | ||
2435 | shorten_keyfile); | ||
2436 | shorten_zonekey = GNUNET_CRYPTO_rsa_key_create_from_file (shorten_keyfile); | ||
2437 | GNUNET_free (shorten_keyfile); | ||
2438 | } | ||
2439 | |||
2475 | compile_regex (&re_dotplus, (char*) RE_A_HREF); | 2440 | compile_regex (&re_dotplus, (char*) RE_A_HREF); |
2476 | 2441 | ||
2477 | gns_handle = GNUNET_GNS_connect (cfg); | 2442 | gns_handle = GNUNET_GNS_connect (cfg); |
@@ -2483,8 +2448,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
2483 | return; | 2448 | return; |
2484 | } | 2449 | } |
2485 | 2450 | ||
2486 | use_shorten = load_local_shorten_key (cfg); | ||
2487 | |||
2488 | if (NULL == gns_handle) | 2451 | if (NULL == gns_handle) |
2489 | { | 2452 | { |
2490 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2453 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c index 6b0ae5dca..a1614e7dd 100644 --- a/src/gns/gnunet-gns.c +++ b/src/gns/gnunet-gns.c | |||
@@ -149,10 +149,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
149 | struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL; | 149 | struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL; |
150 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; | 150 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; |
151 | struct GNUNET_CRYPTO_ShortHashCode *zone = NULL; | 151 | struct GNUNET_CRYPTO_ShortHashCode *zone = NULL; |
152 | struct GNUNET_CRYPTO_ShortHashCode *shorten_zone = NULL; | ||
153 | struct GNUNET_CRYPTO_ShortHashCode user_zone; | 152 | struct GNUNET_CRYPTO_ShortHashCode user_zone; |
154 | struct GNUNET_CRYPTO_ShortHashCode user_shorten_zone; | ||
155 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename; | 153 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename; |
154 | struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key = NULL; | ||
156 | 155 | ||
157 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", | 156 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", |
158 | "ZONEKEY", &keyfile)) | 157 | "ZONEKEY", &keyfile)) |
@@ -182,29 +181,18 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
182 | } | 181 | } |
183 | 182 | ||
184 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", | 183 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", |
185 | "AUTO_IMPORT_ZONEKEY", | 184 | "SHORTEN_ZONEKEY", &keyfile)) |
186 | &keyfile)) | ||
187 | { | 185 | { |
188 | if (!raw) | 186 | if (!raw) |
189 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 187 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
190 | "No private key for shorten zone found!\n"); | 188 | "No shorten key found!\n"); |
191 | shorten_zone = NULL; | 189 | shorten_key = NULL; |
192 | } | 190 | } |
193 | else | 191 | else |
194 | { | 192 | { |
195 | if (GNUNET_YES == GNUNET_DISK_file_test (keyfile)) | 193 | if (GNUNET_YES == GNUNET_DISK_file_test (keyfile)) |
196 | { | 194 | { |
197 | key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | 195 | shorten_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); |
198 | GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); | ||
199 | GNUNET_CRYPTO_short_hash(&pkey, | ||
200 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
201 | &user_shorten_zone); | ||
202 | shorten_zone = &user_shorten_zone; | ||
203 | GNUNET_CRYPTO_short_hash_to_enc (shorten_zone, &zonename); | ||
204 | if (!raw) | ||
205 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
206 | "Using shorten zone: %s!\n", &zonename); | ||
207 | GNUNET_CRYPTO_rsa_key_free(key); | ||
208 | } | 196 | } |
209 | GNUNET_free(keyfile); | 197 | GNUNET_free(keyfile); |
210 | } | 198 | } |
@@ -226,7 +214,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
226 | { | 214 | { |
227 | /** shorten name */ | 215 | /** shorten name */ |
228 | GNUNET_GNS_shorten_zone (gns, shorten_name, | 216 | GNUNET_GNS_shorten_zone (gns, shorten_name, |
229 | zone, shorten_zone, | 217 | zone, |
230 | &process_shorten_result, | 218 | &process_shorten_result, |
231 | shorten_name); | 219 | shorten_name); |
232 | } | 220 | } |
@@ -236,9 +224,10 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
236 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 224 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
237 | "Lookup\n"); | 225 | "Lookup\n"); |
238 | GNUNET_GNS_lookup_zone (gns, lookup_name, | 226 | GNUNET_GNS_lookup_zone (gns, lookup_name, |
239 | zone, shorten_zone, | 227 | zone, |
240 | rtype, | 228 | rtype, |
241 | GNUNET_YES, //Use DHT | 229 | GNUNET_YES, //Use DHT |
230 | shorten_key, | ||
242 | &process_lookup_result, lookup_name); | 231 | &process_lookup_result, lookup_name); |
243 | } | 232 | } |
244 | 233 | ||
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 8f8340207..79aedccf4 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -64,8 +64,16 @@ struct ClientShortenHandle | |||
64 | struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key; | 64 | struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key; |
65 | 65 | ||
66 | /* name to shorten */ | 66 | /* name to shorten */ |
67 | char* name; | 67 | char name[MAX_DNS_NAME_LENGTH]; |
68 | 68 | ||
69 | /* root zone */ | ||
70 | struct GNUNET_CRYPTO_ShortHashCode root_zone; | ||
71 | |||
72 | /* private zone */ | ||
73 | struct GNUNET_CRYPTO_ShortHashCode private_zone; | ||
74 | |||
75 | /* shorten zone */ | ||
76 | struct GNUNET_CRYPTO_ShortHashCode shorten_zone; | ||
69 | }; | 77 | }; |
70 | 78 | ||
71 | 79 | ||
@@ -94,6 +102,12 @@ struct ClientLookupHandle | |||
94 | /* the requesting client that */ | 102 | /* the requesting client that */ |
95 | struct GNUNET_SERVER_Client *client; | 103 | struct GNUNET_SERVER_Client *client; |
96 | 104 | ||
105 | /* The zone we look up in */ | ||
106 | struct GNUNET_CRYPTO_ShortHashCode zone; | ||
107 | |||
108 | /* Do we only want to lookup from local cache? */ | ||
109 | int only_cached; | ||
110 | |||
97 | /* request id */ | 111 | /* request id */ |
98 | uint64_t unique_id; | 112 | uint64_t unique_id; |
99 | 113 | ||
@@ -167,6 +181,12 @@ static int auto_import_pkey; | |||
167 | /* lookup timeout */ | 181 | /* lookup timeout */ |
168 | static struct GNUNET_TIME_Relative default_lookup_timeout; | 182 | static struct GNUNET_TIME_Relative default_lookup_timeout; |
169 | 183 | ||
184 | /* name of the private zone */ | ||
185 | static char *private_zone_id; | ||
186 | |||
187 | /* name of the public zone */ | ||
188 | static char *shorten_zone_id; | ||
189 | |||
170 | /** | 190 | /** |
171 | * Continue shutdown | 191 | * Continue shutdown |
172 | */ | 192 | */ |
@@ -424,56 +444,6 @@ update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
424 | NULL); | 444 | NULL); |
425 | } | 445 | } |
426 | 446 | ||
427 | /** | ||
428 | * Lookup the shorten key for the zone | ||
429 | * | ||
430 | * @param short_zone the zone we want a private key for | ||
431 | * @return NULL of not found else the key | ||
432 | */ | ||
433 | struct GNUNET_CRYPTO_RsaPrivateKey* | ||
434 | lookup_shorten_key(struct GNUNET_CRYPTO_ShortHashCode *short_zone) | ||
435 | { | ||
436 | char* keydir; | ||
437 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename; | ||
438 | char* location; | ||
439 | struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL; | ||
440 | |||
441 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
442 | "Looking for shorten zonekey\n"); | ||
443 | |||
444 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (GNS_cfg, | ||
445 | "namestore", | ||
446 | "ZONEFILE_DIRECTORY", &keydir)) | ||
447 | { | ||
448 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
449 | "No zonefile directory!\n"); | ||
450 | return NULL; | ||
451 | } | ||
452 | |||
453 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
454 | "Zonefile directory is %s\n", keydir); | ||
455 | |||
456 | GNUNET_CRYPTO_short_hash_to_enc (short_zone, &zonename); | ||
457 | |||
458 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
459 | "Zonefile for shorten is %s.zkey\n", &zonename); | ||
460 | |||
461 | GNUNET_asprintf(&location, "%s%s%s.zkey", keydir, | ||
462 | DIR_SEPARATOR_STR, &zonename); | ||
463 | |||
464 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
465 | "Checking for %s\n", location); | ||
466 | |||
467 | if (GNUNET_YES == GNUNET_DISK_file_test (location)) | ||
468 | key = GNUNET_CRYPTO_rsa_key_create_from_file (location); | ||
469 | |||
470 | GNUNET_free(location); | ||
471 | GNUNET_free(keydir); | ||
472 | |||
473 | return key; | ||
474 | |||
475 | } | ||
476 | |||
477 | /* END DHT ZONE PROPAGATION */ | 447 | /* END DHT ZONE PROPAGATION */ |
478 | 448 | ||
479 | /** | 449 | /** |
@@ -512,12 +482,115 @@ send_shorten_response(void* cls, const char* name) | |||
512 | GNUNET_SERVER_receive_done (csh->client, GNUNET_OK); | 482 | GNUNET_SERVER_receive_done (csh->client, GNUNET_OK); |
513 | 483 | ||
514 | GNUNET_free(rmsg); | 484 | GNUNET_free(rmsg); |
515 | GNUNET_free_non_null(csh->name); | ||
516 | GNUNET_free_non_null(csh->shorten_key); | 485 | GNUNET_free_non_null(csh->shorten_key); |
517 | GNUNET_free(csh); | 486 | GNUNET_free(csh); |
518 | 487 | ||
519 | } | 488 | } |
520 | 489 | ||
490 | |||
491 | static void | ||
492 | process_shorten_zone_shorten (void *cls, | ||
493 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key, | ||
494 | struct GNUNET_TIME_Absolute expiration, | ||
495 | const char *name, | ||
496 | unsigned int rd_count, | ||
497 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
498 | const struct GNUNET_CRYPTO_RsaSignature *signature) | ||
499 | { | ||
500 | struct ClientShortenHandle *csh = cls; | ||
501 | struct GNUNET_TIME_Relative remaining_time; | ||
502 | |||
503 | remaining_time = GNUNET_TIME_absolute_get_remaining (expiration); | ||
504 | |||
505 | if ((rd_count == 1) && | ||
506 | (remaining_time.rel_value != 0)) | ||
507 | { | ||
508 | remaining_time = GNUNET_TIME_absolute_get_remaining (rd->expiration); | ||
509 | if ((rd->record_type == GNUNET_GNS_RECORD_PKEY) && | ||
510 | (remaining_time.rel_value != 0)) | ||
511 | { | ||
512 | csh->shorten_zone = *((struct GNUNET_CRYPTO_ShortHashCode*)rd->data); | ||
513 | } | ||
514 | } | ||
515 | gns_resolver_shorten_name (&csh->root_zone, | ||
516 | &csh->private_zone, | ||
517 | &csh->shorten_zone, | ||
518 | csh->name, | ||
519 | private_zone_id, | ||
520 | shorten_zone_id, | ||
521 | &send_shorten_response, csh); | ||
522 | |||
523 | } | ||
524 | |||
525 | static void | ||
526 | process_private_zone_shorten (void *cls, | ||
527 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key, | ||
528 | struct GNUNET_TIME_Absolute expiration, | ||
529 | const char *name, | ||
530 | unsigned int rd_count, | ||
531 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
532 | const struct GNUNET_CRYPTO_RsaSignature *signature) | ||
533 | { | ||
534 | struct GNUNET_TIME_Relative remaining_time; | ||
535 | struct ClientShortenHandle *csh = cls; | ||
536 | |||
537 | remaining_time = GNUNET_TIME_absolute_get_remaining (expiration); | ||
538 | |||
539 | if ((rd_count == 1) && | ||
540 | (remaining_time.rel_value != 0)) | ||
541 | { | ||
542 | remaining_time = GNUNET_TIME_absolute_get_remaining (rd->expiration); | ||
543 | if ((rd->record_type == GNUNET_GNS_RECORD_PKEY) && | ||
544 | (remaining_time.rel_value != 0)) | ||
545 | { | ||
546 | |||
547 | |||
548 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
549 | "Looking for shorten zone in private zone\n"); | ||
550 | csh->private_zone = *((struct GNUNET_CRYPTO_ShortHashCode*)rd->data); | ||
551 | GNUNET_NAMESTORE_lookup_record (namestore_handle, | ||
552 | &csh->private_zone, | ||
553 | shorten_zone_id, | ||
554 | GNUNET_GNS_RECORD_ANY, | ||
555 | &process_shorten_zone_shorten, | ||
556 | cls); | ||
557 | } | ||
558 | return; | ||
559 | } | ||
560 | |||
561 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
562 | "No private zone found!\n"); | ||
563 | gns_resolver_shorten_name (&csh->root_zone, | ||
564 | &csh->private_zone, | ||
565 | &csh->shorten_zone, | ||
566 | csh->name, | ||
567 | private_zone_id, | ||
568 | shorten_zone_id, | ||
569 | &send_shorten_response, csh); | ||
570 | |||
571 | } | ||
572 | |||
573 | /** | ||
574 | * Lookup the zone infos and shorten name | ||
575 | * | ||
576 | * @param csh the shorten handle | ||
577 | * | ||
578 | */ | ||
579 | static void | ||
580 | start_shorten_name (struct ClientShortenHandle *csh) | ||
581 | { | ||
582 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
583 | "Looking for private zone in root zone\n"); | ||
584 | |||
585 | GNUNET_NAMESTORE_lookup_record (namestore_handle, | ||
586 | &csh->root_zone, | ||
587 | private_zone_id, | ||
588 | GNUNET_GNS_RECORD_ANY, | ||
589 | &process_private_zone_shorten, | ||
590 | csh); | ||
591 | } | ||
592 | |||
593 | |||
521 | /** | 594 | /** |
522 | * Handle a shorten message from the api | 595 | * Handle a shorten message from the api |
523 | * | 596 | * |
@@ -525,9 +598,9 @@ send_shorten_response(void* cls, const char* name) | |||
525 | * @param client the client | 598 | * @param client the client |
526 | * @param message the message | 599 | * @param message the message |
527 | */ | 600 | */ |
528 | static void handle_shorten(void *cls, | 601 | static void handle_shorten (void *cls, |
529 | struct GNUNET_SERVER_Client * client, | 602 | struct GNUNET_SERVER_Client * client, |
530 | const struct GNUNET_MessageHeader * message) | 603 | const struct GNUNET_MessageHeader * message) |
531 | { | 604 | { |
532 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "SHORTEN"); | 605 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "SHORTEN"); |
533 | 606 | ||
@@ -535,8 +608,6 @@ static void handle_shorten(void *cls, | |||
535 | struct ClientShortenHandle *csh; | 608 | struct ClientShortenHandle *csh; |
536 | char name[MAX_DNS_NAME_LENGTH]; | 609 | char name[MAX_DNS_NAME_LENGTH]; |
537 | char* nameptr = name; | 610 | char* nameptr = name; |
538 | struct GNUNET_CRYPTO_ShortHashCode zone; | ||
539 | struct GNUNET_CRYPTO_RsaPrivateKey *key; | ||
540 | 611 | ||
541 | if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientShortenMessage)) | 612 | if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientShortenMessage)) |
542 | { | 613 | { |
@@ -568,7 +639,6 @@ static void handle_shorten(void *cls, | |||
568 | if (strlen (name) < strlen(GNUNET_GNS_TLD)) { | 639 | if (strlen (name) < strlen(GNUNET_GNS_TLD)) { |
569 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 640 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
570 | "SHORTEN: %s is too short", name); | 641 | "SHORTEN: %s is too short", name); |
571 | csh->name = NULL; | ||
572 | send_shorten_response(csh, name); | 642 | send_shorten_response(csh, name); |
573 | return; | 643 | return; |
574 | } | 644 | } |
@@ -576,7 +646,6 @@ static void handle_shorten(void *cls, | |||
576 | if (strlen (name) > MAX_DNS_NAME_LENGTH) { | 646 | if (strlen (name) > MAX_DNS_NAME_LENGTH) { |
577 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 647 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
578 | "SHORTEN: %s is too long", name); | 648 | "SHORTEN: %s is too long", name); |
579 | csh->name = NULL; | ||
580 | send_shorten_response(csh, name); | 649 | send_shorten_response(csh, name); |
581 | return; | 650 | return; |
582 | } | 651 | } |
@@ -585,34 +654,21 @@ static void handle_shorten(void *cls, | |||
585 | { | 654 | { |
586 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 655 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
587 | "%s is not our domain. Returning\n", name); | 656 | "%s is not our domain. Returning\n", name); |
588 | csh->name = NULL; | ||
589 | send_shorten_response(csh, name); | 657 | send_shorten_response(csh, name); |
590 | return; | 658 | return; |
591 | } | 659 | } |
660 | |||
661 | strcpy (csh->name, name); | ||
592 | 662 | ||
593 | GNUNET_SERVER_notification_context_add (nc, client); | 663 | GNUNET_SERVER_notification_context_add (nc, client); |
594 | 664 | ||
595 | if (1 == ntohl(sh_msg->use_default_zone)) | 665 | if (1 == ntohl(sh_msg->use_default_zone)) |
596 | zone = zone_hash; //Default zone | 666 | csh->root_zone = zone_hash; //Default zone |
597 | else | 667 | else |
598 | zone = sh_msg->zone; | 668 | csh->root_zone = sh_msg->zone; |
669 | |||
670 | start_shorten_name (csh); | ||
599 | 671 | ||
600 | /* Start shortening */ | ||
601 | if (GNUNET_YES == auto_import_pkey) | ||
602 | { | ||
603 | if (0 == ntohl(sh_msg->use_shorten_zone)) | ||
604 | key = NULL; | ||
605 | else | ||
606 | { | ||
607 | key = lookup_shorten_key(&sh_msg->shorten_zone); | ||
608 | csh->shorten_key = key; | ||
609 | } | ||
610 | gns_resolver_shorten_name(zone, zone, name, key, | ||
611 | &send_shorten_response, csh); | ||
612 | } | ||
613 | else | ||
614 | gns_resolver_shorten_name(zone, zone, name, NULL, | ||
615 | &send_shorten_response, csh); | ||
616 | } | 672 | } |
617 | 673 | ||
618 | 674 | ||
@@ -823,9 +879,10 @@ handle_lookup(void *cls, | |||
823 | char name[MAX_DNS_NAME_LENGTH]; | 879 | char name[MAX_DNS_NAME_LENGTH]; |
824 | struct ClientLookupHandle *clh; | 880 | struct ClientLookupHandle *clh; |
825 | char* nameptr = name; | 881 | char* nameptr = name; |
826 | struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL; | ||
827 | struct GNUNET_CRYPTO_ShortHashCode zone; | ||
828 | int only_cached; | 882 | int only_cached; |
883 | struct GNUNET_CRYPTO_RsaPrivateKey *key; | ||
884 | struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *pkey; | ||
885 | char* tmp_pkey; | ||
829 | 886 | ||
830 | if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientLookupMessage)) | 887 | if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientLookupMessage)) |
831 | { | 888 | { |
@@ -847,8 +904,20 @@ handle_lookup(void *cls, | |||
847 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 904 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
848 | return; | 905 | return; |
849 | } | 906 | } |
907 | |||
908 | if (1 == ntohl(sh_msg->have_key)) | ||
909 | { | ||
910 | pkey = (struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *)&sh_msg[1]; | ||
911 | tmp_pkey = (char*)&sh_msg[1]; | ||
912 | key = GNUNET_CRYPTO_rsa_decode_key (tmp_pkey, ntohs(pkey->len)); | ||
913 | GNUNET_STRINGS_utf8_tolower(&tmp_pkey[ntohs(pkey->len)], &nameptr); | ||
914 | } | ||
915 | else | ||
916 | { | ||
917 | key = NULL; | ||
918 | GNUNET_STRINGS_utf8_tolower((char*)&sh_msg[1], &nameptr); | ||
919 | } | ||
850 | 920 | ||
851 | GNUNET_STRINGS_utf8_tolower((char*)&sh_msg[1], &nameptr); | ||
852 | namelen = strlen(name)+1; | 921 | namelen = strlen(name)+1; |
853 | clh = GNUNET_malloc(sizeof(struct ClientLookupHandle)); | 922 | clh = GNUNET_malloc(sizeof(struct ClientLookupHandle)); |
854 | clh->client = client; | 923 | clh->client = client; |
@@ -856,7 +925,7 @@ handle_lookup(void *cls, | |||
856 | strcpy(clh->name, name); | 925 | strcpy(clh->name, name); |
857 | clh->unique_id = sh_msg->id; | 926 | clh->unique_id = sh_msg->id; |
858 | clh->type = ntohl(sh_msg->type); | 927 | clh->type = ntohl(sh_msg->type); |
859 | clh->shorten_key = NULL; | 928 | clh->shorten_key = key; |
860 | 929 | ||
861 | only_cached = ntohl(sh_msg->only_cached); | 930 | only_cached = ntohl(sh_msg->only_cached); |
862 | 931 | ||
@@ -869,33 +938,25 @@ handle_lookup(void *cls, | |||
869 | } | 938 | } |
870 | 939 | ||
871 | if (1 == ntohl(sh_msg->use_default_zone)) | 940 | if (1 == ntohl(sh_msg->use_default_zone)) |
872 | zone = zone_hash; //Default zone | 941 | clh->zone = zone_hash; //Default zone |
873 | else | 942 | else |
874 | zone = sh_msg->zone; | 943 | clh->zone = sh_msg->zone; |
875 | 944 | ||
876 | if (GNUNET_YES == auto_import_pkey) | 945 | if (GNUNET_YES == auto_import_pkey) |
877 | { | 946 | { |
878 | if (1 == ntohl(sh_msg->use_shorten_zone)) | 947 | gns_resolver_lookup_record (clh->zone, clh->zone, clh->type, clh->name, |
879 | key = zone_key; | 948 | clh->shorten_key, |
880 | else | 949 | default_lookup_timeout, |
881 | { | 950 | clh->only_cached, |
882 | key = lookup_shorten_key(&sh_msg->shorten_zone); | 951 | &send_lookup_response, clh); |
883 | clh->shorten_key = key; | ||
884 | } | ||
885 | |||
886 | gns_resolver_lookup_record(zone, zone, clh->type, name, | ||
887 | key, | ||
888 | default_lookup_timeout, | ||
889 | only_cached, | ||
890 | &send_lookup_response, clh); | ||
891 | } | 952 | } |
892 | else | 953 | else |
893 | { | 954 | { |
894 | gns_resolver_lookup_record(zone, zone, clh->type, name, | 955 | gns_resolver_lookup_record (clh->zone, clh->zone, clh->type, name, |
895 | NULL, | 956 | NULL, |
896 | default_lookup_timeout, | 957 | default_lookup_timeout, |
897 | only_cached, | 958 | only_cached, |
898 | &send_lookup_response, clh); | 959 | &send_lookup_response, clh); |
899 | } | 960 | } |
900 | } | 961 | } |
901 | 962 | ||
@@ -977,6 +1038,22 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
977 | 1038 | ||
978 | } | 1039 | } |
979 | 1040 | ||
1041 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (c, "gns", | ||
1042 | "PRIVATE_ZONE", | ||
1043 | &private_zone_id)) | ||
1044 | { | ||
1045 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
1046 | "Private zone id: %s\n", private_zone_id); | ||
1047 | } | ||
1048 | |||
1049 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (c, "gns", | ||
1050 | "SHORTEN_ZONE", | ||
1051 | &shorten_zone_id)) | ||
1052 | { | ||
1053 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
1054 | "Shorten zone id: %s\n", shorten_zone_id); | ||
1055 | } | ||
1056 | |||
980 | dht_max_update_interval = GNUNET_GNS_DHT_MAX_UPDATE_INTERVAL; | 1057 | dht_max_update_interval = GNUNET_GNS_DHT_MAX_UPDATE_INTERVAL; |
981 | 1058 | ||
982 | if (GNUNET_OK == | 1059 | if (GNUNET_OK == |
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 71f42e941..ff7842758 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -168,6 +168,7 @@ process_pseu_lookup_ns (void* cls, | |||
168 | GNUNET_free (gph->ahead); | 168 | GNUNET_free (gph->ahead); |
169 | gph->ahead = iter; | 169 | gph->ahead = iter; |
170 | } while (iter != NULL); | 170 | } while (iter != NULL); |
171 | GNUNET_CRYPTO_rsa_key_free (gph->key); | ||
171 | 172 | ||
172 | GNUNET_free (gph); | 173 | GNUNET_free (gph); |
173 | return; | 174 | return; |
@@ -208,8 +209,8 @@ process_pseu_lookup_ns (void* cls, | |||
208 | GNUNET_free (gph->ahead); | 209 | GNUNET_free (gph->ahead); |
209 | gph->ahead = iter; | 210 | gph->ahead = iter; |
210 | } while (iter != NULL); | 211 | } while (iter != NULL); |
211 | 212 | GNUNET_CRYPTO_rsa_key_free (gph->key); | |
212 | GNUNET_free(gph); | 213 | GNUNET_free (gph); |
213 | 214 | ||
214 | } | 215 | } |
215 | 216 | ||
@@ -329,7 +330,7 @@ process_auth_discovery_dht_result(void* cls, | |||
329 | GNUNET_free (gph->ahead); | 330 | GNUNET_free (gph->ahead); |
330 | gph->ahead = iter; | 331 | gph->ahead = iter; |
331 | } while (iter != NULL); | 332 | } while (iter != NULL); |
332 | 333 | GNUNET_CRYPTO_rsa_key_free (gph->key); | |
333 | GNUNET_free (gph); | 334 | GNUNET_free (gph); |
334 | return; | 335 | return; |
335 | } | 336 | } |
@@ -528,7 +529,7 @@ process_zone_to_name_discover (void *cls, | |||
528 | GNUNET_free (gph->ahead); | 529 | GNUNET_free (gph->ahead); |
529 | gph->ahead = iter; | 530 | gph->ahead = iter; |
530 | } while (iter != NULL); | 531 | } while (iter != NULL); |
531 | 532 | GNUNET_CRYPTO_rsa_key_free (gph->key); | |
532 | GNUNET_free (gph); | 533 | GNUNET_free (gph); |
533 | } | 534 | } |
534 | else | 535 | else |
@@ -579,6 +580,7 @@ start_shorten (struct AuthorityChain *atail, | |||
579 | struct AuthorityChain *acopy; | 580 | struct AuthorityChain *acopy; |
580 | struct GetPseuAuthorityHandle *gph; | 581 | struct GetPseuAuthorityHandle *gph; |
581 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; | 582 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; |
583 | struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *pb_key; | ||
582 | 584 | ||
583 | /* First copy the authority chain in reverse order */ | 585 | /* First copy the authority chain in reverse order */ |
584 | for (iter = atail; iter != NULL; iter = iter->prev) | 586 | for (iter = atail; iter != NULL; iter = iter->prev) |
@@ -593,7 +595,9 @@ start_shorten (struct AuthorityChain *atail, | |||
593 | gph = GNUNET_malloc (sizeof (struct GetPseuAuthorityHandle)); | 595 | gph = GNUNET_malloc (sizeof (struct GetPseuAuthorityHandle)); |
594 | 596 | ||
595 | GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); | 597 | GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); |
596 | gph->key = key;//GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_RsaPrivateKey)); | 598 | pb_key = GNUNET_CRYPTO_rsa_encode_key (key); |
599 | gph->key = GNUNET_CRYPTO_rsa_decode_key ((char*)pb_key, ntohs (pb_key->len)); | ||
600 | //gph->key = key;//GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_RsaPrivateKey)); | ||
597 | //memcpy (gph->key, key, sizeof (struct GNUNET_CRYPTO_RsaPrivateKey)); | 601 | //memcpy (gph->key, key, sizeof (struct GNUNET_CRYPTO_RsaPrivateKey)); |
598 | 602 | ||
599 | GNUNET_CRYPTO_short_hash (&pkey, | 603 | GNUNET_CRYPTO_short_hash (&pkey, |
@@ -2293,6 +2297,12 @@ gns_resolver_lookup_record(struct GNUNET_CRYPTO_ShortHashCode zone, | |||
2293 | rh->get_handle = NULL; | 2297 | rh->get_handle = NULL; |
2294 | rh->private_local_zone = pzone; | 2298 | rh->private_local_zone = pzone; |
2295 | rh->only_cached = only_cached; | 2299 | rh->only_cached = only_cached; |
2300 | |||
2301 | if (NULL == key) | ||
2302 | { | ||
2303 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2304 | "No shorten key for resolution\n"); | ||
2305 | } | ||
2296 | 2306 | ||
2297 | if (timeout.rel_value != GNUNET_TIME_UNIT_FOREVER_REL.rel_value) | 2307 | if (timeout.rel_value != GNUNET_TIME_UNIT_FOREVER_REL.rel_value) |
2298 | { | 2308 | { |
@@ -2394,7 +2404,6 @@ gns_resolver_lookup_record(struct GNUNET_CRYPTO_ShortHashCode zone, | |||
2394 | 2404 | ||
2395 | /******** END Record Resolver ***********/ | 2405 | /******** END Record Resolver ***********/ |
2396 | 2406 | ||
2397 | |||
2398 | /** | 2407 | /** |
2399 | * Callback calles by namestore for a zone to name | 2408 | * Callback calles by namestore for a zone to name |
2400 | * result | 2409 | * result |
@@ -2408,7 +2417,29 @@ gns_resolver_lookup_record(struct GNUNET_CRYPTO_ShortHashCode zone, | |||
2408 | * @param signature the signature for the record data | 2417 | * @param signature the signature for the record data |
2409 | */ | 2418 | */ |
2410 | static void | 2419 | static void |
2411 | process_zone_to_name_shorten(void *cls, | 2420 | process_zone_to_name_shorten_root (void *cls, |
2421 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | ||
2422 | struct GNUNET_TIME_Absolute expire, | ||
2423 | const char *name, | ||
2424 | unsigned int rd_len, | ||
2425 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
2426 | const struct GNUNET_CRYPTO_RsaSignature *signature); | ||
2427 | |||
2428 | |||
2429 | /** | ||
2430 | * Callback called by namestore for a zone to name | ||
2431 | * result | ||
2432 | * | ||
2433 | * @param cls the closure | ||
2434 | * @param zone_key the zone we queried | ||
2435 | * @param expire the expiration time of the name | ||
2436 | * @param name the name found or NULL | ||
2437 | * @param rd_len number of records for the name | ||
2438 | * @param rd the record data (PKEY) for the name | ||
2439 | * @param signature the signature for the record data | ||
2440 | */ | ||
2441 | static void | ||
2442 | process_zone_to_name_shorten_shorten (void *cls, | ||
2412 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | 2443 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, |
2413 | struct GNUNET_TIME_Absolute expire, | 2444 | struct GNUNET_TIME_Absolute expire, |
2414 | const char *name, | 2445 | const char *name, |
@@ -2424,53 +2455,184 @@ process_zone_to_name_shorten(void *cls, | |||
2424 | char tmp_name[MAX_DNS_NAME_LENGTH]; | 2455 | char tmp_name[MAX_DNS_NAME_LENGTH]; |
2425 | size_t answer_len; | 2456 | size_t answer_len; |
2426 | 2457 | ||
2427 | /* we found a match in our own zone */ | 2458 | /* we found a match in our own root zone */ |
2428 | if (rd_len != 0) | 2459 | if (rd_len != 0) |
2429 | { | 2460 | { |
2430 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2461 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
2431 | "result strlen %d\n", strlen(name)); | 2462 | "result strlen %d\n", strlen(name)); |
2432 | answer_len = strlen(rh->name) + strlen(name) + strlen(GNUNET_GNS_TLD) + 3; | 2463 | answer_len = strlen(rh->name) + strlen(name) + strlen(GNUNET_GNS_TLD) + 3; |
2433 | memset(result, 0, answer_len); | 2464 | memset(result, 0, answer_len); |
2465 | |||
2434 | if (strlen(rh->name) > 0) | 2466 | if (strlen(rh->name) > 0) |
2435 | { | 2467 | { |
2436 | strcpy(result, rh->name); | 2468 | sprintf (result, "%s.%s.%s.%s.%s", |
2437 | strcpy(result+strlen(rh->name), "."); | 2469 | rh->name, name, |
2470 | nsh->shorten_zone_name, nsh->private_zone_name, | ||
2471 | GNUNET_GNS_TLD); | ||
2472 | } | ||
2473 | else | ||
2474 | { | ||
2475 | sprintf (result, "%s.%s.%s.%s", name, | ||
2476 | nsh->shorten_zone_name, nsh->private_zone_name, | ||
2477 | GNUNET_GNS_TLD); | ||
2438 | } | 2478 | } |
2439 | |||
2440 | strcpy(result+strlen(result), name); | ||
2441 | strcpy(result+strlen(result), "."); | ||
2442 | strcpy(result+strlen(result), GNUNET_GNS_TLD); | ||
2443 | 2479 | ||
2444 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2480 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
2445 | "Sending shorten result %s\n", result); | 2481 | "Found shorten result %s\n", result); |
2446 | 2482 | if (strlen (nsh->result) > strlen (result)) | |
2447 | nsh->proc(nsh->proc_cls, result); | 2483 | strcpy (nsh->result, result); |
2448 | GNUNET_free(nsh); | ||
2449 | free_resolver_handle(rh); | ||
2450 | } | 2484 | } |
2451 | else if (GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone, | 2485 | else if (GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone, |
2452 | &rh->private_local_zone) == 0) | 2486 | nsh->shorten_zone) == 0) |
2487 | { | ||
2488 | /** | ||
2489 | * This is our zone append .gnunet unless name is empty | ||
2490 | * (it shouldn't be, usually FIXME what happens if we | ||
2491 | * shorten to our zone to a "" record??) | ||
2492 | */ | ||
2493 | |||
2494 | sprintf (result, "%s.%s.%s.%s", | ||
2495 | rh->name, | ||
2496 | nsh->shorten_zone_name, nsh->private_zone_name, | ||
2497 | GNUNET_GNS_TLD); | ||
2498 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
2499 | "Our zone: Found %s as shorten result\n", result); | ||
2500 | |||
2501 | if (strlen (nsh->result) > strlen (result)) | ||
2502 | strcpy (nsh->result, result); | ||
2503 | //nsh->proc(nsh->proc_cls, result); | ||
2504 | //GNUNET_free(nsh); | ||
2505 | //free_resolver_handle(rh); | ||
2506 | //return; | ||
2507 | } | ||
2508 | |||
2509 | |||
2510 | /** | ||
2511 | * No PSEU found. | ||
2512 | * continue with next authority if exists | ||
2513 | */ | ||
2514 | if ((rh->authority_chain_head->next == NULL)) | ||
2515 | { | ||
2516 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2517 | "Sending %s as shorten result\n", nsh->result); | ||
2518 | nsh->proc(nsh->proc_cls, nsh->result); | ||
2519 | GNUNET_free (nsh); | ||
2520 | free_resolver_handle (rh); | ||
2521 | return; | ||
2522 | } | ||
2523 | next_authority = rh->authority_chain_head; | ||
2524 | |||
2525 | GNUNET_snprintf(tmp_name, MAX_DNS_NAME_LENGTH, | ||
2526 | "%s.%s", rh->name, next_authority->name); | ||
2527 | |||
2528 | strcpy(rh->name, tmp_name); | ||
2529 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
2530 | "No PSEU found for authority %s. Promoting back: %s\n", | ||
2531 | next_authority->name, rh->name); | ||
2532 | |||
2533 | GNUNET_CONTAINER_DLL_remove(rh->authority_chain_head, | ||
2534 | rh->authority_chain_tail, | ||
2535 | next_authority); | ||
2536 | |||
2537 | GNUNET_NAMESTORE_zone_to_name (namestore_handle, | ||
2538 | &rh->authority_chain_tail->zone, | ||
2539 | &rh->authority_chain_head->zone, | ||
2540 | &process_zone_to_name_shorten_root, | ||
2541 | rh); | ||
2542 | } | ||
2543 | |||
2544 | /** | ||
2545 | * Callback calles by namestore for a zone to name | ||
2546 | * result | ||
2547 | * | ||
2548 | * @param cls the closure | ||
2549 | * @param zone_key the zone we queried | ||
2550 | * @param expire the expiration time of the name | ||
2551 | * @param name the name found or NULL | ||
2552 | * @param rd_len number of records for the name | ||
2553 | * @param rd the record data (PKEY) for the name | ||
2554 | * @param signature the signature for the record data | ||
2555 | */ | ||
2556 | static void | ||
2557 | process_zone_to_name_shorten_private (void *cls, | ||
2558 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | ||
2559 | struct GNUNET_TIME_Absolute expire, | ||
2560 | const char *name, | ||
2561 | unsigned int rd_len, | ||
2562 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
2563 | const struct GNUNET_CRYPTO_RsaSignature *signature) | ||
2564 | { | ||
2565 | struct ResolverHandle *rh = (struct ResolverHandle *)cls; | ||
2566 | struct NameShortenHandle* nsh = (struct NameShortenHandle*)rh->proc_cls; | ||
2567 | struct AuthorityChain *next_authority; | ||
2568 | |||
2569 | char result[MAX_DNS_NAME_LENGTH]; | ||
2570 | char tmp_name[MAX_DNS_NAME_LENGTH]; | ||
2571 | size_t answer_len; | ||
2572 | |||
2573 | /* we found a match in our own root zone */ | ||
2574 | if (rd_len != 0) | ||
2453 | { | 2575 | { |
2454 | /* our zone, just append .gnunet */ | 2576 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
2455 | answer_len = strlen(rh->name) + strlen(GNUNET_GNS_TLD) + 2; | 2577 | "result strlen %d\n", strlen(name)); |
2578 | answer_len = strlen(rh->name) + strlen(name) + strlen(GNUNET_GNS_TLD) + 3; | ||
2456 | memset(result, 0, answer_len); | 2579 | memset(result, 0, answer_len); |
2457 | strcpy(result, rh->name); | ||
2458 | strcpy(result+strlen(rh->name), "."); | ||
2459 | strcpy(result+strlen(rh->name)+1, GNUNET_GNS_TLD); | ||
2460 | 2580 | ||
2581 | if (strlen(rh->name) > 0) | ||
2582 | { | ||
2583 | sprintf (result, "%s.%s.%s", rh->name, name, GNUNET_GNS_TLD); | ||
2584 | } | ||
2585 | else | ||
2586 | { | ||
2587 | sprintf (result, "%s.%s", name, GNUNET_GNS_TLD); | ||
2588 | } | ||
2589 | |||
2461 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2590 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
2462 | "Our zone: Sending name as shorten result %s\n", rh->name); | 2591 | "Found shorten result %s\n", result); |
2592 | if (strlen (nsh->result) > strlen (result)) | ||
2593 | strcpy (nsh->result, result); | ||
2594 | } | ||
2595 | else if (GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone, | ||
2596 | nsh->private_zone) == 0) | ||
2597 | { | ||
2598 | /** | ||
2599 | * This is our zone append .gnunet unless name is empty | ||
2600 | * (it shouldn't be, usually FIXME what happens if we | ||
2601 | * shorten to our zone to a "" record??) | ||
2602 | */ | ||
2463 | 2603 | ||
2464 | nsh->proc(nsh->proc_cls, result); | 2604 | sprintf (result, "%s.%s.%s", |
2465 | GNUNET_free(nsh); | 2605 | rh->name, nsh->private_zone_name, GNUNET_GNS_TLD); |
2466 | free_resolver_handle(rh); | 2606 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
2607 | "Our private zone: Found %s as shorten result %s\n", result); | ||
2608 | if (strlen (nsh->result) > strlen (result)) | ||
2609 | strcpy (nsh->result, result); | ||
2610 | } | ||
2611 | |||
2612 | if (nsh->shorten_zone != NULL) | ||
2613 | { | ||
2614 | /* backtrack authorities for names in priv zone */ | ||
2615 | GNUNET_NAMESTORE_zone_to_name (namestore_handle, | ||
2616 | nsh->shorten_zone, | ||
2617 | &rh->authority_chain_head->zone, | ||
2618 | &process_zone_to_name_shorten_shorten, | ||
2619 | rh); | ||
2467 | } | 2620 | } |
2468 | else | 2621 | else |
2469 | { | 2622 | { |
2470 | /** | 2623 | /** |
2471 | * No PSEU found. | 2624 | * No PSEU found. |
2472 | * continue with next authority | 2625 | * continue with next authority if exists |
2473 | */ | 2626 | */ |
2627 | if ((rh->authority_chain_head->next == NULL)) | ||
2628 | { | ||
2629 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
2630 | "Sending %s as shorten result\n", nsh->result); | ||
2631 | nsh->proc(nsh->proc_cls, nsh->result); | ||
2632 | GNUNET_free(nsh); | ||
2633 | free_resolver_handle(rh); | ||
2634 | return; | ||
2635 | } | ||
2474 | next_authority = rh->authority_chain_head; | 2636 | next_authority = rh->authority_chain_head; |
2475 | 2637 | ||
2476 | GNUNET_snprintf(tmp_name, MAX_DNS_NAME_LENGTH, | 2638 | GNUNET_snprintf(tmp_name, MAX_DNS_NAME_LENGTH, |
@@ -2488,32 +2650,125 @@ process_zone_to_name_shorten(void *cls, | |||
2488 | GNUNET_NAMESTORE_zone_to_name (namestore_handle, | 2650 | GNUNET_NAMESTORE_zone_to_name (namestore_handle, |
2489 | &rh->authority_chain_tail->zone, | 2651 | &rh->authority_chain_tail->zone, |
2490 | &rh->authority_chain_head->zone, | 2652 | &rh->authority_chain_head->zone, |
2491 | &process_zone_to_name_shorten, | 2653 | &process_zone_to_name_shorten_root, |
2492 | rh); | 2654 | rh); |
2493 | } | 2655 | } |
2494 | } | 2656 | } |
2495 | 2657 | ||
2496 | /** | 2658 | /** |
2497 | * DHT resolution for delegation. Processing result. | 2659 | * Callback calles by namestore for a zone to name |
2660 | * result | ||
2498 | * | 2661 | * |
2499 | * @param cls the closure | 2662 | * @param cls the closure |
2500 | * @param rh resolver handle | 2663 | * @param zone_key the zone we queried |
2501 | * @param rd_count number of results | 2664 | * @param expire the expiration time of the name |
2502 | * @param rd record data | 2665 | * @param name the name found or NULL |
2666 | * @param rd_len number of records for the name | ||
2667 | * @param rd the record data (PKEY) for the name | ||
2668 | * @param signature the signature for the record data | ||
2503 | */ | 2669 | */ |
2504 | static void | 2670 | static void |
2505 | handle_delegation_dht_bg_shorten(void* cls, struct ResolverHandle *rh, | 2671 | process_zone_to_name_shorten_root (void *cls, |
2506 | unsigned int rd_count, | 2672 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, |
2507 | const struct GNUNET_NAMESTORE_RecordData *rd) | 2673 | struct GNUNET_TIME_Absolute expire, |
2674 | const char *name, | ||
2675 | unsigned int rd_len, | ||
2676 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
2677 | const struct GNUNET_CRYPTO_RsaSignature *signature) | ||
2508 | { | 2678 | { |
2679 | struct ResolverHandle *rh = (struct ResolverHandle *)cls; | ||
2680 | struct NameShortenHandle* nsh = (struct NameShortenHandle*)rh->proc_cls; | ||
2681 | struct AuthorityChain *next_authority; | ||
2682 | |||
2683 | char result[MAX_DNS_NAME_LENGTH]; | ||
2684 | char tmp_name[MAX_DNS_NAME_LENGTH]; | ||
2685 | size_t answer_len; | ||
2509 | 2686 | ||
2510 | /* We resolved full name for delegation. resolving record */ | 2687 | /* we found a match in our own root zone */ |
2511 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2688 | if (rd_len != 0) |
2512 | "GNS_SHORTEN: Resolved up to %s for delegation via DHT in background.\n", | 2689 | { |
2513 | rh->name); | 2690 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
2514 | free_resolver_handle(rh); | 2691 | "result strlen %d\n", strlen(name)); |
2692 | answer_len = strlen(rh->name) + strlen(name) + strlen(GNUNET_GNS_TLD) + 3; | ||
2693 | memset(result, 0, answer_len); | ||
2694 | |||
2695 | if (strlen(rh->name) > 0) | ||
2696 | { | ||
2697 | sprintf (result, "%s.%s.%s", rh->name, name, GNUNET_GNS_TLD); | ||
2698 | } | ||
2699 | else | ||
2700 | { | ||
2701 | sprintf (result, "%s.%s", name, GNUNET_GNS_TLD); | ||
2702 | } | ||
2703 | |||
2704 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
2705 | "Found shorten result %s\n", result); | ||
2706 | if (strlen (nsh->result) > strlen (result)) | ||
2707 | strcpy (nsh->result, result); | ||
2708 | } | ||
2709 | else if (GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone, | ||
2710 | nsh->root_zone) == 0) | ||
2711 | { | ||
2712 | /** | ||
2713 | * This is our zone append .gnunet unless name is empty | ||
2714 | * (it shouldn't be, usually FIXME what happens if we | ||
2715 | * shorten to our zone to a "" record??) | ||
2716 | */ | ||
2717 | |||
2718 | sprintf (result, "%s.%s", rh->name, GNUNET_GNS_TLD); | ||
2719 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
2720 | "Our zone: Found %s as shorten result\n", result); | ||
2721 | if (strlen (nsh->result) > strlen (result)) | ||
2722 | strcpy (nsh->result, result); | ||
2723 | } | ||
2724 | |||
2725 | if (nsh->private_zone != NULL) | ||
2726 | { | ||
2727 | /* backtrack authorities for names in priv zone */ | ||
2728 | GNUNET_NAMESTORE_zone_to_name (namestore_handle, | ||
2729 | nsh->private_zone, | ||
2730 | &rh->authority_chain_head->zone, | ||
2731 | &process_zone_to_name_shorten_private, | ||
2732 | rh); | ||
2733 | } | ||
2734 | else | ||
2735 | { | ||
2736 | /** | ||
2737 | * No PSEU found. | ||
2738 | * continue with next authority if exists | ||
2739 | */ | ||
2740 | if ((rh->authority_chain_head->next == NULL)) | ||
2741 | { | ||
2742 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
2743 | "Sending %s as shorten result\n", nsh->result); | ||
2744 | nsh->proc(nsh->proc_cls, nsh->result); | ||
2745 | GNUNET_free(nsh); | ||
2746 | free_resolver_handle(rh); | ||
2747 | return; | ||
2748 | } | ||
2749 | next_authority = rh->authority_chain_head; | ||
2750 | |||
2751 | GNUNET_snprintf(tmp_name, MAX_DNS_NAME_LENGTH, | ||
2752 | "%s.%s", rh->name, next_authority->name); | ||
2753 | |||
2754 | strcpy(rh->name, tmp_name); | ||
2755 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
2756 | "No PSEU found for authority %s. Promoting back: %s\n", | ||
2757 | next_authority->name, rh->name); | ||
2758 | |||
2759 | GNUNET_CONTAINER_DLL_remove(rh->authority_chain_head, | ||
2760 | rh->authority_chain_tail, | ||
2761 | next_authority); | ||
2762 | |||
2763 | GNUNET_NAMESTORE_zone_to_name (namestore_handle, | ||
2764 | &rh->authority_chain_tail->zone, | ||
2765 | &rh->authority_chain_head->zone, | ||
2766 | &process_zone_to_name_shorten_root, | ||
2767 | rh); | ||
2768 | } | ||
2515 | } | 2769 | } |
2516 | 2770 | ||
2771 | |||
2517 | /** | 2772 | /** |
2518 | * Process result from namestore delegation lookup | 2773 | * Process result from namestore delegation lookup |
2519 | * for shorten operation | 2774 | * for shorten operation |
@@ -2531,8 +2786,6 @@ handle_delegation_ns_shorten(void* cls, | |||
2531 | { | 2786 | { |
2532 | struct NameShortenHandle *nsh; | 2787 | struct NameShortenHandle *nsh; |
2533 | char result[MAX_DNS_NAME_LENGTH]; | 2788 | char result[MAX_DNS_NAME_LENGTH]; |
2534 | size_t answer_len; | ||
2535 | struct ResolverHandle *rh_bg; | ||
2536 | 2789 | ||
2537 | nsh = (struct NameShortenHandle *)cls; | 2790 | nsh = (struct NameShortenHandle *)cls; |
2538 | 2791 | ||
@@ -2545,9 +2798,10 @@ handle_delegation_ns_shorten(void* cls, | |||
2545 | 2798 | ||
2546 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2799 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
2547 | "PKEY resolved as far as possible in ns up to %s!\n", rh->name); | 2800 | "PKEY resolved as far as possible in ns up to %s!\n", rh->name); |
2801 | memset(result, 0, sizeof (result)); | ||
2548 | 2802 | ||
2549 | if (GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone, | 2803 | if (GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone, |
2550 | &rh->private_local_zone) == 0) | 2804 | nsh->root_zone) == 0) |
2551 | { | 2805 | { |
2552 | /** | 2806 | /** |
2553 | * This is our zone append .gnunet unless name is empty | 2807 | * This is our zone append .gnunet unless name is empty |
@@ -2555,64 +2809,57 @@ handle_delegation_ns_shorten(void* cls, | |||
2555 | * shorten to our zone to a "" record??) | 2809 | * shorten to our zone to a "" record??) |
2556 | */ | 2810 | */ |
2557 | 2811 | ||
2558 | answer_len = strlen(rh->name) + strlen(GNUNET_GNS_TLD) + 2; | 2812 | sprintf (result, "%s.%s", rh->name, GNUNET_GNS_TLD); |
2559 | memset(result, 0, answer_len); | 2813 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
2560 | strcpy(result, rh->name); | 2814 | "Our zone: Found %s as shorten result\n", result); |
2561 | strcpy(result+strlen(rh->name), "."); | 2815 | |
2562 | strcpy(result+strlen(rh->name)+1, GNUNET_GNS_TLD); | 2816 | if (strlen (nsh->result) > strlen (result)) |
2817 | strcpy (nsh->result, result); | ||
2563 | 2818 | ||
2819 | } | ||
2820 | else if (GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone, | ||
2821 | nsh->private_zone) == 0) | ||
2822 | { | ||
2823 | /** | ||
2824 | * This is our zone append .gnunet unless name is empty | ||
2825 | * (it shouldn't be, usually FIXME what happens if we | ||
2826 | * shorten to our zone to a "" record??) | ||
2827 | */ | ||
2828 | |||
2829 | sprintf (result, "%s.%s.%s", | ||
2830 | rh->name, nsh->private_zone_name, GNUNET_GNS_TLD); | ||
2564 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2831 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
2565 | "Our zone: Sending name as shorten result %s\n", rh->name); | 2832 | "Our zone: Found %s as shorten result %s\n", result); |
2566 | 2833 | ||
2567 | nsh->proc(nsh->proc_cls, result); | 2834 | if (strlen (nsh->result) > strlen (result)) |
2568 | GNUNET_free(nsh); | 2835 | strcpy (nsh->result, result); |
2569 | free_resolver_handle(rh); | ||
2570 | return; | ||
2571 | } | 2836 | } |
2572 | 2837 | else if (GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone, | |
2573 | /** | 2838 | nsh->shorten_zone) == 0) |
2574 | * we have to this before zone to name for rh might | ||
2575 | * be freed by then | ||
2576 | */ | ||
2577 | rh_bg = NULL; | ||
2578 | if (!is_canonical(rh->name)) | ||
2579 | { | 2839 | { |
2580 | rh_bg = GNUNET_malloc(sizeof(struct ResolverHandle)); | 2840 | /** |
2581 | memcpy(rh_bg, rh, sizeof(struct ResolverHandle)); | 2841 | * This is our zone append .gnunet unless name is empty |
2582 | rh_bg->id = rid++; | 2842 | * (it shouldn't be, usually FIXME what happens if we |
2843 | * shorten to our zone to a "" record??) | ||
2844 | */ | ||
2845 | |||
2846 | sprintf (result, "%s.%s.%s", | ||
2847 | rh->name, nsh->private_zone_name, GNUNET_GNS_TLD); | ||
2848 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
2849 | "Our zone: Found %s as shorten result\n", result); | ||
2850 | |||
2851 | if (strlen (nsh->result) > strlen (result)) | ||
2852 | strcpy (nsh->result, result); | ||
2583 | } | 2853 | } |
2584 | 2854 | ||
2855 | |||
2585 | /* backtrack authorities for names */ | 2856 | /* backtrack authorities for names */ |
2586 | GNUNET_NAMESTORE_zone_to_name (namestore_handle, | 2857 | GNUNET_NAMESTORE_zone_to_name (namestore_handle, |
2587 | &rh->authority_chain_tail->zone, //ours | 2858 | nsh->root_zone, |
2588 | &rh->authority_chain_head->zone, | 2859 | &rh->authority_chain_head->zone, |
2589 | &process_zone_to_name_shorten, | 2860 | &process_zone_to_name_shorten_root, |
2590 | rh); | 2861 | rh); |
2591 | 2862 | ||
2592 | if (rh_bg == NULL) | ||
2593 | { | ||
2594 | return; | ||
2595 | } | ||
2596 | |||
2597 | /** | ||
2598 | * If authority resolution is incomplete we can do a background lookup | ||
2599 | * of the full name so that next time we can (likely) fully or at least | ||
2600 | * further shorten the name | ||
2601 | */ | ||
2602 | rh_bg->authority_chain_head = GNUNET_malloc(sizeof(struct AuthorityChain)); | ||
2603 | rh_bg->authority_chain_tail = rh_bg->authority_chain_head; | ||
2604 | rh_bg->authority_chain_head->zone = rh_bg->authority; | ||
2605 | |||
2606 | rh_bg->proc = &handle_delegation_dht_bg_shorten; | ||
2607 | rh_bg->proc_cls = NULL; | ||
2608 | rh_bg->timeout = GNUNET_TIME_UNIT_FOREVER_REL; | ||
2609 | |||
2610 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
2611 | "GNS_SHORTEN: Starting background lookup for %s\n", | ||
2612 | rh_bg->name); | ||
2613 | |||
2614 | resolve_delegation_dht(rh_bg); | ||
2615 | |||
2616 | } | 2863 | } |
2617 | 2864 | ||
2618 | 2865 | ||
@@ -2662,6 +2909,9 @@ process_zone_to_name_zkey(void *cls, | |||
2662 | else | 2909 | else |
2663 | GNUNET_snprintf(new_name, MAX_DNS_NAME_LENGTH, "%s.%s", | 2910 | GNUNET_snprintf(new_name, MAX_DNS_NAME_LENGTH, "%s.%s", |
2664 | enc, GNUNET_GNS_TLD_ZKEY); | 2911 | enc, GNUNET_GNS_TLD_ZKEY); |
2912 | |||
2913 | strcpy (nsh->result, new_name); | ||
2914 | |||
2665 | nsh->proc(nsh->proc_cls, new_name); | 2915 | nsh->proc(nsh->proc_cls, new_name); |
2666 | GNUNET_free(nsh); | 2916 | GNUNET_free(nsh); |
2667 | free_resolver_handle(rh); | 2917 | free_resolver_handle(rh); |
@@ -2692,20 +2942,24 @@ process_zone_to_name_zkey(void *cls, | |||
2692 | /** | 2942 | /** |
2693 | * Shorten api from resolver | 2943 | * Shorten api from resolver |
2694 | * | 2944 | * |
2695 | * @param zone the zone to use | 2945 | * @param zone the root zone to use |
2696 | * @param pzone the private local zone | 2946 | * @param pzone the private zone to use |
2947 | * @param szone the shorten zone to use | ||
2697 | * @param name the name to shorten | 2948 | * @param name the name to shorten |
2698 | * @param key optional private key for background lookups and PSEU import | 2949 | * @param private_zone_name name of the private zone |
2950 | * @param shorten_zone_name name of the shorten zone | ||
2699 | * @param proc the processor to call with result | 2951 | * @param proc the processor to call with result |
2700 | * @param proc_cls closure to pass to proc | 2952 | * @param proc_cls closure to pass to proc |
2701 | */ | 2953 | */ |
2702 | void | 2954 | void |
2703 | gns_resolver_shorten_name(struct GNUNET_CRYPTO_ShortHashCode zone, | 2955 | gns_resolver_shorten_name (struct GNUNET_CRYPTO_ShortHashCode *zone, |
2704 | struct GNUNET_CRYPTO_ShortHashCode pzone, | 2956 | struct GNUNET_CRYPTO_ShortHashCode *pzone, |
2705 | const char* name, | 2957 | struct GNUNET_CRYPTO_ShortHashCode *szone, |
2706 | struct GNUNET_CRYPTO_RsaPrivateKey *key, | 2958 | const char* name, |
2707 | ShortenResultProcessor proc, | 2959 | const char* private_zone_name, |
2708 | void* proc_cls) | 2960 | const char* shorten_zone_name, |
2961 | ShortenResultProcessor proc, | ||
2962 | void* proc_cls) | ||
2709 | { | 2963 | { |
2710 | struct ResolverHandle *rh; | 2964 | struct ResolverHandle *rh; |
2711 | struct NameShortenHandle *nsh; | 2965 | struct NameShortenHandle *nsh; |
@@ -2718,31 +2972,37 @@ gns_resolver_shorten_name(struct GNUNET_CRYPTO_ShortHashCode zone, | |||
2718 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2972 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2719 | "Starting shorten for %s!\n", name); | 2973 | "Starting shorten for %s!\n", name); |
2720 | 2974 | ||
2721 | if (is_canonical((char*)name)) | 2975 | if (is_canonical ((char*)name)) |
2722 | { | 2976 | { |
2723 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2977 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2724 | "%s is canonical. Returning verbatim\n", name); | 2978 | "%s is canonical. Returning verbatim\n", name); |
2725 | proc(proc_cls, name); | 2979 | proc (proc_cls, name); |
2726 | return; | 2980 | return; |
2727 | } | 2981 | } |
2728 | 2982 | ||
2729 | nsh = GNUNET_malloc(sizeof (struct NameShortenHandle)); | 2983 | nsh = GNUNET_malloc (sizeof (struct NameShortenHandle)); |
2730 | 2984 | ||
2731 | nsh->proc = proc; | 2985 | nsh->proc = proc; |
2732 | nsh->proc_cls = proc_cls; | 2986 | nsh->proc_cls = proc_cls; |
2733 | 2987 | nsh->root_zone = zone; | |
2734 | rh = GNUNET_malloc(sizeof (struct ResolverHandle)); | 2988 | nsh->private_zone = pzone; |
2735 | rh->authority = zone; | 2989 | nsh->shorten_zone = szone; |
2990 | strcpy (nsh->private_zone_name, private_zone_name); | ||
2991 | strcpy (nsh->shorten_zone_name, shorten_zone_name); | ||
2992 | strcpy (nsh->result, name); | ||
2993 | |||
2994 | rh = GNUNET_malloc (sizeof (struct ResolverHandle)); | ||
2995 | rh->authority = *zone; | ||
2736 | rh->id = rid++; | 2996 | rh->id = rid++; |
2737 | rh->priv_key = key; | 2997 | rh->priv_key = NULL; |
2738 | rh->proc = &handle_delegation_ns_shorten; | 2998 | rh->proc = &handle_delegation_ns_shorten; |
2739 | rh->proc_cls = nsh; | 2999 | rh->proc_cls = nsh; |
2740 | rh->id = rid++; | 3000 | rh->id = rid++; |
2741 | rh->private_local_zone = pzone; | 3001 | rh->private_local_zone = *zone; |
2742 | 3002 | ||
2743 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3003 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2744 | "Checking for TLD...\n"); | 3004 | "Checking for TLD...\n"); |
2745 | if (is_zkey_tld(name) == GNUNET_YES) | 3005 | if (is_zkey_tld (name) == GNUNET_YES) |
2746 | { | 3006 | { |
2747 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3007 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2748 | "TLD is zkey\n"); | 3008 | "TLD is zkey\n"); |
@@ -2751,30 +3011,30 @@ gns_resolver_shorten_name(struct GNUNET_CRYPTO_ShortHashCode zone, | |||
2751 | * build hash and use as initial authority | 3011 | * build hash and use as initial authority |
2752 | * FIXME sscanf | 3012 | * FIXME sscanf |
2753 | */ | 3013 | */ |
2754 | memset(rh->name, 0, | 3014 | memset (rh->name, 0, |
2755 | strlen(name)-strlen(GNUNET_GNS_TLD_ZKEY)); | 3015 | strlen (name)-strlen (GNUNET_GNS_TLD_ZKEY)); |
2756 | memcpy(rh->name, name, | 3016 | memcpy (rh->name, name, |
2757 | strlen(name)-strlen(GNUNET_GNS_TLD_ZKEY) - 1); | 3017 | strlen(name)-strlen (GNUNET_GNS_TLD_ZKEY) - 1); |
2758 | pop_tld(rh->name, string_hash); | 3018 | pop_tld (rh->name, string_hash); |
2759 | 3019 | ||
2760 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3020 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2761 | "ZKEY is %s!\n", string_hash); | 3021 | "ZKEY is %s!\n", string_hash); |
2762 | 3022 | ||
2763 | GNUNET_STRINGS_utf8_toupper(string_hash, &nzkey_ptr); | 3023 | GNUNET_STRINGS_utf8_toupper (string_hash, &nzkey_ptr); |
2764 | 3024 | ||
2765 | if (GNUNET_OK != GNUNET_CRYPTO_short_hash_from_string(nzkey, | 3025 | if (GNUNET_OK != GNUNET_CRYPTO_short_hash_from_string (nzkey, |
2766 | &zkey)) | 3026 | &zkey)) |
2767 | { | 3027 | { |
2768 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 3028 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2769 | "Cannot convert ZKEY %s to hash!\n", nzkey); | 3029 | "Cannot convert ZKEY %s to hash!\n", nzkey); |
2770 | GNUNET_free(rh); | 3030 | GNUNET_free (rh); |
2771 | GNUNET_free(nsh); | 3031 | GNUNET_free (nsh); |
2772 | proc(proc_cls, name); | 3032 | proc (proc_cls, name); |
2773 | return; | 3033 | return; |
2774 | } | 3034 | } |
2775 | 3035 | ||
2776 | GNUNET_NAMESTORE_zone_to_name (namestore_handle, | 3036 | GNUNET_NAMESTORE_zone_to_name (namestore_handle, |
2777 | &zone, //ours | 3037 | zone, //ours |
2778 | &zkey, | 3038 | &zkey, |
2779 | &process_zone_to_name_zkey, | 3039 | &process_zone_to_name_zkey, |
2780 | rh); | 3040 | rh); |
@@ -2788,19 +3048,19 @@ gns_resolver_shorten_name(struct GNUNET_CRYPTO_ShortHashCode zone, | |||
2788 | /** | 3048 | /** |
2789 | * Presumably GNUNET tld | 3049 | * Presumably GNUNET tld |
2790 | */ | 3050 | */ |
2791 | memset(rh->name, 0, | 3051 | memset (rh->name, 0, |
2792 | strlen(name)-strlen(GNUNET_GNS_TLD)); | 3052 | strlen (name)-strlen (GNUNET_GNS_TLD)); |
2793 | memcpy(rh->name, name, | 3053 | memcpy (rh->name, name, |
2794 | strlen(name)-strlen(GNUNET_GNS_TLD) - 1); | 3054 | strlen (name)-strlen (GNUNET_GNS_TLD) - 1); |
2795 | } | 3055 | } |
2796 | 3056 | ||
2797 | rh->authority_chain_head = GNUNET_malloc(sizeof(struct AuthorityChain)); | 3057 | rh->authority_chain_head = GNUNET_malloc (sizeof (struct AuthorityChain)); |
2798 | rh->authority_chain_tail = rh->authority_chain_head; | 3058 | rh->authority_chain_tail = rh->authority_chain_head; |
2799 | rh->authority_chain_head->zone = zone; | 3059 | rh->authority_chain_head->zone = *zone; |
2800 | 3060 | ||
2801 | 3061 | ||
2802 | /* Start delegation resolution in our namestore */ | 3062 | /* Start delegation resolution in our namestore */ |
2803 | resolve_delegation_ns(rh); | 3063 | resolve_delegation_ns (rh); |
2804 | } | 3064 | } |
2805 | 3065 | ||
2806 | /*********** END NAME SHORTEN ********************/ | 3066 | /*********** END NAME SHORTEN ********************/ |
diff --git a/src/gns/gnunet-service-gns_resolver.h b/src/gns/gnunet-service-gns_resolver.h index 2a2c341d3..1b54d3c2c 100644 --- a/src/gns/gnunet-service-gns_resolver.h +++ b/src/gns/gnunet-service-gns_resolver.h | |||
@@ -206,6 +206,25 @@ struct NameShortenHandle | |||
206 | 206 | ||
207 | /* closure to pass to proc */ | 207 | /* closure to pass to proc */ |
208 | void* proc_cls; | 208 | void* proc_cls; |
209 | |||
210 | /* result of shorten */ | ||
211 | char result[MAX_DNS_NAME_LENGTH]; | ||
212 | |||
213 | /* root zone */ | ||
214 | struct GNUNET_CRYPTO_ShortHashCode *root_zone; | ||
215 | |||
216 | /* private zone */ | ||
217 | struct GNUNET_CRYPTO_ShortHashCode *private_zone; | ||
218 | |||
219 | /* name of private zone */ | ||
220 | char private_zone_name[MAX_DNS_LABEL_LENGTH]; | ||
221 | |||
222 | /* shorten zone */ | ||
223 | struct GNUNET_CRYPTO_ShortHashCode *shorten_zone; | ||
224 | |||
225 | /* name of shorten zone */ | ||
226 | char shorten_zone_name[MAX_DNS_LABEL_LENGTH]; | ||
227 | |||
209 | }; | 228 | }; |
210 | 229 | ||
211 | /** | 230 | /** |
@@ -309,18 +328,22 @@ gns_resolver_lookup_record(struct GNUNET_CRYPTO_ShortHashCode zone, | |||
309 | * There is no guarantee that the shortened name will | 328 | * There is no guarantee that the shortened name will |
310 | * actually be canonical/short etc. | 329 | * actually be canonical/short etc. |
311 | * | 330 | * |
312 | * @param zone the zone to perform the operation in | 331 | * @param zone the root zone to use |
313 | * @param pzone the private local zone | 332 | * @param pzone the private zone to use |
333 | * @param szone the shorten zone to use | ||
314 | * @param name name to shorten | 334 | * @param name name to shorten |
315 | * @param key optional private key for background lookups and PSEU import | 335 | * @param private_zone_name name of the private zone |
336 | * @param shorten_zone_name name of the shorten zone | ||
316 | * @param proc the processor to call on shorten result | 337 | * @param proc the processor to call on shorten result |
317 | * @param proc_cls the closure to pass to proc | 338 | * @param proc_cls the closure to pass to proc |
318 | */ | 339 | */ |
319 | void | 340 | void |
320 | gns_resolver_shorten_name(struct GNUNET_CRYPTO_ShortHashCode zone, | 341 | gns_resolver_shorten_name(struct GNUNET_CRYPTO_ShortHashCode *zone, |
321 | struct GNUNET_CRYPTO_ShortHashCode pzone, | 342 | struct GNUNET_CRYPTO_ShortHashCode *pzone, |
343 | struct GNUNET_CRYPTO_ShortHashCode *szone, | ||
322 | const char* name, | 344 | const char* name, |
323 | struct GNUNET_CRYPTO_RsaPrivateKey *key, | 345 | const char* private_zone_name, |
346 | const char* shorten_zone_name, | ||
324 | ShortenResultProcessor proc, | 347 | ShortenResultProcessor proc, |
325 | void* proc_cls); | 348 | void* proc_cls); |
326 | 349 | ||
diff --git a/src/gns/test_gns_dht_delegated_lookup.c b/src/gns/test_gns_dht_delegated_lookup.c index e444023c8..07fa9f246 100644 --- a/src/gns/test_gns_dht_delegated_lookup.c +++ b/src/gns/test_gns_dht_delegated_lookup.c | |||
@@ -164,6 +164,7 @@ commence_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
164 | 164 | ||
165 | GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A, | 165 | GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A, |
166 | GNUNET_NO, | 166 | GNUNET_NO, |
167 | NULL, | ||
167 | &on_lookup_result, TEST_DOMAIN); | 168 | &on_lookup_result, TEST_DOMAIN); |
168 | } | 169 | } |
169 | 170 | ||
diff --git a/src/gns/test_gns_dht_threepeer.c b/src/gns/test_gns_dht_threepeer.c index c001d54e2..ebc858741 100644 --- a/src/gns/test_gns_dht_threepeer.c +++ b/src/gns/test_gns_dht_threepeer.c | |||
@@ -205,6 +205,7 @@ commence_testing(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
205 | 205 | ||
206 | GNUNET_GNS_lookup(gh, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A, | 206 | GNUNET_GNS_lookup(gh, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A, |
207 | GNUNET_NO, | 207 | GNUNET_NO, |
208 | NULL, | ||
208 | &on_lookup_result, TEST_DOMAIN); | 209 | &on_lookup_result, TEST_DOMAIN); |
209 | die_task = | 210 | die_task = |
210 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from lookup"); | 211 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from lookup"); |
diff --git a/src/gns/test_gns_max_queries.c b/src/gns/test_gns_max_queries.c index 88d43dd78..45931b3b3 100644 --- a/src/gns/test_gns_max_queries.c +++ b/src/gns/test_gns_max_queries.c | |||
@@ -180,11 +180,13 @@ commence_testing (void *cls, int32_t success, const char *emsg) | |||
180 | "www.doesnotexist-%d.bob.gnunet", i); | 180 | "www.doesnotexist-%d.bob.gnunet", i); |
181 | GNUNET_GNS_lookup(gns_handle, lookup_name, GNUNET_GNS_RECORD_TYPE_A, | 181 | GNUNET_GNS_lookup(gns_handle, lookup_name, GNUNET_GNS_RECORD_TYPE_A, |
182 | GNUNET_NO, | 182 | GNUNET_NO, |
183 | NULL, | ||
183 | &on_lookup_result_dummy, NULL); | 184 | &on_lookup_result_dummy, NULL); |
184 | } | 185 | } |
185 | 186 | ||
186 | GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A, | 187 | GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A, |
187 | GNUNET_NO, | 188 | GNUNET_NO, |
189 | NULL, | ||
188 | &on_lookup_result, TEST_DOMAIN); | 190 | &on_lookup_result, TEST_DOMAIN); |
189 | } | 191 | } |
190 | 192 | ||
diff --git a/src/gns/test_gns_pseu_shorten.c b/src/gns/test_gns_pseu_shorten.c index 88fe17c29..34c69709b 100644 --- a/src/gns/test_gns_pseu_shorten.c +++ b/src/gns/test_gns_pseu_shorten.c | |||
@@ -43,14 +43,16 @@ | |||
43 | #define DEFAULT_NUM_PEERS 2 | 43 | #define DEFAULT_NUM_PEERS 2 |
44 | 44 | ||
45 | /* test records to resolve */ | 45 | /* test records to resolve */ |
46 | #define TEST_DOMAIN "www.alice.bob.gnunet" | 46 | #define TEST_DOMAIN "www.alicewonderland.bobbuilder.gnunet" |
47 | #define TEST_IP "127.0.0.1" | 47 | #define TEST_IP "127.0.0.1" |
48 | #define TEST_RECORD_NAME "www" | 48 | #define TEST_RECORD_NAME "www" |
49 | 49 | ||
50 | #define TEST_AUTHORITY_BOB "bob" | 50 | #define TEST_PRIVATE_ZONE "private" |
51 | #define TEST_AUTHORITY_ALICE "alice" | 51 | #define TEST_SHORTEN_ZONE "short" |
52 | #define TEST_AUTHORITY_BOB "bobbuilder" | ||
53 | #define TEST_AUTHORITY_ALICE "alicewonderland" | ||
52 | #define TEST_PSEU_ALICE "carol" | 54 | #define TEST_PSEU_ALICE "carol" |
53 | #define TEST_EXPECTED_RESULT "www.carol.gnunet" | 55 | #define TEST_EXPECTED_RESULT "www.carol.short.private.gnunet" |
54 | 56 | ||
55 | #define DHT_OPERATION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 57 | #define DHT_OPERATION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
56 | 58 | ||
@@ -85,12 +87,18 @@ const struct GNUNET_CONFIGURATION_Handle *cfg; | |||
85 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey; | 87 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey; |
86 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey; | 88 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey; |
87 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded our_pkey; | 89 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded our_pkey; |
90 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded priv_pkey; | ||
91 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded short_pkey; | ||
88 | struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; | 92 | struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; |
89 | struct GNUNET_CRYPTO_RsaPrivateKey *bob_key; | 93 | struct GNUNET_CRYPTO_RsaPrivateKey *bob_key; |
90 | struct GNUNET_CRYPTO_RsaPrivateKey *our_key; | 94 | struct GNUNET_CRYPTO_RsaPrivateKey *our_key; |
95 | struct GNUNET_CRYPTO_RsaPrivateKey *priv_key; | ||
96 | struct GNUNET_CRYPTO_RsaPrivateKey *short_key; | ||
91 | struct GNUNET_CRYPTO_ShortHashCode alice_hash; | 97 | struct GNUNET_CRYPTO_ShortHashCode alice_hash; |
92 | struct GNUNET_CRYPTO_ShortHashCode bob_hash; | 98 | struct GNUNET_CRYPTO_ShortHashCode bob_hash; |
93 | struct GNUNET_CRYPTO_ShortHashCode our_zone; | 99 | struct GNUNET_CRYPTO_ShortHashCode our_zone; |
100 | struct GNUNET_CRYPTO_ShortHashCode priv_zone; | ||
101 | struct GNUNET_CRYPTO_ShortHashCode short_zone; | ||
94 | 102 | ||
95 | /** | 103 | /** |
96 | * Check whether peers successfully shut down. | 104 | * Check whether peers successfully shut down. |
@@ -163,9 +171,9 @@ static void | |||
163 | do_shorten(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 171 | do_shorten(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
164 | { | 172 | { |
165 | GNUNET_GNS_shorten_zone (gns_handle, TEST_DOMAIN, | 173 | GNUNET_GNS_shorten_zone (gns_handle, TEST_DOMAIN, |
166 | &our_zone, &our_zone, | 174 | &our_zone, |
167 | &process_shorten_result, | 175 | &process_shorten_result, |
168 | TEST_DOMAIN); | 176 | TEST_DOMAIN); |
169 | } | 177 | } |
170 | 178 | ||
171 | static void | 179 | static void |
@@ -235,10 +243,11 @@ commence_testing (void *cls, int success) | |||
235 | } | 243 | } |
236 | 244 | ||
237 | GNUNET_GNS_lookup_zone (gns_handle, TEST_DOMAIN, | 245 | GNUNET_GNS_lookup_zone (gns_handle, TEST_DOMAIN, |
238 | &our_zone, &our_zone, | 246 | &our_zone, |
239 | GNUNET_GNS_RECORD_TYPE_A, | 247 | GNUNET_GNS_RECORD_TYPE_A, |
240 | GNUNET_NO, | 248 | GNUNET_NO, |
241 | &on_lookup_result, TEST_DOMAIN); | 249 | short_key, |
250 | &on_lookup_result, TEST_DOMAIN); | ||
242 | } | 251 | } |
243 | 252 | ||
244 | /** | 253 | /** |
@@ -501,12 +510,49 @@ put_pkey_dht(void *cls, int32_t success, const char *emsg) | |||
501 | } | 510 | } |
502 | 511 | ||
503 | static void | 512 | static void |
504 | do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, | 513 | fin_init_zone (void *cls, int32_t success, const char *emsg) |
505 | const struct GNUNET_CONFIGURATION_Handle *_cfg, | 514 | { |
506 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 515 | struct GNUNET_NAMESTORE_RecordData rd; |
516 | rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
517 | rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); | ||
518 | rd.data = &bob_hash; | ||
519 | rd.record_type = GNUNET_GNS_RECORD_PKEY; | ||
520 | |||
521 | GNUNET_NAMESTORE_record_create (namestore_handle, | ||
522 | our_key, | ||
523 | TEST_AUTHORITY_BOB, | ||
524 | &rd, | ||
525 | &put_pkey_dht, | ||
526 | NULL); | ||
527 | |||
528 | } | ||
529 | |||
530 | static void | ||
531 | cont_init_zone (void *cls, int32_t success, const char *emsg) | ||
532 | { | ||
533 | |||
534 | struct GNUNET_NAMESTORE_RecordData rd; | ||
535 | rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
536 | rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); | ||
537 | rd.data = &short_zone; | ||
538 | rd.record_type = GNUNET_GNS_RECORD_PKEY; | ||
539 | |||
540 | GNUNET_NAMESTORE_record_create (namestore_handle, | ||
541 | priv_key, | ||
542 | TEST_SHORTEN_ZONE, | ||
543 | &rd, | ||
544 | &fin_init_zone, | ||
545 | NULL); | ||
546 | } | ||
547 | |||
548 | static void | ||
549 | do_lookup (void *cls, const struct GNUNET_PeerIdentity *id, | ||
550 | const struct GNUNET_CONFIGURATION_Handle *_cfg, | ||
551 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | ||
507 | { | 552 | { |
508 | 553 | ||
509 | 554 | char* private_keyfile; | |
555 | char* shorten_keyfile; | ||
510 | char* our_keyfile; | 556 | char* our_keyfile; |
511 | 557 | ||
512 | cfg = _cfg; | 558 | cfg = _cfg; |
@@ -539,34 +585,63 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, | |||
539 | ok = -1; | 585 | ok = -1; |
540 | return; | 586 | return; |
541 | } | 587 | } |
542 | 588 | ||
589 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", | ||
590 | "SHORTEN_ZONEKEY", | ||
591 | &shorten_keyfile)) | ||
592 | { | ||
593 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
594 | "Failed to get shorten zone key from cfg\n"); | ||
595 | ok = -1; | ||
596 | return; | ||
597 | } | ||
598 | |||
599 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", | ||
600 | "PRIVATE_ZONEKEY", | ||
601 | &private_keyfile)) | ||
602 | { | ||
603 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
604 | "Failed to get private zone key from cfg\n"); | ||
605 | ok = -1; | ||
606 | return; | ||
607 | } | ||
543 | our_key = GNUNET_CRYPTO_rsa_key_create_from_file (our_keyfile); | 608 | our_key = GNUNET_CRYPTO_rsa_key_create_from_file (our_keyfile); |
609 | priv_key = GNUNET_CRYPTO_rsa_key_create_from_file (private_keyfile); | ||
610 | short_key = GNUNET_CRYPTO_rsa_key_create_from_file (shorten_keyfile); | ||
544 | bob_key = GNUNET_CRYPTO_rsa_key_create_from_file (KEYFILE_BOB); | 611 | bob_key = GNUNET_CRYPTO_rsa_key_create_from_file (KEYFILE_BOB); |
545 | alice_key = GNUNET_CRYPTO_rsa_key_create_from_file (KEYFILE_ALICE); | 612 | alice_key = GNUNET_CRYPTO_rsa_key_create_from_file (KEYFILE_ALICE); |
546 | 613 | ||
547 | GNUNET_free(our_keyfile); | 614 | GNUNET_free(our_keyfile); |
615 | GNUNET_free(shorten_keyfile); | ||
616 | GNUNET_free(private_keyfile); | ||
548 | 617 | ||
549 | GNUNET_CRYPTO_rsa_key_get_public (our_key, &our_pkey); | 618 | GNUNET_CRYPTO_rsa_key_get_public (our_key, &our_pkey); |
619 | GNUNET_CRYPTO_rsa_key_get_public (priv_key, &priv_pkey); | ||
620 | GNUNET_CRYPTO_rsa_key_get_public (short_key, &short_pkey); | ||
550 | GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey); | 621 | GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey); |
551 | GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); | 622 | GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); |
552 | GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); | 623 | GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); |
553 | GNUNET_CRYPTO_short_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash); | 624 | GNUNET_CRYPTO_short_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash); |
554 | GNUNET_CRYPTO_short_hash(&our_pkey, sizeof(our_pkey), &our_zone); | 625 | GNUNET_CRYPTO_short_hash(&our_pkey, sizeof(our_pkey), &our_zone); |
555 | 626 | GNUNET_CRYPTO_short_hash(&priv_pkey, sizeof(priv_pkey), &priv_zone); | |
627 | GNUNET_CRYPTO_short_hash(&short_pkey, sizeof(short_pkey), &short_zone); | ||
628 | |||
556 | struct GNUNET_NAMESTORE_RecordData rd; | 629 | struct GNUNET_NAMESTORE_RecordData rd; |
557 | rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; | 630 | rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; |
558 | rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); | 631 | rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); |
559 | rd.data = &bob_hash; | 632 | rd.data = &priv_zone; |
560 | rd.record_type = GNUNET_GNS_RECORD_PKEY; | 633 | rd.record_type = GNUNET_GNS_RECORD_PKEY; |
561 | 634 | ||
562 | GNUNET_NAMESTORE_record_create (namestore_handle, | 635 | GNUNET_NAMESTORE_record_create (namestore_handle, |
563 | our_key, | 636 | our_key, |
564 | TEST_AUTHORITY_BOB, | 637 | TEST_PRIVATE_ZONE, |
565 | &rd, | 638 | &rd, |
566 | &put_pkey_dht, | 639 | &cont_init_zone, |
567 | NULL); | 640 | NULL); |
568 | 641 | ||
569 | 642 | ||
643 | |||
644 | |||
570 | } | 645 | } |
571 | 646 | ||
572 | static void | 647 | static void |
diff --git a/src/gns/test_gns_simple_delegated_lookup.c b/src/gns/test_gns_simple_delegated_lookup.c index 3f89b7d91..9e5226285 100644 --- a/src/gns/test_gns_simple_delegated_lookup.c +++ b/src/gns/test_gns_simple_delegated_lookup.c | |||
@@ -165,6 +165,7 @@ commence_testing (void *cls, int32_t success, const char *emsg) | |||
165 | 165 | ||
166 | GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A, | 166 | GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A, |
167 | GNUNET_NO, | 167 | GNUNET_NO, |
168 | NULL, | ||
168 | &on_lookup_result, TEST_DOMAIN); | 169 | &on_lookup_result, TEST_DOMAIN); |
169 | } | 170 | } |
170 | 171 | ||
diff --git a/src/gns/test_gns_simple_lookup.c b/src/gns/test_gns_simple_lookup.c index 46ce3084e..a1d6b02ae 100644 --- a/src/gns/test_gns_simple_lookup.c +++ b/src/gns/test_gns_simple_lookup.c | |||
@@ -150,6 +150,7 @@ commence_testing (void *cls, int32_t success, const char *emsg) | |||
150 | 150 | ||
151 | GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A, | 151 | GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A, |
152 | GNUNET_YES, | 152 | GNUNET_YES, |
153 | NULL, | ||
153 | &on_lookup_result, TEST_DOMAIN); | 154 | &on_lookup_result, TEST_DOMAIN); |
154 | } | 155 | } |
155 | 156 | ||
diff --git a/src/gns/test_gns_simple_lookup.conf b/src/gns/test_gns_simple_lookup.conf index 9a32fe561..fec6b68d2 100644 --- a/src/gns/test_gns_simple_lookup.conf +++ b/src/gns/test_gns_simple_lookup.conf | |||
@@ -76,6 +76,10 @@ DNS_EXIT = 8.8.8.8 | |||
76 | AUTOSTART = YES | 76 | AUTOSTART = YES |
77 | BINARY = gnunet-service-gns | 77 | BINARY = gnunet-service-gns |
78 | ZONEKEY = $SERVICEHOME/.hostkey | 78 | ZONEKEY = $SERVICEHOME/.hostkey |
79 | PRIVATE_ZONE = private | ||
80 | PRIVATE_ZONEKEY = $SERVICEHOME/gns/zonekey_priv.zkey | ||
81 | SHORTEN_ZONE = short | ||
82 | SHORTEN_ZONEKEY = $SERVICEHOME/gns/zonekey_short.zkey | ||
79 | #ZONEKEY = $SERVICEHOME/gns/zonekey.zkey | 83 | #ZONEKEY = $SERVICEHOME/gns/zonekey.zkey |
80 | HIJACK_DNS = NO | 84 | HIJACK_DNS = NO |
81 | UNIXPATH = /tmp/gnunet-service-gns.sock | 85 | UNIXPATH = /tmp/gnunet-service-gns.sock |
diff --git a/src/gns/test_gns_simple_mx_lookup.c b/src/gns/test_gns_simple_mx_lookup.c index 57531c4eb..c6ec1d684 100644 --- a/src/gns/test_gns_simple_mx_lookup.c +++ b/src/gns/test_gns_simple_mx_lookup.c | |||
@@ -182,6 +182,7 @@ commence_testing (void *cls, int32_t success, const char *emsg) | |||
182 | 182 | ||
183 | GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_MX, | 183 | GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_MX, |
184 | GNUNET_NO, | 184 | GNUNET_NO, |
185 | NULL, | ||
185 | &on_lookup_result, TEST_DOMAIN); | 186 | &on_lookup_result, TEST_DOMAIN); |
186 | } | 187 | } |
187 | 188 | ||
diff --git a/src/gns/test_gns_simple_zkey_lookup.c b/src/gns/test_gns_simple_zkey_lookup.c index 66bca0917..b6d02cf3f 100644 --- a/src/gns/test_gns_simple_zkey_lookup.c +++ b/src/gns/test_gns_simple_zkey_lookup.c | |||
@@ -169,6 +169,7 @@ commence_testing (void *cls, int32_t success, const char *emsg) | |||
169 | 169 | ||
170 | GNUNET_GNS_lookup(gns_handle, name, GNUNET_GNS_RECORD_TYPE_A, | 170 | GNUNET_GNS_lookup(gns_handle, name, GNUNET_GNS_RECORD_TYPE_A, |
171 | GNUNET_NO, | 171 | GNUNET_NO, |
172 | NULL, | ||
172 | &on_lookup_result, NULL); | 173 | &on_lookup_result, NULL); |
173 | } | 174 | } |
174 | 175 | ||