Skip to content

Commit adfd23a

Browse files
committed
feat: add support for common query types
Using `--any` it will query multiple common record types.
1 parent f07b749 commit adfd23a

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

cmd/doggo/cli.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ func setupFlags() *flag.FlagSet {
120120
f.String("tls-hostname", "", "Hostname for certificate verification")
121121
f.Bool("skip-hostname-verification", false, "Skip TLS Hostname Verification")
122122

123+
f.Bool("any", false, "Query all supported DNS record types")
124+
123125
f.BoolP("json", "J", false, "Set the output format as JSON")
124126
f.Bool("short", false, "Short output format")
125127
f.Bool("time", false, "Display how long the response took")

internal/app/questions.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ import (
55
"strings"
66

77
"github.com/miekg/dns"
8+
"github.com/mr-karan/doggo/pkg/models"
89
)
910

1011
// LoadFallbacks sets fallbacks for options
1112
// that are not specified by the user but necessary
1213
// for the resolver.
1314
func (app *App) LoadFallbacks() {
14-
if len(app.QueryFlags.QTypes) == 0 {
15+
if app.QueryFlags.QueryAny {
16+
app.QueryFlags.QTypes = models.GetCommonRecordTypes()
17+
} else if len(app.QueryFlags.QTypes) == 0 {
1518
app.QueryFlags.QTypes = append(app.QueryFlags.QTypes, "A")
1619
}
1720
if len(app.QueryFlags.QClasses) == 0 {

pkg/models/models.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package models
22

3-
import "time"
3+
import (
4+
"strings"
5+
"time"
6+
)
47

58
const (
69
// DefaultTLSPort specifies the default port for a DNS server connecting over TCP over TLS.
@@ -39,6 +42,7 @@ type QueryFlags struct {
3942
Strategy string `koanf:"strategy" strategy:"-"`
4043
InsecureSkipVerify bool `koanf:"skip-hostname-verification" skip-hostname-verification:"-"`
4144
TLSHostname string `koanf:"tls-hostname" tls-hostname:"-"`
45+
QueryAny bool `koanf:"any" json:"any"`
4246
}
4347

4448
// Nameserver represents the type of Nameserver
@@ -47,3 +51,11 @@ type Nameserver struct {
4751
Address string
4852
Type string
4953
}
54+
55+
// CommonRecordTypes is a string containing all common DNS record types
56+
const CommonRecordTypes = "A AAAA CNAME MX NS PTR SOA SRV TXT CAA"
57+
58+
// GetCommonRecordTypes returns a slice of common DNS record types
59+
func GetCommonRecordTypes() []string {
60+
return strings.Fields(CommonRecordTypes)
61+
}

0 commit comments

Comments
 (0)