fix: Incorrect query type in JSON

pull/2/head
Karan Sharma 2020-12-14 11:49:54 +05:30
parent 94b9c6be15
commit 61e92a7ccc
3 changed files with 7 additions and 6 deletions

View File

@ -1,4 +1,4 @@
DOGGO-BIN := doggo.bin DOGGO-BIN := doggo
HASH := $(shell git rev-parse --short HEAD) HASH := $(shell git rev-parse --short HEAD)
BUILD_DATE := $(shell date '+%Y-%m-%d %H:%M:%S') BUILD_DATE := $(shell date '+%Y-%m-%d %H:%M:%S')

View File

@ -8,7 +8,7 @@ import (
// AppHelpTemplate is the text template to customise the Help output. // AppHelpTemplate is the text template to customise the Help output.
// Uses text/template to render templates. // Uses text/template to render templates.
var AppHelpTemplate = `NAME: var AppHelpTemplate = `NAME:
{{.Name}} {{.Description}} 🐶 {{.Name}} - {{.Description}}
USAGE: USAGE:
{{.Name}} [OPTIONS] [--] <arguments> {{.Name}} [OPTIONS] [--] <arguments>

View File

@ -41,9 +41,10 @@ func (hub *Hub) outputJSON(out []Output, msgs []resolvers.Response) {
// get the questions // get the questions
queries := make([]Query, 0, len(msgs)) queries := make([]Query, 0, len(msgs))
for _, ques := range hub.Questions { for _, ques := range hub.Questions {
fmt.Println(ques.Qtype)
q := Query{ q := Query{
Name: ques.Name, Name: ques.Name,
Type: dns.ClassToString[ques.Qtype], Type: dns.TypeToString[ques.Qtype],
Class: dns.ClassToString[ques.Qclass], Class: dns.ClassToString[ques.Qclass],
} }
queries = append(queries, q) queries = append(queries, q)
@ -100,7 +101,7 @@ func (hub *Hub) outputTerminal(out []Output) {
case "AAAA": case "AAAA":
typOut = blue(o.Type) typOut = blue(o.Type)
case "MX": case "MX":
typOut = cyan(o.Type) typOut = red(o.Type)
case "NS": case "NS":
typOut = cyan(o.Type) typOut = cyan(o.Type)
case "CNAME": case "CNAME":
@ -108,7 +109,7 @@ func (hub *Hub) outputTerminal(out []Output) {
case "TXT": case "TXT":
typOut = yellow(o.Type) typOut = yellow(o.Type)
default: default:
typOut = red(o.Type) typOut = blue(o.Type)
} }
output := []string{green(o.Name), typOut, o.Class, o.TTL, o.Address, o.Nameserver} output := []string{green(o.Name), typOut, o.Class, o.TTL, o.Address, o.Nameserver}
// Print how long it took // Print how long it took
@ -163,7 +164,7 @@ func collectOutput(responses []resolvers.Response) []Output {
case *dns.TXT: case *dns.TXT:
addr = t.String() addr = t.String()
case *dns.NS: case *dns.NS:
addr = t.String() addr = t.Ns
case *dns.MX: case *dns.MX:
addr = strconv.Itoa(int(t.Preference)) + " " + t.Mx addr = strconv.Itoa(int(t.Preference)) + " " + t.Mx
case *dns.SOA: case *dns.SOA: