mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-05-16 13:19:17 +02:00
36 lines
993 B
Go
36 lines
993 B
Go
package config
|
|
|
|
import "strings"
|
|
|
|
// MainWebUIUsesHTTPS 判断主 Web UI 是否以 HTTPS 监听(与 internal/app.prepareMainServerTLS 前置条件一致)。
|
|
func MainWebUIUsesHTTPS(s *ServerConfig) bool {
|
|
if s == nil {
|
|
return false
|
|
}
|
|
if s.TLSEnabled {
|
|
return true
|
|
}
|
|
if s.TLSAutoSelfSign {
|
|
return true
|
|
}
|
|
cert := strings.TrimSpace(s.TLSCertPath)
|
|
key := strings.TrimSpace(s.TLSKeyPath)
|
|
return cert != "" && key != ""
|
|
}
|
|
|
|
// ApplyDevHTTPSBootstrap 供 --https / 一键脚本使用:强制开启主站 TLS。
|
|
// 若已配置 tls_cert_path 与 tls_key_path 则仅用 PEM,不开启自签;否则启用 tls_auto_self_sign(内存证书,仅本地测试)。
|
|
func ApplyDevHTTPSBootstrap(cfg *Config) {
|
|
if cfg == nil {
|
|
return
|
|
}
|
|
cfg.Server.TLSEnabled = true
|
|
cert := strings.TrimSpace(cfg.Server.TLSCertPath)
|
|
key := strings.TrimSpace(cfg.Server.TLSKeyPath)
|
|
if cert != "" && key != "" {
|
|
cfg.Server.TLSAutoSelfSign = false
|
|
return
|
|
}
|
|
cfg.Server.TLSAutoSelfSign = true
|
|
}
|