// DefaultDNSProbe set default value for DNSProbe
DefaultDNSProbe = DNSProbe{
IPProtocolFallback: true,
+ RecursionDesired: true,
}
)
TransportProtocol string `yaml:"transport_protocol,omitempty"`
QueryClass string `yaml:"query_class,omitempty"` // Defaults to IN.
QueryName string `yaml:"query_name,omitempty"`
- QueryType string `yaml:"query_type,omitempty"` // Defaults to ANY.
- ValidRcodes []string `yaml:"valid_rcodes,omitempty"` // Defaults to NOERROR.
+ QueryType string `yaml:"query_type,omitempty"` // Defaults to ANY.
+ RecursionDesired bool `yaml:"recursion_desired,omitempty"` // Defaults to true.
+ ValidRcodes []string `yaml:"valid_rcodes,omitempty"` // Defaults to NOERROR.
ValidateAnswer DNSRRValidator `yaml:"validate_answer_rrs,omitempty"`
ValidateAuthority DNSRRValidator `yaml:"validate_authority_rrs,omitempty"`
ValidateAdditional DNSRRValidator `yaml:"validate_additional_rrs,omitempty"`
func recursiveDNSHandler(w dns.ResponseWriter, r *dns.Msg) {
m := new(dns.Msg)
m.SetReply(r)
- answers := []string{
- "example.com. 3600 IN A 127.0.0.1",
- "example.com. 3600 IN A 127.0.0.2",
- }
- for _, rr := range answers {
- a, err := dns.NewRR(rr)
- if err != nil {
- panic(err)
+ if !r.RecursionDesired {
+ m.Rcode = dns.RcodeRefused
+ } else {
+ answers := []string{
+ "example.com. 3600 IN A 127.0.0.1",
+ "example.com. 3600 IN A 127.0.0.2",
+ }
+ for _, rr := range answers {
+ a, err := dns.NewRR(rr)
+ if err != nil {
+ panic(err)
+ }
+ m.Answer = append(m.Answer, a)
}
- m.Answer = append(m.Answer, a)
}
if err := w.WriteMsg(m); err != nil {
panic(err)
IPProtocol: "ip4",
IPProtocolFallback: true,
QueryName: "example.com",
+ RecursionDesired: true,
}, true,
},
{
IPProtocol: "ip4",
IPProtocolFallback: true,
QueryName: "example.com",
+ RecursionDesired: true,
ValidRcodes: []string{"SERVFAIL", "NXDOMAIN"},
}, false,
},
IPProtocol: "ip4",
IPProtocolFallback: true,
QueryName: "example.com",
+ RecursionDesired: true,
ValidateAnswer: config.DNSRRValidator{
FailIfMatchesRegexp: []string{".*7200.*"},
FailIfNotMatchesRegexp: []string{".*3600.*"},
IPProtocol: "ip4",
IPProtocolFallback: true,
QueryName: "example.com",
+ RecursionDesired: true,
ValidateAuthority: config.DNSRRValidator{
FailIfMatchesRegexp: []string{".*7200.*"},
},
IPProtocol: "ip4",
IPProtocolFallback: true,
QueryName: "example.com",
+ RecursionDesired: true,
ValidateAdditional: config.DNSRRValidator{
FailIfNotMatchesRegexp: []string{".*3600.*"},
},
}, false,
},
+ {
+ config.DNSProbe{
+ IPProtocol: "ip4",
+ IPProtocolFallback: true,
+ QueryName: "example.com",
+ RecursionDesired: false,
+ }, false,
+ },
}
for _, protocol := range PROTOCOLS {
"probe_dns_authority_rrs": 0,
"probe_dns_additional_rrs": 0,
}
+ if !test.Probe.RecursionDesired {
+ expectedResults["probe_dns_answer_rrs"] = 0
+ }
checkRegistryResults(expectedResults, mfs, t)
}
}
QueryName: "example.com",
TransportProtocol: protocol,
IPProtocol: "ip6",
+ RecursionDesired: true,
},
}
registry := prometheus.NewRegistry()
Timeout: time.Second,
DNS: config.DNSProbe{
QueryName: "example.com",
+ RecursionDesired: true,
TransportProtocol: protocol,
IPProtocol: "ip4",
},
Timeout: time.Second,
DNS: config.DNSProbe{
QueryName: "example.com",
+ RecursionDesired: true,
TransportProtocol: protocol,
},
}
module = config.Module{
Timeout: time.Second,
DNS: config.DNSProbe{
- QueryName: "example.com",
+ QueryName: "example.com",
+ RecursionDesired: true,
},
}
registry = prometheus.NewRegistry()
IPProtocol: "ip4",
IPProtocolFallback: true,
QueryName: "example.com",
+ RecursionDesired: true,
},
}
registry := prometheus.NewRegistry()