From f3b2f838797666f04be62d5801c87cc6cd4657bd Mon Sep 17 00:00:00 2001 From: Jim Hague Date: Tue, 23 Jan 2018 12:14:40 +0000 Subject: [PATCH] More output tittivating. Make verbose by default in non-monitoring mode. --- src/tools/getdns_server_mon.c | 57 +++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/src/tools/getdns_server_mon.c b/src/tools/getdns_server_mon.c index 5cb05606..f79a95ce 100644 --- a/src/tools/getdns_server_mon.c +++ b/src/tools/getdns_server_mon.c @@ -568,10 +568,10 @@ static exit_value check_result(struct test_info_s *test_info, if (test_info->monitoring) { snprintcat(test_info->perf_output, MAX_PERF_OUTPUT_LEN, - "result=%d;", + "getdns=%d;", error_id); } else { - printf("DNS result:\t\t%s (%d)\n", + printf("getdns result:\t\t%s (%d)\n", getdns_get_errorstr_by_id(error_id), error_id); } @@ -721,6 +721,55 @@ static exit_value get_report_info(struct test_info_s *test_info, if (cert_expire_time) *cert_expire_time = cert_expire_time_val; + getdns_bindata *tls_version; + + if (getdns_dict_get_bindata(d, "tls_version", &tls_version) == GETDNS_RETURN_GOOD) { + const char *version_text = (char *) tls_version->data; + + if (test_info->verbosity >= VERBOSITY_ADDITIONAL) { + if (test_info->monitoring) { + snprintcat(test_info->perf_output, + MAX_PERF_OUTPUT_LEN, + "tls=%s;", + version_text); + } else { + printf("TLS version:\t\t%s\n", version_text); + } + } + + /* + * This is always in the context, so show only if we got + * TLS info in the call reporting. + */ + uint32_t tls_auth; + getdns_dict *context_dict = getdns_context_get_api_information(test_info->context); + + if (getdns_dict_get_int(context_dict, "/all_context/tls_authentication", &tls_auth) == GETDNS_RETURN_GOOD) { + const char *auth_text = "???"; + + switch(tls_auth) { + case GETDNS_AUTHENTICATION_NONE: + auth_text = "Opportunistic"; + break; + + case GETDNS_AUTHENTICATION_REQUIRED: + auth_text = "Strict"; + break; + } + + if (test_info->verbosity >= VERBOSITY_ADDITIONAL) { + if (test_info->monitoring) { + snprintcat(test_info->perf_output, + MAX_PERF_OUTPUT_LEN, + "%s;", + auth_text); + } else { + printf("TLS authentication:\t%s\n", auth_text); + } + } + } + } + return EXIT_OK; } @@ -1718,6 +1767,10 @@ int main(int ac, char *av[]) if (*av == NULL || *av[0] != '@') usage(); + /* Non-monitoring output is chatty by default. */ + if (!test_info.monitoring) + ++test_info.verbosity; + const char *upstream = *av++; getdns_dict *resolver; getdns_bindata *address;