Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
- Drop "desired"
- Drop go 1.17 compat, will be switched entirely to go 1.17 elsewhere
  • Loading branch information
dgl committed Jan 24, 2022
1 parent e129a67 commit 7ffc724
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
3 changes: 2 additions & 1 deletion CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ query_name: <string>
[ query_type: <string> | default = "ANY" ]
[ query_class: <string> | default = "IN" ]

[ recursion_desired: <boolean> | default = true ]
# Set the recursion desired (RD) flag in the request.
[ recursion: <boolean> | default = true ]

# List of valid response codes.
valid_rcodes:
Expand Down
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var (
// DefaultDNSProbe set default value for DNSProbe
DefaultDNSProbe = DNSProbe{
IPProtocolFallback: true,
RecursionDesired: true,
Recursion: true,
}
)

Expand Down Expand Up @@ -266,7 +266,7 @@ type DNSProbe struct {
QueryClass string `yaml:"query_class,omitempty"` // Defaults to IN.
QueryName string `yaml:"query_name,omitempty"`
QueryType string `yaml:"query_type,omitempty"` // Defaults to ANY.
RecursionDesired bool `yaml:"recursion_desired,omitempty"` // Defaults to true.
Recursion 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"`
Expand Down
2 changes: 1 addition & 1 deletion prober/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func ProbeDNS(ctx context.Context, target string, module config.Module, registry

msg := new(dns.Msg)
msg.Id = dns.Id()
msg.RecursionDesired = module.DNS.RecursionDesired
msg.RecursionDesired = module.DNS.Recursion
msg.Question = make([]dns.Question, 1)
msg.Question[0] = dns.Question{dns.Fqdn(module.DNS.QueryName), qt, qc}

Expand Down
26 changes: 13 additions & 13 deletions prober/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ func TestRecursiveDNSResponse(t *testing.T) {
IPProtocol: "ip4",
IPProtocolFallback: true,
QueryName: "example.com",
RecursionDesired: true,
Recursion: true,
}, true,
},
{
config.DNSProbe{
IPProtocol: "ip4",
IPProtocolFallback: true,
QueryName: "example.com",
RecursionDesired: true,
Recursion: true,
ValidRcodes: []string{"SERVFAIL", "NXDOMAIN"},
}, false,
},
Expand All @@ -120,7 +120,7 @@ func TestRecursiveDNSResponse(t *testing.T) {
IPProtocol: "ip4",
IPProtocolFallback: true,
QueryName: "example.com",
RecursionDesired: true,
Recursion: true,
ValidateAnswer: config.DNSRRValidator{
FailIfMatchesRegexp: []string{".*7200.*"},
FailIfNotMatchesRegexp: []string{".*3600.*"},
Expand All @@ -132,7 +132,7 @@ func TestRecursiveDNSResponse(t *testing.T) {
IPProtocol: "ip4",
IPProtocolFallback: true,
QueryName: "example.com",
RecursionDesired: true,
Recursion: true,
ValidateAuthority: config.DNSRRValidator{
FailIfMatchesRegexp: []string{".*7200.*"},
},
Expand All @@ -143,7 +143,7 @@ func TestRecursiveDNSResponse(t *testing.T) {
IPProtocol: "ip4",
IPProtocolFallback: true,
QueryName: "example.com",
RecursionDesired: true,
Recursion: true,
ValidateAdditional: config.DNSRRValidator{
FailIfNotMatchesRegexp: []string{".*3600.*"},
},
Expand All @@ -154,7 +154,7 @@ func TestRecursiveDNSResponse(t *testing.T) {
IPProtocol: "ip4",
IPProtocolFallback: true,
QueryName: "example.com",
RecursionDesired: false,
Recursion: false,
}, false,
},
}
Expand Down Expand Up @@ -183,7 +183,7 @@ func TestRecursiveDNSResponse(t *testing.T) {
"probe_dns_authority_rrs": 0,
"probe_dns_additional_rrs": 0,
}
if !test.Probe.RecursionDesired {
if !test.Probe.Recursion {
expectedResults["probe_dns_answer_rrs"] = 0
}
checkRegistryResults(expectedResults, mfs, t)
Expand Down Expand Up @@ -494,7 +494,7 @@ func TestDNSProtocol(t *testing.T) {
QueryName: "example.com",
TransportProtocol: protocol,
IPProtocol: "ip6",
RecursionDesired: true,
Recursion: true,
},
}
registry := prometheus.NewRegistry()
Expand All @@ -518,7 +518,7 @@ func TestDNSProtocol(t *testing.T) {
Timeout: time.Second,
DNS: config.DNSProbe{
QueryName: "example.com",
RecursionDesired: true,
Recursion: true,
TransportProtocol: protocol,
IPProtocol: "ip4",
},
Expand All @@ -545,7 +545,7 @@ func TestDNSProtocol(t *testing.T) {
Timeout: time.Second,
DNS: config.DNSProbe{
QueryName: "example.com",
RecursionDesired: true,
Recursion: true,
TransportProtocol: protocol,
},
}
Expand All @@ -570,8 +570,8 @@ func TestDNSProtocol(t *testing.T) {
module = config.Module{
Timeout: time.Second,
DNS: config.DNSProbe{
QueryName: "example.com",
RecursionDesired: true,
QueryName: "example.com",
Recursion: true,
},
}
registry = prometheus.NewRegistry()
Expand Down Expand Up @@ -614,7 +614,7 @@ func TestDNSMetrics(t *testing.T) {
IPProtocol: "ip4",
IPProtocolFallback: true,
QueryName: "example.com",
RecursionDesired: true,
Recursion: true,
},
}
registry := prometheus.NewRegistry()
Expand Down
2 changes: 1 addition & 1 deletion prober/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func TestChooseProtocol(t *testing.T) {
registry = prometheus.NewPedanticRegistry()

ip, _, err = chooseProtocol(ctx, "ip4", false, "ipv6.google.com", registry, logger)
if err != nil && err.Error() != "address ipv6.google.com: no suitable address found" && err.Error() != "lookup ipv6.google.com: no such host" {
if err != nil && err.Error() != "address ipv6.google.com: no suitable address found" {
t.Error(err)
} else if err == nil {
t.Error("should set error")
Expand Down

0 comments on commit 7ffc724

Please sign in to comment.