Skip to content

Commit

Permalink
feat: add dns server port flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mmourick committed Jan 9, 2024
1 parent 395869d commit b96372a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/root.go
Expand Up @@ -52,6 +52,7 @@ var (
msg := core.PrepareDNSQuery(domainName, queryType.Type)

response, _, err := core.SendDNSQuery(&client, msg, flagStore.DNSServerIP)
response, _, err := core.SendDNSQuery(&client, msg, flagStore.DNSServerIP, flagStore.DNSServerPort)
if err != nil {
log.Fatal(err)
}
Expand All @@ -66,6 +67,7 @@ func init() {
setupCobraUsageTemplate()
rootCmd.CompletionOptions.DisableDefaultCmd = true
rootCmd.Flags().StringVar(&flagStore.DNSServerIP, "dns-server-ip", "", "IP address of the DNS server")
rootCmd.Flags().StringVar(&flagStore.DNSServerPort, "dns-server-port", "53", "port of the DNS server")
rootCmd.Flags().StringVarP(&flagStore.UserSpecifiedQueryType, "query-type", "q", "", "specific query type to filter on")
rootCmd.Flags().BoolVarP(&flagStore.Debug, "debug", "d", false, "verbose logging")
}
Expand Down
1 change: 1 addition & 0 deletions pkg/core/core.go
Expand Up @@ -50,6 +50,7 @@ func PrepareDNSQuery(domainName string, queryType uint16) dns.Msg {

// SendDNSQuery sends a DNS query to a given DNS server.
func SendDNSQuery(client *dns.Client, msg dns.Msg, dnsServerIP string) (*dns.Msg, time.Duration, error) {
func SendDNSQuery(client *dns.Client, msg dns.Msg, dnsServerIP, dnsServerPort string) (*dns.Msg, time.Duration, error) {
if dnsServerIP == "" {
goOS := runtime.GOOS
if goOS == windows {
Expand Down
1 change: 1 addition & 0 deletions pkg/model/flagstore.go
Expand Up @@ -2,6 +2,7 @@ package model

type Flagstore struct {
DNSServerIP string
DNSServerPort string
UserSpecifiedQueryType string
Debug bool
}

0 comments on commit b96372a

Please sign in to comment.