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

+19 -7
View File
@@ -1,11 +1,13 @@
package httpapi
import (
"encoding/json"
"fmt"
"net/http"
"strconv"
"cloudipvalidator/internal/db"
"cloudipvalidator/internal/inbound"
)
// --- validators ---
@@ -261,21 +263,31 @@ func (s *Server) handleConfigGetInboundChecks(w http.ResponseWriter, r *http.Req
writeDBError(w, err)
return
}
writeJSON(w, http.StatusOK, inboundChecksDTO{Ports: settings.Ports, ICMP: settings.ICMP})
writeJSON(w, http.StatusOK, inboundChecksDTO{Ports: settings.Ports, ICMP: settings.ICMP, TLSChecks: settings.TLSChecks})
}
// handleConfigPutInboundChecks writes directly to the DB (unlike the
// orchestrator-settings PUT above) because port-range/duplicate validation
// is purely local — no cross-field dependency on other orchestrator config.
func (s *Server) handleConfigPutInboundChecks(w http.ResponseWriter, r *http.Request) {
var req inboundChecksDTO
var req struct {
Ports []int `json:"ports"`
ICMP bool `json:"icmp"`
TLSChecks json.RawMessage `json:"tls_checks"`
}
if err := readJSON(r, &req); err != nil {
writeError(w, http.StatusBadRequest, "invalid body: "+err.Error())
return
}
if err := s.DB.SetInboundChecks(r.Context(), req.Ports, req.ICMP); err != nil {
var tlsChecks *[]inbound.TLSCheck
if req.TLSChecks != nil {
var checks []inbound.TLSCheck
if err := json.Unmarshal(req.TLSChecks, &checks); err != nil {
writeError(w, http.StatusBadRequest, "invalid tls_checks: "+err.Error())
return
}
tlsChecks = &checks
}
if err := s.DB.SetInboundChecks(r.Context(), req.Ports, req.ICMP, tlsChecks); err != nil {
writeDBError(w, err)
return
}
writeJSON(w, http.StatusOK, inboundChecksDTO{Ports: req.Ports, ICMP: req.ICMP})
s.handleConfigGetInboundChecks(w, r)
}