From 7e3f1c3cddf17650d9050f0d23f7e3604f8082d9 Mon Sep 17 00:00:00 2001 From: Karan Sharma Date: Wed, 16 Dec 2020 18:50:25 +0530 Subject: [PATCH] feat: Support SOA --- TODO.md | 3 ++- cmd/output.go | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/TODO.md b/TODO.md index 3e8d117..64f852f 100644 --- a/TODO.md +++ b/TODO.md @@ -15,6 +15,7 @@ - [x] Support multiple resolvers - [x] Take multiple transport options and initialise resolvers accordingly. - [x] Add timeout support +- [x] Support SOA/NXDOMAIN ## CLI Features - [x] `ndots` support @@ -36,7 +37,7 @@ - [x] Add client transport options - [x] Fix an issue while loading free form args, where the same records are being added twice - [x] Remove urfave/cli in favour of `pflag + koanf` - +- [ ] Flags - Remove uneeded ones ## Refactors - [ ] Don't abuse Hub as global. Refactor methods to be independent of hub. diff --git a/cmd/output.go b/cmd/output.go index d794b34..9e31032 100644 --- a/cmd/output.go +++ b/cmd/output.go @@ -107,6 +107,8 @@ func (hub *Hub) outputTerminal(out []Output) { typOut = yellow(o.Type) case "TXT": typOut = yellow(o.Type) + case "SOA": + typOut = red(o.Type) default: typOut = blue(o.Type) } @@ -140,9 +142,18 @@ func collectOutput(responses [][]resolvers.Response) []Output { var addr string if r.Message.Rcode != dns.RcodeSuccess { for _, ns := range r.Message.Ns { - blah, ok := ns.(*dns.SOA) - fmt.Println(blah, ok) - blah.String() + // check for SOA record + soa, ok := ns.(*dns.SOA) + if !ok { + // skip this message + continue + } + addr = soa.Ns + " " + soa.Mbox + + " " + strconv.FormatInt(int64(soa.Serial), 10) + + " " + strconv.FormatInt(int64(soa.Refresh), 10) + + " " + strconv.FormatInt(int64(soa.Retry), 10) + + " " + strconv.FormatInt(int64(soa.Expire), 10) + + " " + strconv.FormatInt(int64(soa.Minttl), 10) h := ns.Header() name := h.Name qclass := dns.Class(h.Class).String()