Skip to content

Commit

Permalink
add reverse flag
Browse files Browse the repository at this point in the history
  • Loading branch information
natesales committed Apr 21, 2021
1 parent 0067796 commit 439bb23
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Application Options:
-q, --qname= Query name
-s, --server= DNS server
-t, --type= RR type
-x, --reverse Reverse lookup
-d, --dnssec Request DNSSEC
-r, --raw Output raw DNS format
-c, --chaos Use CHAOS query class
Expand Down
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var opts struct {
Name string `short:"q" long:"qname" description:"Query name"`
Server string `short:"s" long:"server" description:"DNS server"`
Types []string `short:"t" long:"type" description:"RR type"`
Reverse bool `short:"x" long:"reverse" description:"Reverse lookup"`
DNSSEC bool `short:"d" long:"dnssec" description:"Request DNSSEC"`
Raw bool `short:"r" long:"raw" description:"Output raw DNS format"`
Chaos bool `short:"c" long:"chaos" description:"Use CHAOS query class"`
Expand Down Expand Up @@ -108,6 +109,15 @@ func main() {
}
}

// Reverse address if required
if opts.Reverse {
opts.Name, err = dns.ReverseAddr(opts.Name)
if err != nil {
log.Fatal(err)
}
rrTypes = append(rrTypes, dns.StringToType["PTR"])
}

log.Debugf("qname %s", opts.Name)

// Create the upstream server
Expand Down

0 comments on commit 439bb23

Please sign in to comment.