支持可配置反代HTTPS端口并统一管理与重置入口
This commit is contained in:
1 parent
b2b8951bcf
commit
54b19a19f8
23 files changed
+268
-50
No files matched your search
@@ -17,6 +17,7 @@ type Input struct {
|
||||
AdminEmail string
|
||||
AdminPassword string
|
||||
ServerPort int
|
||||
ProxyHTTPSPort int
|
||||
EmailHTTPEnabled bool
|
||||
EmailSMTPEnabled bool
|
||||
EmailSMTPHost string
|
||||
@@ -74,6 +75,9 @@ func Apply(cfg *config.Config, input Input) error {
|
||||
if input.ServerPort < 1 || input.ServerPort > 65535 {
|
||||
return fmt.Errorf("主服务端口无效:%d", input.ServerPort)
|
||||
}
|
||||
if input.ProxyHTTPSPort < 0 || input.ProxyHTTPSPort > 65535 {
|
||||
return fmt.Errorf("代理 HTTPS 端口必须为 1 至 65535,或使用 0 表示默认 443")
|
||||
}
|
||||
if strings.TrimSpace(input.DNSProvider) == "" {
|
||||
return fmt.Errorf("DNS 服务商不能为空")
|
||||
}
|
||||
@@ -116,6 +120,7 @@ func Apply(cfg *config.Config, input Input) error {
|
||||
cfg.ACME.PropagationPollingIntervalSecs = input.PropagationPollingIntervalSecs
|
||||
}
|
||||
cfg.Server.Port = input.ServerPort
|
||||
cfg.Server.ProxyHTTPSPort = input.ProxyHTTPSPort
|
||||
cfg.Server.HTTPSMode = input.HTTPSMode
|
||||
cfg.Web.Enabled = input.WebEnabled
|
||||
cfg.Web.Hostname = strings.TrimSpace(input.WebHostname)
|
||||
|
||||
@@ -42,7 +42,7 @@ func TestApplyBuildsPendingConfig(t *testing.T) {
|
||||
if cfg.Admin.PasswordHash == "password123" || cfg.Admin.PasswordHash == "" {
|
||||
t.Fatal("管理员密码不应明文保存")
|
||||
}
|
||||
if cfg.ResetURL() != "https://panel.example.com/reset" {
|
||||
if cfg.ResetURL() != "https://panel.example.com:8080/reset" {
|
||||
t.Fatalf("密码重置地址生成错误:%s", cfg.ResetURL())
|
||||
}
|
||||
if cfg.ACME.PropagationTimeoutSecs != 1200 || cfg.ACME.PropagationPollingIntervalSecs != 15 {
|
||||
|
||||
Reference in new issue
Block a user