mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-09-27 11:41:43 +02:00
Add files via upload
This commit is contained in:
@@ -44,3 +44,17 @@ func ApplyDevHTTPSBootstrap(cfg *Config) {
|
|||||||
}
|
}
|
||||||
cfg.Server.TLSAutoSelfSign = true
|
cfg.Server.TLSAutoSelfSign = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ApplyPlainHTTPBootstrap 供 --http / 一键脚本使用:强制主站使用明文 HTTP。
|
||||||
|
// 它会覆盖配置文件中的 TLS 开关、自签证书以及证书路径,避免 --http 仍被配置中的 HTTPS 选项重新启用。
|
||||||
|
func ApplyPlainHTTPBootstrap(cfg *Config) {
|
||||||
|
if cfg == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cfg.Server.TLSEnabled = false
|
||||||
|
cfg.Server.TLSAutoSelfSign = false
|
||||||
|
cfg.Server.TLSCertPath = ""
|
||||||
|
cfg.Server.TLSKeyPath = ""
|
||||||
|
disabled := false
|
||||||
|
cfg.Server.TLSHTTPRedirect = &disabled
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestApplyPlainHTTPBootstrapDisablesConfiguredTLS(t *testing.T) {
|
||||||
|
enabled := true
|
||||||
|
cfg := &Config{
|
||||||
|
Server: ServerConfig{
|
||||||
|
TLSEnabled: true,
|
||||||
|
TLSAutoSelfSign: true,
|
||||||
|
TLSCertPath: "/tmp/server.crt",
|
||||||
|
TLSKeyPath: "/tmp/server.key",
|
||||||
|
TLSHTTPRedirect: &enabled,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
ApplyPlainHTTPBootstrap(cfg)
|
||||||
|
|
||||||
|
if MainWebUIUsesHTTPS(&cfg.Server) {
|
||||||
|
t.Fatal("expected --http bootstrap to disable main web UI HTTPS")
|
||||||
|
}
|
||||||
|
if ServerHTTPRedirectEnabled(&cfg.Server) {
|
||||||
|
t.Fatal("expected --http bootstrap to disable HTTP to HTTPS redirect")
|
||||||
|
}
|
||||||
|
if cfg.Server.TLSCertPath != "" || cfg.Server.TLSKeyPath != "" {
|
||||||
|
t.Fatalf("expected TLS cert paths to be cleared, got cert=%q key=%q", cfg.Server.TLSCertPath, cfg.Server.TLSKeyPath)
|
||||||
|
}
|
||||||
|
if cfg.Server.TLSHTTPRedirect == nil || *cfg.Server.TLSHTTPRedirect {
|
||||||
|
t.Fatal("expected TLSHTTPRedirect to be explicitly disabled")
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user