From c42f506dee3ed602999837b1ad3654e176796c0d Mon Sep 17 00:00:00 2001 From: wafuwafu13 Date: Wed, 22 Feb 2023 14:39:13 +0900 Subject: [PATCH] query class is always IN --- check-dns/README.md | 2 +- check-dns/lib/check_dns.go | 7 +------ check-dns/lib/check_dns_test.go | 10 ---------- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/check-dns/README.md b/check-dns/README.md index 35a2fec3..b4f87478 100644 --- a/check-dns/README.md +++ b/check-dns/README.md @@ -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 diff --git a/check-dns/lib/check_dns.go b/check-dns/lib/check_dns.go index 4815258a..bbc05569 100644 --- a/check-dns/lib/check_dns.go +++ b/check-dns/lib/check_dns.go @@ -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"` } @@ -56,10 +55,6 @@ 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{ @@ -67,7 +62,7 @@ func (opts *dnsOpts) run() *checkers.Checker { 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() diff --git a/check-dns/lib/check_dns_test.go b/check-dns/lib/check_dns_test.go index 9fcfc9bf..cf50a987 100644 --- a/check-dns/lib/check_dns_test.go +++ b/check-dns/lib/check_dns_test.go @@ -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,