fix(api): protocol-aware monitor filtering for multi-protocol monitors
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Servers with monitor filtering returned incorrect results when monitors
have same names but different protocols (v4/v6). Monitor lookup now
considers both name and IP version to match the correct protocol.
- Add GetMonitorByNameAndIPVersion SQL query with protocol matching
- Update history parameter parsing to use server IP version context
- Fix both /scores/{ip}/log and Grafana endpoints
- Remove unused GetMonitorByName query
Fixes abh/ntppool#264
Reported-by: Anssi Johansson <https://github.com/avijc>
This commit is contained in:
@@ -8,7 +8,6 @@ package ntpdb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
@@ -82,14 +81,14 @@ func (_d QuerierTxWithTracing) Commit(ctx context.Context) (err error) {
|
||||
return _d.QuerierTx.Commit(ctx)
|
||||
}
|
||||
|
||||
// GetMonitorByName implements QuerierTx
|
||||
func (_d QuerierTxWithTracing) GetMonitorByName(ctx context.Context, tlsName sql.NullString) (m1 Monitor, err error) {
|
||||
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetMonitorByName")
|
||||
// GetMonitorByNameAndIPVersion implements QuerierTx
|
||||
func (_d QuerierTxWithTracing) GetMonitorByNameAndIPVersion(ctx context.Context, arg GetMonitorByNameAndIPVersionParams) (m1 Monitor, err error) {
|
||||
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetMonitorByNameAndIPVersion")
|
||||
defer func() {
|
||||
if _d._spanDecorator != nil {
|
||||
_d._spanDecorator(_span, map[string]interface{}{
|
||||
"ctx": ctx,
|
||||
"tlsName": tlsName}, map[string]interface{}{
|
||||
"ctx": ctx,
|
||||
"arg": arg}, map[string]interface{}{
|
||||
"m1": m1,
|
||||
"err": err})
|
||||
} else if err != nil {
|
||||
@@ -103,7 +102,7 @@ func (_d QuerierTxWithTracing) GetMonitorByName(ctx context.Context, tlsName sql
|
||||
|
||||
_span.End()
|
||||
}()
|
||||
return _d.QuerierTx.GetMonitorByName(ctx, tlsName)
|
||||
return _d.QuerierTx.GetMonitorByNameAndIPVersion(ctx, arg)
|
||||
}
|
||||
|
||||
// GetMonitorsByID implements QuerierTx
|
||||
|
||||
Reference in New Issue
Block a user