From dc4edd55bbdf420a13bc95cfd25cc8fea0803fba Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 14 Oct 2022 16:51:27 +0000 Subject: [PATCH] fix(query): fix printing irregularities (#140) 1. Before, the port printed was duplicated, eg. `;; SERVER: [::1]:53:53 (UDP)` when making query. This has been fixed (not sure what caused it) 2. JSON/XML/YAML date formatting to be compliant with RFC3339 (thanks, std/time!) Co-authored-by: Sam Therapy Reviewed-on: https://git.froth.zone/sam/awl/pulls/140 Reviewed-by: grumbulon --- pkg/query/print.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/pkg/query/print.go b/pkg/query/print.go index 084ad82..19846b8 100644 --- a/pkg/query/print.go +++ b/pkg/query/print.go @@ -147,23 +147,18 @@ func ToString(res util.Response, opts *util.Options) (string, error) { } func serverExtra(opts *util.Options) string { - // Add extra information to server string - var extra string - switch { case opts.TCP: - extra = ":" + strconv.Itoa(opts.Request.Port) + " (TCP)" + return " (TCP)" case opts.TLS: - extra = ":" + strconv.Itoa(opts.Request.Port) + " (TLS)" + return " (TLS)" case opts.HTTPS, opts.DNSCrypt: - extra = "" + return "" case opts.QUIC: - extra = ":" + strconv.Itoa(opts.Request.Port) + " (QUIC)" + return " (QUIC)" default: - extra = ":" + strconv.Itoa(opts.Request.Port) + " (UDP)" + return " (UDP)" } - - return extra } // stringParse edits the raw responses to user requests. @@ -419,7 +414,7 @@ func MakePrintable(res util.Response, opts *util.Options) (*Message, error) { ret.Statistics = Statistics{ RTT: res.RTT.String(), Server: opts.Request.Server + serverExtra(opts), - When: time.Now().Format(time.RFC1123Z), + When: time.Now().Format(time.RFC3339), MsgSize: res.DNS.Len(), } } else {