Skip to content

Commit 35a165b

Browse files
committed
fix: 清理 Linux-only 防火墙测试中残留的 allowedPorts 测试、修正前端文案和 uat 脚本
1 parent 74c1502 commit 35a165b

3 files changed

Lines changed: 3 additions & 100 deletions

File tree

internal/network/worker_firewall_linux_test.go

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -188,46 +188,6 @@ func TestApplyWorkerFirewallRules_Basic(t *testing.T) {
188188
}
189189
}
190190

191-
// TestApplyWorkerFirewallRules_WithAllowedPorts 验证额外端口映射规则。
192-
func TestApplyWorkerFirewallRules_WithAllowedPorts(t *testing.T) {
193-
ns, origNS := newTestNetNS(t)
194-
defer cleanupTestNetNS(t, ns, origNS)
195-
196-
gwIP := net.ParseIP("10.0.0.1")
197-
bridgeGW := net.ParseIP("172.18.0.1")
198-
allowedPorts := []uint16{8080, 8443}
199-
200-
err := ApplyWorkerFirewallRules(ns, gwIP, bridgeGW, 22, allowedPorts)
201-
if err != nil {
202-
t.Fatalf("ApplyWorkerFirewallRules failed: %v", err)
203-
}
204-
205-
conn, err := nftables.New(nftables.WithNetNSFd(int(ns)))
206-
if err != nil {
207-
t.Fatalf("open nftables conn: %v", err)
208-
}
209-
210-
tbl := getTableByName(t, conn, "cloudproxy")
211-
if tbl == nil {
212-
t.Fatal("cloudproxy table not found")
213-
}
214-
215-
inputChain := getChainByName(t, conn, tbl, "input")
216-
if inputChain == nil {
217-
t.Fatal("input chain not found")
218-
}
219-
220-
inputRules, err := conn.GetRules(tbl, inputChain)
221-
if err != nil {
222-
t.Fatalf("get input rules: %v", err)
223-
}
224-
225-
// 基础规则 5 条 + 2 个额外端口 = 7 条
226-
expectedMin := 5 + len(allowedPorts)
227-
if len(inputRules) < expectedMin {
228-
t.Fatalf("input rules = %d, want >= %d", len(inputRules), expectedMin)
229-
}
230-
}
231191

232192
// TestApplyWorkerFirewallRules_InvalidNetNS 验证无效 netns handle 返回错误。
233193
func TestApplyWorkerFirewallRules_InvalidNetNS(t *testing.T) {
@@ -439,60 +399,7 @@ func TestApplyWorkerFirewallRules_CustomSSHPort(t *testing.T) {
439399
}
440400
}
441401

442-
// TestApplyWorkerFirewallRules_NilAllowedPorts 验证 nil allowedPorts 不 panic。
443-
func TestApplyWorkerFirewallRules_NilAllowedPorts(t *testing.T) {
444-
ns, origNS := newTestNetNS(t)
445-
defer cleanupTestNetNS(t, ns, origNS)
446402

447-
gwIP := net.ParseIP("10.0.0.1")
448-
bridgeGW := net.ParseIP("172.18.0.1")
449-
450-
// nil allowedPorts
451-
err := ApplyWorkerFirewallRules(ns, gwIP, bridgeGW, 22, nil)
452-
if err != nil {
453-
t.Fatalf("ApplyWorkerFirewallRules with nil allowedPorts failed: %v", err)
454-
}
455-
}
456-
457-
// TestApplyWorkerFirewallRules_EmptyAllowedPorts 验证空 allowedPorts 切片。
458-
func TestApplyWorkerFirewallRules_EmptyAllowedPorts(t *testing.T) {
459-
ns, origNS := newTestNetNS(t)
460-
defer cleanupTestNetNS(t, ns, origNS)
461-
462-
gwIP := net.ParseIP("10.0.0.1")
463-
bridgeGW := net.ParseIP("172.18.0.1")
464-
465-
// 空切片
466-
err := ApplyWorkerFirewallRules(ns, gwIP, bridgeGW, 22, []uint16{})
467-
if err != nil {
468-
t.Fatalf("ApplyWorkerFirewallRules with empty allowedPorts failed: %v", err)
469-
}
470-
471-
conn, err := nftables.New(nftables.WithNetNSFd(int(ns)))
472-
if err != nil {
473-
t.Fatalf("open nftables conn: %v", err)
474-
}
475-
476-
tbl := getTableByName(t, conn, "cloudproxy")
477-
if tbl == nil {
478-
t.Fatal("cloudproxy table not found")
479-
}
480-
481-
inputChain := getChainByName(t, conn, tbl, "input")
482-
if inputChain == nil {
483-
t.Fatal("input chain not found")
484-
}
485-
486-
inputRules, err := conn.GetRules(tbl, inputChain)
487-
if err != nil {
488-
t.Fatalf("get input rules: %v", err)
489-
}
490-
491-
// lo + ct_established + gwIP + bridgeGW + SSH = 5 条(无额外端口)
492-
if len(inputRules) != 5 {
493-
t.Fatalf("input rules = %d, want 5", len(inputRules))
494-
}
495-
}
496403

497404
// TestApplyThenCleanupThenApply 验证清理后可以重新应用规则。
498405
func TestApplyThenCleanupThenApply(t *testing.T) {

tests/scripts/uat-vscode-remote-ssh.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ scenario_direct_tcpip_forward() {
590590
local ssh_port
591591
ssh_port="$(detect_ssh_port "$container")"
592592
if [ -z "$ssh_port" ]; then
593-
skip "direct_tcpip_forward" "无法确定 SSH 端口(设置 --ssh-port 或确保容器有端口映射"
593+
skip "direct_tcpip_forward" "无法确定 SSH 端口(设置 --ssh-port 或确保容器已启动"
594594
write_json_report "direct_tcpip_forward" "skip"
595595
return 0
596596
fi

web/admin/src/routes/_dashboard/hosts/$hostId.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ function HostDetailPage() {
390390
</div>
391391
<div>
392392
<span className="block text-sm font-semibold">配置详情</span>
393-
<span className="text-xs text-muted-foreground">出口 IP 绑定、挂载路径、端口映射</span>
393+
<span className="text-xs text-muted-foreground">出口 IP 绑定、挂载路径</span>
394394
</div>
395395
</div>
396396
<ChevronDown className={`h-4 w-4 text-muted-foreground transition-transform ${configOpen ? "" : "-rotate-90"}`} />
@@ -403,15 +403,11 @@ function HostDetailPage() {
403403
<p className="mb-4 text-xs text-muted-foreground">每台主机必须绑定一个出口 IP</p>
404404
<BindingManager hostId={hostId} hostStatus={host.status} bindings={bindings} />
405405
</div>
406-
<div className="px-2 py-2 lg:border-r lg:border-border/40 lg:px-4">
406+
<div className="px-2 py-2 lg:px-4">
407407
<h3 className="mb-1 text-sm font-semibold">挂载路径</h3>
408408
<p className="mb-4 text-xs text-muted-foreground">{isRunning ? "运行中不可编辑" : "停止中,可以编辑"}</p>
409409
<MountManager hostId={hostId} hostStatus={host.status} mounts={host.host_mounts ?? []} />
410410
</div>
411-
<div className="px-2 py-2 lg:px-4">
412-
<h3 className="mb-1 text-sm font-semibold">端口映射</h3>
413-
<p className="mb-4 text-xs text-muted-foreground">{isRunning ? "运行中不可编辑" : "停止中,可以编辑"}</p>
414-
</div>
415411
</div>
416412
</div>
417413
)}

0 commit comments

Comments
 (0)