Support configurable TLS probes in the API and dashboard
This commit is contained in:
1 parent
0bde5627f0
commit
c7fdd2c430
38 files changed
+495
-203
No files matched your search
@@ -0,0 +1,37 @@
|
||||
package inbound
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
)
|
||||
|
||||
type TLSCheck struct {
|
||||
Port int `json:"port" yaml:"port"`
|
||||
Version string `json:"version" yaml:"version"`
|
||||
}
|
||||
|
||||
func ValidateTLSChecks(checks []TLSCheck) error {
|
||||
seen := make(map[int]bool, len(checks))
|
||||
for _, check := range checks {
|
||||
if check.Port < 1 || check.Port > 65535 {
|
||||
return fmt.Errorf("TLS port %d is outside 1..65535", check.Port)
|
||||
}
|
||||
if check.Version != "1.2" && check.Version != "1.3" {
|
||||
return fmt.Errorf("TLS port %d requires version 1.2 or 1.3", check.Port)
|
||||
}
|
||||
if seen[check.Port] {
|
||||
return fmt.Errorf("duplicate TLS port %d", check.Port)
|
||||
}
|
||||
seen[check.Port] = true
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EffectiveTLSChecks resolves a nil (automatic mode) configuration.
|
||||
// An explicitly empty slice disables TLS checks.
|
||||
func EffectiveTLSChecks(ports []int, checks []TLSCheck) []TLSCheck {
|
||||
if checks == nil && slices.Contains(ports, 443) {
|
||||
return []TLSCheck{{Port: 443}}
|
||||
}
|
||||
return checks
|
||||
}
|
||||
Reference in new issue
Block a user