整改基线:封存公网端口分离与远程后端回归候选
Security Checks / security (push) Waiting to run

This commit is contained in:
xuans committed 2026-09-18 01:05:50 +08:00
1 parent a4280e7abc
commit d193324e6d
23 files changed
+338 -43

No files matched your search

+18 -16
View File
@@ -40,14 +40,15 @@ func AcmeChallenge(w http.ResponseWriter, r *http.Request) {
}
type sslResponse struct {
Port int `json:"port"`
HTTPPort int `json:"httpPort"`
HTTPSPort int `json:"httpsPort"`
TLSMode string `json:"tlsMode"`
HTTPSEnabled bool `json:"httpsEnabled"`
WebDomain string `json:"webDomain"`
Type string `json:"type"`
Ready bool `json:"ready"`
Port int `json:"port"`
HTTPPort int `json:"httpPort"`
HTTPSPort int `json:"httpsPort"`
PublicHTTPSPort int `json:"publicHttpsPort"`
TLSMode string `json:"tlsMode"`
HTTPSEnabled bool `json:"httpsEnabled"`
WebDomain string `json:"webDomain"`
Type string `json:"type"`
Ready bool `json:"ready"`
}
func buildSetupSSLResponse(sslType string, cfg *config.Config, httpConfig config.HTTPConfig, webDomain string, ready bool) sslResponse {
@@ -60,14 +61,15 @@ func buildSetupSSLResponse(sslType string, cfg *config.Config, httpConfig config
httpsPort = 443
}
return sslResponse{
Port: httpPort,
HTTPPort: httpPort,
HTTPSPort: httpsPort,
TLSMode: httpConfig.TLSMode,
HTTPSEnabled: httpConfig.HTTPSEnabled,
WebDomain: webDomain,
Type: sslType,
Ready: ready,
Port: httpPort,
HTTPPort: httpPort,
HTTPSPort: httpsPort,
PublicHTTPSPort: config.ResolvePublicHTTPSPort(httpConfig),
TLSMode: httpConfig.TLSMode,
HTTPSEnabled: httpConfig.HTTPSEnabled,
WebDomain: webDomain,
Type: sslType,
Ready: ready,
}
}
@@ -60,6 +60,15 @@ func TestBuildSetupSSLResponseUsesConfiguredProxyPorts(t *testing.T) {
}
}
func TestBuildSetupSSLResponseSeparatesPublicPort(t *testing.T) {
response := buildSetupSSLResponse("1", nil, config.HTTPConfig{
Port: 8001, HTTPSPort: 8002, HTTPSEnabled: true, PublicHTTPSPort: 443,
}, "mail.example.com", true)
if response.HTTPSPort != 8002 || response.HTTPPort != 8001 || response.PublicHTTPSPort != 443 {
t.Fatalf("初始化响应混淆公网与内部端口:%+v", response)
}
}
func TestBuildSetupSSLResponseDefaultsHTTPSPort(t *testing.T) {
response := buildSetupSSLResponse(
config.SSLTypeAutoHTTP,