From: Christian Grothoff Date: Wed, 22 Feb 2017 20:29:42 +0000 (+0100) Subject: remove support for reverse lookup and shortening from GNS (#4849) X-Git-Tag: taler-0.2.1~75 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=cd9531932c72478a3f7c17eb78238daa2302b2ef;p=oweals%2Fgnunet.git remove support for reverse lookup and shortening from GNS (#4849) --- diff --git a/contrib/gnunet-gns-import.sh b/contrib/gnunet-gns-import.sh index 75f84fd0e..8c9d1b9d4 100755 --- a/contrib/gnunet-gns-import.sh +++ b/contrib/gnunet-gns-import.sh @@ -39,9 +39,8 @@ while getopts "c:" opt; do esac done -# By default, we create three GNS zones: +# By default, we create two GNS zones: gnunet-identity -C master-zone $options -gnunet-identity -C short-zone $options gnunet-identity -C private-zone $options # Additionally, we create the FS SKS zone 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, &my_zone, GNUNET_GNSRECORD_TYPE_PHONE, GNUNET_NO, - NULL /* FIXME: add shortening support */, &handle_gns_response, call); GNUNET_assert (NULL != call->gns_lookup); 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) EXTRA_DIST = \ test_gns_defaults.conf \ test_gns_lookup.conf \ - test_gns_nick_shorten.conf \ test_gns_proxy.conf \ test_gns_simple_lookup.conf \ gns-helper-service-w32.conf \ @@ -184,8 +183,6 @@ w32nsp_resolve_LDADD = -lws2_32 gnunet_service_gns_SOURCES = \ gnunet-service-gns.c \ gnunet-service-gns_resolver.c gnunet-service-gns_resolver.h \ - gnunet-service-gns_reverser.c gnunet-service-gns_reverser.h \ - gnunet-service-gns_shorten.c gnunet-service-gns_shorten.h \ gnunet-service-gns_interceptor.c gnunet-service-gns_interceptor.h gnunet_service_gns_LDADD = \ -lm \ @@ -254,14 +251,12 @@ check_SCRIPTS = \ test_gns_gns2dns_lookup.sh \ test_gns_dht_lookup.sh\ test_gns_delegated_lookup.sh \ - test_gns_nick_shorten.sh\ test_gns_plus_lookup.sh\ test_gns_zkey_lookup.sh\ test_gns_rel_expiration.sh\ test_gns_soa_lookup.sh\ test_gns_revocation.sh\ - test_gns_cname_lookup.sh \ - test_gns_reverse_lookup.sh + test_gns_cname_lookup.sh if ENABLE_TEST_RUN if 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,50 +72,19 @@ struct LookupMessage int16_t options GNUNET_PACKED; /** - * Is a shorten key attached? + * Always 0. */ - int16_t have_key GNUNET_PACKED; + int16_t reserved GNUNET_PACKED; /** * the type of record to look up */ int32_t type GNUNET_PACKED; - /** - * The key for shorten, if @e have_key is set - */ - struct GNUNET_CRYPTO_EcdsaPrivateKey shorten_key; - /* Followed by the zero-terminated name to look up */ }; -/** - * Message from client to GNS service to lookup records. - */ -struct ReverseLookupMessage -{ - /** - * Header of type #GNUNET_MESSAGE_TYPE_GNS_REVERSE_LOOKUP - */ - struct GNUNET_MessageHeader header; - - /** - * Unique identifier for this request (for key collisions). - */ - uint32_t id GNUNET_PACKED; - - /** - * Zone that is target for reverse lookup - */ - struct GNUNET_CRYPTO_EcdsaPublicKey zone_pkey; - - /** - * Root zone - */ - struct GNUNET_CRYPTO_EcdsaPublicKey root_pkey; -}; - /** * Message from GNS service to client: new results. */ @@ -140,24 +109,6 @@ struct LookupResultMessage }; -/** - * Message from GNS service to client: new results. - */ -struct ReverseLookupResultMessage -{ - /** - * Header of type #GNUNET_MESSAGE_TYPE_GNS_REVERSE_LOOKUP_RESULT - */ - struct GNUNET_MessageHeader header; - - /** - * Unique identifier for this request (for key collisions). - */ - uint32_t id GNUNET_PACKED; - - /* followed by the resulting name of the reverse lookup */ -}; - GNUNET_NETWORK_STRUCT_END 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 }; -/** - * Handle to a lookup request - */ -struct GNUNET_GNS_ReverseLookupRequest -{ - - /** - * DLL - */ - struct GNUNET_GNS_ReverseLookupRequest *next; - - /** - * DLL - */ - struct GNUNET_GNS_ReverseLookupRequest *prev; - - /** - * handle to gns - */ - struct GNUNET_GNS_Handle *gns_handle; - - /** - * processor to call on lookup result - */ - GNUNET_GNS_ReverseLookupResultProcessor lookup_proc; - - /** - * @e lookup_proc closure - */ - void *proc_cls; - - /** - * Envelope with the message for this queue entry. - */ - struct GNUNET_MQ_Envelope *env; - - /** - * request id - */ - uint32_t r_id; - -}; - /** * Connection to the GNS service. @@ -149,15 +106,6 @@ struct GNUNET_GNS_Handle */ struct GNUNET_GNS_LookupRequest *lookup_tail; - /** - * Head of linked list of active reverse lookup requests. - */ - struct GNUNET_GNS_ReverseLookupRequest *rev_lookup_head; - - /** - * Tail of linked list of active reverse lookup requests. - */ - struct GNUNET_GNS_ReverseLookupRequest *rev_lookup_tail; /** * Reconnect task */ @@ -232,71 +180,13 @@ mq_error_handler (void *cls, enum GNUNET_MQ_Error error) { struct GNUNET_GNS_Handle *handle = cls; - LOG (GNUNET_ERROR_TYPE_WARNING, "Problem with message queue. error: %i\n", + + LOG (GNUNET_ERROR_TYPE_WARNING, + "Problem with message queue. error: %i\n", error); force_reconnect (handle); } -/** - * Check validity of message received from the GNS service - * - * @param cls the `struct GNUNET_GNS_Handle *` - * @param loookup_msg the incoming message - */ -static int -check_rev_result (void *cls, - const struct ReverseLookupResultMessage *lookup_msg) -{ - size_t mlen = ntohs (lookup_msg->header.size) - sizeof (*lookup_msg); - char *name; - - name = (char*) &lookup_msg[1]; - if ('\0' != name[mlen-1]) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - return GNUNET_OK; -} - - -/** - * Handler for messages received from the GNS service - * - * @param cls the `struct GNUNET_GNS_Handle *` - * @param loookup_msg the incoming message - */ -static void -handle_rev_result (void *cls, - const struct ReverseLookupResultMessage *lookup_msg) -{ - struct GNUNET_GNS_Handle *handle = cls; - char *name; - uint32_t r_id = ntohl (lookup_msg->id); - struct GNUNET_GNS_ReverseLookupRequest *rlr; - GNUNET_GNS_ReverseLookupResultProcessor proc; - void *proc_cls; - - name = (char*)&lookup_msg[1]; - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Received reverse lookup reply from GNS service (%s)\n", - name); - for (rlr = handle->rev_lookup_head; NULL != rlr; rlr = rlr->next) - if (rlr->r_id == r_id) - break; - if (NULL == rlr) - return; - proc = rlr->lookup_proc; - proc_cls = rlr->proc_cls; - GNUNET_CONTAINER_DLL_remove (handle->rev_lookup_head, - handle->rev_lookup_tail, - rlr); - GNUNET_free (rlr); - proc (proc_cls, - name); -} - - /** * Check validity of message received from the GNS service @@ -382,14 +272,9 @@ reconnect (struct GNUNET_GNS_Handle *handle) GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT, struct LookupResultMessage, handle), - GNUNET_MQ_hd_var_size (rev_result, - GNUNET_MESSAGE_TYPE_GNS_REVERSE_LOOKUP_RESULT, - struct ReverseLookupResultMessage, - handle), GNUNET_MQ_handler_end () }; struct GNUNET_GNS_LookupRequest *lh; - struct GNUNET_GNS_ReverseLookupRequest *rlh; GNUNET_assert (NULL == handle->mq); LOG (GNUNET_ERROR_TYPE_DEBUG, @@ -404,9 +289,6 @@ reconnect (struct GNUNET_GNS_Handle *handle) for (lh = handle->lookup_head; NULL != lh; lh = lh->next) GNUNET_MQ_send_copy (handle->mq, lh->env); - for (rlh = handle->rev_lookup_head; NULL != rlh; rlh = rlh->next) - GNUNET_MQ_send_copy (handle->mq, - rlh->env); } @@ -452,7 +334,6 @@ GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle) handle->reconnect_task = NULL; } GNUNET_assert (NULL == handle->lookup_head); - GNUNET_assert (NULL == handle->rev_lookup_head); GNUNET_free (handle); } @@ -474,22 +355,6 @@ GNUNET_GNS_lookup_cancel (struct GNUNET_GNS_LookupRequest *lr) GNUNET_free (lr); } -/** - * Cancel pending reverse lookup request - * - * @param lr the lookup request to cancel - */ -void -GNUNET_GNS_reverse_lookup_cancel (struct GNUNET_GNS_ReverseLookupRequest *lr) -{ - struct GNUNET_GNS_Handle *handle = lr->gns_handle; - - GNUNET_CONTAINER_DLL_remove (handle->rev_lookup_head, - handle->rev_lookup_tail, - lr); - GNUNET_MQ_discard (lr->env); - GNUNET_free (lr); -} /** * Perform an asynchronous lookup operation on the GNS. @@ -499,7 +364,6 @@ GNUNET_GNS_reverse_lookup_cancel (struct GNUNET_GNS_ReverseLookupRequest *lr) * @param zone the zone to start the resolution in * @param type the record type to look up * @param options local options for the lookup - * @param shorten_zone_key the private key of the shorten zone (can be NULL) * @param proc processor to call on result * @param proc_cls closure for @a proc * @return handle to the get request @@ -510,7 +374,6 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, uint32_t type, enum GNUNET_GNS_LocalOptions options, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone_key, GNUNET_GNS_LookupResultProcessor proc, void *proc_cls) { @@ -545,11 +408,6 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, lookup_msg->options = htons ((uint16_t) options); lookup_msg->zone = *zone; lookup_msg->type = htonl (type); - if (NULL != shorten_zone_key) - { - lookup_msg->have_key = htons (GNUNET_YES); - lookup_msg->shorten_key = *shorten_zone_key; - } GNUNET_memcpy (&lookup_msg[1], name, nlen); @@ -562,50 +420,4 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, return lr; } -/** - * Perform an asynchronous reverse lookup operation on the GNS. - * - * @param handle handle to the GNS service - * @param zone_key zone to find a name for - * @param root_key our zone - * @param proc processor to call on result - * @param proc_cls closure for @a proc - * @return handle to the request - */ -struct GNUNET_GNS_ReverseLookupRequest* -GNUNET_GNS_reverse_lookup (struct GNUNET_GNS_Handle *handle, - const struct GNUNET_CRYPTO_EcdsaPublicKey *zone_key, - const struct GNUNET_CRYPTO_EcdsaPublicKey *root_key, - GNUNET_GNS_ReverseLookupResultProcessor proc, - void *proc_cls) -{ - /* IPC to shorten gns names, return shorten_handle */ - struct ReverseLookupMessage *rev_lookup_msg; - struct GNUNET_GNS_ReverseLookupRequest *lr; - - if ((NULL == zone_key) || (NULL == root_key)) - { - GNUNET_break (0); - return NULL; - } - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Trying to reverse lookup in GNS\n"); - lr = GNUNET_new (struct GNUNET_GNS_ReverseLookupRequest); - lr->gns_handle = handle; - lr->lookup_proc = proc; - lr->proc_cls = proc_cls; - lr->r_id = handle->r_id_gen++; - lr->env = GNUNET_MQ_msg (rev_lookup_msg, - GNUNET_MESSAGE_TYPE_GNS_REVERSE_LOOKUP); - rev_lookup_msg->id = htonl (lr->r_id); - rev_lookup_msg->zone_pkey = *zone_key; - rev_lookup_msg->root_pkey = *root_key; - GNUNET_CONTAINER_DLL_insert (handle->rev_lookup_head, - handle->rev_lookup_tail, - lr); - if (NULL != handle->mq) - GNUNET_MQ_send_copy (handle->mq, - lr->env); - return lr; -} /* 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, &my_zone, type, GNUNET_NO, - NULL /* no shorten */, &result_processor, request); } @@ -618,7 +617,7 @@ run_dnsd () if (NULL != listen_socket4) { struct sockaddr_in v4; - + memset (&v4, 0, sizeof (v4)); v4.sin_family = AF_INET; #if HAVE_SOCKADDR_IN_SIN_LEN @@ -641,7 +640,7 @@ run_dnsd () if (NULL != listen_socket6) { struct sockaddr_in6 v6; - + memset (&v6, 0, sizeof (v6)); v6.sin6_family = AF_INET6; #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 * Headers from response */ struct HttpResponseHeader *header_tail; - + /** * SSL Certificate status */ @@ -694,16 +694,6 @@ static struct Socks5Request *s5r_tail; */ static struct GNUNET_CRYPTO_EcdsaPublicKey local_gns_zone; -/** - * The users local shorten zone - */ -static struct GNUNET_CRYPTO_EcdsaPrivateKey local_shorten_zone; - -/** - * Is shortening enabled? - */ -static int do_shorten; - /** * The CA for SSL certificate generation */ @@ -873,7 +863,7 @@ check_ssl_certificate (struct Socks5Request *s5r) gnutls_x509_crt_t x509_cert; int rc; const char *name; - + s5r->ssl_checked = GNUNET_YES; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "XXXXXX\n"); if (CURLE_OK != @@ -1039,7 +1029,7 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls) size_t delta_cdomain; int domain_matched; char *tok; - + /* first, check SSL certificate */ if ((GNUNET_YES != s5r->ssl_checked) && (HTTPS_PORT == s5r->port)) @@ -1047,7 +1037,7 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls) if (GNUNET_OK != check_ssl_certificate (s5r)) return 0; } - + ndup = GNUNET_strndup (buffer, bytes); hdr_type = strtok (ndup, ":"); if (NULL == hdr_type) @@ -1287,7 +1277,7 @@ curl_upload_cb (void *buf, size_t size, size_t nmemb, void *cls) struct Socks5Request *s5r = cls; size_t len = size * nmemb; size_t to_copy; - + if ( (0 == s5r->io_len) && (SOCKS5_SOCKET_UPLOAD_DONE != s5r->state) ) { @@ -1763,7 +1753,7 @@ create_response (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing %u bytes UPLOAD\n", (unsigned int) *upload_data_size); - + /* FIXME: This must be set or a header with Transfer-Encoding: chunked. Else * upload callback is not called! */ @@ -2827,7 +2817,6 @@ do_s5r_read (void *cls) &local_gns_zone, GNUNET_DNSPARSER_TYPE_A, GNUNET_NO /* only cached */, - (GNUNET_YES == do_shorten) ? &local_shorten_zone : NULL, &handle_gns_result, s5r); break; @@ -3140,46 +3129,6 @@ run_cont () } -/** - * Method called to inform about the egos of the shorten zone of this peer. - * - * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get, - * this function is only called ONCE, and 'NULL' being passed in - * @a ego does indicate an error (i.e. name is taken or no default - * value is known). If @a ego is non-NULL and if '*ctx' - * is set in those callbacks, the value WILL be passed to a subsequent - * call to the identity callback of #GNUNET_IDENTITY_connect (if - * that one was not NULL). - * - * @param cls closure, NULL - * @param ego ego handle - * @param ctx context for application to store data for this ego - * (during the lifetime of this process, initially NULL) - * @param name name assigned by the user for this ego, - * NULL if the user just deleted the ego and it - * must thus no longer be used - */ -static void -identity_shorten_cb (void *cls, - struct GNUNET_IDENTITY_Ego *ego, - void **ctx, - const char *name) -{ - id_op = NULL; - if (NULL == ego) - { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("No ego configured for `shorten-zone`\n")); - } - else - { - local_shorten_zone = *GNUNET_IDENTITY_ego_get_private_key (ego); - do_shorten = GNUNET_YES; - } - run_cont (); -} - - /** * Method called to inform about the egos of the master zone of this peer. * @@ -3216,10 +3165,7 @@ identity_master_cb (void *cls, } GNUNET_IDENTITY_ego_get_public_key (ego, &local_gns_zone); - id_op = GNUNET_IDENTITY_get (identity, - "gns-short", - &identity_shorten_cb, - NULL); + run_cont (); } @@ -3232,7 +3178,9 @@ identity_master_cb (void *cls, * @param c configuration */ static void -run (void *cls, char *const *args, const char *cfgfile, +run (void *cls, + char *const *args, + const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { char* cafile_cfg = NULL; @@ -3323,22 +3271,26 @@ main (int argc, char *const *argv) "cURL fail"; int ret; - if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) + if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, + &argc, &argv)) return 2; - GNUNET_log_setup ("gnunet-gns-proxy", "WARNING", NULL); - curl_failure_response = MHD_create_response_from_buffer (strlen (page), - (void*)page, - MHD_RESPMEM_PERSISTENT); + GNUNET_log_setup ("gnunet-gns-proxy", + "WARNING", + NULL); + curl_failure_response + = MHD_create_response_from_buffer (strlen (page), + (void *) page, + MHD_RESPMEM_PERSISTENT); ret = (GNUNET_OK == - GNUNET_PROGRAM_run (argc, argv, "gnunet-gns-proxy", + GNUNET_PROGRAM_run (argc, argv, + "gnunet-gns-proxy", _("GNUnet GNS proxy"), options, &run, NULL)) ? 0 : 1; MHD_destroy_response (curl_failure_response); GNUNET_free_non_null ((char *) argv); - GNUNET_CRYPTO_ecdsa_key_clear (&local_shorten_zone); return ret; } 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 @@ /* This file is part of GNUnet. - Copyright (C) 2012-2013 GNUnet e.V. + Copyright (C) 2012-2013, 2017 GNUnet e.V. GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -65,16 +65,6 @@ static char *zone_ego_name; */ static char *public_key; -/** - * Reverse key - */ -static char *reverse_key; - -/** - * Reverse key - */ -static struct GNUNET_CRYPTO_EcdsaPublicKey rkey; - /** * Set to GNUNET_GNS_LO_LOCAL_MASTER if we are looking up in the master zone. */ @@ -95,11 +85,6 @@ static int rtype; */ static struct GNUNET_GNS_LookupRequest *lookup_request; -/** - * Handle to reverse lookup request - */ -static struct GNUNET_GNS_ReverseLookupRequest *rev_lookup_request; - /** * Lookup an ego with the identity service. */ @@ -174,24 +159,6 @@ do_timeout (void *cls) GNUNET_SCHEDULER_shutdown (); } -static void -process_reverse_result (void *cls, - const char *name) -{ - rev_lookup_request = NULL; - if (NULL == name) - { - printf ("No name found.\n"); - return; - } - if (raw) - printf ("%s\n", name); - else - printf ("%s is known as %s\n", - reverse_key, - name); - GNUNET_SCHEDULER_shutdown (); -} /** * Function called with the result of a GNS lookup. @@ -201,7 +168,8 @@ process_reverse_result (void *cls, * @param rd array of @a rd_count records with the results */ static void -process_lookup_result (void *cls, uint32_t rd_count, +process_lookup_result (void *cls, + uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd) { const char *name = cls; @@ -253,11 +221,9 @@ process_lookup_result (void *cls, uint32_t rd_count, * identified by the given public key and the shorten zone. * * @param pkey public key to use for the zone, can be NULL - * @param shorten_key private key used for shortening, can be NULL */ static void -lookup_with_keys (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key) +lookup_with_public_key (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey) { if (NULL != lookup_type) rtype = GNUNET_GNSRECORD_typename_to_number (lookup_type); @@ -277,18 +243,9 @@ lookup_with_keys (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey, pkey, rtype, local_options, - shorten_key, &process_lookup_result, lookup_name); } - else if (NULL != reverse_key) - { - rev_lookup_request = GNUNET_GNS_reverse_lookup (gns, - &rkey, - pkey, - &process_reverse_result, - NULL); - } else { fprintf (stderr, @@ -299,63 +256,6 @@ lookup_with_keys (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey, } -/** - * Method called to with the ego we are to use for shortening - * during the lookup. - * - * @param cls closure contains the public key to use - * @param ego ego handle, NULL if not found - * @param ctx context for application to store data for this ego - * (during the lifetime of this process, initially NULL) - * @param name name assigned by the user for this ego, - * NULL if the user just deleted the ego and it - * must thus no longer be used - */ -static void -identity_shorten_cb (void *cls, - struct GNUNET_IDENTITY_Ego *ego, - void **ctx, - const char *name) -{ - struct GNUNET_CRYPTO_EcdsaPublicKey *pkeym = cls; - - id_op = NULL; - if (NULL == ego) - lookup_with_keys (pkeym, NULL); - else - lookup_with_keys (pkeym, - GNUNET_IDENTITY_ego_get_private_key (ego)); - GNUNET_free (pkeym); -} - - -/** - * Perform the actual resolution, starting with the zone - * identified by the given public key. - * - * @param pkey public key to use for the zone - */ -static void -lookup_with_public_key (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey) -{ - struct GNUNET_CRYPTO_EcdsaPublicKey *pkeym; - - GNUNET_assert (NULL != pkey); - pkeym = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); - *pkeym = *pkey; - GNUNET_break (NULL == id_op); - id_op = GNUNET_IDENTITY_get (identity, - "gns-short", - &identity_shorten_cb, - pkeym); - if (NULL == id_op) - { - GNUNET_break (0); - lookup_with_keys (pkey, NULL); - } -} - - /** * Method called to with the ego we are to use for the lookup, * when the ego is determined by a name. @@ -449,7 +349,6 @@ run (void *cls, cfg = c; gns = GNUNET_GNS_connect (cfg); - identity = GNUNET_IDENTITY_connect (cfg, NULL, NULL); if (NULL == gns) { fprintf (stderr, @@ -457,22 +356,13 @@ run (void *cls, return; } tt = GNUNET_SCHEDULER_add_delayed (timeout, - &do_timeout, NULL); - GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); - if (NULL != reverse_key) - { - if (GNUNET_OK != - GNUNET_CRYPTO_ecdsa_public_key_from_string (reverse_key, - strlen (reverse_key), - &rkey)) - { - fprintf (stderr, - _("Reverse key `%s' is not well-formed\n"), - reverse_key); - GNUNET_SCHEDULER_shutdown (); - return; - } - } + &do_timeout, + NULL); + GNUNET_SCHEDULER_add_shutdown (&do_shutdown, + NULL); + identity = GNUNET_IDENTITY_connect (cfg, + NULL, + NULL); if (NULL != public_key) { if (GNUNET_OK != @@ -489,20 +379,6 @@ run (void *cls, lookup_with_public_key (&pkey); return; } - if (NULL != reverse_key) - { - if (GNUNET_OK != - GNUNET_CRYPTO_ecdsa_public_key_from_string (reverse_key, - strlen (reverse_key), - &rkey)) - { - fprintf (stderr, - _("Reverse key `%s' is not well-formed\n"), - reverse_key); - GNUNET_SCHEDULER_shutdown (); - return; - } - } if (NULL != zone_ego_name) { el = GNUNET_IDENTITY_ego_lookup (cfg, @@ -541,7 +417,8 @@ run (void *cls, * @return 0 ok, 1 on error */ int -main (int argc, char *const *argv) +main (int argc, + char *const *argv) { static const struct GNUNET_GETOPT_CommandLineOption options[] = { {'u', "lookup", "NAME", @@ -562,21 +439,22 @@ main (int argc, char *const *argv) {'z', "zone", "NAME", gettext_noop ("Specify the name of the ego of the zone to lookup the record in"), 1, &GNUNET_GETOPT_set_string, &zone_ego_name}, - {'R', "reverse", "PKEY", - gettext_noop ("Specify the public key of the zone to reverse lookup a name for"), 1, - &GNUNET_GETOPT_set_string, &reverse_key}, GNUNET_GETOPT_OPTION_END }; int ret; timeout = GNUNET_TIME_UNIT_FOREVER_REL; - if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) + if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, + &argc, &argv)) return 2; - GNUNET_log_setup ("gnunet-gns", "WARNING", NULL); + GNUNET_log_setup ("gnunet-gns", + "WARNING", + NULL); ret = (GNUNET_OK == - GNUNET_PROGRAM_run (argc, argv, "gnunet-gns", + GNUNET_PROGRAM_run (argc, argv, + "gnunet-gns", _("GNUnet GNS resolver tool"), options, &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 * We keep these in a DLL. */ struct ClientLookupHandle *prev; - + /** * Client handle */ @@ -72,11 +72,6 @@ struct ClientLookupHandle */ struct GNS_ResolverHandle *lookup; - /** - * Active handle for a reverse lookup - */ - struct GNS_ReverserHandle *rev_lookup; - /** * request id */ @@ -173,8 +168,6 @@ shutdown_task (void *cls) identity_handle = NULL; } GNS_resolver_done (); - GNS_reverse_done (); - GNS_shorten_done (); if (NULL != statistics) { GNUNET_STATISTICS_destroy (statistics, @@ -221,15 +214,13 @@ client_disconnect_cb (void *cls, { if (NULL != clh->lookup) GNS_resolver_lookup_cancel (clh->lookup); - if (NULL != clh->rev_lookup) - GNS_reverse_lookup_cancel (clh->rev_lookup); GNUNET_CONTAINER_DLL_remove (gc->clh_head, gc->clh_tail, clh); GNUNET_free (clh); } - GNUNET_free (gc); + GNUNET_free (gc); } @@ -288,7 +279,9 @@ send_lookup_response (void* cls, (char*) &rmsg[1]); GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(clh->gc->client), env); - GNUNET_CONTAINER_DLL_remove (clh->gc->clh_head, clh->gc->clh_tail, clh); + GNUNET_CONTAINER_DLL_remove (clh->gc->clh_head, + clh->gc->clh_tail, + clh); GNUNET_free (clh); GNUNET_STATISTICS_update (statistics, "Completed lookups", 1, @@ -299,47 +292,6 @@ send_lookup_response (void* cls, GNUNET_NO); } -/** - * Reply to client with the result from our reverse lookup. - * - * @param cls the closure (our client lookup handle) - * @param rd_count the number of records in @a rd - * @param rd the record data - */ -static void -send_reverse_lookup_response (void* cls, - const char *name) -{ - struct ClientLookupHandle *clh = cls; - struct GNUNET_MQ_Envelope *env; - struct ReverseLookupResultMessage *rmsg; - size_t len; - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending LOOKUP_RESULT message with %s\n", - name); - - if (NULL == name) - len = 1; - else - len = strlen (name) + 1; - env = GNUNET_MQ_msg_extra (rmsg, - len, - GNUNET_MESSAGE_TYPE_GNS_REVERSE_LOOKUP_RESULT); - rmsg->id = clh->request_id; - if (1 < len) - GNUNET_memcpy ((char*) &rmsg[1], - name, - strlen (name)); - GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(clh->gc->client), - env); - GNUNET_CONTAINER_DLL_remove (clh->gc->clh_head, clh->gc->clh_tail, clh); - GNUNET_free (clh); - GNUNET_STATISTICS_update (statistics, - "Completed reverse lookups", 1, - GNUNET_NO); -} - /** * Checks a #GNUNET_MESSAGE_TYPE_GNS_LOOKUP message @@ -371,6 +323,7 @@ check_lookup (void *cls, return GNUNET_OK; } + /** * Handle lookup requests from client * @@ -387,20 +340,17 @@ handle_lookup (void *cls, struct ClientLookupHandle *clh; char *nameptr = name; const char *utf_in; - const struct GNUNET_CRYPTO_EcdsaPrivateKey *key; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received LOOKUP message\n"); GNUNET_SERVICE_client_continue (gc->client); - if (GNUNET_YES == ntohs (sh_msg->have_key)) - key = &sh_msg->shorten_key; - else - key = NULL; utf_in = (const char *) &sh_msg[1]; GNUNET_STRINGS_utf8_tolower (utf_in, nameptr); clh = GNUNET_new (struct ClientLookupHandle); - GNUNET_CONTAINER_DLL_insert (gc->clh_head, gc->clh_tail, clh); + GNUNET_CONTAINER_DLL_insert (gc->clh_head, + gc->clh_tail, + clh); clh->gc = gc; clh->request_id = sh_msg->id; if ( (GNUNET_DNSPARSER_TYPE_A == ntohl (sh_msg->type)) && @@ -422,7 +372,6 @@ handle_lookup (void *cls, clh->lookup = GNS_resolver_lookup (&sh_msg->zone, ntohl (sh_msg->type), name, - key, (enum GNUNET_GNS_LocalOptions) ntohs (sh_msg->options), &send_lookup_response, clh); GNUNET_STATISTICS_update (statistics, @@ -430,82 +379,6 @@ handle_lookup (void *cls, 1, GNUNET_NO); } -/** - * Handle reverse lookup requests from client - * - * @param cls the closure - * @param client the client - * @param message the message - */ -static void -handle_rev_lookup (void *cls, - const struct ReverseLookupMessage *sh_msg) -{ - struct GnsClient *gc = cls; - struct ClientLookupHandle *clh; - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received REVERSE_LOOKUP message\n"); - GNUNET_SERVICE_client_continue (gc->client); - - clh = GNUNET_new (struct ClientLookupHandle); - GNUNET_CONTAINER_DLL_insert (gc->clh_head, gc->clh_tail, clh); - clh->gc = gc; - clh->request_id = sh_msg->id; - clh->rev_lookup = GNS_reverse_lookup (&sh_msg->zone_pkey, - &sh_msg->root_pkey, - &send_reverse_lookup_response, - clh); - GNUNET_STATISTICS_update (statistics, - "Reverse lookup attempts", - 1, GNUNET_NO); -} - - -/** - * Method called to inform about the ego to be used for the master zone - * for DNS interceptions. - * - * This function is only called ONCE, and 'NULL' being passed in - * @a ego does indicate that interception is not configured. - * If @a ego is non-NULL, we should start to intercept DNS queries - * and resolve ".gnu" queries using the given ego as the master zone. - * - * @param cls closure, our `const struct GNUNET_CONFIGURATION_Handle *c` - * @param ego ego handle - * @param ctx context for application to store data for this ego - * (during the lifetime of this process, initially NULL) - * @param name name assigned by the user for this ego, - * NULL if the user just deleted the ego and it - * must thus no longer be used - */ -static void -identity_reverse_cb (void *cls, - struct GNUNET_IDENTITY_Ego *ego, - void **ctx, - const char *name) -{ - identity_op = NULL; - - if (NULL == ego) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("No ego configured for `%s`\n"), - "gns-master"); - - return; - } - if (GNUNET_SYSERR == - GNS_reverse_init (namestore_handle, - GNUNET_IDENTITY_ego_get_private_key (ego), - name)) - { - GNUNET_break (0); - GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); - return; - } -} - /** * Method called to inform about the ego to be used for the master zone @@ -532,16 +405,10 @@ identity_intercept_cb (void *cls, { const struct GNUNET_CONFIGURATION_Handle *cfg = cls; struct GNUNET_CRYPTO_EcdsaPublicKey dns_root; - identity_op = NULL; + identity_op = NULL; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for gns-intercept ego\n"); - identity_op = GNUNET_IDENTITY_get (identity_handle, - "gns-reverse", - &identity_reverse_cb, - (void*)cfg); - - if (NULL == ego) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -553,10 +420,12 @@ identity_intercept_cb (void *cls, GNUNET_IDENTITY_ego_get_public_key (ego, &dns_root); if (GNUNET_SYSERR == - GNS_interceptor_init (&dns_root, cfg)) + GNS_interceptor_init (&dns_root, + cfg)) { GNUNET_break (0); - GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); + GNUNET_SCHEDULER_add_now (&shutdown_task, + NULL); return; } } @@ -577,7 +446,7 @@ run (void *cls, unsigned long long max_parallel_bg_queries = 16; v6_enabled = GNUNET_NETWORK_test_pf (PF_INET6); - v4_enabled = GNUNET_NETWORK_test_pf (PF_INET); + v4_enabled = GNUNET_NETWORK_test_pf (PF_INET); namestore_handle = GNUNET_NAMESTORE_connect (c); if (NULL == namestore_handle) { @@ -635,11 +504,9 @@ run (void *cls, dht_handle, c, max_parallel_bg_queries); - GNS_shorten_init (namestore_handle, - namecache_handle, - dht_handle); statistics = GNUNET_STATISTICS_create ("gns", c); - GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); + GNUNET_SCHEDULER_add_shutdown (&shutdown_task, + NULL); } @@ -657,10 +524,6 @@ GNUNET_SERVICE_MAIN GNUNET_MESSAGE_TYPE_GNS_LOOKUP, struct LookupMessage, NULL), - GNUNET_MQ_hd_fixed_size (rev_lookup, - GNUNET_MESSAGE_TYPE_GNS_REVERSE_LOOKUP, - struct ReverseLookupMessage, - NULL), GNUNET_MQ_handler_end()); 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, ilh->lookup = GNS_resolver_lookup (&zone, p->queries[0].type, p->queries[0].name, - NULL /* FIXME: enable shorten for DNS intercepts? */, GNUNET_NO, &reply_to_dns, ilh); 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 @@ -326,11 +326,6 @@ struct GNS_ResolverHandle */ struct AuthorityChain *ac_tail; - /** - * Private key of the shorten zone, NULL to not shorten. - */ - struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key; - /** * ID of a task associated with the resolution process. */ @@ -1750,23 +1745,6 @@ handle_gns_resolution_result (void *cls, } /* end: switch */ } /* end: for rd_count */ - /* trigger shortening */ - if ((NULL != rh->shorten_key) && - (NULL != shorten_ac) && - (GNUNET_NO == shorten_ac->shortening_started) && - (NULL != shorten_ac->suggested_shortening_label)) - { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Start shortening for label `%s' based on nick `%s'\n", - shorten_ac->label, - shorten_ac->suggested_shortening_label); - shorten_ac->shortening_started = GNUNET_YES; - GNS_shorten_start (shorten_ac->label, - shorten_ac->suggested_shortening_label, - &shorten_ac->authority_info.gns_authority, - rh->shorten_key); - } - /* yes, we are done, return result */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Returning GNS response for `%s' with %u answers\n", @@ -2374,7 +2352,6 @@ start_resolver_lookup (struct GNS_ResolverHandle *rh) * @param zone the zone to perform the lookup in * @param record_type the record type to look up * @param name the name to look up - * @param shorten_key a private key for use with PSEU import (can be NULL) * @param options local options to control local lookup * @param proc the processor to call on result * @param proc_cls the closure to pass to @a proc @@ -2384,16 +2361,13 @@ struct GNS_ResolverHandle * GNS_resolver_lookup (const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, uint32_t record_type, const char *name, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key, enum GNUNET_GNS_LocalOptions options, GNS_ResultProcessor proc, void *proc_cls) { struct GNS_ResolverHandle *rh; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - (NULL == shorten_key) - ? "Starting lookup for `%s' with shortening disabled\n" - : "Starting lookup for `%s' with shortening enabled\n", + "Starting lookup for `%s'\n", name); rh = GNUNET_new (struct GNS_ResolverHandle); GNUNET_CONTAINER_DLL_insert (rlh_head, @@ -2406,11 +2380,6 @@ GNS_resolver_lookup (const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, rh->record_type = record_type; rh->name = GNUNET_strdup (name); rh->name_resolution_pos = strlen (name); - if (NULL != shorten_key) - { - rh->shorten_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPrivateKey); - *rh->shorten_key = *shorten_key; - } start_resolver_lookup (rh); return rh; } @@ -2507,7 +2476,6 @@ GNS_resolver_lookup_cancel (struct GNS_ResolverHandle *rh) dr); GNUNET_free (dr); } - GNUNET_free_non_null (rh->shorten_key); GNUNET_free (rh->name); GNUNET_free (rh); } 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; * @param rd_count number of records in @a rd * @param rd records returned for the lookup */ -typedef void (*GNS_ResultProcessor)(void *cls, - uint32_t rd_count, - const struct GNUNET_GNSRECORD_Data *rd); +typedef void +(*GNS_ResultProcessor)(void *cls, + uint32_t rd_count, + const struct GNUNET_GNSRECORD_Data *rd); /** @@ -77,7 +78,6 @@ typedef void (*GNS_ResultProcessor)(void *cls, * @param zone the zone to perform the lookup in * @param record_type the record type to look up * @param name the name to look up - * @param shorten_key optional private key for authority caching, can be NULL * @param options options set to control local lookup * @param proc the processor to call * @param proc_cls the closure to pass to @a proc @@ -87,7 +87,6 @@ struct GNS_ResolverHandle * GNS_resolver_lookup (const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, uint32_t record_type, const char *name, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key, enum GNUNET_GNS_LocalOptions options, GNS_ResultProcessor proc, void *proc_cls); @@ -102,8 +101,6 @@ void GNS_resolver_lookup_cancel (struct GNS_ResolverHandle *rh); - - /** * Generic function to check for TLDs. Checks if "name" ends in ".tld" * 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, * identified by the given public key and the shorten zone. * * @param pkey public key to use for the zone, can be NULL - * @param shorten_key private key used for shortening, can be NULL */ static void -lookup_with_keys (struct LookupHandle *handle, const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key) +lookup_with_public_key (struct LookupHandle *handle) { if (UINT32_MAX == handle->type) { @@ -354,7 +353,6 @@ lookup_with_keys (struct LookupHandle *handle, const struct GNUNET_CRYPTO_EcdsaP &handle->pkey, handle->type, handle->options, - shorten_key, &process_lookup_result, handle); } @@ -365,55 +363,6 @@ lookup_with_keys (struct LookupHandle *handle, const struct GNUNET_CRYPTO_EcdsaP } } -/** - * Method called to with the ego we are to use for shortening - * during the lookup. - * - * @param cls closure contains the public key to use - * @param ego ego handle, NULL if not found - * @param ctx context for application to store data for this ego - * (during the lifetime of this process, initially NULL) - * @param name name assigned by the user for this ego, - * NULL if the user just deleted the ego and it - * must thus no longer be used - */ -static void -identity_shorten_cb (void *cls, - struct GNUNET_IDENTITY_Ego *ego, - void **ctx, - const char *name) -{ - struct LookupHandle *handle = cls; - - handle->id_op = NULL; - if (NULL == ego) - lookup_with_keys (handle, NULL); - else - lookup_with_keys (handle, - GNUNET_IDENTITY_ego_get_private_key (ego)); -} - -/** - * Perform the actual resolution, starting with the zone - * identified by the given public key. - * - * @param pkey public key to use for the zone - */ -static void -lookup_with_public_key (struct LookupHandle *handle) -{ - handle->pkeym = handle->pkey; - GNUNET_break (NULL == handle->id_op); - handle->id_op = GNUNET_IDENTITY_get (handle->identity, - "gns-short", - &identity_shorten_cb, - handle); - if (NULL == handle->id_op) - { - GNUNET_break (0); - lookup_with_keys (handle, NULL); - } -} /** * Method called to with the ego we are to use for the lookup, @@ -444,6 +393,7 @@ identity_zone_cb (void *cls, json_decref(handle->json_root); } + /** * Method called to with the ego we are to use for the lookup, * 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 @@ -#!/bin/bash -trap "gnunet-arm -e -c test_gns_nick_shorten.conf" SIGINT -which timeout &> /dev/null && DO_TIMEOUT="timeout 5" - -# This test tests shortening functionality based on NICK records: -# -# zone "delegatedego": Alice's zone -# zone "testego": Local zone with delegation to alice - -LOCATION=$(which gnunet-config) -if [ -z $LOCATION ] -then - LOCATION="gnunet-config" -fi -$LOCATION --version 1> /dev/null -if test $? != 0 -then - echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" - exit 77 -fi - -# Deleting home directory from previous runs -TEST_CONFIG="test_gns_nick_shorten.conf " -rm -rf /tmp/test-gnunet-gns-peer-1/ -TEST_IP="127.0.0.1" -TEST_IP="127.0.0.2" -TEST_NICK_EGO="ego" -TEST_NICK_DELEGATED="alice" -TEST_NAME="www.mybestfriendalice.gnu" -TEST_NAME_SHORT="www.alice.short.gnu" - -# export GNUNET_FORCE_LOG="namestore;;;;DEBUG/gns;;;;DEBUG/;;;;WARNING" - -# Start gnunet -echo "Starting arm with configuration $TEST_CONFIG" -gnunet-arm -s -c $TEST_CONFIG - -# Create initial identities: short-zone, delegated-zone, testego -echo "Creating identities" -gnunet-identity -d -c $TEST_CONFIG -gnunet-identity -C short-zone -c $TEST_CONFIG -gnunet-identity -C delegatedego -c $TEST_CONFIG -gnunet-identity -e short-zone -s gns-short -c $TEST_CONFIG -gnunet-identity -C testego -c $TEST_CONFIG - -echo "Adding nick names for identities" -gnunet-namestore -z testego -i $TEST_NICK_EGO -c $TEST_CONFIG -gnunet-namestore -z delegatedego -i $TEST_NICK_DELEGATED -c $TEST_CONFIG - -# Adding label www in Alice's delegatedego zone -echo "Adding www record with IP $TEST_IP" -gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e never -c test_gns_nick_shorten.conf - -# Retrieve PKEYs for delegation -DELEGATED_PKEY=$(gnunet-identity -d -c $TEST_CONFIG| grep delegatedego | awk '{print $3}') -echo "Alice's PKEY is $DELEGATED_PKEY" - -SHORTEN_PKEY=$(gnunet-identity -c test_gns_nick_shorten.conf -d | grep short-zone | awk '{print $3}') -echo "Shorten PKEY is $SHORTEN_PKEY" - -# Delegate the name "short" to shortenzone -gnunet-namestore -p -z testego -a -n short -t PKEY -V $SHORTEN_PKEY -e never -c test_gns_nick_shorten.conf - -# Delegate the name "mybestfriendalice" to alice -gnunet-namestore -p -z testego -a -n mybestfriendalice -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_nick_shorten.conf - -# Perform lookup to shorten -echo "Start gns..." -gnunet-arm -c test_gns_nick_shorten.conf -i gns - - -RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_NAME -t A -c test_gns_nick_shorten.conf` - -sleep 1 - -echo "Lookup shortened names" -PKEY_SHORT_RES=$($DO_TIMEOUT gnunet-gns --raw -c test_gns_nick_shorten.conf -z short-zone -u alice.gnu -t PKEY) -echo "Resolving alice's PKEY in shorten zone: $PKEY_SHORT_RES" -PKEY_RES=$($DO_TIMEOUT gnunet-gns --raw -c test_gns_nick_shorten.conf -z testego -u alice.short.gnu -t PKEY) -echo "Resolving alice's PKEY in master zone: $PKEY_RES" - -RES=0 -if [ "$DELEGATED_PKEY" == "$PKEY_SHORT_RES" ] -then - echo "PASS: Resolved delegation for shorten name in shortened zone" -else - echo "FAIL: Expected PKEY in $DELEGATED_PKEY, received PKEY '$PKEY_SHORT_RES' in shorten zone." - RES=1 -fi - -if [ "$DELEGATED_PKEY" == "$PKEY_RES" ] -then - echo "PASS: Resolved delegation for shorten name in master zone" -else - echo "FAIL: Expected PKEY in $DELEGATED_PKEY, received PKEY $PKEY_SHORT_RES in master zone." - RES=1 -fi - -if [ $RES -eq 0 ] -then - RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_NAME_SHORT -t A -c test_gns_nick_shorten.conf` - if [ "$RES_IP" == "$TEST_IP" ] - then - echo "PASS: Received $TEST_IP for $TEST_NAME_SHORT" - else - echo "FAIL: Expected IP in $TEST_IP, received IP '$RES_IP' for $TEST_SHORT_NAME." - RES=1 - fi -fi - - -# Clean up -echo "Clean up..." -gnunet-namestore -z testego -d -n mybestfriendalice -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_nick_shorten.conf -gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e never -c test_gns_nick_shorten.conf -gnunet-identity -D -z testego -c $TEST_CONFIG -gnunet-identity -D -z delegatedego -c $TEST_CONFIG -gnunet-identity -D -z short-zone -c $TEST_CONFIG - -gnunet-arm -e -c test_gns_nick_shorten.conf -rm -rf /tmp/test-gnunet-gns-peer-1/ - -exit $RES - 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 @@ -#!/bin/bash -trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT -which timeout &> /dev/null && DO_TIMEOUT="timeout 30" - -LOCATION=$(which gnunet-config) -if [ -z $LOCATION ] -then - LOCATION="gnunet-config" -fi -$LOCATION --version 1> /dev/null -if test $? != 0 -then - echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" - exit 77 -fi - -TEST_NAME="dave.bob.alice.gnu" -gnunet-arm -s -c test_gns_lookup.conf -gnunet-identity -C bob -c test_gns_lookup.conf -BOB_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep bob | awk '{print $3}') -gnunet-identity -C daveego -c test_gns_lookup.conf -DAVE_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep dave | awk '{print $3}') -gnunet-identity -C aliceego -c test_gns_lookup.conf -ALICE_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep alice | awk '{print $3}') -gnunet-identity -C testego -c test_gns_lookup.conf -ROOT_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep testego | awk '{print $3}') - -gnunet-identity -s gns-reverse -e bob -c test_gns_lookup.conf - -gnunet-namestore -p -z testego -a -n alice -t PKEY -V $ALICE_PKEY -e never -c test_gns_lookup.conf -gnunet-namestore -p -z aliceego -a -n bob -t PKEY -V $BOB_PKEY -e never -c test_gns_lookup.conf -gnunet-namestore -p -z aliceego -a -n + -t REVERSE -V "alice $ROOT_PKEY 0" -e never -c test_gns_lookup.conf -gnunet-namestore -p -z bob -a -n dave -t PKEY -V $DAVE_PKEY -e never -c test_gns_lookup.conf -gnunet-namestore -p -z bob -a -n alice -t PKEY -V $ALICE_PKEY -e never -c test_gns_lookup.conf -#gnunet-namestore -p -z bob -a -n + -t REVERSE -V "bob $ALICE_PKEY 0" -e never -c test_gns_lookup.conf -gnunet-namestore -p -z daveego -a -n + -t REVERSE -V "dave $BOB_PKEY 0" -e never -c test_gns_lookup.conf -gnunet-namestore -p -z daveego -a -n bob -t PKEY -V $BOB_PKEY -e never -c test_gns_lookup.conf -gnunet-arm -i gns -c test_gns_lookup.conf -sleep 10 -RES_NAME=`$DO_TIMEOUT gnunet-gns --raw -z testego -R $DAVE_PKEY -c test_gns_lookup.conf` -gnunet-arm -e -c test_gns_lookup.conf -rm -rf /tmp/test-gnunet-gns-peer-1/ - -if [ "$RES_NAME" == "$TEST_NAME" ] -then - exit 0 -else - echo "Failed to resolve to proper IP, got $RES_IP." - exit 1 -fi 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, GNUNET_CONTAINER_DLL_insert (attr->val_head, attr->val_tail, val); - GNUNET_assert (GNUNET_OK == + GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (ego_entry->attr_map, &key, attr, @@ -949,7 +949,7 @@ create_issue_result_message (const char* label, struct IssueResultMessage *irm; char *tmp_str; size_t len; - + GNUNET_asprintf (&tmp_str, "%s,%s,%s", label, ticket, token); len = strlen (tmp_str) + 1; env = GNUNET_MQ_msg_extra (irm, @@ -1279,7 +1279,7 @@ check_exchange_message (void *cls, return GNUNET_SYSERR; } return GNUNET_OK; -} +} /** * @@ -1326,7 +1326,6 @@ handle_exchange_message (void *cls, &xchange_handle->ticket->payload->identity_key, GNUNET_GNSRECORD_TYPE_ID_TOKEN, GNUNET_GNS_LO_LOCAL_MASTER, - NULL, &process_lookup_result, xchange_handle); 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 @@ /* This file is part of GNUnet - Copyright (C) 2012-2014 GNUnet e.V. + Copyright (C) 2012-2014, 2017 GNUnet e.V. GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -95,16 +95,6 @@ typedef void uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd); -/** - * Iterator called on obtained result for a GNS lookup. - * - * @param cls closure - * @param name result of the reverse lookup - */ -typedef void -(*GNUNET_GNS_ReverseLookupResultProcessor) (void *cls, - const char* name); - /** * Options for the GNS lookup. @@ -138,13 +128,8 @@ enum GNUNET_GNS_LocalOptions * @param zone zone to look in * @param type the GNS record type to look for * @param options local options for the lookup - * @param shorten_zone_key the private key of the shorten zone (can be NULL); - * specify to enable automatic shortening (given a PSEU - * record, if a given pseudonym is not yet used in the - * shorten zone, we automatically add the respective zone - * under that name) * @param proc function to call on result - * @param proc_cls closure for processor + * @param proc_cls closure for @a proc * @return handle to the queued request */ struct GNUNET_GNS_LookupRequest * @@ -153,27 +138,9 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, uint32_t type, enum GNUNET_GNS_LocalOptions options, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone_key, GNUNET_GNS_LookupResultProcessor proc, void *proc_cls); -/** - * Perform an asynchronous reverse lookup operation on the GNS. - * - * @param handle handle to the GNS service - * @param zone_key zone to find a name for - * @param root_key our zone - * @param proc processor to call on result - * @param proc_cls closure for @a proc - * @return handle to the request - */ -struct GNUNET_GNS_ReverseLookupRequest * -GNUNET_GNS_reverse_lookup (struct GNUNET_GNS_Handle *handle, - const struct GNUNET_CRYPTO_EcdsaPublicKey *zone_key, - const struct GNUNET_CRYPTO_EcdsaPublicKey *root_key, - GNUNET_GNS_ReverseLookupResultProcessor proc, - void *proc_cls); - /** * 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, GNUNET_memcpy (gcls->password, password, password_size); } - GNUNET_GNS_lookup (gns, gns_name, &greq->ego_pub_key, - GNUNET_GNSRECORD_TYPE_PLACE, GNUNET_GNS_LO_DEFAULT, - NULL, gns_result_guest_enter, gcls); + GNUNET_GNS_lookup (gns, gns_name, + &greq->ego_pub_key, + GNUNET_GNSRECORD_TYPE_PLACE, + GNUNET_GNS_LO_DEFAULT, + &gns_result_guest_enter, gcls); }