反代模式停用自动证书签发续期并完善初始化提示与测试
Security Checks / security (push) Waiting to run

This commit is contained in:
xuans committed 2026-09-06 13:27:06 +08:00
1 parent 7ffb1e751d
commit 369f502c10
20 files changed
+599 -56

No files matched your search

+2
View File
@@ -31,6 +31,7 @@ type PublicIssue struct {
type ConfigStatus struct {
SetupState SetupState `json:"setupState"`
TLSMode string `json:"tlsMode"`
ActiveGeneration uint64 `json:"activeGeneration"`
LastValidAt *time.Time `json:"lastValidAt,omitempty"`
PendingRestart []ServiceName `json:"pendingRestart,omitempty"`
@@ -248,6 +249,7 @@ func (m *ConfigManager) Status() ConfigStatus {
m.mu.RLock()
defer m.mu.RUnlock()
status := m.status
status.TLSMode = m.current.Root.HTTP.TLSMode
status.PendingRestart = append([]ServiceName(nil), status.PendingRestart...)
status.DegradedReasons = append([]PublicIssue(nil), status.DegradedReasons...)
if status.LastValidAt != nil {
+2 -1
View File
@@ -145,7 +145,8 @@ func sameSSLPolicy(left, right *Config) bool {
return reflect.DeepEqual(left.SSL, right.SSL) && left.SSLType == right.SSLType &&
left.SSLPrivateKeyPath == right.SSLPrivateKeyPath && left.SSLPublicKeyPath == right.SSLPublicKeyPath &&
left.Domain == right.Domain && left.WebDomain == right.WebDomain &&
reflect.DeepEqual(left.Domains, right.Domains) && left.HttpsEnabled == right.HttpsEnabled
reflect.DeepEqual(left.Domains, right.Domains) && left.HttpsEnabled == right.HttpsEnabled &&
left.TLSMode == right.TLSMode
}
func mergeServices(previous, next []ServiceName) []ServiceName {
+13
View File
@@ -0,0 +1,13 @@
package config
import "strings"
// UsesProxyHTTPS 表示网页 HTTPS 由反向代理终止,不代表邮件协议可以关闭 TLS。
func (c *Config) UsesProxyHTTPS() bool {
return c != nil && strings.EqualFold(strings.TrimSpace(c.TLSMode), HTTPSTLSModeProxy)
}
// AutomaticSSLEnabled 保留原证书策略,但反代模式下禁止 Smail 自动签发和续期。
func (c *Config) AutomaticSSLEnabled() bool {
return c != nil && !c.UsesProxyHTTPS() && (c.SSLType == SSLTypeAutoHTTP || c.SSLType == SSLTypeAutoDNS)
}