Skip to content

Commit c42f506

Browse files
author
wafuwafu13
committed
query class is always IN
1 parent 4d599f6 commit c42f506

File tree

3 files changed

+2
-17
lines changed

3 files changed

+2
-17
lines changed

check-dns/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ Monitor DNS response.
1313
-s, --server= DNS server you want to use for the lookup
1414
-p, --port= Port number you want to use (default: 53)
1515
-q, --querytype= DNS record query type (default: A)
16-
-c, --queryclass= DNS record class type (default: IN)
1716
--norec Set not recursive mode
1817
-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
1918
```
2019

20+
- query class is always IN.
2121
- Punycode is not supported.
2222

2323
### Check DNS server status

check-dns/lib/check_dns.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ type dnsOpts struct {
1717
Server string `short:"s" long:"server" description:"DNS server you want to use for the lookup"`
1818
Port int `short:"p" long:"port" default:"53" description:"Port number you want to use"`
1919
QueryType string `short:"q" long:"querytype" default:"A" description:"DNS record query type"`
20-
QueryClass string `short:"c" long:"queryclass" default:"IN" description:"DNS record class type"`
2120
Norec bool `long:"norec" description:"Set not recursive mode"`
2221
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"`
2322
}
@@ -56,18 +55,14 @@ func (opts *dnsOpts) run() *checkers.Checker {
5655
if !ok {
5756
return checkers.Critical(fmt.Sprintf("%s is invalid query type", opts.QueryType))
5857
}
59-
queryClass, ok := dns.StringToClass[strings.ToUpper(opts.QueryClass)]
60-
if !ok {
61-
return checkers.Critical(fmt.Sprintf("%s is invalid query class", opts.QueryClass))
62-
}
6358

6459
c := new(dns.Client)
6560
m := &dns.Msg{
6661
MsgHdr: dns.MsgHdr{
6762
RecursionDesired: !opts.Norec,
6863
Opcode: dns.OpcodeQuery,
6964
},
70-
Question: []dns.Question{{Name: dns.Fqdn(opts.Host), Qtype: queryType, Qclass: uint16(queryClass)}},
65+
Question: []dns.Question{{Name: dns.Fqdn(opts.Host), Qtype: queryType, Qclass: dns.StringToClass["IN"]}},
7166
}
7267
m.Id = dns.Id()
7368

check-dns/lib/check_dns_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,6 @@ func TestCheckDns(t *testing.T) {
6868
checkers.CRITICAL,
6969
[]string{"AAA is invalid query type"},
7070
},
71-
{
72-
[]string{"-H", "a.root-servers.net", "-s", "8.8.8.8", "-c", "IN"},
73-
checkers.OK,
74-
[]string{"status: NOERROR"},
75-
},
76-
{
77-
[]string{"-H", "a.root-servers.net", "-s", "8.8.8.8", "-c", "INN"},
78-
checkers.CRITICAL,
79-
[]string{"INN is invalid query class"},
80-
},
8171
{
8272
[]string{"-H", "a.root-servers.net", "-s", "8.8.8.8", "-e", "198.41.0.4"},
8373
checkers.OK,

0 commit comments

Comments
 (0)