Address publication review feedback
Add the AGPL LICENSE file and a deployment-security note in the README to clarify that the unauthenticated /collect endpoint must run on a trusted network. Fix the IPv6 reachability rule so it consults the IP actually probed: PingTargetResult now carries ResolvedIP populated from pinger.IPAddr(), which lets the rule classify hostname targets correctly instead of always reporting "No IPv6 target pinged". Tighten error handling: ipsFromService now propagates JSON errors, ExtractMetrics wraps decode failures, the count option returns an explicit error when out of range instead of silently clamping, and the "all pings failed" message no longer concatenates every per-target error. Threshold validation is factored into validateThresholdPair and shared between the RTT and packet-loss rules. Add unit tests covering address resolution, threshold validation, and each rule's evaluation paths.
This commit is contained in:
parent
706fc2a4c1
commit
34b70969c8
16 changed files with 1270 additions and 33 deletions
|
|
@ -42,11 +42,20 @@ func Rules() []sdk.CheckRule {
|
|||
}
|
||||
}
|
||||
|
||||
// Rule returns the primary rule (reachability) for backward compatibility
|
||||
// with callers that expect a single rule; prefer Rules() which returns the
|
||||
// full rule set.
|
||||
func Rule() sdk.CheckRule {
|
||||
return &reachabilityRule{}
|
||||
// validateThresholdPair checks that warn and crit are within [min, max] and
|
||||
// that crit is strictly greater than warn. The names are used in error
|
||||
// messages so callers get diagnostics naming their actual options.
|
||||
func validateThresholdPair(warnName, critName string, warn, crit, min, max float64) error {
|
||||
if warn < min || warn > max {
|
||||
return fmt.Errorf("%s must be between %v and %v", warnName, min, max)
|
||||
}
|
||||
if crit < min || crit > max {
|
||||
return fmt.Errorf("%s must be between %v and %v", critName, min, max)
|
||||
}
|
||||
if crit <= warn {
|
||||
return fmt.Errorf("%s (%v) must be greater than %s (%v)", critName, crit, warnName, warn)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// loadPingData fetches the ping observation. On error, returns a CheckState
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue