Registry: the "last result" column now also shows, per level (egress,
ingress), how many of the recorded checks of the latest cycle succeeded, split
by check family (tcp-22 and tcp-443 are both "tcp"). One grouped query per
chunk of addresses; new fields last_cycle_id, egress, ingress in
GET /admin/registry; the dashboard renders them under the verdict.
Verdict integrity (migration 0010):
- the prober is handed an address once per site and attempt, not on every
poll, so results are no longer overwritten by later probe rounds;
- UpsertCheckIfOpen refuses writes once the address is aggregating or has its
verdict, or for an older attempt; senders get {"ok":true,"ignored":N} and a
result_dropped event is recorded;
- the checking window counts from checking_started_at, not from assigned_at;
- checks.recorded_at (server clock) and checks.after_verdict (flag for rows
written after the verdict in existing data);
- the verdict rule is a pure function (computeVerdict) and the aggregated
event carries the egress/ingress check counts.
Rebuilt bin/control-api and bin/admin-dashboard to match. Plans and summaries
are in docs/changes; README, API, USAGE, DASHBOARD and DIAGRAMS are updated.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
113 lines
2.9 KiB
Go
113 lines
2.9 KiB
Go
package httpapi
|
|
|
|
// Request/response bodies for the /api/v1 surface. Kept in one file since
|
|
// they're small and mostly 1:1 with a single handler each.
|
|
|
|
type registerAgentRequest struct {
|
|
ValidatorID string `json:"validator_id"`
|
|
Hostname string `json:"hostname"`
|
|
AgentVersion string `json:"agent_version"`
|
|
}
|
|
|
|
type registerAgentResponse struct {
|
|
OK bool `json:"ok"`
|
|
PollIntervalSeconds int `json:"poll_interval_seconds"`
|
|
}
|
|
|
|
type heartbeatRequest struct {
|
|
LocalState string `json:"local_state"`
|
|
CurrentIPAddress string `json:"current_ip_address,omitempty"`
|
|
}
|
|
|
|
type okResponse struct {
|
|
OK bool `json:"ok"`
|
|
}
|
|
|
|
// resultsResponse answers the result-submission endpoints. Ignored counts the
|
|
// submitted checks that were dropped because the address already has its
|
|
// verdict (or the result belongs to an earlier attempt); the sender must not
|
|
// retry them.
|
|
type resultsResponse struct {
|
|
OK bool `json:"ok"`
|
|
Ignored int `json:"ignored,omitempty"`
|
|
}
|
|
|
|
type observedIPResponse struct {
|
|
IP string `json:"ip"`
|
|
Source string `json:"source"`
|
|
}
|
|
|
|
type checkConfigDTO struct {
|
|
Type string `json:"type"`
|
|
Targets []string `json:"targets"`
|
|
}
|
|
|
|
type assignmentResponse struct {
|
|
IPID int64 `json:"ip_id"`
|
|
IPAddress string `json:"ip_address"`
|
|
Phase string `json:"phase"`
|
|
CheckConfig []checkConfigDTO `json:"check_config,omitempty"`
|
|
}
|
|
|
|
type selfCheckRequest struct {
|
|
IPID int64 `json:"ip_id"`
|
|
DetectedEgress string `json:"detected_egress_ip"`
|
|
Success bool `json:"success"`
|
|
Detail string `json:"detail"`
|
|
}
|
|
|
|
type agentEventRequest struct {
|
|
EventType string `json:"event_type"`
|
|
IPID *int64 `json:"ip_id,omitempty"`
|
|
Payload string `json:"payload,omitempty"`
|
|
}
|
|
|
|
type checkResultDTO struct {
|
|
IPID int64 `json:"ip_id"`
|
|
CheckType string `json:"check_type"`
|
|
Target string `json:"target,omitempty"`
|
|
Success bool `json:"success"`
|
|
LatencyMS int64 `json:"latency_ms"`
|
|
Detail string `json:"detail,omitempty"`
|
|
CheckedAt string `json:"checked_at"`
|
|
}
|
|
|
|
type agentResultsRequest struct {
|
|
Results []checkResultDTO `json:"results"`
|
|
}
|
|
|
|
type agentCompleteRequest struct {
|
|
IPID int64 `json:"ip_id"`
|
|
}
|
|
|
|
type registerProberRequest struct {
|
|
SiteID string `json:"site_id"`
|
|
Hostname string `json:"hostname"`
|
|
}
|
|
|
|
type proberAssignment struct {
|
|
IPID int64 `json:"ip_id"`
|
|
IPAddress string `json:"ip_address"`
|
|
Ports []int `json:"ports"`
|
|
ICMP bool `json:"icmp"`
|
|
}
|
|
|
|
type proberResultDTO struct {
|
|
IPID int64 `json:"ip_id"`
|
|
IPAddress string `json:"ip_address"`
|
|
CheckType string `json:"check_type"`
|
|
Success bool `json:"success"`
|
|
LatencyMS int64 `json:"latency_ms"`
|
|
Detail string `json:"detail,omitempty"`
|
|
CheckedAt string `json:"checked_at"`
|
|
Complete bool `json:"complete"`
|
|
}
|
|
|
|
type proberResultsRequest struct {
|
|
Results []proberResultDTO `json:"results"`
|
|
}
|
|
|
|
type errorResponse struct {
|
|
Error string `json:"error"`
|
|
}
|