Support configurable TLS probes in the API and dashboard

This commit is contained in:
ayurishchev committed 2026-11-20 21:15:22 +03:00
1 parent 0bde5627f0
commit c7fdd2c430
38 files changed
+495 -203

No files matched your search

+13 -27
View File
@@ -1,7 +1,7 @@
// Package probercore implements a prober's poll loop: register once with
// its site identity, then each cycle fetch the set of IPs currently under
// test and run inbound reachability checks (TCP connect on each configured
// port, ICMP echo) directly against each one — this is the real,
// test and run inbound reachability checks (TCP, SSH, TLS and ICMP)
// directly against each one — this is the real,
// unmediated network test; only the control channel goes through the
// Control API.
package probercore
@@ -15,6 +15,7 @@ import (
"cloudipvalidator/internal/apiclient"
"cloudipvalidator/internal/checkrunner"
"cloudipvalidator/internal/config"
"cloudipvalidator/internal/inbound"
)
type Prober struct {
@@ -110,10 +111,11 @@ func (p *Prober) registerWithRetry(ctx context.Context) error {
}
type assignment struct {
IPID int64 `json:"ip_id"`
IPAddress string `json:"ip_address"`
Ports []int `json:"ports"`
ICMP bool `json:"icmp"`
IPID int64 `json:"ip_id"`
IPAddress string `json:"ip_address"`
Ports []int `json:"ports"`
ICMP bool `json:"icmp"`
TLSChecks []inbound.TLSCheck `json:"tls_checks"`
}
type resultDTO struct {
@@ -148,25 +150,6 @@ func (p *Prober) pollOnce(ctx context.Context) {
}
}
// extraChecksForPort returns checks to run in addition to the base
// TCPConnect for ports where a bare TCP handshake doesn't actually prove
// the expected service is behind it: a real TLS handshake on 443, a real
// SSH banner exchange on 22. nil for every other port.
func extraChecksForPort(host string, port int, timeout time.Duration) []func(ctx context.Context) checkrunner.Result {
switch port {
case 443:
return []func(ctx context.Context) checkrunner.Result{
checkrunner.TLSHandshake(host, port, timeout),
}
case 22:
return []func(ctx context.Context) checkrunner.Result{
checkrunner.SSHBanner(host, timeout),
}
default:
return nil
}
}
func (p *Prober) probeOne(ctx context.Context, a assignment) {
tcpTimeout := time.Duration(p.cfg.Checks.TCPTimeoutSeconds) * time.Second
icmpTimeout := time.Duration(p.cfg.Checks.ICMPTimeoutSeconds) * time.Second
@@ -182,10 +165,13 @@ func (p *Prober) probeOne(ctx context.Context, a assignment) {
for _, port := range a.Ports {
record(checkrunner.TCPConnect(a.IPAddress, port, tcpTimeout)(ctx))
for _, extra := range extraChecksForPort(a.IPAddress, port, tcpTimeout) {
record(extra(ctx))
if port == 22 {
record(checkrunner.SSHBanner(a.IPAddress, tcpTimeout)(ctx))
}
}
for _, check := range inbound.EffectiveTLSChecks(a.Ports, a.TLSChecks) {
record(checkrunner.TLSHandshake(a.IPAddress, check.Port, check.Version, tcpTimeout)(ctx))
}
if a.ICMP {
record(checkrunner.ICMPEcho(a.IPAddress, p.cfg.Checks.ICMPCount, icmpTimeout)(ctx))
}