gnunet

Main GNUnet Logic
Log | Files | Refs | Submodules | README | LICENSE

commit 36e3661bf28bef5ed2a39a9c53e58c2aee98c285
parent da0e276e204314facb376fad2b422aa2a732fd8d
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date:   Sun, 24 Aug 2025 11:46:04 +0200

build: add codespell to precommit hook if available

Diffstat:
Mcontrib/conf/uncrustify_precommit | 15+++++++++++++++
Ascripts/check_codespell.sh | 99+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ascripts/dictionary.txt | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mscripts/meson.build | 1+
Msrc/include/gnunet_pils_service.h | 2+-
Msrc/lib/hello/hello-uri.c | 16++++++++--------
Msrc/lib/util/test_time.c | 6+++---
Msrc/service/core/gnunet-service-core_kx.c | 2+-
Msrc/service/core/meson.build | 2+-
Msrc/service/core/test_core_basic.sh | 2+-
Msrc/service/core/test_core_plugin_underlay_dummy.c | 4++--
Msrc/service/core/test_core_underlay_dummy.c | 2+-
Msrc/service/core/testing_core_cmd_recv.c | 2+-
Msrc/service/core/testing_core_cmd_send.c | 2+-
Msrc/service/gns/gnunet-dns2gns.c | 475+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/service/hostlist/gnunet-daemon-hostlist_server.c | 6+++---
Msrc/service/messenger/messenger_api.c | 2+-
Msrc/service/pils/pils_api.c | 6+++---
18 files changed, 671 insertions(+), 27 deletions(-)

diff --git a/contrib/conf/uncrustify_precommit b/contrib/conf/uncrustify_precommit @@ -33,6 +33,21 @@ then echo " Uncrustify your code in your next commit. " echo " See https://docs.gnunet.org/latest/developers/style.html#coding-style " echo "================================================================" + exit 1 fi + +# Make sure we have no stupid spelling error +if (which codespell > /dev/null) +then + export REPORT=$(mktemp /tmp/codespellXXXXXX) + ( set -o pipefail; + echo "Checking for spelling errors with codespell..." + scripts/check_codespell.sh src 2> ${REPORT}; + ) || { echo "Please fix the code spell errors in ${REPORT} first"; exit 2; } +else + echo "No codespell installed, skipping spell check." + echo "** Please consider installing codespell! **" +fi + # Do not fail exit 0 diff --git a/scripts/check_codespell.sh b/scripts/check_codespell.sh @@ -0,0 +1,99 @@ +#!/bin/bash +set -exuo pipefail + +job_dir=$(dirname "${BASH_SOURCE[0]}") + +skip=$(cat <<EOF +ABOUT-NLS +*/debian/tmp/** +*.bbl +*.bib +*build-aux* +*.bst +*.cache/* +*/cbdc-es.tex +*/cbdc-it.tex +ChangeLog +*.cls +configure* +config.status +config.guess +config.sub +depcomp +*/contrib/* +*/contrib/hellos/** +*.dat +*.deflate +*.doc +*/doc/* +**/doc/flows/main.de.tex +*/doc/texinfo.tex +*.docx +*.ecc +*.eot +*.epgz +*.eps +*.epub +**/ExchangeSelection/example.ts +*.fee +*.fees +*.file +**/fonts/** +*.gif +*/.git/** +*.gz +*/i18n/strings.ts +*.info +*.jpeg +*.jpg +*.??.json +*.json +*.json-* +*/keys/* +*key +*.latexmkrc +*libtool* +ltmain.sh +*.log +*/m4/* +*.m4 +**/*.map +*.min.js +*.mp4 +*.odg +*.ods +*.odt +*.pack.js +*.pdf +*.png +*.PNG +*.po +*.pptx +*.priv +**/rfc.bib +*.rpath +*.sqlite +**/*.svg +*.svg +*.tag +**/signing-key.asc +**/templating/mustach** +*/templating/test?/** +*/testcurl/test_tricky.c +*.tgz +*.ttf +*.ttf +**/valgrind.h +*/vpn/tests/** +*.wav +*.woff +*.woff2 +*.xcf +*.xlsx +*.zkey +EOF +); + +echo Current directory: `pwd` + +codespell -I "${job_dir}"/dictionary.txt -S ${skip//$'\n'/,} diff --git a/scripts/dictionary.txt b/scripts/dictionary.txt @@ -0,0 +1,54 @@ +# List of "words" that codespell should ignore in our sources. +# +# Note: The word sensitivity depends on how the to-be-ignored word is +# spelled in codespell_lib/data/dictionary.txt. F.e. if there is a word +# 'foo' and you add 'Foo' _here_, codespell will continue to complain +# about 'Foo'. +# +BRE +ND +Nd +TE +TEH +UPDATEing +WAN +abd +aci +acn +ba +bre +cant +clen +ciph +complet +doas +ect +ehr +fo +hel +ifset +ist +keypair +nd +oce +onl +openin +ot +ser +sie +som +sme +sover +te +te +teh +tha +ths +updateing +wan +wih +decose +ges +AKE +PRIS +servent diff --git a/scripts/meson.build b/scripts/meson.build @@ -21,6 +21,7 @@ binfiles = [ 'pogen.sh', 'rename.sh', 'gana_update.sh', + 'check_codespell.sh', 'dictionary.txt' ] foreach f : binfiles diff --git a/src/include/gnunet_pils_service.h b/src/include/gnunet_pils_service.h @@ -223,7 +223,7 @@ GNUNET_PILS_derive_pid (size_t seed_key_bytes, /** * Create HELLO signature. * - * @param handle hande to the pils service + * @param handle handle to the pils service * @param builder the builder to use * @param et expiration time to sign * @param cb callback to call with the signature diff --git a/src/lib/hello/hello-uri.c b/src/lib/hello/hello-uri.c @@ -822,7 +822,7 @@ GNUNET_HELLO_parser_to_url (const struct GNUNET_HELLO_Parser *parser) NULL != a; a = a->next) { - char *ue; + char *eou_url_encoded; char *tmp; int pfx_len; const char *eou; @@ -839,15 +839,15 @@ GNUNET_HELLO_parser_to_url (const struct GNUNET_HELLO_Parser *parser) eou += 3; GNUNET_STRINGS_urlencode (a->uri_len - 4 - pfx_len, eou, - &ue); + &eou_url_encoded); GNUNET_asprintf (&tmp, "%s%s%.*s=%s", result, sep, pfx_len, a->uri, - ue); - GNUNET_free (ue); + eou_url_encoded); + GNUNET_free (eou_url_encoded); GNUNET_free (result); result = tmp; sep = "&"; @@ -1096,7 +1096,7 @@ GNUNET_HELLO_build_url (const struct GNUNET_HELLO_Builder *builder, NULL != a; a = a->next) { - char *ue; + char *eou_url_encoded; char *tmp; int pfx_len; const char *eou; @@ -1113,15 +1113,15 @@ GNUNET_HELLO_build_url (const struct GNUNET_HELLO_Builder *builder, eou += 3; GNUNET_STRINGS_urlencode (a->uri_len - 4 - pfx_len, eou, - &ue); + &eou_url_encoded); GNUNET_asprintf (&tmp, "%s%s%.*s=%s", *result, sep, pfx_len, a->uri, - ue); - GNUNET_free (ue); + eou_url_encoded); + GNUNET_free (eou_url_encoded); GNUNET_free (*result); *result = tmp; sep = "&"; diff --git a/src/lib/util/test_time.c b/src/lib/util/test_time.c @@ -30,7 +30,7 @@ int main (int argc, char *argv[]) { struct GNUNET_TIME_Absolute now; - struct GNUNET_TIME_AbsoluteNBO nown; + struct GNUNET_TIME_AbsoluteNBO now_nbo; struct GNUNET_TIME_Absolute future; struct GNUNET_TIME_Absolute past; struct GNUNET_TIME_Absolute last; @@ -138,9 +138,9 @@ main (int argc, char *argv[]) reln = GNUNET_TIME_relative_hton (rel); GNUNET_assert (rel.rel_value_us == GNUNET_TIME_relative_ntoh ( reln).rel_value_us); - nown = GNUNET_TIME_absolute_hton (now); + now_nbo = GNUNET_TIME_absolute_hton (now); GNUNET_assert (now.abs_value_us == GNUNET_TIME_absolute_ntoh ( - nown).abs_value_us); + now_nbo).abs_value_us); /* check absolute addition */ future = GNUNET_TIME_absolute_add (now, GNUNET_TIME_UNIT_SECONDS); diff --git a/src/service/core/gnunet-service-core_kx.c b/src/service/core/gnunet-service-core_kx.c @@ -2717,7 +2717,7 @@ check_rekey (struct GSC_KeyExchangeInfo *kx) kx->current_epoch_expiration.abs_value_us, kx->current_sqn); // Can this trigger? Maybe if we receive a lot of - // heatbeats? + // heartbeats? GNUNET_assert (UINT64_MAX > kx->current_epoch); kx->current_epoch++; kx->current_epoch_expiration = diff --git a/src/service/core/meson.build b/src/service/core/meson.build @@ -236,7 +236,7 @@ test( # FIXME test_core_basic # this currently works on my (ch3) machine, but is not expected to work on -# others. It is expecting the netjail testing scripts in a locatin +# others. It is expecting the netjail testing scripts in a location # specific to my machine, because currently they're not available in the # build dir testcore_basic = find_program( diff --git a/src/service/core/test_core_basic.sh b/src/service/core/test_core_basic.sh @@ -1,7 +1,7 @@ #!/bin/bash # FIXME # this currently works on my (ch3) machine, but is not expected to work on -# others. It is expecting the netjail testing scripts in a locatin +# others. It is expecting the netjail testing scripts in a location # specific to my machine, because currently they're not available in the # build dir #exec ../../../scripts/netjail/netjail_test_master.sh gnunet-testing-netjail-launcher test_core_basic_topo.conf diff --git a/src/service/core/test_core_plugin_underlay_dummy.c b/src/service/core/test_core_plugin_underlay_dummy.c @@ -196,7 +196,7 @@ static void { struct UnderlayDummyState *uds = cls; struct Channel *channel; - (void) peer_id; /* unused - the underlay dummy doesn't know abot peer ids */ + (void) peer_id; /* unused - the underlay dummy doesn't know about peer ids */ LOG (GNUNET_ERROR_TYPE_DEBUG, "A new connection was established\n"); @@ -503,7 +503,7 @@ exec_send_run (void *cls, udss->num_messages); /* For now send on all available channels as we don't know at this stage * which is an usable channel - this should be fine as the unusable channel - * will (probably) be discovered and cleand up in the process. */ + * will (probably) be discovered and cleaned up in the process. */ for (struct Channel *c_iter = uds->channels_head; NULL != c_iter; c_iter = c_iter->next) diff --git a/src/service/core/test_core_underlay_dummy.c b/src/service/core/test_core_underlay_dummy.c @@ -217,7 +217,7 @@ static void *notify_connect_cb ( struct GNUNET_MQ_Envelope *env; struct GNUNET_UNDERLAY_DUMMY_Message *msg; struct Connection *connection; - (void) peer_id; /* unused - the underlay dummy doesn't know abot peer ids */ + (void) peer_id; /* unused - the underlay dummy doesn't know about peer ids */ if (0 == num_addresses) { diff --git a/src/service/core/testing_core_cmd_recv.c b/src/service/core/testing_core_cmd_recv.c @@ -201,7 +201,7 @@ handle_msg_test (void *cls, * This might be done nicer - via a barrier? Check the other node's receive * state? * The number of 3 Milliseconds was chosen by looking at logs and then - * continuously runnint the test and seeing how many actually work reliably + * continuously running the test and seeing how many actually work reliably * (Increased it quite a bit in the end for valgrind - no repeated tests * this time.) */ diff --git a/src/service/core/testing_core_cmd_send.c b/src/service/core/testing_core_cmd_send.c @@ -96,7 +96,7 @@ send_messages (struct SendState *send_state) GNUNET_assert (NULL != connect_state->channels_head); /* For now send on all available channels as we don't know at this stage * which is an usable channel - this should be fine as the unusable channel - * will (probably) be discovered and cleand up in the process. */ + * will (probably) be discovered and cleaned up in the process. */ for (channel_iter = connect_state->channels_head; NULL != channel_iter; channel_iter = channel_iter->next) diff --git a/src/service/gns/gnunet-dns2gns.c b/src/service/gns/gnunet-dns2gns.c @@ -456,6 +456,459 @@ vpn_allocation_cb (void *cls, } +struct Dns2GnsMirrorEntry +{ + + struct Dns2GnsMirrorEntry *prev; + + struct Dns2GnsMirrorEntry *next; + + /** + * The time according to the + * mirrored zone's SOA when we should + * expire the cached records in GNS. + * We will set this value to the absolute + * expiration of the GNS2DNS record(s) instead of + * a shorter-lived TTL. + */ + struct GNUNET_TIME_Absolute soa_expiration; + + char *suffix; + + bool enabled; +}; + +#define MAX_GNS2DNS_RECORDS 20 + +struct Dns2GnsSyncJob +{ + + /** + * The time according to the + * mirrored zone's SOA when we should + * expire the cached records in GNS. + * We will set this value to the absolute + * expiration of the GNS2DNS record(s) instead of + * a shorter-lived TTL. + */ + struct GNUNET_TIME_Absolute zone_expiration; + + /** + * This will become the name field in the GNS2DNS record(s) + */ + char dns2gns_name[GNUNET_DNSPARSER_MAX_NAME_LENGTH]; + + /** + * The suffix zone name (e.g. the DNS TLD) + */ + char mirrored_suffix[GNUNET_DNSPARSER_MAX_NAME_LENGTH]; + + /** + * The suffix for the zone cut of this particular name. + */ + char name_suffix[GNUNET_DNSPARSER_MAX_NAME_LENGTH]; + + /** + * The remaining labels of the name w/o suffix + */ + char name_prefix[GNUNET_DNSPARSER_MAX_NAME_LENGTH]; + + /** + * The associated mirror entry + */ + const struct Dns2GnsMirrorEntry *mirror_entry; + + /** + * Socket used to make the request, NULL if not active. + */ + struct GNUNET_DNSSTUB_RequestSocket *dns_req; + + /** + * random 16-bit DNS query identifier. + */ + uint16_t dns_req_id; + + /** + * GNS2DNS records we synthesize + */ + struct GNUNET_GNSRECORD_Data rd[MAX_GNS2DNS_RECORDS]; + + /** + * Rd count + */ + unsigned int rd_count; + +}; +static struct Dns2GnsMirrorEntry *mirrors_head; + +static struct Dns2GnsMirrorEntry *mirrors_tail; + +static void +iter_sections_mirroring (void *cls, + const char *section, + const char *option, + const char *value) +{ + if (0 != strncmp (section, + "dns2gns-mirror-", + strlen ("dns2gns-mirror-"))) + return; + + { + struct Dns2GnsMirrorEntry *entry; + + entry = GNUNET_new (struct Dns2GnsMirrorEntry); + entry->enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, + section, + "ENABLED"); + GNUNET_CONFIGURATION_get_value_string (cfg, + section, + "SUFFIX", + &entry->suffix); + GNUNET_CONTAINER_DLL_insert (mirrors_head, + mirrors_tail, + entry); + } +} + + +static struct Dns2GnsMirrorEntry* +find_mirror_entry (const char *hostname) +{ + for (struct Dns2GnsMirrorEntry *e = mirrors_head; + NULL != e; + e = e->next) + { + const char *suffix_tmp; + if (GNUNET_YES != e->enabled) + continue; + if (strlen (e->suffix) > strlen (hostname)) + continue; + suffix_tmp = hostname + (strlen (hostname) - strlen (e->suffix)); + if (0 == strcmp (suffix_tmp, e->suffix)) + return e; + } + return NULL; +} + + +static const char* +get_next_label (char *name) +{ + char *next_lbl; + printf ("%s\n", name); + next_lbl = strrchr (name, '.'); + if (NULL != next_lbl) + { + *next_lbl = 0; + return next_lbl + 1; + } + printf ("%s\n", name); + return NULL; +} + + +/** + * Function called with the result of a DNS resolution. + * + * @param cls closure with the `struct Request` + * @param dns dns response, never NULL + * @param dns_len number of bytes in @a dns + */ +static void +process_result_ip (void *cls, + const struct GNUNET_TUN_DnsHeader *dns, + size_t dns_len) +{ + struct Dns2GnsSyncJob *req = cls; + struct GNUNET_DNSPARSER_Packet *p; + int num_answers; + + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Stub DNS reply for `%s'\n", + req->name_suffix); + if (NULL == dns) + { + /* stub gave up */ + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Stub gave up on DNS reply for `%s'\n", + req->name_suffix); + GNUNET_free (req); + return; + } + GNUNET_assert (req->dns_req_id == dns->id); + GNUNET_DNSSTUB_resolve_cancel (req->dns_req); + req->dns_req = NULL; + p = GNUNET_DNSPARSER_parse ((const char *) dns, + dns_len); + if (NULL == p) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to parse DNS reply for `%s'\n", + req->name_suffix); + GNUNET_free (req); + return; + } + for (unsigned int i = 0; i < p->num_answers; i++) + { + struct GNUNET_DNSPARSER_Record *rs = &p->answers[i]; + + // We leave room for IPv4 and 6 addresses + if (i > MAX_GNS2DNS_RECORDS) + break; + if (rs->type != GNUNET_DNSPARSER_TYPE_A) + continue; + req->rd[i].record_type = GNUNET_GNSRECORD_TYPE_GNS2DNS; + req->rd[i].data = GNUNET_strdup (rs->data.hostname); + req->rd[i].expiration_time = req->mirror_entry->soa_expiration.abs_value_us; + req->rd[i].data_size = 0; + req->rd_count++; + } + num_answers = p->num_answers; + GNUNET_DNSPARSER_free_packet (p); + if (num_answers == 0) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "No NS records found.\n"); + char *next_hostname; + const char *next_lbl = get_next_label (req->name_prefix); + if (NULL == next_lbl) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "End of name reached.\n"); + GNUNET_free (req); + return; // FIXME response? + } + GNUNET_asprintf (&next_hostname, "%s.%s", next_lbl, req->name_suffix); + resolve_sync_ns (req); + } + GNUNET_free (req); + resolve_sync_ip (req); + +} + + +static void +resolve_sync_ip (struct Dns2GnsSyncJob *sj) +{ + struct GNUNET_GNSRECORD_Data *rd; + struct GNUNET_DNSPARSER_Packet p; + struct GNUNET_DNSPARSER_Query q; + char *raw; + size_t raw_size; + int ret; + + sj = NULL; + for (int i = 0; i < sj->rd_count; i++) + { + if (sj->rd[i].data_size > 0) + continue; + rd = &sj->rd[i]; + } + if (NULL == sj) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "We are done. Storing records...\n"); + return; + } + q.name = (char *) rd->data; + q.type = GNUNET_DNSPARSER_TYPE_A; + q.dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET; + + memset (&p, + 0, + sizeof(p)); + p.num_queries = 1; + p.queries = &q; + p.id = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, + UINT16_MAX); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Resolving hostname `%s'\n", + (char*) rd->data); + ret = GNUNET_DNSPARSER_pack (&p, + UINT16_MAX, + &raw, + &raw_size); + if (GNUNET_OK != ret) + { + if (GNUNET_NO == ret) + GNUNET_free (raw); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to pack query for hostname `%s'\n", + (char*) rd->data); + return; + } + + // req->raw = raw; + // req->raw_len = raw_size; + sj->dns_req_id = p.id; + sj->dns_req = GNUNET_DNSSTUB_resolve (dns_stub, + raw, + raw_size, + &process_result_ip, + sj); +} + + +static void +resolve_sync_ns (struct Dns2GnsSyncJob *sj); + +/** + * Function called with the result of a DNS resolution. + * + * @param cls closure with the `struct Request` + * @param dns dns response, never NULL + * @param dns_len number of bytes in @a dns + */ +static void +process_result (void *cls, + const struct GNUNET_TUN_DnsHeader *dns, + size_t dns_len) +{ + struct Dns2GnsSyncJob *req = cls; + struct GNUNET_DNSPARSER_Packet *p; + int num_answers; + + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Stub DNS reply for `%s'\n", + req->name_suffix); + if (NULL == dns) + { + /* stub gave up */ + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Stub gave up on DNS reply for `%s'\n", + req->name_suffix); + GNUNET_free (req); + return; + } + GNUNET_assert (req->dns_req_id == dns->id); + GNUNET_DNSSTUB_resolve_cancel (req->dns_req); + req->dns_req = NULL; + p = GNUNET_DNSPARSER_parse ((const char *) dns, + dns_len); + if (NULL == p) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to parse DNS reply for `%s'\n", + req->name_suffix); + GNUNET_free (req); + return; + } + for (unsigned int i = 0; i < p->num_answers; i++) + { + struct GNUNET_DNSPARSER_Record *rs = &p->answers[i]; + + // We leave room for IPv4 and 6 addresses + if (i > MAX_GNS2DNS_RECORDS) + break; + if (rs->type != GNUNET_DNSPARSER_TYPE_NS) + continue; + req->rd[i].record_type = GNUNET_GNSRECORD_TYPE_GNS2DNS; + req->rd[i].data = GNUNET_strdup (rs->data.hostname); + req->rd[i].expiration_time = req->mirror_entry->soa_expiration.abs_value_us; + req->rd[i].data_size = 0; + req->rd_count++; + } + num_answers = p->num_answers; + GNUNET_DNSPARSER_free_packet (p); + if (num_answers == 0) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "No NS records found.\n"); + char *next_hostname; + const char *next_lbl = get_next_label (req->name_prefix); + if (NULL == next_lbl) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "End of name reached.\n"); + GNUNET_free (req); + return; // FIXME response? + } + GNUNET_asprintf (&next_hostname, "%s.%s", next_lbl, req->name_suffix); + resolve_sync_ns (req); + } + GNUNET_free (req); + resolve_sync_ip (req); + +} + + +static void +resolve_sync_ns (struct Dns2GnsSyncJob *sj) +{ + struct GNUNET_DNSPARSER_Packet p; + struct GNUNET_DNSPARSER_Query q; + char *raw; + size_t raw_size; + int ret; + + if (GNUNET_OK != + GNUNET_DNSPARSER_check_name (sj->name_suffix)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Refusing invalid hostname `%s'\n", + sj->name_suffix); + return; + } + q.name = (char *) sj->name_suffix; + q.type = GNUNET_DNSPARSER_TYPE_NS; + q.dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET; + + memset (&p, + 0, + sizeof(p)); + p.num_queries = 1; + p.queries = &q; + p.id = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, + UINT16_MAX); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Resolving hostname `%s'\n", + sj->name_suffix); + ret = GNUNET_DNSPARSER_pack (&p, + UINT16_MAX, + &raw, + &raw_size); + if (GNUNET_OK != ret) + { + if (GNUNET_NO == ret) + GNUNET_free (raw); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to pack query for hostname `%s'\n", + sj->name_suffix); + return; + } + + // req->raw = raw; + // req->raw_len = raw_size; + sj->dns_req_id = p.id; + sj->dns_req = GNUNET_DNSSTUB_resolve (dns_stub, + raw, + raw_size, + &process_result, + sj); +} + + +static void +find_zone_cut (struct Dns2GnsSyncJob *sj, + const char *hostname) +{ + const char *first_lbl; + size_t prefix_len; + prefix_len = strlen (hostname) - strlen (sj->mirror_entry->suffix); + memcpy (sj->name_prefix, + hostname, + prefix_len); + first_lbl = get_next_label (sj->name_prefix); + GNUNET_assert (NULL != first_lbl); + sprintf (sj->name_suffix, + "%s%s", + first_lbl, + sj->mirror_entry->suffix); + resolve_sync_ns (sj); +} + + /** * Iterator called on obtained result for a GNS lookup. * @@ -497,6 +950,27 @@ result_processor (void *cls, request); return; } + // was_gns == GNUNET_YES + + // If record set is empty AND + // was_gns == GNUNET_YES AND + // we want to mirror this zone + // we should try to get it from DNS + if (0 == rd_count) + { + struct Dns2GnsSyncJob *sj; + + sj = GNUNET_new (struct Dns2GnsSyncJob); + sj->mirror_entry = find_mirror_entry (request->packet->queries[0].name); + if (NULL != sj->mirror_entry) + { + find_zone_cut (sj, request->packet->queries[0].name); + } + else + { + GNUNET_free (sj); + } + } packet = request->packet; packet->flags.query_or_response = 1; packet->flags.return_code = GNUNET_TUN_DNS_RETURN_CODE_NO_ERROR; @@ -977,6 +1451,7 @@ run (void *cls, listen_socket6, &read_dns6, listen_socket6); + GNUNET_CONFIGURATION_iterate (cfg, &iter_sections_mirroring, NULL); } diff --git a/src/service/hostlist/gnunet-daemon-hostlist_server.c b/src/service/hostlist/gnunet-daemon-hostlist_server.c @@ -168,7 +168,7 @@ add_cors_headers (struct MHD_Response *resp) static struct MHD_Response* -build_json_response (const struct HostSet *bu) +build_json_response (const struct HostSet *host_set) { struct GNUNET_MessageHeader *hello; struct GNUNET_HELLO_Parser *hparser; @@ -180,9 +180,9 @@ build_json_response (const struct HostSet *bu) hello_uri_j = json_object (); hello_array = json_array (); - while (offset < bu->size) + while (offset < host_set->size) { - hello = (struct GNUNET_MessageHeader*) (bu->data + offset); + hello = (struct GNUNET_MessageHeader*) (host_set->data + offset); hparser = GNUNET_HELLO_parser_from_msg (hello); if (NULL == hparser) { diff --git a/src/service/messenger/messenger_api.c b/src/service/messenger/messenger_api.c @@ -86,7 +86,7 @@ GNUNET_MESSENGER_name_of_kind (enum GNUNET_MESSENGER_MessageKind kind) case GNUNET_MESSENGER_KIND_TAG: return "TAG"; case GNUNET_MESSENGER_KIND_SUBSCRIBTION: - return "SUBSCRIBTION"; + return "SUBSCRIPTION"; case GNUNET_MESSENGER_KIND_TALK: return "TALK"; case GNUNET_MESSENGER_KIND_ANNOUNCEMENT: diff --git a/src/service/pils/pils_api.c b/src/service/pils/pils_api.c @@ -89,7 +89,7 @@ struct GNUNET_PILS_Handle /* Closure to the #pid_change_cb callback */ void *pid_change_cb_cls; - /* Task regularily trying to connect to the service */ + /* Task regularly trying to connect to the service */ struct GNUNET_SCHEDULER_Task *reconnect_task; /* Delay until the next reconnect */ @@ -526,7 +526,7 @@ GNUNET_PILS_derive_pid (size_t seed_key_bytes, * We now expand the PRK to the key size we actually require. * FIXME: IF we want to use elligator, we need to find a * private key that can actually be used as such. - * For that, we may want to add a coutner to the initial secret key + * For that, we may want to add a counter to the initial secret key * to the above PRF. */ GNUNET_CRYPTO_hkdf_expand (outkey, @@ -566,7 +566,7 @@ GNUNET_PILS_feed_addresses (struct GNUNET_PILS_Handle *handle, /** * Create HELLO signature. * - * @param handle hande to the pils service + * @param handle handle to the pils service * @param builder the builder to use * @param et expiration time to sign * @param cb callback to call with the signature