aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-04-23 12:42:00 +0200
committerChristian Grothoff <christian@grothoff.org>2018-04-23 12:42:00 +0200
commite1f46c052dca3cd7a390f18f97b10162fe537a15 (patch)
treedaa43ca3b189b6f86425801dc94413a71a04a66c /src
parentff4d7b51f37f61633766664647e9b148af1e4f0a (diff)
downloadgnunet-e1f46c052dca3cd7a390f18f97b10162fe537a15.tar.gz
gnunet-e1f46c052dca3cd7a390f18f97b10162fe537a15.zip
move to @ for empty label, fix empty-label resolution bug in GNS API, install gnunet-zoneimport and add man page
Diffstat (limited to 'src')
-rw-r--r--src/gns/gns_tld_api.c14
-rw-r--r--src/gns/gnunet-service-gns_resolver.c8
-rw-r--r--src/include/gnunet_gns_service.h9
-rw-r--r--src/namecache/plugin_namecache_sqlite.c8
-rw-r--r--src/namestore/Makefile.am4
-rw-r--r--src/namestore/gnunet-namestore.c2
-rw-r--r--src/namestore/gnunet-service-namestore.c16
-rw-r--r--src/namestore/gnunet-zoneimport.c25
-rw-r--r--src/namestore/namestore_api.c2
-rw-r--r--src/namestore/plugin_rest_namestore.c2
10 files changed, 41 insertions, 49 deletions
diff --git a/src/gns/gns_tld_api.c b/src/gns/gns_tld_api.c
index 293e37140..8a4d03b11 100644
--- a/src/gns/gns_tld_api.c
+++ b/src/gns/gns_tld_api.c
@@ -94,7 +94,7 @@ struct GNUNET_GNS_LookupWithTldRequest
94 * @return the part of @a name after the last ".", 94 * @return the part of @a name after the last ".",
95 * or @a name if @a name does not contain a "." 95 * or @a name if @a name does not contain a "."
96 */ 96 */
97static const char * 97static char *
98get_tld (const char *name) 98get_tld (const char *name)
99{ 99{
100 const char *tld; 100 const char *tld;
@@ -105,14 +105,14 @@ get_tld (const char *name)
105 tld = name; 105 tld = name;
106 else 106 else
107 tld++; /* skip the '.' */ 107 tld++; /* skip the '.' */
108 return tld; 108 return GNUNET_strdup (tld);
109} 109}
110 110
111 111
112/** 112/**
113 * Eat the TLD of the given @a name. 113 * Eat the TLD of the given @a name.
114 * 114 *
115 * @param name a name 115 * @param[in,out] name a name
116 */ 116 */
117static void 117static void
118eat_tld (char *name) 118eat_tld (char *name)
@@ -124,7 +124,7 @@ eat_tld (char *name)
124 (unsigned char) '.'); 124 (unsigned char) '.');
125 if (NULL == tld) 125 if (NULL == tld)
126 strcpy (name, 126 strcpy (name,
127 GNUNET_GNS_MASTERZONE_STR); 127 GNUNET_GNS_EMPTY_LABEL_AT);
128 else 128 else
129 *tld = '\0'; 129 *tld = '\0';
130} 130}
@@ -229,7 +229,7 @@ GNUNET_GNS_lookup_with_tld (struct GNUNET_GNS_Handle *handle,
229 void *proc_cls) 229 void *proc_cls)
230{ 230{
231 struct GNUNET_GNS_LookupWithTldRequest *ltr; 231 struct GNUNET_GNS_LookupWithTldRequest *ltr;
232 const char *tld; 232 char *tld;
233 char *dot_tld; 233 char *dot_tld;
234 char *zonestr; 234 char *zonestr;
235 struct GNUNET_CRYPTO_EcdsaPublicKey pkey; 235 struct GNUNET_CRYPTO_EcdsaPublicKey pkey;
@@ -251,6 +251,7 @@ GNUNET_GNS_lookup_with_tld (struct GNUNET_GNS_Handle *handle,
251 eat_tld (ltr->name); 251 eat_tld (ltr->name);
252 lookup_with_public_key (ltr, 252 lookup_with_public_key (ltr,
253 &pkey); 253 &pkey);
254 GNUNET_free (tld);
254 return ltr; 255 return ltr;
255 } 256 }
256 257
@@ -277,6 +278,7 @@ GNUNET_GNS_lookup_with_tld (struct GNUNET_GNS_Handle *handle,
277 GNUNET_free (dot_tld); 278 GNUNET_free (dot_tld);
278 GNUNET_free (ltr->name); 279 GNUNET_free (ltr->name);
279 GNUNET_free (ltr); 280 GNUNET_free (ltr);
281 GNUNET_free (tld);
280 return NULL; 282 return NULL;
281 } 283 }
282 GNUNET_free (dot_tld); 284 GNUNET_free (dot_tld);
@@ -284,6 +286,7 @@ GNUNET_GNS_lookup_with_tld (struct GNUNET_GNS_Handle *handle,
284 eat_tld (ltr->name); 286 eat_tld (ltr->name);
285 lookup_with_public_key (ltr, 287 lookup_with_public_key (ltr,
286 &pkey); 288 &pkey);
289 GNUNET_free (tld);
287 return ltr; 290 return ltr;
288 } 291 }
289 GNUNET_free (dot_tld); 292 GNUNET_free (dot_tld);
@@ -301,6 +304,7 @@ GNUNET_GNS_lookup_with_tld (struct GNUNET_GNS_Handle *handle,
301 tld, 304 tld,
302 &identity_zone_cb, 305 &identity_zone_cb,
303 ltr); 306 ltr);
307 GNUNET_free (tld);
304 if (NULL == ltr->id_op) 308 if (NULL == ltr->id_op)
305 { 309 {
306 GNUNET_free (ltr->name); 310 GNUNET_free (ltr->name);
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 74eb47f29..745a2f3bd 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -2096,14 +2096,14 @@ handle_gns_resolution_result (void *cls,
2096 rd_off++; 2096 rd_off++;
2097 if (GNUNET_GNSRECORD_TYPE_PKEY != rh->record_type) 2097 if (GNUNET_GNSRECORD_TYPE_PKEY != rh->record_type)
2098 { 2098 {
2099 /* try to resolve "+" */ 2099 /* try to resolve "@" */
2100 struct AuthorityChain *ac; 2100 struct AuthorityChain *ac;
2101 2101
2102 ac = GNUNET_new (struct AuthorityChain); 2102 ac = GNUNET_new (struct AuthorityChain);
2103 ac->rh = rh; 2103 ac->rh = rh;
2104 ac->gns_authority = GNUNET_YES; 2104 ac->gns_authority = GNUNET_YES;
2105 ac->authority_info.gns_authority = pub; 2105 ac->authority_info.gns_authority = pub;
2106 ac->label = GNUNET_strdup (GNUNET_GNS_MASTERZONE_STR); 2106 ac->label = GNUNET_strdup (GNUNET_GNS_EMPTY_LABEL_AT);
2107 ac->suggested_shortening_label = NULL; 2107 ac->suggested_shortening_label = NULL;
2108 ac->shortening_started = GNUNET_NO; 2108 ac->shortening_started = GNUNET_NO;
2109 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head, 2109 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head,
@@ -2629,8 +2629,8 @@ start_resolver_lookup (void *cls)
2629 ac->suggested_shortening_label = NULL; 2629 ac->suggested_shortening_label = NULL;
2630 if (NULL == ac->label) 2630 if (NULL == ac->label)
2631 /* name was just the "TLD", so we default to label 2631 /* name was just the "TLD", so we default to label
2632 #GNUNET_GNS_MASTERZONE_STR */ 2632 #GNUNET_GNS_EMPTY_LABEL_AT */
2633 ac->label = GNUNET_strdup (GNUNET_GNS_MASTERZONE_STR); 2633 ac->label = GNUNET_strdup (GNUNET_GNS_EMPTY_LABEL_AT);
2634 ac->gns_authority = GNUNET_YES; 2634 ac->gns_authority = GNUNET_YES;
2635 ac->authority_info.gns_authority = rh->authority_zone; 2635 ac->authority_info.gns_authority = rh->authority_zone;
2636 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head, 2636 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head,
diff --git a/src/include/gnunet_gns_service.h b/src/include/gnunet_gns_service.h
index 8c1f64783..ff3110406 100644
--- a/src/include/gnunet_gns_service.h
+++ b/src/include/gnunet_gns_service.h
@@ -48,13 +48,10 @@ extern "C"
48 48
49 49
50/** 50/**
51 * String we use to indicate the local master zone or a 51 * String we use to indicate an empty label (top-level
52 * root entry in the current zone. 52 * entry in the zone). DNS uses "@", so do we.
53 *
54 * FIXME: probably should be changed to "@" and renamed
55 * (this name is confusing!)
56 */ 53 */
57#define GNUNET_GNS_MASTERZONE_STR "+" 54#define GNUNET_GNS_EMPTY_LABEL_AT "@"
58 55
59/** 56/**
60 * Connection to the GNS service. 57 * Connection to the GNS service.
diff --git a/src/namecache/plugin_namecache_sqlite.c b/src/namecache/plugin_namecache_sqlite.c
index 37d6d3b62..e8a61a232 100644
--- a/src/namecache/plugin_namecache_sqlite.c
+++ b/src/namecache/plugin_namecache_sqlite.c
@@ -411,10 +411,10 @@ namecache_sqlite_cache_block (void *cls,
411 GNUNET_CRYPTO_hash (&block->derived_key, 411 GNUNET_CRYPTO_hash (&block->derived_key,
412 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), 412 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
413 &query); 413 &query);
414 fprintf (stderr, 414 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
415 "Caching new version of block %s (expires %llu)\n", 415 "Caching new version of block %s (expires %llu)\n",
416 GNUNET_h2s (&query), 416 GNUNET_h2s (&query),
417 (unsigned long long) expiration.abs_value_us); 417 (unsigned long long) expiration.abs_value_us);
418 expiration = GNUNET_TIME_absolute_ntoh (block->expiration_time); 418 expiration = GNUNET_TIME_absolute_ntoh (block->expiration_time);
419 if (block_size > 64 * 65536) 419 if (block_size > 64 * 65536)
420 { 420 {
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am
index fd8f8054f..5f18506a7 100644
--- a/src/namestore/Makefile.am
+++ b/src/namestore/Makefile.am
@@ -124,9 +124,7 @@ libexec_PROGRAMS = \
124 gnunet-service-namestore 124 gnunet-service-namestore
125 125
126bin_PROGRAMS = \ 126bin_PROGRAMS = \
127 gnunet-namestore 127 gnunet-namestore \
128
129noinst_PROGRAMS = \
130 gnunet-zoneimport 128 gnunet-zoneimport
131 129
132if HAVE_MHD 130if HAVE_MHD
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index 9a1805af4..660737595 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -408,7 +408,7 @@ display_record (void *cls,
408 { 408 {
409 if ( (GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) && 409 if ( (GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
410 (0 != strcmp (rname, 410 (0 != strcmp (rname,
411 GNUNET_GNS_MASTERZONE_STR)) ) 411 GNUNET_GNS_EMPTY_LABEL_AT)) )
412 continue; 412 continue;
413 typestring = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type); 413 typestring = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type);
414 s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type, 414 s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index 3a3291c07..3685c93af 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -362,13 +362,13 @@ client_connect_cb (void *cls,
362 362
363 363
364/** 364/**
365 * Function called with the records for the #GNUNET_GNS_MASTERZONE_STR 365 * Function called with the records for the #GNUNET_GNS_EMPTY_LABEL_AT
366 * label in the zone. Used to locate the #GNUNET_GNSRECORD_TYPE_NICK 366 * label in the zone. Used to locate the #GNUNET_GNSRECORD_TYPE_NICK
367 * record, which (if found) is then copied to @a cls for future use. 367 * record, which (if found) is then copied to @a cls for future use.
368 * 368 *
369 * @param cls a `struct GNUNET_GNSRECORD_Data **` for storing the nick (if found) 369 * @param cls a `struct GNUNET_GNSRECORD_Data **` for storing the nick (if found)
370 * @param private_key the private key of the zone (unused) 370 * @param private_key the private key of the zone (unused)
371 * @param label should be #GNUNET_GNS_MASTERZONE_STR 371 * @param label should be #GNUNET_GNS_EMPTY_LABEL_AT
372 * @param rd_count number of records in @a rd 372 * @param rd_count number of records in @a rd
373 * @param rd records stored under @a label in the zone 373 * @param rd records stored under @a label in the zone
374 */ 374 */
@@ -382,7 +382,7 @@ lookup_nick_it (void *cls,
382 struct GNUNET_GNSRECORD_Data **res = cls; 382 struct GNUNET_GNSRECORD_Data **res = cls;
383 383
384 (void) private_key; 384 (void) private_key;
385 if (0 != strcmp (label, GNUNET_GNS_MASTERZONE_STR)) 385 if (0 != strcmp (label, GNUNET_GNS_EMPTY_LABEL_AT))
386 { 386 {
387 GNUNET_break (0); 387 GNUNET_break (0);
388 return; 388 return;
@@ -423,7 +423,7 @@ get_nick_record (const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone)
423 nick = NULL; 423 nick = NULL;
424 res = GSN_database->lookup_records (GSN_database->cls, 424 res = GSN_database->lookup_records (GSN_database->cls,
425 zone, 425 zone,
426 GNUNET_GNS_MASTERZONE_STR, 426 GNUNET_GNS_EMPTY_LABEL_AT,
427 &lookup_nick_it, 427 &lookup_nick_it,
428 &nick); 428 &nick);
429 if ( (GNUNET_OK != res) || 429 if ( (GNUNET_OK != res) ||
@@ -531,7 +531,7 @@ send_lookup_response (struct NamestoreClient *nc,
531 char *rd_ser; 531 char *rd_ser;
532 532
533 nick = get_nick_record (zone_key); 533 nick = get_nick_record (zone_key);
534 if ((NULL != nick) && (0 != strcmp(name, GNUNET_GNS_MASTERZONE_STR))) 534 if ((NULL != nick) && (0 != strcmp(name, GNUNET_GNS_EMPTY_LABEL_AT)))
535 { 535 {
536 nick->flags = (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE; 536 nick->flags = (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE;
537 merge_with_nick_records (nick, 537 merge_with_nick_records (nick,
@@ -766,7 +766,7 @@ lookup_it (void *cls,
766 { 766 {
767 if ( (NULL != rlc->nick) && 767 if ( (NULL != rlc->nick) &&
768 (0 != strcmp (label, 768 (0 != strcmp (label,
769 GNUNET_GNS_MASTERZONE_STR)) ) 769 GNUNET_GNS_EMPTY_LABEL_AT)) )
770 { 770 {
771 /* Merge */ 771 /* Merge */
772 rd_res = NULL; 772 rd_res = NULL;
@@ -1043,12 +1043,12 @@ handle_record_store (void *cls,
1043 unsigned int rd_clean_off; 1043 unsigned int rd_clean_off;
1044 1044
1045 /* remove "NICK" records, unless this is for the 1045 /* remove "NICK" records, unless this is for the
1046 #GNUNET_GNS_MASTERZONE_STR label */ 1046 #GNUNET_GNS_EMPTY_LABEL_AT label */
1047 rd_clean_off = 0; 1047 rd_clean_off = 0;
1048 for (unsigned int i=0;i<rd_count;i++) 1048 for (unsigned int i=0;i<rd_count;i++)
1049 { 1049 {
1050 rd_clean[rd_clean_off] = rd[i]; 1050 rd_clean[rd_clean_off] = rd[i];
1051 if ( (0 == strcmp (GNUNET_GNS_MASTERZONE_STR, 1051 if ( (0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT,
1052 conv_name)) || 1052 conv_name)) ||
1053 (GNUNET_GNSRECORD_TYPE_NICK != rd[i].record_type) ) 1053 (GNUNET_GNSRECORD_TYPE_NICK != rd[i].record_type) )
1054 rd_clean_off++; 1054 rd_clean_off++;
diff --git a/src/namestore/gnunet-zoneimport.c b/src/namestore/gnunet-zoneimport.c
index 279bfddea..89afeeeb1 100644
--- a/src/namestore/gnunet-zoneimport.c
+++ b/src/namestore/gnunet-zoneimport.c
@@ -21,9 +21,6 @@
21 * @file src/namestore/gnunet-zoneimport.c 21 * @file src/namestore/gnunet-zoneimport.c
22 * @brief import a DNS zone for publication in GNS, incremental 22 * @brief import a DNS zone for publication in GNS, incremental
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 *
25 * TODO:
26 * - set NICKname for zone's records
27 */ 24 */
28#include "platform.h" 25#include "platform.h"
29#include <gnunet_util_lib.h> 26#include <gnunet_util_lib.h>
@@ -50,11 +47,6 @@
50 */ 47 */
51#define MAX_RETRIES 5 48#define MAX_RETRIES 5
52 49
53/**
54 * After how many lookups should we always sync to disk?
55 */
56#define TRANSACTION_SYNC_FREQ 100
57
58 50
59/** 51/**
60 * Some zones may include authoritative records for other 52 * Some zones may include authoritative records for other
@@ -795,6 +787,7 @@ store_completed_cb (void *cls,
795 const char *emsg) 787 const char *emsg)
796{ 788{
797 struct Request *req = cls; 789 struct Request *req = cls;
790 struct Record *rec;
798 791
799 req->qe = NULL; 792 req->qe = NULL;
800 pending--; 793 pending--;
@@ -811,6 +804,14 @@ store_completed_cb (void *cls,
811 "Stored records under `%s'\n", 804 "Stored records under `%s'\n",
812 req->label); 805 req->label);
813 } 806 }
807 /* Free records */
808 while (NULL != (rec = req->rec_head))
809 {
810 GNUNET_CONTAINER_DLL_remove (req->rec_head,
811 req->rec_tail,
812 rec);
813 GNUNET_free (rec);
814 }
814} 815}
815 816
816 817
@@ -877,14 +878,6 @@ process_result (void *cls,
877 pending--; 878 pending--;
878 return; 879 return;
879 } 880 }
880 /* Free old/legacy records */
881 while (NULL != (rec = req->rec_head))
882 {
883 GNUNET_CONTAINER_DLL_remove (req->rec_head,
884 req->rec_tail,
885 rec);
886 GNUNET_free (rec);
887 }
888 /* import new records */ 881 /* import new records */
889 req->issue_num = 0; /* success, reset counter! */ 882 req->issue_num = 0; /* success, reset counter! */
890 req->p = p; 883 req->p = p;
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c
index a187bd250..05bdf17da 100644
--- a/src/namestore/namestore_api.c
+++ b/src/namestore/namestore_api.c
@@ -1087,7 +1087,7 @@ GNUNET_NAMESTORE_set_nick (struct GNUNET_NAMESTORE_Handle *h,
1087 rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE; 1087 rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE;
1088 return GNUNET_NAMESTORE_records_store (h, 1088 return GNUNET_NAMESTORE_records_store (h,
1089 pkey, 1089 pkey,
1090 GNUNET_GNS_MASTERZONE_STR, 1090 GNUNET_GNS_EMPTY_LABEL_AT,
1091 1, 1091 1,
1092 &rd, 1092 &rd,
1093 cont, 1093 cont,
diff --git a/src/namestore/plugin_rest_namestore.c b/src/namestore/plugin_rest_namestore.c
index 4602106da..aedb39159 100644
--- a/src/namestore/plugin_rest_namestore.c
+++ b/src/namestore/plugin_rest_namestore.c
@@ -460,7 +460,7 @@ namestore_list_response (void *cls,
460 for (unsigned int i=0; i<rd_len; i++) 460 for (unsigned int i=0; i<rd_len; i++)
461 { 461 {
462 if ( (GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) && 462 if ( (GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
463 (0 != strcmp (rname, GNUNET_GNS_MASTERZONE_STR)) ) 463 (0 != strcmp (rname, GNUNET_GNS_EMPTY_LABEL_AT)) )
464 continue; 464 continue;
465 465
466 if ( (rd[i].record_type != handle->type) && 466 if ( (rd[i].record_type != handle->type) &&