完善初始化向导、通知配置与证书流程

This commit is contained in:
xuans committed 2026-08-29 11:52:31 +08:00
1 parent b2833b761d
commit f85ef10527
41 files changed
+3645 -1697

No files matched your search

+3 -1
View File
@@ -124,7 +124,9 @@ func (m *manager) rollbackFirewalld(ctx context.Context, result Result) error {
func ufwIsActive(output []byte) bool {
for _, line := range strings.Split(strings.ToLower(string(output)), "\n") {
if strings.TrimSpace(line) == "status: active" {
line = strings.TrimSpace(strings.ReplaceAll(line, ":", ":"))
line = strings.Join(strings.Fields(line), " ")
if line == "status: active" || line == "状态: 激活" {
return true
}
}
+13
View File
@@ -139,6 +139,19 @@ func TestUFWKeepsExistingRule(t *testing.T) {
}
}
func TestUFWRecognizesChineseActiveStatus(t *testing.T) {
runner := &fakeRunner{
paths: map[string]string{"ufw": "/usr/sbin/ufw"},
responses: []runnerResponse{{result: CommandResult{Output: []byte("状态: 激活\n8443/tcp ALLOW Anywhere\n")}}},
}
result, err := NewManagerForOS("linux", runner).OpenTCP(context.Background(), 8443)
if err != nil {
t.Fatalf("中文 UFW 状态检查失败:%v", err)
}
if result.Created || result.Backend != backendUFW {
t.Fatalf("中文 UFW 已有规则不应重复创建:%+v", result)
}
}
func TestFirewalldCreatesPermanentRuleAndReloads(t *testing.T) {
runner := &fakeRunner{
paths: map[string]string{"firewall-cmd": "/usr/bin/firewall-cmd"},