Files
ARTEX-chixuweihu/server/egress_blacklist_test.go
T
ji ruo d786de90af feat(traffic,sandbox): add TUN/netstack transparent gateway, egress controls, CAP_NET_RAW hardening, and i18n fixes
- Implement full-traffic transparent gateway (cmd/artex-gateway, traffic/netstack.go, traffic/transparent.go) using Linux TUN + gVisor netstack deferred TCP handshakes (eliminating nmap/nc false-positive open ports), real ICMPv4 Echo proxying, UDP/DNS interception, and per-container upstream proxy overrides.
- Add egress blacklist + asset-intercept sync, non-HTTP flow/DNS SQLite persistence and APIs, and /system/proxy & /function/traffic TCP/UDP/DNS UI panels.
- Fix sandbox Playwright MCP browser loopback --proxy-server rewrite and NODE_EXTRA_CA_CERTS override in server/mcpstdio.go.
- Strip all SUID/SGID binaries in Dockerfile.sandbox, grant minimal cap_net_raw+ep to nmap/nping/ping with ARTEX_SANDBOX_ALLOW_NET_RAW toggle, and enforce IPv4/IPv6 anti-spoofing in iptables and netstack.
- Remove hardcoded Chinese "(全局)" from GET /api/proxy/routes, localize ContainerRoutesTab / NonHTTPTrafficPanel labels, and expose reactive locale/isEn from useLiveTranslation for React Compiler compatibility.
2026-12-02 02:51:36 +08:00

39 lines
1.3 KiB
Go

package server
import (
"testing"
"github.com/Autumn-27/artex/db"
)
func TestTranslateAssetInterceptRules(t *testing.T) {
in := []db.AssetInterceptRule{
{ID: 1, Enabled: true, Kind: "exact_domain", Pattern: "Admin.Example.com", Note: "prod"},
{ID: 2, Enabled: true, Kind: "fuzzy_domain", Pattern: "gov.cn", Note: "gov"},
{ID: 3, Enabled: true, Kind: "exact_ip", Pattern: "198.51.100.9"},
{ID: 4, Enabled: true, Kind: "cidr", Pattern: "203.0.113.0/24"},
{ID: 5, Enabled: true, Kind: "exact_url", Pattern: "https://pay.example.org:8443/checkout"},
{ID: 6, Enabled: false, Kind: "exact_domain", Pattern: "disabled.example.com"},
{ID: 7, Enabled: true, Kind: "fuzzy_url", Pattern: "/admin/delete"},
}
got := translateAssetInterceptRules(in)
if len(got) != 5 {
t.Fatalf("translated %d rules, want 5: %+v", len(got), got)
}
want := []struct {
kind string
pattern string
}{
{"domain", "admin.example.com"},
{"suffix", "*.gov.cn"},
{"ip", "198.51.100.9"},
{"cidr", "203.0.113.0/24"},
{"domain", "pay.example.org"},
}
for i, w := range want {
if got[i].Kind != w.kind || got[i].Pattern != w.pattern || got[i].Source != "asset_intercept" {
t.Fatalf("rule[%d] = %+v, want kind=%s pattern=%s source=asset_intercept", i, got[i], w.kind, w.pattern)
}
}
}