diff --git a/.travis.yml b/.travis.yml index 6e06c4e..dcf1a28 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ script: - "gofmt -l $(find . -name '*.go' | tr '\\n' ' ') >/dev/null" # Check whether files were not gofmt'ed. - "gosrc=$(find . -name '*.go' | tr '\\n' ' '); [ $(gofmt -l $gosrc 2>&- | wc -l) -eq 0 ] || (echo 'gofmt was not run on these files:'; gofmt -l $gosrc 2>&-; false)" - - go tool vet . + - go vet . - go test -c - docker build --pull --no-cache --rm -t=dns -f travis/Dockerfile . - docker run -v $PWD:/usr/src:ro dns /bin/sh -c './dnsmasq_exporter.test -test.v' diff --git a/dnsmasq.go b/dnsmasq.go index 2f74278..ccb52ef 100644 --- a/dnsmasq.go +++ b/dnsmasq.go @@ -111,6 +111,14 @@ type server struct { leasesPath string } +func question(name string) dns.Question { + return dns.Question{ + Name: name, + Qtype: dns.TypeTXT, + Qclass: dns.ClassCHAOS, + } +} + func (s *server) metrics(w http.ResponseWriter, r *http.Request) { var eg errgroup.Group @@ -121,13 +129,13 @@ func (s *server) metrics(w http.ResponseWriter, r *http.Request) { RecursionDesired: true, }, Question: []dns.Question{ - dns.Question{"cachesize.bind.", dns.TypeTXT, dns.ClassCHAOS}, - dns.Question{"insertions.bind.", dns.TypeTXT, dns.ClassCHAOS}, - dns.Question{"evictions.bind.", dns.TypeTXT, dns.ClassCHAOS}, - dns.Question{"misses.bind.", dns.TypeTXT, dns.ClassCHAOS}, - dns.Question{"hits.bind.", dns.TypeTXT, dns.ClassCHAOS}, - dns.Question{"auth.bind.", dns.TypeTXT, dns.ClassCHAOS}, - dns.Question{"servers.bind.", dns.TypeTXT, dns.ClassCHAOS}, + question("cachesize.bind."), + question("insertions.bind."), + question("evictions.bind."), + question("misses.bind."), + question("hits.bind."), + question("auth.bind."), + question("servers.bind."), }, } in, _, err := s.dnsClient.Exchange(msg, s.dnsmasqAddr)