aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/conversation/conversation_api_call.c1
-rw-r--r--src/gns/Makefile.am7
-rw-r--r--src/gns/gns.h53
-rw-r--r--src/gns/gns_api.c194
-rw-r--r--src/gns/gnunet-dns2gns.c5
-rw-r--r--src/gns/gnunet-gns-proxy.c90
-rw-r--r--src/gns/gnunet-gns.c162
-rw-r--r--src/gns/gnunet-service-gns.c171
-rw-r--r--src/gns/gnunet-service-gns_interceptor.c1
-rw-r--r--src/gns/gnunet-service-gns_resolver.c34
-rw-r--r--src/gns/gnunet-service-gns_resolver.h11
-rw-r--r--src/gns/plugin_rest_gns.c54
-rwxr-xr-xsrc/gns/test_gns_nick_shorten.sh124
-rwxr-xr-xsrc/gns/test_gns_reverse_lookup.sh50
-rw-r--r--src/identity-provider/gnunet-service-identity-provider.c7
-rw-r--r--src/include/gnunet_gns_service.h37
-rw-r--r--src/social/gnunet-service-social.c8
17 files changed, 83 insertions, 926 deletions
diff --git a/src/conversation/conversation_api_call.c b/src/conversation/conversation_api_call.c
index a6bc506bc..7e4a147a0 100644
--- a/src/conversation/conversation_api_call.c
+++ b/src/conversation/conversation_api_call.c
@@ -603,7 +603,6 @@ GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
603 &my_zone, 603 &my_zone,
604 GNUNET_GNSRECORD_TYPE_PHONE, 604 GNUNET_GNSRECORD_TYPE_PHONE,
605 GNUNET_NO, 605 GNUNET_NO,
606 NULL /* FIXME: add shortening support */,
607 &handle_gns_response, call); 606 &handle_gns_response, call);
608 GNUNET_assert (NULL != call->gns_lookup); 607 GNUNET_assert (NULL != call->gns_lookup);
609 return call; 608 return call;
diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am
index d59908c0a..3afad8ea7 100644
--- a/src/gns/Makefile.am
+++ b/src/gns/Makefile.am
@@ -12,7 +12,6 @@ SUBDIRS = . $(NSS_SUBDIR)
12EXTRA_DIST = \ 12EXTRA_DIST = \
13 test_gns_defaults.conf \ 13 test_gns_defaults.conf \
14 test_gns_lookup.conf \ 14 test_gns_lookup.conf \
15 test_gns_nick_shorten.conf \
16 test_gns_proxy.conf \ 15 test_gns_proxy.conf \
17 test_gns_simple_lookup.conf \ 16 test_gns_simple_lookup.conf \
18 gns-helper-service-w32.conf \ 17 gns-helper-service-w32.conf \
@@ -184,8 +183,6 @@ w32nsp_resolve_LDADD = -lws2_32
184gnunet_service_gns_SOURCES = \ 183gnunet_service_gns_SOURCES = \
185 gnunet-service-gns.c \ 184 gnunet-service-gns.c \
186 gnunet-service-gns_resolver.c gnunet-service-gns_resolver.h \ 185 gnunet-service-gns_resolver.c gnunet-service-gns_resolver.h \
187 gnunet-service-gns_reverser.c gnunet-service-gns_reverser.h \
188 gnunet-service-gns_shorten.c gnunet-service-gns_shorten.h \
189 gnunet-service-gns_interceptor.c gnunet-service-gns_interceptor.h 186 gnunet-service-gns_interceptor.c gnunet-service-gns_interceptor.h
190gnunet_service_gns_LDADD = \ 187gnunet_service_gns_LDADD = \
191 -lm \ 188 -lm \
@@ -254,14 +251,12 @@ check_SCRIPTS = \
254 test_gns_gns2dns_lookup.sh \ 251 test_gns_gns2dns_lookup.sh \
255 test_gns_dht_lookup.sh\ 252 test_gns_dht_lookup.sh\
256 test_gns_delegated_lookup.sh \ 253 test_gns_delegated_lookup.sh \
257 test_gns_nick_shorten.sh\
258 test_gns_plus_lookup.sh\ 254 test_gns_plus_lookup.sh\
259 test_gns_zkey_lookup.sh\ 255 test_gns_zkey_lookup.sh\
260 test_gns_rel_expiration.sh\ 256 test_gns_rel_expiration.sh\
261 test_gns_soa_lookup.sh\ 257 test_gns_soa_lookup.sh\
262 test_gns_revocation.sh\ 258 test_gns_revocation.sh\
263 test_gns_cname_lookup.sh \ 259 test_gns_cname_lookup.sh
264 test_gns_reverse_lookup.sh
265 260
266if ENABLE_TEST_RUN 261if ENABLE_TEST_RUN
267if HAVE_SQLITE 262if HAVE_SQLITE
diff --git a/src/gns/gns.h b/src/gns/gns.h
index ca5525f80..d77bf53c6 100644
--- a/src/gns/gns.h
+++ b/src/gns/gns.h
@@ -72,51 +72,20 @@ struct LookupMessage
72 int16_t options GNUNET_PACKED; 72 int16_t options GNUNET_PACKED;
73 73
74 /** 74 /**
75 * Is a shorten key attached? 75 * Always 0.
76 */ 76 */
77 int16_t have_key GNUNET_PACKED; 77 int16_t reserved GNUNET_PACKED;
78 78
79 /** 79 /**
80 * the type of record to look up 80 * the type of record to look up
81 */ 81 */
82 int32_t type GNUNET_PACKED; 82 int32_t type GNUNET_PACKED;
83 83
84 /**
85 * The key for shorten, if @e have_key is set
86 */
87 struct GNUNET_CRYPTO_EcdsaPrivateKey shorten_key;
88
89 /* Followed by the zero-terminated name to look up */ 84 /* Followed by the zero-terminated name to look up */
90}; 85};
91 86
92 87
93/** 88/**
94 * Message from client to GNS service to lookup records.
95 */
96struct ReverseLookupMessage
97{
98 /**
99 * Header of type #GNUNET_MESSAGE_TYPE_GNS_REVERSE_LOOKUP
100 */
101 struct GNUNET_MessageHeader header;
102
103 /**
104 * Unique identifier for this request (for key collisions).
105 */
106 uint32_t id GNUNET_PACKED;
107
108 /**
109 * Zone that is target for reverse lookup
110 */
111 struct GNUNET_CRYPTO_EcdsaPublicKey zone_pkey;
112
113 /**
114 * Root zone
115 */
116 struct GNUNET_CRYPTO_EcdsaPublicKey root_pkey;
117};
118
119/**
120 * Message from GNS service to client: new results. 89 * Message from GNS service to client: new results.
121 */ 90 */
122struct LookupResultMessage 91struct LookupResultMessage
@@ -140,24 +109,6 @@ struct LookupResultMessage
140 109
141}; 110};
142 111
143/**
144 * Message from GNS service to client: new results.
145 */
146struct ReverseLookupResultMessage
147{
148 /**
149 * Header of type #GNUNET_MESSAGE_TYPE_GNS_REVERSE_LOOKUP_RESULT
150 */
151 struct GNUNET_MessageHeader header;
152
153 /**
154 * Unique identifier for this request (for key collisions).
155 */
156 uint32_t id GNUNET_PACKED;
157
158 /* followed by the resulting name of the reverse lookup */
159};
160
161 112
162GNUNET_NETWORK_STRUCT_END 113GNUNET_NETWORK_STRUCT_END
163 114
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c
index 5d6158bd4..15a59a4bc 100644
--- a/src/gns/gns_api.c
+++ b/src/gns/gns_api.c
@@ -79,49 +79,6 @@ struct GNUNET_GNS_LookupRequest
79 79
80}; 80};
81 81
82/**
83 * Handle to a lookup request
84 */
85struct GNUNET_GNS_ReverseLookupRequest
86{
87
88 /**
89 * DLL
90 */
91 struct GNUNET_GNS_ReverseLookupRequest *next;
92
93 /**
94 * DLL
95 */
96 struct GNUNET_GNS_ReverseLookupRequest *prev;
97
98 /**
99 * handle to gns
100 */
101 struct GNUNET_GNS_Handle *gns_handle;
102
103 /**
104 * processor to call on lookup result
105 */
106 GNUNET_GNS_ReverseLookupResultProcessor lookup_proc;
107
108 /**
109 * @e lookup_proc closure
110 */
111 void *proc_cls;
112
113 /**
114 * Envelope with the message for this queue entry.
115 */
116 struct GNUNET_MQ_Envelope *env;
117
118 /**
119 * request id
120 */
121 uint32_t r_id;
122
123};
124
125 82
126/** 83/**
127 * Connection to the GNS service. 84 * Connection to the GNS service.
@@ -150,15 +107,6 @@ struct GNUNET_GNS_Handle
150 struct GNUNET_GNS_LookupRequest *lookup_tail; 107 struct GNUNET_GNS_LookupRequest *lookup_tail;
151 108
152 /** 109 /**
153 * Head of linked list of active reverse lookup requests.
154 */
155 struct GNUNET_GNS_ReverseLookupRequest *rev_lookup_head;
156
157 /**
158 * Tail of linked list of active reverse lookup requests.
159 */
160 struct GNUNET_GNS_ReverseLookupRequest *rev_lookup_tail;
161 /**
162 * Reconnect task 110 * Reconnect task
163 */ 111 */
164 struct GNUNET_SCHEDULER_Task *reconnect_task; 112 struct GNUNET_SCHEDULER_Task *reconnect_task;
@@ -232,71 +180,13 @@ mq_error_handler (void *cls,
232 enum GNUNET_MQ_Error error) 180 enum GNUNET_MQ_Error error)
233{ 181{
234 struct GNUNET_GNS_Handle *handle = cls; 182 struct GNUNET_GNS_Handle *handle = cls;
235 LOG (GNUNET_ERROR_TYPE_WARNING, "Problem with message queue. error: %i\n", 183
184 LOG (GNUNET_ERROR_TYPE_WARNING,
185 "Problem with message queue. error: %i\n",
236 error); 186 error);
237 force_reconnect (handle); 187 force_reconnect (handle);
238} 188}
239 189
240/**
241 * Check validity of message received from the GNS service
242 *
243 * @param cls the `struct GNUNET_GNS_Handle *`
244 * @param loookup_msg the incoming message
245 */
246static int
247check_rev_result (void *cls,
248 const struct ReverseLookupResultMessage *lookup_msg)
249{
250 size_t mlen = ntohs (lookup_msg->header.size) - sizeof (*lookup_msg);
251 char *name;
252
253 name = (char*) &lookup_msg[1];
254 if ('\0' != name[mlen-1])
255 {
256 GNUNET_break (0);
257 return GNUNET_SYSERR;
258 }
259 return GNUNET_OK;
260}
261
262
263/**
264 * Handler for messages received from the GNS service
265 *
266 * @param cls the `struct GNUNET_GNS_Handle *`
267 * @param loookup_msg the incoming message
268 */
269static void
270handle_rev_result (void *cls,
271 const struct ReverseLookupResultMessage *lookup_msg)
272{
273 struct GNUNET_GNS_Handle *handle = cls;
274 char *name;
275 uint32_t r_id = ntohl (lookup_msg->id);
276 struct GNUNET_GNS_ReverseLookupRequest *rlr;
277 GNUNET_GNS_ReverseLookupResultProcessor proc;
278 void *proc_cls;
279
280 name = (char*)&lookup_msg[1];
281 LOG (GNUNET_ERROR_TYPE_DEBUG,
282 "Received reverse lookup reply from GNS service (%s)\n",
283 name);
284 for (rlr = handle->rev_lookup_head; NULL != rlr; rlr = rlr->next)
285 if (rlr->r_id == r_id)
286 break;
287 if (NULL == rlr)
288 return;
289 proc = rlr->lookup_proc;
290 proc_cls = rlr->proc_cls;
291 GNUNET_CONTAINER_DLL_remove (handle->rev_lookup_head,
292 handle->rev_lookup_tail,
293 rlr);
294 GNUNET_free (rlr);
295 proc (proc_cls,
296 name);
297}
298
299
300 190
301/** 191/**
302 * Check validity of message received from the GNS service 192 * Check validity of message received from the GNS service
@@ -382,14 +272,9 @@ reconnect (struct GNUNET_GNS_Handle *handle)
382 GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT, 272 GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT,
383 struct LookupResultMessage, 273 struct LookupResultMessage,
384 handle), 274 handle),
385 GNUNET_MQ_hd_var_size (rev_result,
386 GNUNET_MESSAGE_TYPE_GNS_REVERSE_LOOKUP_RESULT,
387 struct ReverseLookupResultMessage,
388 handle),
389 GNUNET_MQ_handler_end () 275 GNUNET_MQ_handler_end ()
390 }; 276 };
391 struct GNUNET_GNS_LookupRequest *lh; 277 struct GNUNET_GNS_LookupRequest *lh;
392 struct GNUNET_GNS_ReverseLookupRequest *rlh;
393 278
394 GNUNET_assert (NULL == handle->mq); 279 GNUNET_assert (NULL == handle->mq);
395 LOG (GNUNET_ERROR_TYPE_DEBUG, 280 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -404,9 +289,6 @@ reconnect (struct GNUNET_GNS_Handle *handle)
404 for (lh = handle->lookup_head; NULL != lh; lh = lh->next) 289 for (lh = handle->lookup_head; NULL != lh; lh = lh->next)
405 GNUNET_MQ_send_copy (handle->mq, 290 GNUNET_MQ_send_copy (handle->mq,
406 lh->env); 291 lh->env);
407 for (rlh = handle->rev_lookup_head; NULL != rlh; rlh = rlh->next)
408 GNUNET_MQ_send_copy (handle->mq,
409 rlh->env);
410} 292}
411 293
412 294
@@ -452,7 +334,6 @@ GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle)
452 handle->reconnect_task = NULL; 334 handle->reconnect_task = NULL;
453 } 335 }
454 GNUNET_assert (NULL == handle->lookup_head); 336 GNUNET_assert (NULL == handle->lookup_head);
455 GNUNET_assert (NULL == handle->rev_lookup_head);
456 GNUNET_free (handle); 337 GNUNET_free (handle);
457} 338}
458 339
@@ -474,22 +355,6 @@ GNUNET_GNS_lookup_cancel (struct GNUNET_GNS_LookupRequest *lr)
474 GNUNET_free (lr); 355 GNUNET_free (lr);
475} 356}
476 357
477/**
478 * Cancel pending reverse lookup request
479 *
480 * @param lr the lookup request to cancel
481 */
482void
483GNUNET_GNS_reverse_lookup_cancel (struct GNUNET_GNS_ReverseLookupRequest *lr)
484{
485 struct GNUNET_GNS_Handle *handle = lr->gns_handle;
486
487 GNUNET_CONTAINER_DLL_remove (handle->rev_lookup_head,
488 handle->rev_lookup_tail,
489 lr);
490 GNUNET_MQ_discard (lr->env);
491 GNUNET_free (lr);
492}
493 358
494/** 359/**
495 * Perform an asynchronous lookup operation on the GNS. 360 * Perform an asynchronous lookup operation on the GNS.
@@ -499,7 +364,6 @@ GNUNET_GNS_reverse_lookup_cancel (struct GNUNET_GNS_ReverseLookupRequest *lr)
499 * @param zone the zone to start the resolution in 364 * @param zone the zone to start the resolution in
500 * @param type the record type to look up 365 * @param type the record type to look up
501 * @param options local options for the lookup 366 * @param options local options for the lookup
502 * @param shorten_zone_key the private key of the shorten zone (can be NULL)
503 * @param proc processor to call on result 367 * @param proc processor to call on result
504 * @param proc_cls closure for @a proc 368 * @param proc_cls closure for @a proc
505 * @return handle to the get request 369 * @return handle to the get request
@@ -510,7 +374,6 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
510 const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, 374 const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
511 uint32_t type, 375 uint32_t type,
512 enum GNUNET_GNS_LocalOptions options, 376 enum GNUNET_GNS_LocalOptions options,
513 const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone_key,
514 GNUNET_GNS_LookupResultProcessor proc, 377 GNUNET_GNS_LookupResultProcessor proc,
515 void *proc_cls) 378 void *proc_cls)
516{ 379{
@@ -545,11 +408,6 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
545 lookup_msg->options = htons ((uint16_t) options); 408 lookup_msg->options = htons ((uint16_t) options);
546 lookup_msg->zone = *zone; 409 lookup_msg->zone = *zone;
547 lookup_msg->type = htonl (type); 410 lookup_msg->type = htonl (type);
548 if (NULL != shorten_zone_key)
549 {
550 lookup_msg->have_key = htons (GNUNET_YES);
551 lookup_msg->shorten_key = *shorten_zone_key;
552 }
553 GNUNET_memcpy (&lookup_msg[1], 411 GNUNET_memcpy (&lookup_msg[1],
554 name, 412 name,
555 nlen); 413 nlen);
@@ -562,50 +420,4 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
562 return lr; 420 return lr;
563} 421}
564 422
565/**
566 * Perform an asynchronous reverse lookup operation on the GNS.
567 *
568 * @param handle handle to the GNS service
569 * @param zone_key zone to find a name for
570 * @param root_key our zone
571 * @param proc processor to call on result
572 * @param proc_cls closure for @a proc
573 * @return handle to the request
574 */
575struct GNUNET_GNS_ReverseLookupRequest*
576GNUNET_GNS_reverse_lookup (struct GNUNET_GNS_Handle *handle,
577 const struct GNUNET_CRYPTO_EcdsaPublicKey *zone_key,
578 const struct GNUNET_CRYPTO_EcdsaPublicKey *root_key,
579 GNUNET_GNS_ReverseLookupResultProcessor proc,
580 void *proc_cls)
581{
582 /* IPC to shorten gns names, return shorten_handle */
583 struct ReverseLookupMessage *rev_lookup_msg;
584 struct GNUNET_GNS_ReverseLookupRequest *lr;
585
586 if ((NULL == zone_key) || (NULL == root_key))
587 {
588 GNUNET_break (0);
589 return NULL;
590 }
591 LOG (GNUNET_ERROR_TYPE_DEBUG,
592 "Trying to reverse lookup in GNS\n");
593 lr = GNUNET_new (struct GNUNET_GNS_ReverseLookupRequest);
594 lr->gns_handle = handle;
595 lr->lookup_proc = proc;
596 lr->proc_cls = proc_cls;
597 lr->r_id = handle->r_id_gen++;
598 lr->env = GNUNET_MQ_msg (rev_lookup_msg,
599 GNUNET_MESSAGE_TYPE_GNS_REVERSE_LOOKUP);
600 rev_lookup_msg->id = htonl (lr->r_id);
601 rev_lookup_msg->zone_pkey = *zone_key;
602 rev_lookup_msg->root_pkey = *root_key;
603 GNUNET_CONTAINER_DLL_insert (handle->rev_lookup_head,
604 handle->rev_lookup_tail,
605 lr);
606 if (NULL != handle->mq)
607 GNUNET_MQ_send_copy (handle->mq,
608 lr->env);
609 return lr;
610}
611/* end of gns_api.c */ 423/* end of gns_api.c */
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c
index f58303789..bb37a42a3 100644
--- a/src/gns/gnunet-dns2gns.c
+++ b/src/gns/gnunet-dns2gns.c
@@ -483,7 +483,6 @@ handle_request (struct GNUNET_NETWORK_Handle *lsock,
483 &my_zone, 483 &my_zone,
484 type, 484 type,
485 GNUNET_NO, 485 GNUNET_NO,
486 NULL /* no shorten */,
487 &result_processor, 486 &result_processor,
488 request); 487 request);
489 } 488 }
@@ -618,7 +617,7 @@ run_dnsd ()
618 if (NULL != listen_socket4) 617 if (NULL != listen_socket4)
619 { 618 {
620 struct sockaddr_in v4; 619 struct sockaddr_in v4;
621 620
622 memset (&v4, 0, sizeof (v4)); 621 memset (&v4, 0, sizeof (v4));
623 v4.sin_family = AF_INET; 622 v4.sin_family = AF_INET;
624#if HAVE_SOCKADDR_IN_SIN_LEN 623#if HAVE_SOCKADDR_IN_SIN_LEN
@@ -641,7 +640,7 @@ run_dnsd ()
641 if (NULL != listen_socket6) 640 if (NULL != listen_socket6)
642 { 641 {
643 struct sockaddr_in6 v6; 642 struct sockaddr_in6 v6;
644 643
645 memset (&v6, 0, sizeof (v6)); 644 memset (&v6, 0, sizeof (v6));
646 v6.sin6_family = AF_INET6; 645 v6.sin6_family = AF_INET6;
647#if HAVE_SOCKADDR_IN_SIN_LEN 646#if HAVE_SOCKADDR_IN_SIN_LEN
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c
index 3a38970a8..6eb87a95e 100644
--- a/src/gns/gnunet-gns-proxy.c
+++ b/src/gns/gnunet-gns-proxy.c
@@ -606,7 +606,7 @@ struct Socks5Request
606 * Headers from response 606 * Headers from response
607 */ 607 */
608 struct HttpResponseHeader *header_tail; 608 struct HttpResponseHeader *header_tail;
609 609
610 /** 610 /**
611 * SSL Certificate status 611 * SSL Certificate status
612 */ 612 */
@@ -695,16 +695,6 @@ static struct Socks5Request *s5r_tail;
695static struct GNUNET_CRYPTO_EcdsaPublicKey local_gns_zone; 695static struct GNUNET_CRYPTO_EcdsaPublicKey local_gns_zone;
696 696
697/** 697/**
698 * The users local shorten zone
699 */
700static struct GNUNET_CRYPTO_EcdsaPrivateKey local_shorten_zone;
701
702/**
703 * Is shortening enabled?
704 */
705static int do_shorten;
706
707/**
708 * The CA for SSL certificate generation 698 * The CA for SSL certificate generation
709 */ 699 */
710static struct ProxyCA proxy_ca; 700static struct ProxyCA proxy_ca;
@@ -873,7 +863,7 @@ check_ssl_certificate (struct Socks5Request *s5r)
873 gnutls_x509_crt_t x509_cert; 863 gnutls_x509_crt_t x509_cert;
874 int rc; 864 int rc;
875 const char *name; 865 const char *name;
876 866
877 s5r->ssl_checked = GNUNET_YES; 867 s5r->ssl_checked = GNUNET_YES;
878 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "XXXXXX\n"); 868 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "XXXXXX\n");
879 if (CURLE_OK != 869 if (CURLE_OK !=
@@ -1039,7 +1029,7 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls)
1039 size_t delta_cdomain; 1029 size_t delta_cdomain;
1040 int domain_matched; 1030 int domain_matched;
1041 char *tok; 1031 char *tok;
1042 1032
1043 /* first, check SSL certificate */ 1033 /* first, check SSL certificate */
1044 if ((GNUNET_YES != s5r->ssl_checked) && 1034 if ((GNUNET_YES != s5r->ssl_checked) &&
1045 (HTTPS_PORT == s5r->port)) 1035 (HTTPS_PORT == s5r->port))
@@ -1047,7 +1037,7 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls)
1047 if (GNUNET_OK != check_ssl_certificate (s5r)) 1037 if (GNUNET_OK != check_ssl_certificate (s5r))
1048 return 0; 1038 return 0;
1049 } 1039 }
1050 1040
1051 ndup = GNUNET_strndup (buffer, bytes); 1041 ndup = GNUNET_strndup (buffer, bytes);
1052 hdr_type = strtok (ndup, ":"); 1042 hdr_type = strtok (ndup, ":");
1053 if (NULL == hdr_type) 1043 if (NULL == hdr_type)
@@ -1287,7 +1277,7 @@ curl_upload_cb (void *buf, size_t size, size_t nmemb, void *cls)
1287 struct Socks5Request *s5r = cls; 1277 struct Socks5Request *s5r = cls;
1288 size_t len = size * nmemb; 1278 size_t len = size * nmemb;
1289 size_t to_copy; 1279 size_t to_copy;
1290 1280
1291 if ( (0 == s5r->io_len) && 1281 if ( (0 == s5r->io_len) &&
1292 (SOCKS5_SOCKET_UPLOAD_DONE != s5r->state) ) 1282 (SOCKS5_SOCKET_UPLOAD_DONE != s5r->state) )
1293 { 1283 {
@@ -1763,7 +1753,7 @@ create_response (void *cls,
1763 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1753 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1764 "Processing %u bytes UPLOAD\n", 1754 "Processing %u bytes UPLOAD\n",
1765 (unsigned int) *upload_data_size); 1755 (unsigned int) *upload_data_size);
1766 1756
1767 /* FIXME: This must be set or a header with Transfer-Encoding: chunked. Else 1757 /* FIXME: This must be set or a header with Transfer-Encoding: chunked. Else
1768 * upload callback is not called! 1758 * upload callback is not called!
1769 */ 1759 */
@@ -2827,7 +2817,6 @@ do_s5r_read (void *cls)
2827 &local_gns_zone, 2817 &local_gns_zone,
2828 GNUNET_DNSPARSER_TYPE_A, 2818 GNUNET_DNSPARSER_TYPE_A,
2829 GNUNET_NO /* only cached */, 2819 GNUNET_NO /* only cached */,
2830 (GNUNET_YES == do_shorten) ? &local_shorten_zone : NULL,
2831 &handle_gns_result, 2820 &handle_gns_result,
2832 s5r); 2821 s5r);
2833 break; 2822 break;
@@ -3141,46 +3130,6 @@ run_cont ()
3141 3130
3142 3131
3143/** 3132/**
3144 * Method called to inform about the egos of the shorten zone of this peer.
3145 *
3146 * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get,
3147 * this function is only called ONCE, and 'NULL' being passed in
3148 * @a ego does indicate an error (i.e. name is taken or no default
3149 * value is known). If @a ego is non-NULL and if '*ctx'
3150 * is set in those callbacks, the value WILL be passed to a subsequent
3151 * call to the identity callback of #GNUNET_IDENTITY_connect (if
3152 * that one was not NULL).
3153 *
3154 * @param cls closure, NULL
3155 * @param ego ego handle
3156 * @param ctx context for application to store data for this ego
3157 * (during the lifetime of this process, initially NULL)
3158 * @param name name assigned by the user for this ego,
3159 * NULL if the user just deleted the ego and it
3160 * must thus no longer be used
3161 */
3162static void
3163identity_shorten_cb (void *cls,
3164 struct GNUNET_IDENTITY_Ego *ego,
3165 void **ctx,
3166 const char *name)
3167{
3168 id_op = NULL;
3169 if (NULL == ego)
3170 {
3171 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
3172 _("No ego configured for `shorten-zone`\n"));
3173 }
3174 else
3175 {
3176 local_shorten_zone = *GNUNET_IDENTITY_ego_get_private_key (ego);
3177 do_shorten = GNUNET_YES;
3178 }
3179 run_cont ();
3180}
3181
3182
3183/**
3184 * Method called to inform about the egos of the master zone of this peer. 3133 * Method called to inform about the egos of the master zone of this peer.
3185 * 3134 *
3186 * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get, 3135 * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get,
@@ -3216,10 +3165,7 @@ identity_master_cb (void *cls,
3216 } 3165 }
3217 GNUNET_IDENTITY_ego_get_public_key (ego, 3166 GNUNET_IDENTITY_ego_get_public_key (ego,
3218 &local_gns_zone); 3167 &local_gns_zone);
3219 id_op = GNUNET_IDENTITY_get (identity, 3168 run_cont ();
3220 "gns-short",
3221 &identity_shorten_cb,
3222 NULL);
3223} 3169}
3224 3170
3225 3171
@@ -3232,7 +3178,9 @@ identity_master_cb (void *cls,
3232 * @param c configuration 3178 * @param c configuration
3233 */ 3179 */
3234static void 3180static void
3235run (void *cls, char *const *args, const char *cfgfile, 3181run (void *cls,
3182 char *const *args,
3183 const char *cfgfile,
3236 const struct GNUNET_CONFIGURATION_Handle *c) 3184 const struct GNUNET_CONFIGURATION_Handle *c)
3237{ 3185{
3238 char* cafile_cfg = NULL; 3186 char* cafile_cfg = NULL;
@@ -3323,22 +3271,26 @@ main (int argc, char *const *argv)
3323 "</head><body>cURL fail</body></html>"; 3271 "</head><body>cURL fail</body></html>";
3324 int ret; 3272 int ret;
3325 3273
3326 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 3274 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv,
3275 &argc, &argv))
3327 return 2; 3276 return 2;
3328 GNUNET_log_setup ("gnunet-gns-proxy", "WARNING", NULL); 3277 GNUNET_log_setup ("gnunet-gns-proxy",
3329 curl_failure_response = MHD_create_response_from_buffer (strlen (page), 3278 "WARNING",
3330 (void*)page, 3279 NULL);
3331 MHD_RESPMEM_PERSISTENT); 3280 curl_failure_response
3281 = MHD_create_response_from_buffer (strlen (page),
3282 (void *) page,
3283 MHD_RESPMEM_PERSISTENT);
3332 3284
3333 ret = 3285 ret =
3334 (GNUNET_OK == 3286 (GNUNET_OK ==
3335 GNUNET_PROGRAM_run (argc, argv, "gnunet-gns-proxy", 3287 GNUNET_PROGRAM_run (argc, argv,
3288 "gnunet-gns-proxy",
3336 _("GNUnet GNS proxy"), 3289 _("GNUnet GNS proxy"),
3337 options, 3290 options,
3338 &run, NULL)) ? 0 : 1; 3291 &run, NULL)) ? 0 : 1;
3339 MHD_destroy_response (curl_failure_response); 3292 MHD_destroy_response (curl_failure_response);
3340 GNUNET_free_non_null ((char *) argv); 3293 GNUNET_free_non_null ((char *) argv);
3341 GNUNET_CRYPTO_ecdsa_key_clear (&local_shorten_zone);
3342 return ret; 3294 return ret;
3343} 3295}
3344 3296
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c
index 17fe4cbda..a261e008b 100644
--- a/src/gns/gnunet-gns.c
+++ b/src/gns/gnunet-gns.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2012-2013 GNUnet e.V. 3 Copyright (C) 2012-2013, 2017 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -66,16 +66,6 @@ static char *zone_ego_name;
66static char *public_key; 66static char *public_key;
67 67
68/** 68/**
69 * Reverse key
70 */
71static char *reverse_key;
72
73/**
74 * Reverse key
75 */
76static struct GNUNET_CRYPTO_EcdsaPublicKey rkey;
77
78/**
79 * Set to GNUNET_GNS_LO_LOCAL_MASTER if we are looking up in the master zone. 69 * Set to GNUNET_GNS_LO_LOCAL_MASTER if we are looking up in the master zone.
80 */ 70 */
81static enum GNUNET_GNS_LocalOptions local_options; 71static enum GNUNET_GNS_LocalOptions local_options;
@@ -96,11 +86,6 @@ static int rtype;
96static struct GNUNET_GNS_LookupRequest *lookup_request; 86static struct GNUNET_GNS_LookupRequest *lookup_request;
97 87
98/** 88/**
99 * Handle to reverse lookup request
100 */
101static struct GNUNET_GNS_ReverseLookupRequest *rev_lookup_request;
102
103/**
104 * Lookup an ego with the identity service. 89 * Lookup an ego with the identity service.
105 */ 90 */
106static struct GNUNET_IDENTITY_EgoLookup *el; 91static struct GNUNET_IDENTITY_EgoLookup *el;
@@ -174,24 +159,6 @@ do_timeout (void *cls)
174 GNUNET_SCHEDULER_shutdown (); 159 GNUNET_SCHEDULER_shutdown ();
175} 160}
176 161
177static void
178process_reverse_result (void *cls,
179 const char *name)
180{
181 rev_lookup_request = NULL;
182 if (NULL == name)
183 {
184 printf ("No name found.\n");
185 return;
186 }
187 if (raw)
188 printf ("%s\n", name);
189 else
190 printf ("%s is known as %s\n",
191 reverse_key,
192 name);
193 GNUNET_SCHEDULER_shutdown ();
194}
195 162
196/** 163/**
197 * Function called with the result of a GNS lookup. 164 * Function called with the result of a GNS lookup.
@@ -201,7 +168,8 @@ process_reverse_result (void *cls,
201 * @param rd array of @a rd_count records with the results 168 * @param rd array of @a rd_count records with the results
202 */ 169 */
203static void 170static void
204process_lookup_result (void *cls, uint32_t rd_count, 171process_lookup_result (void *cls,
172 uint32_t rd_count,
205 const struct GNUNET_GNSRECORD_Data *rd) 173 const struct GNUNET_GNSRECORD_Data *rd)
206{ 174{
207 const char *name = cls; 175 const char *name = cls;
@@ -253,11 +221,9 @@ process_lookup_result (void *cls, uint32_t rd_count,
253 * identified by the given public key and the shorten zone. 221 * identified by the given public key and the shorten zone.
254 * 222 *
255 * @param pkey public key to use for the zone, can be NULL 223 * @param pkey public key to use for the zone, can be NULL
256 * @param shorten_key private key used for shortening, can be NULL
257 */ 224 */
258static void 225static void
259lookup_with_keys (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey, 226lookup_with_public_key (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey)
260 const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key)
261{ 227{
262 if (NULL != lookup_type) 228 if (NULL != lookup_type)
263 rtype = GNUNET_GNSRECORD_typename_to_number (lookup_type); 229 rtype = GNUNET_GNSRECORD_typename_to_number (lookup_type);
@@ -277,18 +243,9 @@ lookup_with_keys (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey,
277 pkey, 243 pkey,
278 rtype, 244 rtype,
279 local_options, 245 local_options,
280 shorten_key,
281 &process_lookup_result, 246 &process_lookup_result,
282 lookup_name); 247 lookup_name);
283 } 248 }
284 else if (NULL != reverse_key)
285 {
286 rev_lookup_request = GNUNET_GNS_reverse_lookup (gns,
287 &rkey,
288 pkey,
289 &process_reverse_result,
290 NULL);
291 }
292 else 249 else
293 { 250 {
294 fprintf (stderr, 251 fprintf (stderr,
@@ -300,63 +257,6 @@ lookup_with_keys (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey,
300 257
301 258
302/** 259/**
303 * Method called to with the ego we are to use for shortening
304 * during the lookup.
305 *
306 * @param cls closure contains the public key to use
307 * @param ego ego handle, NULL if not found
308 * @param ctx context for application to store data for this ego
309 * (during the lifetime of this process, initially NULL)
310 * @param name name assigned by the user for this ego,
311 * NULL if the user just deleted the ego and it
312 * must thus no longer be used
313 */
314static void
315identity_shorten_cb (void *cls,
316 struct GNUNET_IDENTITY_Ego *ego,
317 void **ctx,
318 const char *name)
319{
320 struct GNUNET_CRYPTO_EcdsaPublicKey *pkeym = cls;
321
322 id_op = NULL;
323 if (NULL == ego)
324 lookup_with_keys (pkeym, NULL);
325 else
326 lookup_with_keys (pkeym,
327 GNUNET_IDENTITY_ego_get_private_key (ego));
328 GNUNET_free (pkeym);
329}
330
331
332/**
333 * Perform the actual resolution, starting with the zone
334 * identified by the given public key.
335 *
336 * @param pkey public key to use for the zone
337 */
338static void
339lookup_with_public_key (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey)
340{
341 struct GNUNET_CRYPTO_EcdsaPublicKey *pkeym;
342
343 GNUNET_assert (NULL != pkey);
344 pkeym = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey);
345 *pkeym = *pkey;
346 GNUNET_break (NULL == id_op);
347 id_op = GNUNET_IDENTITY_get (identity,
348 "gns-short",
349 &identity_shorten_cb,
350 pkeym);
351 if (NULL == id_op)
352 {
353 GNUNET_break (0);
354 lookup_with_keys (pkey, NULL);
355 }
356}
357
358
359/**
360 * Method called to with the ego we are to use for the lookup, 260 * Method called to with the ego we are to use for the lookup,
361 * when the ego is determined by a name. 261 * when the ego is determined by a name.
362 * 262 *
@@ -449,7 +349,6 @@ run (void *cls,
449 349
450 cfg = c; 350 cfg = c;
451 gns = GNUNET_GNS_connect (cfg); 351 gns = GNUNET_GNS_connect (cfg);
452 identity = GNUNET_IDENTITY_connect (cfg, NULL, NULL);
453 if (NULL == gns) 352 if (NULL == gns)
454 { 353 {
455 fprintf (stderr, 354 fprintf (stderr,
@@ -457,22 +356,13 @@ run (void *cls,
457 return; 356 return;
458 } 357 }
459 tt = GNUNET_SCHEDULER_add_delayed (timeout, 358 tt = GNUNET_SCHEDULER_add_delayed (timeout,
460 &do_timeout, NULL); 359 &do_timeout,
461 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); 360 NULL);
462 if (NULL != reverse_key) 361 GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
463 { 362 NULL);
464 if (GNUNET_OK != 363 identity = GNUNET_IDENTITY_connect (cfg,
465 GNUNET_CRYPTO_ecdsa_public_key_from_string (reverse_key, 364 NULL,
466 strlen (reverse_key), 365 NULL);
467 &rkey))
468 {
469 fprintf (stderr,
470 _("Reverse key `%s' is not well-formed\n"),
471 reverse_key);
472 GNUNET_SCHEDULER_shutdown ();
473 return;
474 }
475 }
476 if (NULL != public_key) 366 if (NULL != public_key)
477 { 367 {
478 if (GNUNET_OK != 368 if (GNUNET_OK !=
@@ -489,20 +379,6 @@ run (void *cls,
489 lookup_with_public_key (&pkey); 379 lookup_with_public_key (&pkey);
490 return; 380 return;
491 } 381 }
492 if (NULL != reverse_key)
493 {
494 if (GNUNET_OK !=
495 GNUNET_CRYPTO_ecdsa_public_key_from_string (reverse_key,
496 strlen (reverse_key),
497 &rkey))
498 {
499 fprintf (stderr,
500 _("Reverse key `%s' is not well-formed\n"),
501 reverse_key);
502 GNUNET_SCHEDULER_shutdown ();
503 return;
504 }
505 }
506 if (NULL != zone_ego_name) 382 if (NULL != zone_ego_name)
507 { 383 {
508 el = GNUNET_IDENTITY_ego_lookup (cfg, 384 el = GNUNET_IDENTITY_ego_lookup (cfg,
@@ -541,7 +417,8 @@ run (void *cls,
541 * @return 0 ok, 1 on error 417 * @return 0 ok, 1 on error
542 */ 418 */
543int 419int
544main (int argc, char *const *argv) 420main (int argc,
421 char *const *argv)
545{ 422{
546 static const struct GNUNET_GETOPT_CommandLineOption options[] = { 423 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
547 {'u', "lookup", "NAME", 424 {'u', "lookup", "NAME",
@@ -562,21 +439,22 @@ main (int argc, char *const *argv)
562 {'z', "zone", "NAME", 439 {'z', "zone", "NAME",
563 gettext_noop ("Specify the name of the ego of the zone to lookup the record in"), 1, 440 gettext_noop ("Specify the name of the ego of the zone to lookup the record in"), 1,
564 &GNUNET_GETOPT_set_string, &zone_ego_name}, 441 &GNUNET_GETOPT_set_string, &zone_ego_name},
565 {'R', "reverse", "PKEY",
566 gettext_noop ("Specify the public key of the zone to reverse lookup a name for"), 1,
567 &GNUNET_GETOPT_set_string, &reverse_key},
568 GNUNET_GETOPT_OPTION_END 442 GNUNET_GETOPT_OPTION_END
569 }; 443 };
570 int ret; 444 int ret;
571 445
572 timeout = GNUNET_TIME_UNIT_FOREVER_REL; 446 timeout = GNUNET_TIME_UNIT_FOREVER_REL;
573 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 447 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv,
448 &argc, &argv))
574 return 2; 449 return 2;
575 450
576 GNUNET_log_setup ("gnunet-gns", "WARNING", NULL); 451 GNUNET_log_setup ("gnunet-gns",
452 "WARNING",
453 NULL);
577 ret = 454 ret =
578 (GNUNET_OK == 455 (GNUNET_OK ==
579 GNUNET_PROGRAM_run (argc, argv, "gnunet-gns", 456 GNUNET_PROGRAM_run (argc, argv,
457 "gnunet-gns",
580 _("GNUnet GNS resolver tool"), 458 _("GNUnet GNS resolver tool"),
581 options, 459 options,
582 &run, NULL)) ? 0 : 1; 460 &run, NULL)) ? 0 : 1;
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index cec31ff48..1e8d07bc5 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -61,7 +61,7 @@ struct ClientLookupHandle
61 * We keep these in a DLL. 61 * We keep these in a DLL.
62 */ 62 */
63 struct ClientLookupHandle *prev; 63 struct ClientLookupHandle *prev;
64 64
65 /** 65 /**
66 * Client handle 66 * Client handle
67 */ 67 */
@@ -73,11 +73,6 @@ struct ClientLookupHandle
73 struct GNS_ResolverHandle *lookup; 73 struct GNS_ResolverHandle *lookup;
74 74
75 /** 75 /**
76 * Active handle for a reverse lookup
77 */
78 struct GNS_ReverserHandle *rev_lookup;
79
80 /**
81 * request id 76 * request id
82 */ 77 */
83 uint32_t request_id; 78 uint32_t request_id;
@@ -173,8 +168,6 @@ shutdown_task (void *cls)
173 identity_handle = NULL; 168 identity_handle = NULL;
174 } 169 }
175 GNS_resolver_done (); 170 GNS_resolver_done ();
176 GNS_reverse_done ();
177 GNS_shorten_done ();
178 if (NULL != statistics) 171 if (NULL != statistics)
179 { 172 {
180 GNUNET_STATISTICS_destroy (statistics, 173 GNUNET_STATISTICS_destroy (statistics,
@@ -221,15 +214,13 @@ client_disconnect_cb (void *cls,
221 { 214 {
222 if (NULL != clh->lookup) 215 if (NULL != clh->lookup)
223 GNS_resolver_lookup_cancel (clh->lookup); 216 GNS_resolver_lookup_cancel (clh->lookup);
224 if (NULL != clh->rev_lookup)
225 GNS_reverse_lookup_cancel (clh->rev_lookup);
226 GNUNET_CONTAINER_DLL_remove (gc->clh_head, 217 GNUNET_CONTAINER_DLL_remove (gc->clh_head,
227 gc->clh_tail, 218 gc->clh_tail,
228 clh); 219 clh);
229 GNUNET_free (clh); 220 GNUNET_free (clh);
230 } 221 }
231 222
232 GNUNET_free (gc); 223 GNUNET_free (gc);
233} 224}
234 225
235 226
@@ -288,7 +279,9 @@ send_lookup_response (void* cls,
288 (char*) &rmsg[1]); 279 (char*) &rmsg[1]);
289 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(clh->gc->client), 280 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(clh->gc->client),
290 env); 281 env);
291 GNUNET_CONTAINER_DLL_remove (clh->gc->clh_head, clh->gc->clh_tail, clh); 282 GNUNET_CONTAINER_DLL_remove (clh->gc->clh_head,
283 clh->gc->clh_tail,
284 clh);
292 GNUNET_free (clh); 285 GNUNET_free (clh);
293 GNUNET_STATISTICS_update (statistics, 286 GNUNET_STATISTICS_update (statistics,
294 "Completed lookups", 1, 287 "Completed lookups", 1,
@@ -299,47 +292,6 @@ send_lookup_response (void* cls,
299 GNUNET_NO); 292 GNUNET_NO);
300} 293}
301 294
302/**
303 * Reply to client with the result from our reverse lookup.
304 *
305 * @param cls the closure (our client lookup handle)
306 * @param rd_count the number of records in @a rd
307 * @param rd the record data
308 */
309static void
310send_reverse_lookup_response (void* cls,
311 const char *name)
312{
313 struct ClientLookupHandle *clh = cls;
314 struct GNUNET_MQ_Envelope *env;
315 struct ReverseLookupResultMessage *rmsg;
316 size_t len;
317
318 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
319 "Sending LOOKUP_RESULT message with %s\n",
320 name);
321
322 if (NULL == name)
323 len = 1;
324 else
325 len = strlen (name) + 1;
326 env = GNUNET_MQ_msg_extra (rmsg,
327 len,
328 GNUNET_MESSAGE_TYPE_GNS_REVERSE_LOOKUP_RESULT);
329 rmsg->id = clh->request_id;
330 if (1 < len)
331 GNUNET_memcpy ((char*) &rmsg[1],
332 name,
333 strlen (name));
334 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(clh->gc->client),
335 env);
336 GNUNET_CONTAINER_DLL_remove (clh->gc->clh_head, clh->gc->clh_tail, clh);
337 GNUNET_free (clh);
338 GNUNET_STATISTICS_update (statistics,
339 "Completed reverse lookups", 1,
340 GNUNET_NO);
341}
342
343 295
344/** 296/**
345 * Checks a #GNUNET_MESSAGE_TYPE_GNS_LOOKUP message 297 * Checks a #GNUNET_MESSAGE_TYPE_GNS_LOOKUP message
@@ -371,6 +323,7 @@ check_lookup (void *cls,
371 return GNUNET_OK; 323 return GNUNET_OK;
372} 324}
373 325
326
374/** 327/**
375 * Handle lookup requests from client 328 * Handle lookup requests from client
376 * 329 *
@@ -387,20 +340,17 @@ handle_lookup (void *cls,
387 struct ClientLookupHandle *clh; 340 struct ClientLookupHandle *clh;
388 char *nameptr = name; 341 char *nameptr = name;
389 const char *utf_in; 342 const char *utf_in;
390 const struct GNUNET_CRYPTO_EcdsaPrivateKey *key;
391 343
392 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 344 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
393 "Received LOOKUP message\n"); 345 "Received LOOKUP message\n");
394 GNUNET_SERVICE_client_continue (gc->client); 346 GNUNET_SERVICE_client_continue (gc->client);
395 if (GNUNET_YES == ntohs (sh_msg->have_key))
396 key = &sh_msg->shorten_key;
397 else
398 key = NULL;
399 utf_in = (const char *) &sh_msg[1]; 347 utf_in = (const char *) &sh_msg[1];
400 GNUNET_STRINGS_utf8_tolower (utf_in, nameptr); 348 GNUNET_STRINGS_utf8_tolower (utf_in, nameptr);
401 349
402 clh = GNUNET_new (struct ClientLookupHandle); 350 clh = GNUNET_new (struct ClientLookupHandle);
403 GNUNET_CONTAINER_DLL_insert (gc->clh_head, gc->clh_tail, clh); 351 GNUNET_CONTAINER_DLL_insert (gc->clh_head,
352 gc->clh_tail,
353 clh);
404 clh->gc = gc; 354 clh->gc = gc;
405 clh->request_id = sh_msg->id; 355 clh->request_id = sh_msg->id;
406 if ( (GNUNET_DNSPARSER_TYPE_A == ntohl (sh_msg->type)) && 356 if ( (GNUNET_DNSPARSER_TYPE_A == ntohl (sh_msg->type)) &&
@@ -422,7 +372,6 @@ handle_lookup (void *cls,
422 clh->lookup = GNS_resolver_lookup (&sh_msg->zone, 372 clh->lookup = GNS_resolver_lookup (&sh_msg->zone,
423 ntohl (sh_msg->type), 373 ntohl (sh_msg->type),
424 name, 374 name,
425 key,
426 (enum GNUNET_GNS_LocalOptions) ntohs (sh_msg->options), 375 (enum GNUNET_GNS_LocalOptions) ntohs (sh_msg->options),
427 &send_lookup_response, clh); 376 &send_lookup_response, clh);
428 GNUNET_STATISTICS_update (statistics, 377 GNUNET_STATISTICS_update (statistics,
@@ -430,82 +379,6 @@ handle_lookup (void *cls,
430 1, GNUNET_NO); 379 1, GNUNET_NO);
431} 380}
432 381
433/**
434 * Handle reverse lookup requests from client
435 *
436 * @param cls the closure
437 * @param client the client
438 * @param message the message
439 */
440static void
441handle_rev_lookup (void *cls,
442 const struct ReverseLookupMessage *sh_msg)
443{
444 struct GnsClient *gc = cls;
445 struct ClientLookupHandle *clh;
446
447 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
448 "Received REVERSE_LOOKUP message\n");
449 GNUNET_SERVICE_client_continue (gc->client);
450
451 clh = GNUNET_new (struct ClientLookupHandle);
452 GNUNET_CONTAINER_DLL_insert (gc->clh_head, gc->clh_tail, clh);
453 clh->gc = gc;
454 clh->request_id = sh_msg->id;
455 clh->rev_lookup = GNS_reverse_lookup (&sh_msg->zone_pkey,
456 &sh_msg->root_pkey,
457 &send_reverse_lookup_response,
458 clh);
459 GNUNET_STATISTICS_update (statistics,
460 "Reverse lookup attempts",
461 1, GNUNET_NO);
462}
463
464
465/**
466 * Method called to inform about the ego to be used for the master zone
467 * for DNS interceptions.
468 *
469 * This function is only called ONCE, and 'NULL' being passed in
470 * @a ego does indicate that interception is not configured.
471 * If @a ego is non-NULL, we should start to intercept DNS queries
472 * and resolve ".gnu" queries using the given ego as the master zone.
473 *
474 * @param cls closure, our `const struct GNUNET_CONFIGURATION_Handle *c`
475 * @param ego ego handle
476 * @param ctx context for application to store data for this ego
477 * (during the lifetime of this process, initially NULL)
478 * @param name name assigned by the user for this ego,
479 * NULL if the user just deleted the ego and it
480 * must thus no longer be used
481 */
482static void
483identity_reverse_cb (void *cls,
484 struct GNUNET_IDENTITY_Ego *ego,
485 void **ctx,
486 const char *name)
487{
488 identity_op = NULL;
489
490 if (NULL == ego)
491 {
492 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
493 _("No ego configured for `%s`\n"),
494 "gns-master");
495
496 return;
497 }
498 if (GNUNET_SYSERR ==
499 GNS_reverse_init (namestore_handle,
500 GNUNET_IDENTITY_ego_get_private_key (ego),
501 name))
502 {
503 GNUNET_break (0);
504 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
505 return;
506 }
507}
508
509 382
510/** 383/**
511 * Method called to inform about the ego to be used for the master zone 384 * Method called to inform about the ego to be used for the master zone
@@ -532,16 +405,10 @@ identity_intercept_cb (void *cls,
532{ 405{
533 const struct GNUNET_CONFIGURATION_Handle *cfg = cls; 406 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
534 struct GNUNET_CRYPTO_EcdsaPublicKey dns_root; 407 struct GNUNET_CRYPTO_EcdsaPublicKey dns_root;
535 identity_op = NULL;
536 408
409 identity_op = NULL;
537 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 410 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
538 "Looking for gns-intercept ego\n"); 411 "Looking for gns-intercept ego\n");
539 identity_op = GNUNET_IDENTITY_get (identity_handle,
540 "gns-reverse",
541 &identity_reverse_cb,
542 (void*)cfg);
543
544
545 if (NULL == ego) 412 if (NULL == ego)
546 { 413 {
547 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 414 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -553,10 +420,12 @@ identity_intercept_cb (void *cls,
553 GNUNET_IDENTITY_ego_get_public_key (ego, 420 GNUNET_IDENTITY_ego_get_public_key (ego,
554 &dns_root); 421 &dns_root);
555 if (GNUNET_SYSERR == 422 if (GNUNET_SYSERR ==
556 GNS_interceptor_init (&dns_root, cfg)) 423 GNS_interceptor_init (&dns_root,
424 cfg))
557 { 425 {
558 GNUNET_break (0); 426 GNUNET_break (0);
559 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); 427 GNUNET_SCHEDULER_add_now (&shutdown_task,
428 NULL);
560 return; 429 return;
561 } 430 }
562} 431}
@@ -577,7 +446,7 @@ run (void *cls,
577 unsigned long long max_parallel_bg_queries = 16; 446 unsigned long long max_parallel_bg_queries = 16;
578 447
579 v6_enabled = GNUNET_NETWORK_test_pf (PF_INET6); 448 v6_enabled = GNUNET_NETWORK_test_pf (PF_INET6);
580 v4_enabled = GNUNET_NETWORK_test_pf (PF_INET); 449 v4_enabled = GNUNET_NETWORK_test_pf (PF_INET);
581 namestore_handle = GNUNET_NAMESTORE_connect (c); 450 namestore_handle = GNUNET_NAMESTORE_connect (c);
582 if (NULL == namestore_handle) 451 if (NULL == namestore_handle)
583 { 452 {
@@ -635,11 +504,9 @@ run (void *cls,
635 dht_handle, 504 dht_handle,
636 c, 505 c,
637 max_parallel_bg_queries); 506 max_parallel_bg_queries);
638 GNS_shorten_init (namestore_handle,
639 namecache_handle,
640 dht_handle);
641 statistics = GNUNET_STATISTICS_create ("gns", c); 507 statistics = GNUNET_STATISTICS_create ("gns", c);
642 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); 508 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
509 NULL);
643} 510}
644 511
645 512
@@ -657,10 +524,6 @@ GNUNET_SERVICE_MAIN
657 GNUNET_MESSAGE_TYPE_GNS_LOOKUP, 524 GNUNET_MESSAGE_TYPE_GNS_LOOKUP,
658 struct LookupMessage, 525 struct LookupMessage,
659 NULL), 526 NULL),
660 GNUNET_MQ_hd_fixed_size (rev_lookup,
661 GNUNET_MESSAGE_TYPE_GNS_REVERSE_LOOKUP,
662 struct ReverseLookupMessage,
663 NULL),
664 GNUNET_MQ_handler_end()); 527 GNUNET_MQ_handler_end());
665 528
666 529
diff --git a/src/gns/gnunet-service-gns_interceptor.c b/src/gns/gnunet-service-gns_interceptor.c
index 7a3cfc0dd..a9e207891 100644
--- a/src/gns/gnunet-service-gns_interceptor.c
+++ b/src/gns/gnunet-service-gns_interceptor.c
@@ -333,7 +333,6 @@ handle_dns_request (void *cls,
333 ilh->lookup = GNS_resolver_lookup (&zone, 333 ilh->lookup = GNS_resolver_lookup (&zone,
334 p->queries[0].type, 334 p->queries[0].type,
335 p->queries[0].name, 335 p->queries[0].name,
336 NULL /* FIXME: enable shorten for DNS intercepts? */,
337 GNUNET_NO, 336 GNUNET_NO,
338 &reply_to_dns, ilh); 337 &reply_to_dns, ilh);
339 return; 338 return;
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 5e957871e..40b340ad7 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -327,11 +327,6 @@ struct GNS_ResolverHandle
327 struct AuthorityChain *ac_tail; 327 struct AuthorityChain *ac_tail;
328 328
329 /** 329 /**
330 * Private key of the shorten zone, NULL to not shorten.
331 */
332 struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key;
333
334 /**
335 * ID of a task associated with the resolution process. 330 * ID of a task associated with the resolution process.
336 */ 331 */
337 struct GNUNET_SCHEDULER_Task * task_id; 332 struct GNUNET_SCHEDULER_Task * task_id;
@@ -1750,23 +1745,6 @@ handle_gns_resolution_result (void *cls,
1750 } /* end: switch */ 1745 } /* end: switch */
1751 } /* end: for rd_count */ 1746 } /* end: for rd_count */
1752 1747
1753 /* trigger shortening */
1754 if ((NULL != rh->shorten_key) &&
1755 (NULL != shorten_ac) &&
1756 (GNUNET_NO == shorten_ac->shortening_started) &&
1757 (NULL != shorten_ac->suggested_shortening_label))
1758 {
1759 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1760 "Start shortening for label `%s' based on nick `%s'\n",
1761 shorten_ac->label,
1762 shorten_ac->suggested_shortening_label);
1763 shorten_ac->shortening_started = GNUNET_YES;
1764 GNS_shorten_start (shorten_ac->label,
1765 shorten_ac->suggested_shortening_label,
1766 &shorten_ac->authority_info.gns_authority,
1767 rh->shorten_key);
1768 }
1769
1770 /* yes, we are done, return result */ 1748 /* yes, we are done, return result */
1771 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1772 "Returning GNS response for `%s' with %u answers\n", 1750 "Returning GNS response for `%s' with %u answers\n",
@@ -2374,7 +2352,6 @@ start_resolver_lookup (struct GNS_ResolverHandle *rh)
2374 * @param zone the zone to perform the lookup in 2352 * @param zone the zone to perform the lookup in
2375 * @param record_type the record type to look up 2353 * @param record_type the record type to look up
2376 * @param name the name to look up 2354 * @param name the name to look up
2377 * @param shorten_key a private key for use with PSEU import (can be NULL)
2378 * @param options local options to control local lookup 2355 * @param options local options to control local lookup
2379 * @param proc the processor to call on result 2356 * @param proc the processor to call on result
2380 * @param proc_cls the closure to pass to @a proc 2357 * @param proc_cls the closure to pass to @a proc
@@ -2384,16 +2361,13 @@ struct GNS_ResolverHandle *
2384GNS_resolver_lookup (const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, 2361GNS_resolver_lookup (const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
2385 uint32_t record_type, 2362 uint32_t record_type,
2386 const char *name, 2363 const char *name,
2387 const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key,
2388 enum GNUNET_GNS_LocalOptions options, 2364 enum GNUNET_GNS_LocalOptions options,
2389 GNS_ResultProcessor proc, void *proc_cls) 2365 GNS_ResultProcessor proc, void *proc_cls)
2390{ 2366{
2391 struct GNS_ResolverHandle *rh; 2367 struct GNS_ResolverHandle *rh;
2392 2368
2393 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2369 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2394 (NULL == shorten_key) 2370 "Starting lookup for `%s'\n",
2395 ? "Starting lookup for `%s' with shortening disabled\n"
2396 : "Starting lookup for `%s' with shortening enabled\n",
2397 name); 2371 name);
2398 rh = GNUNET_new (struct GNS_ResolverHandle); 2372 rh = GNUNET_new (struct GNS_ResolverHandle);
2399 GNUNET_CONTAINER_DLL_insert (rlh_head, 2373 GNUNET_CONTAINER_DLL_insert (rlh_head,
@@ -2406,11 +2380,6 @@ GNS_resolver_lookup (const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
2406 rh->record_type = record_type; 2380 rh->record_type = record_type;
2407 rh->name = GNUNET_strdup (name); 2381 rh->name = GNUNET_strdup (name);
2408 rh->name_resolution_pos = strlen (name); 2382 rh->name_resolution_pos = strlen (name);
2409 if (NULL != shorten_key)
2410 {
2411 rh->shorten_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPrivateKey);
2412 *rh->shorten_key = *shorten_key;
2413 }
2414 start_resolver_lookup (rh); 2383 start_resolver_lookup (rh);
2415 return rh; 2384 return rh;
2416} 2385}
@@ -2507,7 +2476,6 @@ GNS_resolver_lookup_cancel (struct GNS_ResolverHandle *rh)
2507 dr); 2476 dr);
2508 GNUNET_free (dr); 2477 GNUNET_free (dr);
2509 } 2478 }
2510 GNUNET_free_non_null (rh->shorten_key);
2511 GNUNET_free (rh->name); 2479 GNUNET_free (rh->name);
2512 GNUNET_free (rh); 2480 GNUNET_free (rh);
2513} 2481}
diff --git a/src/gns/gnunet-service-gns_resolver.h b/src/gns/gnunet-service-gns_resolver.h
index 863398093..c71d3983d 100644
--- a/src/gns/gnunet-service-gns_resolver.h
+++ b/src/gns/gnunet-service-gns_resolver.h
@@ -65,9 +65,10 @@ struct GNS_ResolverHandle;
65 * @param rd_count number of records in @a rd 65 * @param rd_count number of records in @a rd
66 * @param rd records returned for the lookup 66 * @param rd records returned for the lookup
67 */ 67 */
68typedef void (*GNS_ResultProcessor)(void *cls, 68typedef void
69 uint32_t rd_count, 69(*GNS_ResultProcessor)(void *cls,
70 const struct GNUNET_GNSRECORD_Data *rd); 70 uint32_t rd_count,
71 const struct GNUNET_GNSRECORD_Data *rd);
71 72
72 73
73/** 74/**
@@ -77,7 +78,6 @@ typedef void (*GNS_ResultProcessor)(void *cls,
77 * @param zone the zone to perform the lookup in 78 * @param zone the zone to perform the lookup in
78 * @param record_type the record type to look up 79 * @param record_type the record type to look up
79 * @param name the name to look up 80 * @param name the name to look up
80 * @param shorten_key optional private key for authority caching, can be NULL
81 * @param options options set to control local lookup 81 * @param options options set to control local lookup
82 * @param proc the processor to call 82 * @param proc the processor to call
83 * @param proc_cls the closure to pass to @a proc 83 * @param proc_cls the closure to pass to @a proc
@@ -87,7 +87,6 @@ struct GNS_ResolverHandle *
87GNS_resolver_lookup (const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, 87GNS_resolver_lookup (const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
88 uint32_t record_type, 88 uint32_t record_type,
89 const char *name, 89 const char *name,
90 const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key,
91 enum GNUNET_GNS_LocalOptions options, 90 enum GNUNET_GNS_LocalOptions options,
92 GNS_ResultProcessor proc, 91 GNS_ResultProcessor proc,
93 void *proc_cls); 92 void *proc_cls);
@@ -102,8 +101,6 @@ void
102GNS_resolver_lookup_cancel (struct GNS_ResolverHandle *rh); 101GNS_resolver_lookup_cancel (struct GNS_ResolverHandle *rh);
103 102
104 103
105
106
107/** 104/**
108 * Generic function to check for TLDs. Checks if "name" ends in ".tld" 105 * Generic function to check for TLDs. Checks if "name" ends in ".tld"
109 * 106 *
diff --git a/src/gns/plugin_rest_gns.c b/src/gns/plugin_rest_gns.c
index 3cddbc246..5d4734d9a 100644
--- a/src/gns/plugin_rest_gns.c
+++ b/src/gns/plugin_rest_gns.c
@@ -336,10 +336,9 @@ process_lookup_result (void *cls, uint32_t rd_count,
336 * identified by the given public key and the shorten zone. 336 * identified by the given public key and the shorten zone.
337 * 337 *
338 * @param pkey public key to use for the zone, can be NULL 338 * @param pkey public key to use for the zone, can be NULL
339 * @param shorten_key private key used for shortening, can be NULL
340 */ 339 */
341static void 340static void
342lookup_with_keys (struct LookupHandle *handle, const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key) 341lookup_with_public_key (struct LookupHandle *handle)
343{ 342{
344 if (UINT32_MAX == handle->type) 343 if (UINT32_MAX == handle->type)
345 { 344 {
@@ -354,7 +353,6 @@ lookup_with_keys (struct LookupHandle *handle, const struct GNUNET_CRYPTO_EcdsaP
354 &handle->pkey, 353 &handle->pkey,
355 handle->type, 354 handle->type,
356 handle->options, 355 handle->options,
357 shorten_key,
358 &process_lookup_result, 356 &process_lookup_result,
359 handle); 357 handle);
360 } 358 }
@@ -365,55 +363,6 @@ lookup_with_keys (struct LookupHandle *handle, const struct GNUNET_CRYPTO_EcdsaP
365 } 363 }
366} 364}
367 365
368/**
369 * Method called to with the ego we are to use for shortening
370 * during the lookup.
371 *
372 * @param cls closure contains the public key to use
373 * @param ego ego handle, NULL if not found
374 * @param ctx context for application to store data for this ego
375 * (during the lifetime of this process, initially NULL)
376 * @param name name assigned by the user for this ego,
377 * NULL if the user just deleted the ego and it
378 * must thus no longer be used
379 */
380static void
381identity_shorten_cb (void *cls,
382 struct GNUNET_IDENTITY_Ego *ego,
383 void **ctx,
384 const char *name)
385{
386 struct LookupHandle *handle = cls;
387
388 handle->id_op = NULL;
389 if (NULL == ego)
390 lookup_with_keys (handle, NULL);
391 else
392 lookup_with_keys (handle,
393 GNUNET_IDENTITY_ego_get_private_key (ego));
394}
395
396/**
397 * Perform the actual resolution, starting with the zone
398 * identified by the given public key.
399 *
400 * @param pkey public key to use for the zone
401 */
402static void
403lookup_with_public_key (struct LookupHandle *handle)
404{
405 handle->pkeym = handle->pkey;
406 GNUNET_break (NULL == handle->id_op);
407 handle->id_op = GNUNET_IDENTITY_get (handle->identity,
408 "gns-short",
409 &identity_shorten_cb,
410 handle);
411 if (NULL == handle->id_op)
412 {
413 GNUNET_break (0);
414 lookup_with_keys (handle, NULL);
415 }
416}
417 366
418/** 367/**
419 * Method called to with the ego we are to use for the lookup, 368 * Method called to with the ego we are to use for the lookup,
@@ -444,6 +393,7 @@ identity_zone_cb (void *cls,
444 json_decref(handle->json_root); 393 json_decref(handle->json_root);
445} 394}
446 395
396
447/** 397/**
448 * Method called to with the ego we are to use for the lookup, 398 * Method called to with the ego we are to use for the lookup,
449 * when the ego is the one for the default master zone. 399 * when the ego is the one for the default master zone.
diff --git a/src/gns/test_gns_nick_shorten.sh b/src/gns/test_gns_nick_shorten.sh
deleted file mode 100755
index df69bbba9..000000000
--- a/src/gns/test_gns_nick_shorten.sh
+++ /dev/null
@@ -1,124 +0,0 @@
1#!/bin/bash
2trap "gnunet-arm -e -c test_gns_nick_shorten.conf" SIGINT
3which timeout &> /dev/null && DO_TIMEOUT="timeout 5"
4
5# This test tests shortening functionality based on NICK records:
6#
7# zone "delegatedego": Alice's zone
8# zone "testego": Local zone with delegation to alice
9
10LOCATION=$(which gnunet-config)
11if [ -z $LOCATION ]
12then
13 LOCATION="gnunet-config"
14fi
15$LOCATION --version 1> /dev/null
16if test $? != 0
17then
18 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
19 exit 77
20fi
21
22# Deleting home directory from previous runs
23TEST_CONFIG="test_gns_nick_shorten.conf "
24rm -rf /tmp/test-gnunet-gns-peer-1/
25TEST_IP="127.0.0.1"
26TEST_IP="127.0.0.2"
27TEST_NICK_EGO="ego"
28TEST_NICK_DELEGATED="alice"
29TEST_NAME="www.mybestfriendalice.gnu"
30TEST_NAME_SHORT="www.alice.short.gnu"
31
32# export GNUNET_FORCE_LOG="namestore;;;;DEBUG/gns;;;;DEBUG/;;;;WARNING"
33
34# Start gnunet
35echo "Starting arm with configuration $TEST_CONFIG"
36gnunet-arm -s -c $TEST_CONFIG
37
38# Create initial identities: short-zone, delegated-zone, testego
39echo "Creating identities"
40gnunet-identity -d -c $TEST_CONFIG
41gnunet-identity -C short-zone -c $TEST_CONFIG
42gnunet-identity -C delegatedego -c $TEST_CONFIG
43gnunet-identity -e short-zone -s gns-short -c $TEST_CONFIG
44gnunet-identity -C testego -c $TEST_CONFIG
45
46echo "Adding nick names for identities"
47gnunet-namestore -z testego -i $TEST_NICK_EGO -c $TEST_CONFIG
48gnunet-namestore -z delegatedego -i $TEST_NICK_DELEGATED -c $TEST_CONFIG
49
50# Adding label www in Alice's delegatedego zone
51echo "Adding www record with IP $TEST_IP"
52gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e never -c test_gns_nick_shorten.conf
53
54# Retrieve PKEYs for delegation
55DELEGATED_PKEY=$(gnunet-identity -d -c $TEST_CONFIG| grep delegatedego | awk '{print $3}')
56echo "Alice's PKEY is $DELEGATED_PKEY"
57
58SHORTEN_PKEY=$(gnunet-identity -c test_gns_nick_shorten.conf -d | grep short-zone | awk '{print $3}')
59echo "Shorten PKEY is $SHORTEN_PKEY"
60
61# Delegate the name "short" to shortenzone
62gnunet-namestore -p -z testego -a -n short -t PKEY -V $SHORTEN_PKEY -e never -c test_gns_nick_shorten.conf
63
64# Delegate the name "mybestfriendalice" to alice
65gnunet-namestore -p -z testego -a -n mybestfriendalice -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_nick_shorten.conf
66
67# Perform lookup to shorten
68echo "Start gns..."
69gnunet-arm -c test_gns_nick_shorten.conf -i gns
70
71
72RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_NAME -t A -c test_gns_nick_shorten.conf`
73
74sleep 1
75
76echo "Lookup shortened names"
77PKEY_SHORT_RES=$($DO_TIMEOUT gnunet-gns --raw -c test_gns_nick_shorten.conf -z short-zone -u alice.gnu -t PKEY)
78echo "Resolving alice's PKEY in shorten zone: $PKEY_SHORT_RES"
79PKEY_RES=$($DO_TIMEOUT gnunet-gns --raw -c test_gns_nick_shorten.conf -z testego -u alice.short.gnu -t PKEY)
80echo "Resolving alice's PKEY in master zone: $PKEY_RES"
81
82RES=0
83if [ "$DELEGATED_PKEY" == "$PKEY_SHORT_RES" ]
84then
85 echo "PASS: Resolved delegation for shorten name in shortened zone"
86else
87 echo "FAIL: Expected PKEY in $DELEGATED_PKEY, received PKEY '$PKEY_SHORT_RES' in shorten zone."
88 RES=1
89fi
90
91if [ "$DELEGATED_PKEY" == "$PKEY_RES" ]
92then
93 echo "PASS: Resolved delegation for shorten name in master zone"
94else
95 echo "FAIL: Expected PKEY in $DELEGATED_PKEY, received PKEY $PKEY_SHORT_RES in master zone."
96 RES=1
97fi
98
99if [ $RES -eq 0 ]
100then
101 RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_NAME_SHORT -t A -c test_gns_nick_shorten.conf`
102 if [ "$RES_IP" == "$TEST_IP" ]
103 then
104 echo "PASS: Received $TEST_IP for $TEST_NAME_SHORT"
105 else
106 echo "FAIL: Expected IP in $TEST_IP, received IP '$RES_IP' for $TEST_SHORT_NAME."
107 RES=1
108 fi
109fi
110
111
112# Clean up
113echo "Clean up..."
114gnunet-namestore -z testego -d -n mybestfriendalice -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_nick_shorten.conf
115gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e never -c test_gns_nick_shorten.conf
116gnunet-identity -D -z testego -c $TEST_CONFIG
117gnunet-identity -D -z delegatedego -c $TEST_CONFIG
118gnunet-identity -D -z short-zone -c $TEST_CONFIG
119
120gnunet-arm -e -c test_gns_nick_shorten.conf
121rm -rf /tmp/test-gnunet-gns-peer-1/
122
123exit $RES
124
diff --git a/src/gns/test_gns_reverse_lookup.sh b/src/gns/test_gns_reverse_lookup.sh
deleted file mode 100755
index 189adef11..000000000
--- a/src/gns/test_gns_reverse_lookup.sh
+++ /dev/null
@@ -1,50 +0,0 @@
1#!/bin/bash
2trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT
3which timeout &> /dev/null && DO_TIMEOUT="timeout 30"
4
5LOCATION=$(which gnunet-config)
6if [ -z $LOCATION ]
7then
8 LOCATION="gnunet-config"
9fi
10$LOCATION --version 1> /dev/null
11if test $? != 0
12then
13 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
14 exit 77
15fi
16
17TEST_NAME="dave.bob.alice.gnu"
18gnunet-arm -s -c test_gns_lookup.conf
19gnunet-identity -C bob -c test_gns_lookup.conf
20BOB_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep bob | awk '{print $3}')
21gnunet-identity -C daveego -c test_gns_lookup.conf
22DAVE_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep dave | awk '{print $3}')
23gnunet-identity -C aliceego -c test_gns_lookup.conf
24ALICE_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep alice | awk '{print $3}')
25gnunet-identity -C testego -c test_gns_lookup.conf
26ROOT_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep testego | awk '{print $3}')
27
28gnunet-identity -s gns-reverse -e bob -c test_gns_lookup.conf
29
30gnunet-namestore -p -z testego -a -n alice -t PKEY -V $ALICE_PKEY -e never -c test_gns_lookup.conf
31gnunet-namestore -p -z aliceego -a -n bob -t PKEY -V $BOB_PKEY -e never -c test_gns_lookup.conf
32gnunet-namestore -p -z aliceego -a -n + -t REVERSE -V "alice $ROOT_PKEY 0" -e never -c test_gns_lookup.conf
33gnunet-namestore -p -z bob -a -n dave -t PKEY -V $DAVE_PKEY -e never -c test_gns_lookup.conf
34gnunet-namestore -p -z bob -a -n alice -t PKEY -V $ALICE_PKEY -e never -c test_gns_lookup.conf
35#gnunet-namestore -p -z bob -a -n + -t REVERSE -V "bob $ALICE_PKEY 0" -e never -c test_gns_lookup.conf
36gnunet-namestore -p -z daveego -a -n + -t REVERSE -V "dave $BOB_PKEY 0" -e never -c test_gns_lookup.conf
37gnunet-namestore -p -z daveego -a -n bob -t PKEY -V $BOB_PKEY -e never -c test_gns_lookup.conf
38gnunet-arm -i gns -c test_gns_lookup.conf
39sleep 10
40RES_NAME=`$DO_TIMEOUT gnunet-gns --raw -z testego -R $DAVE_PKEY -c test_gns_lookup.conf`
41gnunet-arm -e -c test_gns_lookup.conf
42rm -rf /tmp/test-gnunet-gns-peer-1/
43
44if [ "$RES_NAME" == "$TEST_NAME" ]
45then
46 exit 0
47else
48 echo "Failed to resolve to proper IP, got $RES_IP."
49 exit 1
50fi
diff --git a/src/identity-provider/gnunet-service-identity-provider.c b/src/identity-provider/gnunet-service-identity-provider.c
index d72b92c0f..17c288368 100644
--- a/src/identity-provider/gnunet-service-identity-provider.c
+++ b/src/identity-provider/gnunet-service-identity-provider.c
@@ -714,7 +714,7 @@ attribute_collect (void *cls,
714 GNUNET_CONTAINER_DLL_insert (attr->val_head, 714 GNUNET_CONTAINER_DLL_insert (attr->val_head,
715 attr->val_tail, 715 attr->val_tail,
716 val); 716 val);
717 GNUNET_assert (GNUNET_OK == 717 GNUNET_assert (GNUNET_OK ==
718 GNUNET_CONTAINER_multihashmap_put (ego_entry->attr_map, 718 GNUNET_CONTAINER_multihashmap_put (ego_entry->attr_map,
719 &key, 719 &key,
720 attr, 720 attr,
@@ -949,7 +949,7 @@ create_issue_result_message (const char* label,
949 struct IssueResultMessage *irm; 949 struct IssueResultMessage *irm;
950 char *tmp_str; 950 char *tmp_str;
951 size_t len; 951 size_t len;
952 952
953 GNUNET_asprintf (&tmp_str, "%s,%s,%s", label, ticket, token); 953 GNUNET_asprintf (&tmp_str, "%s,%s,%s", label, ticket, token);
954 len = strlen (tmp_str) + 1; 954 len = strlen (tmp_str) + 1;
955 env = GNUNET_MQ_msg_extra (irm, 955 env = GNUNET_MQ_msg_extra (irm,
@@ -1279,7 +1279,7 @@ check_exchange_message (void *cls,
1279 return GNUNET_SYSERR; 1279 return GNUNET_SYSERR;
1280 } 1280 }
1281 return GNUNET_OK; 1281 return GNUNET_OK;
1282} 1282}
1283 1283
1284/** 1284/**
1285 * 1285 *
@@ -1326,7 +1326,6 @@ handle_exchange_message (void *cls,
1326 &xchange_handle->ticket->payload->identity_key, 1326 &xchange_handle->ticket->payload->identity_key,
1327 GNUNET_GNSRECORD_TYPE_ID_TOKEN, 1327 GNUNET_GNSRECORD_TYPE_ID_TOKEN,
1328 GNUNET_GNS_LO_LOCAL_MASTER, 1328 GNUNET_GNS_LO_LOCAL_MASTER,
1329 NULL,
1330 &process_lookup_result, 1329 &process_lookup_result,
1331 xchange_handle); 1330 xchange_handle);
1332 GNUNET_free (lookup_query); 1331 GNUNET_free (lookup_query);
diff --git a/src/include/gnunet_gns_service.h b/src/include/gnunet_gns_service.h
index 44f57014d..ccc868c05 100644
--- a/src/include/gnunet_gns_service.h
+++ b/src/include/gnunet_gns_service.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 Copyright (C) 2012-2014 GNUnet e.V. 3 Copyright (C) 2012-2014, 2017 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -95,16 +95,6 @@ typedef void
95 uint32_t rd_count, 95 uint32_t rd_count,
96 const struct GNUNET_GNSRECORD_Data *rd); 96 const struct GNUNET_GNSRECORD_Data *rd);
97 97
98/**
99 * Iterator called on obtained result for a GNS lookup.
100 *
101 * @param cls closure
102 * @param name result of the reverse lookup
103 */
104typedef void
105(*GNUNET_GNS_ReverseLookupResultProcessor) (void *cls,
106 const char* name);
107
108 98
109/** 99/**
110 * Options for the GNS lookup. 100 * Options for the GNS lookup.
@@ -138,13 +128,8 @@ enum GNUNET_GNS_LocalOptions
138 * @param zone zone to look in 128 * @param zone zone to look in
139 * @param type the GNS record type to look for 129 * @param type the GNS record type to look for
140 * @param options local options for the lookup 130 * @param options local options for the lookup
141 * @param shorten_zone_key the private key of the shorten zone (can be NULL);
142 * specify to enable automatic shortening (given a PSEU
143 * record, if a given pseudonym is not yet used in the
144 * shorten zone, we automatically add the respective zone
145 * under that name)
146 * @param proc function to call on result 131 * @param proc function to call on result
147 * @param proc_cls closure for processor 132 * @param proc_cls closure for @a proc
148 * @return handle to the queued request 133 * @return handle to the queued request
149 */ 134 */
150struct GNUNET_GNS_LookupRequest * 135struct GNUNET_GNS_LookupRequest *
@@ -153,27 +138,9 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
153 const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, 138 const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
154 uint32_t type, 139 uint32_t type,
155 enum GNUNET_GNS_LocalOptions options, 140 enum GNUNET_GNS_LocalOptions options,
156 const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone_key,
157 GNUNET_GNS_LookupResultProcessor proc, 141 GNUNET_GNS_LookupResultProcessor proc,
158 void *proc_cls); 142 void *proc_cls);
159 143
160/**
161 * Perform an asynchronous reverse lookup operation on the GNS.
162 *
163 * @param handle handle to the GNS service
164 * @param zone_key zone to find a name for
165 * @param root_key our zone
166 * @param proc processor to call on result
167 * @param proc_cls closure for @a proc
168 * @return handle to the request
169 */
170struct GNUNET_GNS_ReverseLookupRequest *
171GNUNET_GNS_reverse_lookup (struct GNUNET_GNS_Handle *handle,
172 const struct GNUNET_CRYPTO_EcdsaPublicKey *zone_key,
173 const struct GNUNET_CRYPTO_EcdsaPublicKey *root_key,
174 GNUNET_GNS_ReverseLookupResultProcessor proc,
175 void *proc_cls);
176
177 144
178/** 145/**
179 * Cancel pending lookup request 146 * Cancel pending lookup request
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c
index e6ee24a4f..dee68fdb8 100644
--- a/src/social/gnunet-service-social.c
+++ b/src/social/gnunet-service-social.c
@@ -1955,9 +1955,11 @@ handle_client_guest_enter_by_name (void *cls,
1955 GNUNET_memcpy (gcls->password, password, password_size); 1955 GNUNET_memcpy (gcls->password, password, password_size);
1956 } 1956 }
1957 1957
1958 GNUNET_GNS_lookup (gns, gns_name, &greq->ego_pub_key, 1958 GNUNET_GNS_lookup (gns, gns_name,
1959 GNUNET_GNSRECORD_TYPE_PLACE, GNUNET_GNS_LO_DEFAULT, 1959 &greq->ego_pub_key,
1960 NULL, gns_result_guest_enter, gcls); 1960 GNUNET_GNSRECORD_TYPE_PLACE,
1961 GNUNET_GNS_LO_DEFAULT,
1962 &gns_result_guest_enter, gcls);
1961} 1963}
1962 1964
1963 1965