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

+15 -7
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"cloudipvalidator/internal/config"
"cloudipvalidator/internal/inbound"
)
// BootstrapFromConfig ensures the database's baseline state matches the
@@ -37,7 +38,7 @@ func (d *DB) BootstrapFromConfig(ctx context.Context, cfg *config.ControlAPI) er
if err := d.bootstrapSettings(ctx, cfg.Orchestrator.FIPSettleSeconds); err != nil {
return fmt.Errorf("bootstrap settings: %w", err)
}
if err := d.bootstrapInboundChecks(ctx, cfg.Inbound.Ports, cfg.Inbound.ICMP); err != nil {
if err := d.bootstrapInboundChecks(ctx, cfg.Inbound); err != nil {
return fmt.Errorf("bootstrap inbound checks: %w", err)
}
if err := d.SeedQueue(ctx, cfg.IPAddresses); err != nil {
@@ -125,7 +126,7 @@ func (d *DB) bootstrapSettings(ctx context.Context, fipSettleSeconds int) error
return err
}
func (d *DB) bootstrapInboundChecks(ctx context.Context, ports []int, icmp bool) error {
func (d *DB) bootstrapInboundChecks(ctx context.Context, settings config.InboundConfig) error {
var count int
if err := d.QueryRowContext(ctx, `SELECT COUNT(*) FROM inbound_checks_settings`).Scan(&count); err != nil {
return err
@@ -133,16 +134,23 @@ func (d *DB) bootstrapInboundChecks(ctx context.Context, ports []int, icmp bool)
if count > 0 {
return nil
}
if ports == nil {
ports = []int{}
if err := inbound.ValidateTLSChecks(settings.TLSChecks); err != nil {
return err
}
payload, err := json.Marshal(ports)
if settings.Ports == nil {
settings.Ports = []int{}
}
payload, err := json.Marshal(settings.Ports)
if err != nil {
return err
}
tlsChecks, err := json.Marshal(settings.TLSChecks)
if err != nil {
return err
}
now := timeToDB(Now())
_, err = d.ExecContext(ctx, `
INSERT INTO inbound_checks_settings (id, ports, icmp, created_at, updated_at) VALUES (1, ?, ?, ?, ?)
`, string(payload), icmp, now, now)
INSERT INTO inbound_checks_settings (id, ports, icmp, tls_checks, created_at, updated_at) VALUES (1, ?, ?, ?, ?, ?)
`, string(payload), settings.ICMP, string(tlsChecks), now, now)
return err
}