Skip to content

Commit

Permalink
query class is always IN
Browse files Browse the repository at this point in the history
  • Loading branch information
wafuwafu13 committed Feb 22, 2023
1 parent 4d599f6 commit c42f506
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 17 deletions.
2 changes: 1 addition & 1 deletion check-dns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Monitor DNS response.
-s, --server= DNS server you want to use for the lookup
-p, --port= Port number you want to use (default: 53)
-q, --querytype= DNS record query type (default: A)
-c, --queryclass= DNS record class type (default: IN)
--norec Set not recursive mode
-e, --expected-string= IP-ADDRESS string you expect the DNS server to return. If multiple IP-ADDRESS are returned at once, you have to specify whole string
```

- query class is always IN.
- Punycode is not supported.

### Check DNS server status
Expand Down
7 changes: 1 addition & 6 deletions check-dns/lib/check_dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type dnsOpts struct {
Server string `short:"s" long:"server" description:"DNS server you want to use for the lookup"`
Port int `short:"p" long:"port" default:"53" description:"Port number you want to use"`
QueryType string `short:"q" long:"querytype" default:"A" description:"DNS record query type"`
QueryClass string `short:"c" long:"queryclass" default:"IN" description:"DNS record class type"`
Norec bool `long:"norec" description:"Set not recursive mode"`
ExpectedString []string `short:"e" long:"expected-string" description:"IP-ADDRESS string you expect the DNS server to return. If multiple IP-ADDRESS are returned at once, you have to specify whole string"`
}
Expand Down Expand Up @@ -56,18 +55,14 @@ func (opts *dnsOpts) run() *checkers.Checker {
if !ok {
return checkers.Critical(fmt.Sprintf("%s is invalid query type", opts.QueryType))
}
queryClass, ok := dns.StringToClass[strings.ToUpper(opts.QueryClass)]
if !ok {
return checkers.Critical(fmt.Sprintf("%s is invalid query class", opts.QueryClass))
}

c := new(dns.Client)
m := &dns.Msg{
MsgHdr: dns.MsgHdr{
RecursionDesired: !opts.Norec,
Opcode: dns.OpcodeQuery,
},
Question: []dns.Question{{Name: dns.Fqdn(opts.Host), Qtype: queryType, Qclass: uint16(queryClass)}},
Question: []dns.Question{{Name: dns.Fqdn(opts.Host), Qtype: queryType, Qclass: dns.StringToClass["IN"]}},
}
m.Id = dns.Id()

Expand Down
10 changes: 0 additions & 10 deletions check-dns/lib/check_dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,6 @@ func TestCheckDns(t *testing.T) {
checkers.CRITICAL,
[]string{"AAA is invalid query type"},
},
{
[]string{"-H", "a.root-servers.net", "-s", "8.8.8.8", "-c", "IN"},
checkers.OK,
[]string{"status: NOERROR"},
},
{
[]string{"-H", "a.root-servers.net", "-s", "8.8.8.8", "-c", "INN"},
checkers.CRITICAL,
[]string{"INN is invalid query class"},
},
{
[]string{"-H", "a.root-servers.net", "-s", "8.8.8.8", "-e", "198.41.0.4"},
checkers.OK,
Expand Down

0 comments on commit c42f506

Please sign in to comment.