From acad5296542336d9c5ca96e6ca6dd55369f2f2bb Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Mon, 23 May 2016 12:22:23 +0200 Subject: [PATCH] Default extensions settings via config file --- src/test/getdns_query.c | 44 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/test/getdns_query.c b/src/test/getdns_query.c index 99710662..de96eb64 100644 --- a/src/test/getdns_query.c +++ b/src/test/getdns_query.c @@ -997,7 +997,11 @@ static int _jsmn_get_dict(char *js, jsmntok_t *t, size_t count, return 0; } key = js + t[j].start; - js[t[j].type == JSMN_STRING ? t[j].end : t[j].end - 1] = '\0'; + if (t[j].type== JSMN_PRIMITIVE) { + js[t[j].end - 1] = '\0'; + i++; + } else + js[t[j].end] = '\0'; j += 1; switch (t[j].type) { case JSMN_OBJECT: @@ -1124,6 +1128,20 @@ static getdns_return_t _get_list_or_read_file(const getdns_dict *config, return r; } +#define EXTENSION_SETTING_INT(X) \ + } else if (_streq(setting, #X )) { \ + if ((r = getdns_dict_get_int(config, #X , &n))) \ + fprintf(stderr, "Could not get \"" #X "\""); \ + else if ((r = getdns_dict_set_int(extensions, #X , n))) \ + fprintf(stderr,"Error setting \"" #X "\""); + +#define EXTENSION_SETTING_DICT(X) \ + } else if (_streq(setting, #X )) { \ + if ((r = getdns_dict_get_dict(config, #X , &dict))) \ + fprintf(stderr, "Could not get \"" #X "\""); \ + else if ((r = getdns_dict_set_dict(extensions, #X , dict))) \ + fprintf(stderr,"Error setting \"" #X "\""); + static getdns_return_t configure_with_config_dict(const getdns_dict *config); static getdns_return_t configure_setting_with_config_dict( const getdns_dict *config, const getdns_bindata *setting) @@ -1395,6 +1413,30 @@ static getdns_return_t configure_setting_with_config_dict( fprintf(stderr, "Could not get listen_count"); } + /**************************************/ + /**** ****/ + /**** Default extensions setting ****/ + /**** ****/ + /**************************************/ + EXTENSION_SETTING_DICT(add_opt_parameters) + EXTENSION_SETTING_INT(add_warning_for_bad_dns) + EXTENSION_SETTING_INT(dnssec_return_all_statuses) + EXTENSION_SETTING_INT(dnssec_return_full_validation_chain) + EXTENSION_SETTING_INT(dnssec_return_only_secure) + EXTENSION_SETTING_INT(dnssec_return_status) + EXTENSION_SETTING_INT(dnssec_return_validation_chain) +#if defined(DNSSEC_ROADBLOCK_AVOIDANCE) && defined(HAVE_LIBUNBOUND) + EXTENSION_SETTING_INT(dnssec_roadblock_avoidance) +#endif +#ifdef EDNS_COOKIES + EXTENSION_SETTING_INT(edns_cookies) +#endif + EXTENSION_SETTING_DICT(header) + EXTENSION_SETTING_INT(return_api_information) + EXTENSION_SETTING_INT(return_both_v4_and_v6) + EXTENSION_SETTING_INT(return_call_reporting) + EXTENSION_SETTING_INT(specify_class) + /************************************/ /**** ****/ /**** Ignored context settings ****/