diff options
-rw-r--r-- | doc/man/Makefile.am | 2 | ||||
-rw-r--r-- | doc/man/gnunet-gns.1 | 11 | ||||
-rw-r--r-- | doc/man/gnunet-namestore-fcfsd.1 (renamed from doc/man/gnunet-gns-fcfsd.1) | 6 | ||||
-rw-r--r-- | src/gns/Makefile.am | 10 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 55 | ||||
-rw-r--r-- | src/include/gnunet_namestore_service.h | 39 | ||||
-rw-r--r-- | src/namestore/Makefile.am | 14 | ||||
-rw-r--r-- | src/namestore/gnunet-namestore-fcfsd.c (renamed from src/gns/gnunet-gns-fcfsd.c) | 127 | ||||
-rw-r--r-- | src/namestore/namestore_api.c | 20 | ||||
-rw-r--r-- | src/namestore/namestore_api_common.c | 2 |
10 files changed, 145 insertions, 141 deletions
diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am index db26f0d6a..9e63bb243 100644 --- a/doc/man/Makefile.am +++ b/doc/man/Makefile.am @@ -13,10 +13,10 @@ man_MANS = \ gnunet-ecc.1 \ gnunet-fs.1 \ gnunet-gns.1 \ - gnunet-gns-fcfsd.1 \ gnunet-gns-proxy.1 \ gnunet-identity.1 \ gnunet-namestore.1 \ + gnunet-namestore-fcfsd.1 \ gnunet-nat-server.1 \ gnunet-peerinfo.1 \ gnunet-pseudonym.1 \ diff --git a/doc/man/gnunet-gns.1 b/doc/man/gnunet-gns.1 index ef5a0f9bc..e5e2240b9 100644 --- a/doc/man/gnunet-gns.1 +++ b/doc/man/gnunet-gns.1 @@ -1,4 +1,4 @@ -.TH GNUNET\-GNS 1 "Aug 8, 2012" "GNUnet" +.TH GNUNET\-GNS 1 "Aug 8, 2013" "GNUnet" .SH NAME gnunet\-gns \- Access to GNUnet Name Service @@ -13,10 +13,6 @@ gnunet\-gns \- Access to GNUnet Name Service .SH OPTIONS .B -.IP "\-a NAME, \-\-authority=NAME" -Get the authority of a particular name. -For example the authority for "www.fcfs.gads" is "fcfs.gads". -.B .IP "\-c FILENAME, \-\-config=FILENAME" Use the configuration file FILENAME. .B @@ -26,11 +22,6 @@ This is a quiet mode where only important information is displayed. For example a lookup for an IP address will only yield the IP address, no descriptive text. .B -.IP "\-s NAME, \-\-shorten NAME" -Shorten GNUnet Name Service Name. -The service will try to shorten the delegation chain of the name if a "closer" -authority chain exists relative to your local root zone. -.B .IP "\-t RRTYPE, \-\-type=RRTYPE" Resource Record Type (RRTYPE) to look for. Supported RRTYPE's are: A, AAAA, CNAME, NS, PKEY, PSEU, TLSA, SRV, SOA, MX, LEHO, VPN, REV, PTR, TXT diff --git a/doc/man/gnunet-gns-fcfsd.1 b/doc/man/gnunet-namestore-fcfsd.1 index fbd45e4a2..42b658018 100644 --- a/doc/man/gnunet-gns-fcfsd.1 +++ b/doc/man/gnunet-namestore-fcfsd.1 @@ -1,10 +1,10 @@ -.TH GNUNET\-GNS-FCFSD 1 "Oct 25, 2012" "GNUnet" +.TH GNUNET\-NAMESTORE-FCFSD 1 "Oct 25, 2012" "GNUnet" .SH NAME -gnunet\-gns-fcfsd \- HTTP server for GADS domain registration +gnunet\-namestore-fcfsd \- HTTP server for GNS domain registration .SH SYNOPSIS -.B gnunet\-gns-fcfsd +.B gnunet\-namestore-fcfsd .RI [ options ] .br diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am index 16bd6ca1c..e91014021 100644 --- a/src/gns/Makefile.am +++ b/src/gns/Makefile.am @@ -154,16 +154,6 @@ gnunet_service_gns_DEPENDENCIES = \ -gnunet_gns_fcfsd_SOURCES = \ - gnunet-gns-fcfsd.c -gnunet_gns_fcfsd_LDADD = -lmicrohttpd \ - $(top_builddir)/src/util/libgnunetutil.la \ - $(top_builddir)/src/namestore/libgnunetnamestore.la \ - $(GN_LIBINTL) -gnunet_gns_fcfsd_DEPENDENCIES = \ - $(top_builddir)/src/util/libgnunetutil.la \ - $(top_builddir)/src/namestore/libgnunetnamestore.la - libw32nsp_la_SOURCES = \ w32nsp.c libw32nsp_la_LIBADD = \ diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 8aa9e8188..de9e7e014 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c @@ -491,6 +491,7 @@ process_pseu_lookup_ns (void *cls, { struct GetPseuAuthorityHandle *gph = cls; struct GNUNET_NAMESTORE_RecordData new_pkey; + struct GNUNET_CRYPTO_EccPublicKey pub; gph->namestore_task = NULL; if (rd_count > 0) @@ -502,14 +503,19 @@ process_pseu_lookup_ns (void *cls, time, this time not using PSEU but the original label */ if (0 == strcmp (name, gph->label)) + { free_get_pseu_authority_handle (gph); + } else + { + GNUNET_CRYPTO_ecc_key_get_public (&gph->shorten_zone_key, + &pub); gph->namestore_task = GNUNET_NAMESTORE_lookup (namestore_handle, - &gph->shorten_zone_key, + &pub, gph->label, - GNUNET_NAMESTORE_TYPE_ANY, &process_pseu_lookup_ns, gph); + } return; } /* name is available */ @@ -543,6 +549,10 @@ static void process_pseu_result (struct GetPseuAuthorityHandle* gph, const char *pseu) { + struct GNUNET_CRYPTO_EccPublicKey pub; + + GNUNET_CRYPTO_ecc_key_get_public (&gph->shorten_zone_key, + &pub); if (NULL == pseu) { /* no PSEU found, try original label */ @@ -550,9 +560,8 @@ process_pseu_result (struct GetPseuAuthorityHandle* gph, "No PSEU found, trying original label `%s' instead.\n", gph->label); gph->namestore_task = GNUNET_NAMESTORE_lookup (namestore_handle, - &gph->shorten_zone_key, + &pub, gph->label, - GNUNET_NAMESTORE_TYPE_ANY, &process_pseu_lookup_ns, gph); return; @@ -560,9 +569,8 @@ process_pseu_result (struct GetPseuAuthorityHandle* gph, /* check if 'pseu' is taken */ gph->namestore_task = GNUNET_NAMESTORE_lookup (namestore_handle, - &gph->shorten_zone_key, + &pub, pseu, - GNUNET_NAMESTORE_TYPE_ANY, &process_pseu_lookup_ns, gph); } @@ -1927,12 +1935,12 @@ process_delegation_result_dht (void* cls, /* Check for key revocation and delegate */ - rh->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle, - &rh->authority, - GNUNET_GNS_MASTERZONE_STR, - GNUNET_NAMESTORE_TYPE_REV, - &process_pkey_revocation_result_ns, - rh); + rh->namestore_task = GNUNET_NAMESTORE_lookup (namestore_handle, + &rh->authority, + GNUNET_GNS_MASTERZONE_STR, + GNUNET_NAMESTORE_TYPE_REV, + &process_pkey_revocation_result_ns, + rh); return; } @@ -2801,12 +2809,12 @@ process_delegation_result_ns (void* cls, memcpy ((void*)rh->rd.data, rd[i].data, rd[i].data_size); rh->rd_count = 1; /* Check for key revocation and delegate */ - rh->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle, - &rh->authority, - GNUNET_GNS_MASTERZONE_STR, - GNUNET_NAMESTORE_TYPE_REV, - &process_pkey_revocation_result_ns, - rh); + rh->namestore_task = GNUNET_NAMESTORE_lookup (namestore_handle, + &rh->authority, + GNUNET_GNS_MASTERZONE_STR, + GNUNET_NAMESTORE_TYPE_REV, + &process_pkey_revocation_result_ns, + rh); return; default: /* ignore, move to next result */ @@ -2867,12 +2875,11 @@ resolve_delegation_ns (struct ResolverHandle *rh) rh->name, rh->authority_name, GNUNET_short_h2s (&rh->authority)); - rh->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle, - &rh->authority, - rh->authority_name, - GNUNET_DNSPARSER_TYPE_ANY, - &process_delegation_result_ns, - rh); + rh->namestore_task = GNUNET_NAMESTORE_lookup (namestore_handle, + &rh->authority, + rh->authority_name, + &process_delegation_result_ns, + rh); } #endif diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h index 986e957ec..0fbbb0084 100644 --- a/src/include/gnunet_namestore_service.h +++ b/src/include/gnunet_namestore_service.h @@ -367,6 +367,34 @@ GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h, /** + * Process a records that were decrypted from a block. + * + * @param cls closure + * @param rd_count number of entries in @a rd array + * @param rd array of records with data to store + */ +typedef void (*GNUNET_NAMESTORE_RecordCallback) (void *cls, + unsigned int rd_count, + const struct GNUNET_NAMESTORE_RecordData *rd); + + +/** + * Perform a lookup and decrypt the resulting block. + * + * @param h namestore to perform lookup in + * @param value_zone zone to look up record in + * @param label label to look for + * @param proc function to call with the result + * @param proc_cls closure for @a proc + */ +struct GNUNET_NAMESTORE_QueueEntry * +GNUNET_NAMESTORE_lookup (struct GNUNET_NAMESTORE_Handle *h, + const struct GNUNET_CRYPTO_EccPublicKey *value_zone, + const char *label, + GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls); + + +/** * Cancel a namestore operation. The final callback from the * operation must not have been done yet. Must be called on any * namestore operation that has not yet completed prior to calling @@ -656,17 +684,6 @@ GNUNET_NAMESTORE_block_verify (const struct GNUNET_NAMESTORE_Block *block); /** - * Process a records that were decrypted from a block. - * - * @param cls closure - * @param rd_count number of entries in @a rd array - * @param rd array of records with data to store - */ -typedef void (*GNUNET_NAMESTORE_RecordCallback) (void *cls, - unsigned int rd_count, - const struct GNUNET_NAMESTORE_RecordData *rd); - -/** * Decrypt block. * * @param block block to decrypt diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am index 7c602ac13..b7ff99998 100644 --- a/src/namestore/Makefile.am +++ b/src/namestore/Makefile.am @@ -92,7 +92,8 @@ libexec_PROGRAMS = \ gnunet-service-namestore bin_PROGRAMS = \ - gnunet-namestore + gnunet-namestore \ + gnunet-namestore-fcfsd gnunet_namestore_SOURCES = \ @@ -106,6 +107,17 @@ gnunet_namestore_DEPENDENCIES = \ libgnunetnamestore.la +gnunet_namestore_fcfsd_SOURCES = \ + gnunet-namestore-fcfsd.c +gnunet_namestore_fcfsd_LDADD = -lmicrohttpd \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(top_builddir)/src/namestore/libgnunetnamestore.la \ + $(GN_LIBINTL) +gnunet_namestore_fcfsd_DEPENDENCIES = \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(top_builddir)/src/namestore/libgnunetnamestore.la + + gnunet_service_namestore_SOURCES = \ gnunet-service-namestore.c diff --git a/src/gns/gnunet-gns-fcfsd.c b/src/namestore/gnunet-namestore-fcfsd.c index dd4572cb1..d949806db 100644 --- a/src/gns/gnunet-gns-fcfsd.c +++ b/src/namestore/gnunet-namestore-fcfsd.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2012 Christian Grothoff (and other contributing authors) + (C) 2012-2013 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -27,12 +27,11 @@ * domain name is available and allocating it to the new public key * (should this race be solved by namestore or by fcfsd?) * - nicer error reporting to browser - * - figure out where this binary should go (is gns the right directory!?) */ #include "platform.h" -#include <gnunet_util_lib.h> #include <microhttpd.h> -#include <gnunet_namestore_service.h> +#include "gnunet_util_lib.h" +#include "gnunet_namestore_service.h" /** * Invalid method page. @@ -141,7 +140,7 @@ struct Request /** * Public key submitted via form. */ - char public_key[64]; + char public_key[128]; }; @@ -192,11 +191,6 @@ static GNUNET_SCHEDULER_TaskIdentifier httpd_task; static struct GNUNET_NAMESTORE_Handle *ns; /** - * Hash of the public key of the fcfsd zone. - */ -static struct GNUNET_CRYPTO_ShortHashCode fcfsd_zone; - -/** * Private key for the fcfsd zone. */ static struct GNUNET_CRYPTO_EccPrivateKey *fcfs_zone_pkey; @@ -227,14 +221,13 @@ run_httpd_now () httpd_task = GNUNET_SCHEDULER_add_now (&do_httpd, NULL); } + static void iterate_cb (void *cls, - const struct GNUNET_CRYPTO_EccPublicKey *zone_key, - struct GNUNET_TIME_Absolute expire, - const char *name, - unsigned int rd_len, - const struct GNUNET_NAMESTORE_RecordData *rd, - const struct GNUNET_CRYPTO_EccSignature *signature) + const struct GNUNET_CRYPTO_EccPrivateKey *zone_key, + const char *name, + unsigned int rd_len, + const struct GNUNET_NAMESTORE_RecordData *rd) { struct ZoneinfoRequest *zr = cls; struct MHD_Response *response; @@ -316,21 +309,15 @@ serve_zoneinfo_page (struct MHD_Connection *connection) { struct ZoneinfoRequest *zr; - zr = GNUNET_malloc (sizeof (struct ZoneinfoRequest)); - + zr = GNUNET_new (struct ZoneinfoRequest); zr->zoneinfo = GNUNET_malloc (DEFAULT_ZONEINFO_BUFSIZE); zr->buf_len = DEFAULT_ZONEINFO_BUFSIZE; zr->connection = connection; zr->write_offset = 0; - - printf ("adsadad1!\n"); zr->list_it = GNUNET_NAMESTORE_zone_iteration_start (ns, - &fcfsd_zone, - GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION, - GNUNET_NAMESTORE_RF_PRIVATE, - &iterate_cb, - zr); - + fcfs_zone_pkey, + &iterate_cb, + zr); return MHD_YES; } @@ -493,25 +480,16 @@ put_continuation (void *cls, * * @param cls closure * @param zone_key public key of the zone - * @param expire when does the corresponding block in the DHT expire (until - * when should we never do a DHT lookup for the same name again)?; - * GNUNET_TIME_UNIT_ZERO_ABS if there are no records of any type in the namestore, - * or the expiration time of the block in the namestore (even if there are zero - * records matching the desired record type) * @param name name that is being mapped (at most 255 characters long) * @param rd_count number of entries in 'rd' array * @param rd array of records with data to store - * @param signature signature of the record block, NULL if signature is unavailable (i.e. - * because the user queried for a particular record type only) */ static void zone_to_name_cb (void *cls, - const struct GNUNET_CRYPTO_EccPublicKey *zone_key, - struct GNUNET_TIME_Absolute expire, + const struct GNUNET_CRYPTO_EccPrivateKey *zone_key, const char *name, unsigned int rd_count, - const struct GNUNET_NAMESTORE_RecordData *rd, - const struct GNUNET_CRYPTO_EccSignature *signature) + const struct GNUNET_NAMESTORE_RecordData *rd) { struct Request *request = cls; struct GNUNET_NAMESTORE_RecordData r; @@ -527,22 +505,17 @@ zone_to_name_cb (void *cls, run_httpd_now (); return; } - GNUNET_assert (GNUNET_OK == - GNUNET_CRYPTO_short_hash_from_string2 (request->public_key, - strlen (request->public_key), - &pub)); r.data = &pub; r.data_size = sizeof (pub); r.expiration_time = UINT64_MAX; r.record_type = GNUNET_NAMESTORE_TYPE_PKEY; r.flags = GNUNET_NAMESTORE_RF_AUTHORITY; - request->qe = GNUNET_NAMESTORE_record_put_by_authority (ns, - fcfs_zone_pkey, - request->domain_name, - 1, - &r, - &put_continuation, - request); + request->qe = GNUNET_NAMESTORE_records_store (ns, + fcfs_zone_pkey, + request->domain_name, + 1, &r, + &put_continuation, + request); } @@ -552,35 +525,22 @@ zone_to_name_cb (void *cls, * proceed to check if the requested key already exists. * * @param cls closure - * @param zone_key public key of the zone - * @param expire when does the corresponding block in the DHT expire (until - * when should we never do a DHT lookup for the same name again)?; - * GNUNET_TIME_UNIT_ZERO_ABS if there are no records of any type in the namestore, - * or the expiration time of the block in the namestore (even if there are zero - * records matching the desired record type) + * @param zone_key private key of the zone * @param name name that is being mapped (at most 255 characters long) * @param rd_count number of entries in 'rd' array * @param rd array of records with data to store - * @param signature signature of the record block, NULL if signature is unavailable (i.e. - * because the user queried for a particular record type only) */ static void lookup_result_processor (void *cls, - const struct GNUNET_CRYPTO_EccPublicKey *zone_key, - struct GNUNET_TIME_Absolute expire, + const struct GNUNET_CRYPTO_EccPrivateKey *zone_key, const char *name, unsigned int rd_count, - const struct GNUNET_NAMESTORE_RecordData *rd, - const struct GNUNET_CRYPTO_EccSignature *signature) + const struct GNUNET_NAMESTORE_RecordData *rd) { struct Request *request = cls; - struct GNUNET_CRYPTO_ShortHashCode pub; + struct GNUNET_CRYPTO_EccPublicKey pub; request->qe = NULL; - GNUNET_assert (GNUNET_OK == - GNUNET_CRYPTO_short_hash_from_string2 (request->public_key, - strlen (request->public_key), - &pub)); if (0 != rd_count) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -591,8 +551,18 @@ lookup_result_processor (void *cls, run_httpd_now (); return; } + if (GNUNET_OK != + GNUNET_CRYPTO_ecc_public_key_from_string (request->public_key, + strlen (request->public_key), + &pub)) + { + GNUNET_break (0); + request->phase = RP_FAIL; + run_httpd_now (); + return; + } request->qe = GNUNET_NAMESTORE_zone_to_name (ns, - &fcfsd_zone, + fcfs_zone_pkey, &pub, &zone_to_name_cb, request); @@ -635,7 +605,7 @@ create_response (void *cls, struct MHD_Response *response; struct Request *request; int ret; - struct GNUNET_CRYPTO_ShortHashCode pub; + struct GNUNET_CRYPTO_EccPublicKey pub; if ( (0 == strcmp (method, MHD_HTTP_METHOD_GET)) || (0 == strcmp (method, MHD_HTTP_METHOD_HEAD)) ) @@ -684,9 +654,9 @@ create_response (void *cls, request->pp = NULL; } if (GNUNET_OK != - GNUNET_CRYPTO_short_hash_from_string2 (request->public_key, - strlen (request->public_key), - &pub)) + GNUNET_CRYPTO_ecc_public_key_from_string (request->public_key, + strlen (request->public_key), + &pub)) { /* parse error */ return fill_s_reply ("Failed to parse given public key", @@ -712,12 +682,13 @@ create_response (void *cls, request, connection); } request->phase = RP_LOOKUP; - request->qe = GNUNET_NAMESTORE_lookup_record (ns, - &fcfsd_zone, - request->domain_name, - GNUNET_NAMESTORE_TYPE_PKEY, - &lookup_result_processor, - request); + GNUNET_CRYPTO_ecc_key_get_public (fcfs_zone_pkey, + &pub); + request->qe = GNUNET_NAMESTORE_lookup (ns, + &pub, + request->domain_name, + &lookup_result_processor, + request); break; case RP_LOOKUP: break; @@ -883,7 +854,6 @@ run (void *cls, char *const *args, const char *cfgfile, { char *keyfile; unsigned long long port; - struct GNUNET_CRYPTO_EccPublicKey pub; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, @@ -913,9 +883,6 @@ run (void *cls, char *const *args, const char *cfgfile, _("Failed to read or create private zone key\n")); return; } - GNUNET_CRYPTO_ecc_key_get_public (fcfs_zone_pkey, - &pub); - GNUNET_CRYPTO_short_hash (&pub, sizeof (pub), &fcfsd_zone); ns = GNUNET_NAMESTORE_connect (cfg); if (NULL == ns) { diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c index 98148ba1e..13cc32035 100644 --- a/src/namestore/namestore_api.c +++ b/src/namestore/namestore_api.c @@ -1132,6 +1132,26 @@ GNUNET_NAMESTORE_lookup_block (struct GNUNET_NAMESTORE_Handle *h, /** + * Perform a lookup and decrypt the resulting block. + * + * @param h namestore to perform lookup in + * @param value_zone zone to look up record in + * @param label label to look for + * @param proc function to call with the result + * @param proc_cls closure for @a proc + */ +struct GNUNET_NAMESTORE_QueueEntry * +GNUNET_NAMESTORE_lookup (struct GNUNET_NAMESTORE_Handle *h, + const struct GNUNET_CRYPTO_EccPublicKey *value_zone, + const char *label, + GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls) +{ + GNUNET_break (0); // FIXME: not implemented + return NULL; +} + + +/** * Look for an existing PKEY delegation record for a given public key. * Returns at most one result to the processor. * diff --git a/src/namestore/namestore_api_common.c b/src/namestore/namestore_api_common.c index 5a27f14a1..bfab39384 100644 --- a/src/namestore/namestore_api_common.c +++ b/src/namestore/namestore_api_common.c @@ -364,7 +364,7 @@ int GNUNET_NAMESTORE_block_decrypt (const struct GNUNET_NAMESTORE_Block *block, const struct GNUNET_CRYPTO_EccPublicKey *zone_key, const char *label, - GNUNET_NAMESTORE_RecordMonitor proc, + GNUNET_NAMESTORE_RecordCallback proc, void *proc_cls) { GNUNET_break (0); |