aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-04-23 15:59:03 +0200
committerChristian Grothoff <christian@grothoff.org>2018-04-23 15:59:03 +0200
commit08795cc18190529e28a4ccc54e225534f55ed209 (patch)
tree992187d21a4ce155facd3fc5a8d2cb5860ced164
parent3e2b9dc6d520b6be53a3c41a112f224df12d9f99 (diff)
downloadgnunet-08795cc18190529e28a4ccc54e225534f55ed209.tar.gz
gnunet-08795cc18190529e28a4ccc54e225534f55ed209.zip
fix transition to multi-server in cmd line for gnunet-zoneimport
-rw-r--r--doc/man/gnunet-zoneimport.17
-rw-r--r--src/gnsrecord/gnsrecord_misc.c18
-rw-r--r--src/namestore/gnunet-service-namestore.c68
-rw-r--r--src/namestore/gnunet-zoneimport.c15
4 files changed, 56 insertions, 52 deletions
diff --git a/doc/man/gnunet-zoneimport.1 b/doc/man/gnunet-zoneimport.1
index d268bf9ff..afe3354e6 100644
--- a/doc/man/gnunet-zoneimport.1
+++ b/doc/man/gnunet-zoneimport.1
@@ -4,12 +4,14 @@
4gnunet\-zoneimport \- import DNS zone into GNS zone 4gnunet\-zoneimport \- import DNS zone into GNS zone
5 5
6.SH SYNOPSIS 6.SH SYNOPSIS
7.B gnunet\-zoneimport -s IP 7.B gnunet\-zoneimport [IP]+
8.br 8.br
9 9
10.SH DESCRIPTION 10.SH DESCRIPTION
11\fBgnunet\-zoneimport\fP reads a list of domain names (FQDN) from stdin and issues DNS queries for each of the domain names given. It then checks if a local ego with a name matching the domain exists. Specifically, if the domain name is "example.fr", it will check if an ego "fr" exists, while for a domain "example.com.fr" it will look for an ego called "com.fr"). If so, it will convert the DNS records into GNS records (in particular converting NS records and glue records to GNS2DNS records) and add them to the namestore under the label ("example" in the examples above). 11\fBgnunet\-zoneimport\fP reads a list of domain names (FQDN) from stdin and issues DNS queries for each of the domain names given. It then checks if a local ego with a name matching the domain exists. Specifically, if the domain name is "example.fr", it will check if an ego "fr" exists, while for a domain "example.com.fr" it will look for an ego called "com.fr"). If so, it will convert the DNS records into GNS records (in particular converting NS records and glue records to GNS2DNS records) and add them to the namestore under the label ("example" in the examples above).
12 12
13The arguments given to gnunet\-zoneimport is a list of IP addresses of DNS servers to query.
14
13gnunet\-zoneimport will usually never terminate: it will check when DNS records expire, and re-issue requests when the old DNS records have expired so that GNS always has the latest data. 15gnunet\-zoneimport will usually never terminate: it will check when DNS records expire, and re-issue requests when the old DNS records have expired so that GNS always has the latest data.
14 16
15gnunet\-zoneimport will issue many DNS queries in parallel, but is rate-limited in various ways, so most DNS servers should easily handle the load. gnunet\-zoneimport will perform a limited number of retries if queries fail. 17gnunet\-zoneimport will issue many DNS queries in parallel, but is rate-limited in various ways, so most DNS servers should easily handle the load. gnunet\-zoneimport will perform a limited number of retries if queries fail.
@@ -23,9 +25,6 @@ Finally, gnunet\-zoneimport keeps information for each domain name in memory. T
23.IP "\-c FILENAME, \-\-config=FILENAME" 25.IP "\-c FILENAME, \-\-config=FILENAME"
24Use the configuration file FILENAME. 26Use the configuration file FILENAME.
25.B 27.B
26.IP "\-s IP, \-\-server IP"
27IP address of the DNS server to query. Should be the authoritative server for the domain (lookup the IP address of the NS server!) and not some recursive resolver (which would be both slow and is more likely to return only partial information).
28.B
29.IP "\-h, \-\-help" 28.IP "\-h, \-\-help"
30Print short help on options. 29Print short help on options.
31 30
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c
index 3c1ead437..05f56cf70 100644
--- a/src/gnsrecord/gnsrecord_misc.c
+++ b/src/gnsrecord/gnsrecord_misc.c
@@ -152,8 +152,6 @@ struct GNUNET_TIME_Absolute
152GNUNET_GNSRECORD_record_get_expiration_time (unsigned int rd_count, 152GNUNET_GNSRECORD_record_get_expiration_time (unsigned int rd_count,
153 const struct GNUNET_GNSRECORD_Data *rd) 153 const struct GNUNET_GNSRECORD_Data *rd)
154{ 154{
155 unsigned int c;
156 unsigned int c2;
157 struct GNUNET_TIME_Absolute expire; 155 struct GNUNET_TIME_Absolute expire;
158 struct GNUNET_TIME_Absolute at; 156 struct GNUNET_TIME_Absolute at;
159 struct GNUNET_TIME_Relative rt; 157 struct GNUNET_TIME_Relative rt;
@@ -163,7 +161,7 @@ GNUNET_GNSRECORD_record_get_expiration_time (unsigned int rd_count,
163 if (NULL == rd) 161 if (NULL == rd)
164 return GNUNET_TIME_UNIT_ZERO_ABS; 162 return GNUNET_TIME_UNIT_ZERO_ABS;
165 expire = GNUNET_TIME_UNIT_FOREVER_ABS; 163 expire = GNUNET_TIME_UNIT_FOREVER_ABS;
166 for (c = 0; c < rd_count; c++) 164 for (unsigned int c = 0; c < rd_count; c++)
167 { 165 {
168 if (0 != (rd[c].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) 166 if (0 != (rd[c].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
169 { 167 {
@@ -175,12 +173,12 @@ GNUNET_GNSRECORD_record_get_expiration_time (unsigned int rd_count,
175 at.abs_value_us = rd[c].expiration_time; 173 at.abs_value_us = rd[c].expiration_time;
176 } 174 }
177 175
178 for (c2 = 0; c2 < rd_count; c2++) 176 for (unsigned int c2 = 0; c2 < rd_count; c2++)
179 { 177 {
180 /* Check for shadow record */ 178 /* Check for shadow record */
181 if ((c == c2) || 179 if ( (c == c2) ||
182 (rd[c].record_type != rd[c2].record_type) || 180 (rd[c].record_type != rd[c2].record_type) ||
183 (0 == (rd[c2].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD))) 181 (0 == (rd[c2].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) )
184 continue; 182 continue;
185 /* We have a shadow record */ 183 /* We have a shadow record */
186 if (0 != (rd[c2].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) 184 if (0 != (rd[c2].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
@@ -192,9 +190,11 @@ GNUNET_GNSRECORD_record_get_expiration_time (unsigned int rd_count,
192 { 190 {
193 at_shadow.abs_value_us = rd[c2].expiration_time; 191 at_shadow.abs_value_us = rd[c2].expiration_time;
194 } 192 }
195 at = GNUNET_TIME_absolute_max (at, at_shadow); 193 at = GNUNET_TIME_absolute_max (at,
194 at_shadow);
196 } 195 }
197 expire = GNUNET_TIME_absolute_min (at, expire); 196 expire = GNUNET_TIME_absolute_min (at,
197 expire);
198 } 198 }
199 LOG (GNUNET_ERROR_TYPE_DEBUG, 199 LOG (GNUNET_ERROR_TYPE_DEBUG,
200 "Determined expiration time for block with %u records to be %s\n", 200 "Determined expiration time for block with %u records to be %s\n",
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index 3685c93af..3ba4f9ec3 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -439,9 +439,24 @@ get_nick_record (const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone)
439} 439}
440 440
441 441
442/**
443 * Merge the nick record @a nick_rd with the rest of the
444 * record set given in @a rd2. Store the result in @a rdc_res
445 * and @a rd_res. The @a nick_rd's expiration time is set to
446 * the maximum expiration time of all of the records in @a rd2.
447 *
448 * @param nick_rd the nick record to integrate
449 * @param rd2_length length of the @a rd2 array
450 * @param rd2 array of records
451 * @param rdc_res[out] length of the resulting @a rd_res array
452 * @param rd_res[out] set to an array of records,
453 * including @a nick_rd and @a rd2;
454 * all of the variable-size 'data' fields in @a rd2 are
455 * allocated in the same chunk of memory!
456 */
442static void 457static void
443merge_with_nick_records (const struct GNUNET_GNSRECORD_Data *nick_rd, 458merge_with_nick_records (const struct GNUNET_GNSRECORD_Data *nick_rd,
444 unsigned int rdc2, 459 unsigned int rd2_length,
445 const struct GNUNET_GNSRECORD_Data *rd2, 460 const struct GNUNET_GNSRECORD_Data *rd2,
446 unsigned int *rdc_res, 461 unsigned int *rdc_res,
447 struct GNUNET_GNSRECORD_Data **rd_res) 462 struct GNUNET_GNSRECORD_Data **rd_res)
@@ -452,24 +467,22 @@ merge_with_nick_records (const struct GNUNET_GNSRECORD_Data *nick_rd,
452 int record_offset; 467 int record_offset;
453 size_t data_offset; 468 size_t data_offset;
454 469
455 (*rdc_res) = 1 + rdc2; 470 (*rdc_res) = 1 + rd2_length;
456 if (0 == 1 + rdc2) 471 if (0 == 1 + rd2_length)
457 { 472 {
458 (*rd_res) = NULL; 473 (*rd_res) = NULL;
459 return; 474 return;
460 } 475 }
461
462 req = 0; 476 req = 0;
463 for (unsigned int c=0; c< 1; c++) 477 for (unsigned int c=0; c< 1; c++)
464 req += sizeof (struct GNUNET_GNSRECORD_Data) + nick_rd[c].data_size; 478 req += sizeof (struct GNUNET_GNSRECORD_Data) + nick_rd[c].data_size;
465 for (unsigned int c=0; c< rdc2; c++) 479 for (unsigned int c=0; c< rd2_length; c++)
466 req += sizeof (struct GNUNET_GNSRECORD_Data) + rd2[c].data_size; 480 req += sizeof (struct GNUNET_GNSRECORD_Data) + rd2[c].data_size;
467 (*rd_res) = GNUNET_malloc (req); 481 (*rd_res) = GNUNET_malloc (req);
468 data = (char *) &(*rd_res)[1 + rdc2]; 482 data = (char *) &(*rd_res)[1 + rd2_length];
469 data_offset = 0; 483 data_offset = 0;
470 latest_expiration = 0; 484 latest_expiration = 0;
471 485 for (unsigned int c=0; c< rd2_length; c++)
472 for (unsigned int c=0; c< rdc2; c++)
473 { 486 {
474 if (0 != (rd2[c].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) 487 if (0 != (rd2[c].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
475 { 488 {
@@ -486,17 +499,15 @@ merge_with_nick_records (const struct GNUNET_GNSRECORD_Data *nick_rd,
486 rd2[c].data_size); 499 rd2[c].data_size);
487 data_offset += (*rd_res)[c].data_size; 500 data_offset += (*rd_res)[c].data_size;
488 } 501 }
489 record_offset = rdc2; 502 /* append nick */
490 for (unsigned int c=0; c< 1; c++) 503 record_offset = rd2_length;
491 { 504 (*rd_res)[record_offset] = *nick_rd;
492 (*rd_res)[c+record_offset] = nick_rd[c]; 505 (*rd_res)[record_offset].expiration_time = latest_expiration;
493 (*rd_res)[c+record_offset].expiration_time = latest_expiration; 506 (*rd_res)[record_offset].data = (void *) &data[data_offset];
494 (*rd_res)[c+record_offset].data = (void *) &data[data_offset]; 507 GNUNET_memcpy ((void *) (*rd_res)[record_offset].data,
495 GNUNET_memcpy ((void *) (*rd_res)[c+record_offset].data, 508 nick_rd->data,
496 nick_rd[c].data, 509 nick_rd->data_size);
497 nick_rd[c].data_size); 510 data_offset += (*rd_res)[record_offset].data_size;
498 data_offset += (*rd_res)[c+record_offset].data_size;
499 }
500 GNUNET_assert (req == (sizeof (struct GNUNET_GNSRECORD_Data)) * (*rdc_res) + data_offset); 511 GNUNET_assert (req == (sizeof (struct GNUNET_GNSRECORD_Data)) * (*rdc_res) + data_offset);
501} 512}
502 513
@@ -531,7 +542,9 @@ send_lookup_response (struct NamestoreClient *nc,
531 char *rd_ser; 542 char *rd_ser;
532 543
533 nick = get_nick_record (zone_key); 544 nick = get_nick_record (zone_key);
534 if ((NULL != nick) && (0 != strcmp(name, GNUNET_GNS_EMPTY_LABEL_AT))) 545 if ( (NULL != nick) &&
546 (0 != strcmp (name,
547 GNUNET_GNS_EMPTY_LABEL_AT)))
535 { 548 {
536 nick->flags = (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE; 549 nick->flags = (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE;
537 merge_with_nick_records (nick, 550 merge_with_nick_records (nick,
@@ -677,13 +690,15 @@ refresh_block (struct NamestoreClient *nc,
677 block = GNUNET_GNSRECORD_block_create (zone_key, 690 block = GNUNET_GNSRECORD_block_create (zone_key,
678 GNUNET_TIME_UNIT_ZERO_ABS, 691 GNUNET_TIME_UNIT_ZERO_ABS,
679 name, 692 name,
680 res, rd_count); 693 res,
694 rd_count);
681 else 695 else
682 block = GNUNET_GNSRECORD_block_create (zone_key, 696 block = GNUNET_GNSRECORD_block_create (zone_key,
683 GNUNET_GNSRECORD_record_get_expiration_time (res_count, 697 GNUNET_GNSRECORD_record_get_expiration_time (res_count,
684 res), 698 res),
685 name, 699 name,
686 res, res_count); 700 res,
701 res_count);
687 GNUNET_assert (NULL != block); 702 GNUNET_assert (NULL != block);
688 GNUNET_CRYPTO_ecdsa_key_get_public (zone_key, 703 GNUNET_CRYPTO_ecdsa_key_get_public (zone_key,
689 &pkey); 704 &pkey);
@@ -773,9 +788,10 @@ lookup_it (void *cls,
773 rdc_res = 0; 788 rdc_res = 0;
774 rlc->nick->flags = (rlc->nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE; 789 rlc->nick->flags = (rlc->nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE;
775 merge_with_nick_records (rlc->nick, 790 merge_with_nick_records (rlc->nick,
776 rd_count, rd, 791 rd_count,
777 &rdc_res, &rd_res); 792 rd,
778 793 &rdc_res,
794 &rd_res);
779 rlc->rd_ser_len = GNUNET_GNSRECORD_records_get_size (rdc_res, 795 rlc->rd_ser_len = GNUNET_GNSRECORD_records_get_size (rdc_res,
780 rd_res); 796 rd_res);
781 rlc->res_rd_count = rdc_res; 797 rlc->res_rd_count = rdc_res;
diff --git a/src/namestore/gnunet-zoneimport.c b/src/namestore/gnunet-zoneimport.c
index 2926fe9bd..4fd0f3aef 100644
--- a/src/namestore/gnunet-zoneimport.c
+++ b/src/namestore/gnunet-zoneimport.c
@@ -268,11 +268,6 @@ static struct Request *req_tail;
268static struct GNUNET_SCHEDULER_Task *t; 268static struct GNUNET_SCHEDULER_Task *t;
269 269
270/** 270/**
271 * Which DNS server do we use for queries?
272 */
273static char *dns_server;
274
275/**
276 * Head of list of zones we are managing. 271 * Head of list of zones we are managing.
277 */ 272 */
278static struct Zone *zone_head; 273static struct Zone *zone_head;
@@ -1454,13 +1449,13 @@ run (void *cls,
1454 "Failed to initialize GNUnet DNS STUB\n"); 1449 "Failed to initialize GNUnet DNS STUB\n");
1455 return; 1450 return;
1456 } 1451 }
1457 if (NULL == args[1]) 1452 if (NULL == args[0])
1458 { 1453 {
1459 fprintf (stderr, 1454 fprintf (stderr,
1460 "You must provide a list of DNS resolvers on the command line\n"); 1455 "You must provide a list of DNS resolvers on the command line\n");
1461 return; 1456 return;
1462 } 1457 }
1463 for (unsigned int i=1;NULL != args[i];i++) 1458 for (unsigned int i=0;NULL != args[i];i++)
1464 { 1459 {
1465 if (GNUNET_OK != 1460 if (GNUNET_OK !=
1466 GNUNET_DNSSTUB_add_dns_ip (ctx, 1461 GNUNET_DNSSTUB_add_dns_ip (ctx,
@@ -1500,12 +1495,6 @@ main (int argc,
1500 char *const*argv) 1495 char *const*argv)
1501{ 1496{
1502 struct GNUNET_GETOPT_CommandLineOption options[] = { 1497 struct GNUNET_GETOPT_CommandLineOption options[] = {
1503 GNUNET_GETOPT_option_mandatory
1504 (GNUNET_GETOPT_option_string ('s',
1505 "server",
1506 "IP",
1507 "which DNS server should be used",
1508 &dns_server)),
1509 GNUNET_GETOPT_OPTION_END 1498 GNUNET_GETOPT_OPTION_END
1510 }; 1499 };
1511 1500