diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-04-23 15:02:30 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-04-23 15:02:30 +0200 |
commit | 3e2b9dc6d520b6be53a3c41a112f224df12d9f99 (patch) | |
tree | e00acaef75ca58a934f51a9bc848d28f88f0583c /src/namestore/gnunet-zoneimport.c | |
parent | d6e1cea9a8b3a1eee91e52eb46adc82e2005b975 (diff) | |
parent | e1f46c052dca3cd7a390f18f97b10162fe537a15 (diff) | |
download | gnunet-3e2b9dc6d520b6be53a3c41a112f224df12d9f99.tar.gz gnunet-3e2b9dc6d520b6be53a3c41a112f224df12d9f99.zip |
merge conflict resolution
Diffstat (limited to 'src/namestore/gnunet-zoneimport.c')
-rw-r--r-- | src/namestore/gnunet-zoneimport.c | 70 |
1 files changed, 40 insertions, 30 deletions
diff --git a/src/namestore/gnunet-zoneimport.c b/src/namestore/gnunet-zoneimport.c index a01772e67..2926fe9bd 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 |
@@ -165,9 +157,9 @@ struct Request | |||
165 | 157 | ||
166 | /** | 158 | /** |
167 | * Namestore operation pending for this record. | 159 | * Namestore operation pending for this record. |
168 | */ | 160 | */ |
169 | struct GNUNET_NAMESTORE_QueueEntry *qe; | 161 | struct GNUNET_NAMESTORE_QueueEntry *qe; |
170 | 162 | ||
171 | /** | 163 | /** |
172 | * Zone responsible for this request. | 164 | * Zone responsible for this request. |
173 | */ | 165 | */ |
@@ -481,7 +473,7 @@ check_for_glue (void *cls, | |||
481 | } | 473 | } |
482 | if (NULL == | 474 | if (NULL == |
483 | inet_ntop (AF_INET, | 475 | inet_ntop (AF_INET, |
484 | &rec->data.raw.data, | 476 | rec->data.raw.data, |
485 | ip, | 477 | ip, |
486 | ip_size)) | 478 | ip_size)) |
487 | { | 479 | { |
@@ -515,7 +507,7 @@ check_for_glue (void *cls, | |||
515 | } | 507 | } |
516 | if (NULL == | 508 | if (NULL == |
517 | inet_ntop (AF_INET6, | 509 | inet_ntop (AF_INET6, |
518 | &rec->data.raw.data, | 510 | rec->data.raw.data, |
519 | ip, | 511 | ip, |
520 | ip_size)) | 512 | ip_size)) |
521 | { | 513 | { |
@@ -801,6 +793,7 @@ store_completed_cb (void *cls, | |||
801 | { | 793 | { |
802 | static unsigned int pdot; | 794 | static unsigned int pdot; |
803 | struct Request *req = cls; | 795 | struct Request *req = cls; |
796 | struct Record *rec; | ||
804 | 797 | ||
805 | req->qe = NULL; | 798 | req->qe = NULL; |
806 | pending--; | 799 | pending--; |
@@ -820,6 +813,14 @@ store_completed_cb (void *cls, | |||
820 | if (0 == pdot % 1000) | 813 | if (0 == pdot % 1000) |
821 | fprintf (stderr, "."); | 814 | fprintf (stderr, "."); |
822 | } | 815 | } |
816 | /* Free records */ | ||
817 | while (NULL != (rec = req->rec_head)) | ||
818 | { | ||
819 | GNUNET_CONTAINER_DLL_remove (req->rec_head, | ||
820 | req->rec_tail, | ||
821 | rec); | ||
822 | GNUNET_free (rec); | ||
823 | } | ||
823 | } | 824 | } |
824 | 825 | ||
825 | 826 | ||
@@ -827,13 +828,11 @@ store_completed_cb (void *cls, | |||
827 | * Function called with the result of a DNS resolution. | 828 | * Function called with the result of a DNS resolution. |
828 | * | 829 | * |
829 | * @param cls closure with the `struct Request` | 830 | * @param cls closure with the `struct Request` |
830 | * @param rs socket that received the response | ||
831 | * @param dns dns response, never NULL | 831 | * @param dns dns response, never NULL |
832 | * @param dns_len number of bytes in @a dns | 832 | * @param dns_len number of bytes in @a dns |
833 | */ | 833 | */ |
834 | static void | 834 | static void |
835 | process_result (void *cls, | 835 | process_result (void *cls, |
836 | struct GNUNET_DNSSTUB_RequestSocket *rs, | ||
837 | const struct GNUNET_TUN_DnsHeader *dns, | 836 | const struct GNUNET_TUN_DnsHeader *dns, |
838 | size_t dns_len) | 837 | size_t dns_len) |
839 | { | 838 | { |
@@ -842,7 +841,6 @@ process_result (void *cls, | |||
842 | struct GNUNET_DNSPARSER_Packet *p; | 841 | struct GNUNET_DNSPARSER_Packet *p; |
843 | unsigned int rd_count; | 842 | unsigned int rd_count; |
844 | 843 | ||
845 | (void) rs; | ||
846 | GNUNET_assert (NULL == req->hn); | 844 | GNUNET_assert (NULL == req->hn); |
847 | if (NULL == dns) | 845 | if (NULL == dns) |
848 | { | 846 | { |
@@ -889,14 +887,6 @@ process_result (void *cls, | |||
889 | pending--; | 887 | pending--; |
890 | return; | 888 | return; |
891 | } | 889 | } |
892 | /* Free old/legacy records */ | ||
893 | while (NULL != (rec = req->rec_head)) | ||
894 | { | ||
895 | GNUNET_CONTAINER_DLL_remove (req->rec_head, | ||
896 | req->rec_tail, | ||
897 | rec); | ||
898 | GNUNET_free (rec); | ||
899 | } | ||
900 | /* import new records */ | 890 | /* import new records */ |
901 | req->issue_num = 0; /* success, reset counter! */ | 891 | req->issue_num = 0; /* success, reset counter! */ |
902 | req->p = p; | 892 | req->p = p; |
@@ -979,11 +969,11 @@ submit_req (struct Request *req) | |||
979 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 969 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
980 | "Requesting resolution for `%s'\n", | 970 | "Requesting resolution for `%s'\n", |
981 | req->hostname); | 971 | req->hostname); |
982 | req->rs = GNUNET_DNSSTUB_resolve2 (ctx, | 972 | req->rs = GNUNET_DNSSTUB_resolve (ctx, |
983 | req->raw, | 973 | req->raw, |
984 | req->raw_len, | 974 | req->raw_len, |
985 | &process_result, | 975 | &process_result, |
986 | req); | 976 | req); |
987 | GNUNET_assert (NULL != req->rs); | 977 | GNUNET_assert (NULL != req->rs); |
988 | req->issue_num++; | 978 | req->issue_num++; |
989 | last_request = now; | 979 | last_request = now; |
@@ -1176,7 +1166,7 @@ ns_lookup_result_cb (void *cls, | |||
1176 | const struct GNUNET_GNSRECORD_Data *rd) | 1166 | const struct GNUNET_GNSRECORD_Data *rd) |
1177 | { | 1167 | { |
1178 | struct Request *req = cls; | 1168 | struct Request *req = cls; |
1179 | 1169 | ||
1180 | req->qe = NULL; | 1170 | req->qe = NULL; |
1181 | pending--; | 1171 | pending--; |
1182 | GNUNET_break (0 == memcmp (zone, | 1172 | GNUNET_break (0 == memcmp (zone, |
@@ -1457,13 +1447,33 @@ run (void *cls, | |||
1457 | (void) args; | 1447 | (void) args; |
1458 | (void) cfgfile; | 1448 | (void) cfgfile; |
1459 | req_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | 1449 | req_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |
1460 | ctx = GNUNET_DNSSTUB_start (dns_server); | 1450 | ctx = GNUNET_DNSSTUB_start (256); |
1461 | if (NULL == ctx) | 1451 | if (NULL == ctx) |
1462 | { | 1452 | { |
1463 | fprintf (stderr, | 1453 | fprintf (stderr, |
1464 | "Failed to initialize GNUnet DNS STUB\n"); | 1454 | "Failed to initialize GNUnet DNS STUB\n"); |
1465 | return; | 1455 | return; |
1466 | } | 1456 | } |
1457 | if (NULL == args[1]) | ||
1458 | { | ||
1459 | fprintf (stderr, | ||
1460 | "You must provide a list of DNS resolvers on the command line\n"); | ||
1461 | return; | ||
1462 | } | ||
1463 | for (unsigned int i=1;NULL != args[i];i++) | ||
1464 | { | ||
1465 | if (GNUNET_OK != | ||
1466 | GNUNET_DNSSTUB_add_dns_ip (ctx, | ||
1467 | args[1])) | ||
1468 | { | ||
1469 | fprintf (stderr, | ||
1470 | "Failed to use `%s' for DNS resolver\n", | ||
1471 | args[i]); | ||
1472 | return; | ||
1473 | } | ||
1474 | } | ||
1475 | |||
1476 | |||
1467 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | 1477 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
1468 | NULL); | 1478 | NULL); |
1469 | ns = GNUNET_NAMESTORE_connect (cfg); | 1479 | ns = GNUNET_NAMESTORE_connect (cfg); |