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.
This commit is contained in:
ji ruo committed 2026-12-02 02:51:36 +08:00
1 parent 9c43e694a3
commit d786de90af
69 files changed
+13082 -1433

No files matched your search

+10
View File
@@ -63,6 +63,7 @@ export const messages = {
"nav.asset-intercept": ["资产拦截", "Asset interception"],
"nav.approvals": ["审批记录", "Approval history"],
"nav.sandbox": ["沙箱容器", "Sandbox"],
"nav.proxy": ["代理与出口", "Proxy & Egress"],
"nav.logs": ["日志", "Logs"],
"nav.settings": ["系统配置", "Settings"],
"search.placeholder": ["搜索页面与功能…", "Search pages and features…"],
@@ -251,6 +252,15 @@ export const messages = {
"No findings eligible for AI auto-merge (at least 2 findings per task required)",
],
"findingsAutoMerge.failed": ["启动 AI 自动合并失败:{{message}}", "Failed to start AI auto-merge: {{message}}"],
"traffic.source": ["来源归属", "Source"],
"traffic.scopeAll": ["全部来源", "All sources"],
"traffic.scopeTask": ["任务容器", "Task"],
"traffic.scopeSession": ["对话容器", "Chat"],
"traffic.ownerPlaceholder": ["归属 ID(任务/对话)…", "Owner ID (task/chat)…"],
"traffic.containerPlaceholder": ["容器 ID 前缀…", "Container ID…"],
"traffic.sourceTask": ["任务 #{{id}}", "Task #{{id}}"],
"traffic.sourceSession": ["对话 {{id}}", "Chat {{id}}"],
"traffic.sourceHost": ["宿主机", "Host"],
} satisfies Record<string, readonly [string, string]>;
const statuses: Record<string, readonly (readonly [string, string, string])[]> = {
+38
View File
@@ -367,3 +367,41 @@ test("Repeater renders persisted drafts with translated default group and preser
assert.equal(useRepeaterStore.getState().workspace.tabs[0].rawRequest, "GET / HTTP/1.1\nHost: example.test\n\n");
useRepeaterStore.setState({ workspace: null });
});
test("ContainerRoutesTab localizes effective egress without mixed Chinese/English", async () => {
const { ContainerRoutesTab } = load(base + "/src/app/(main)/system/proxy/_components/container-routes-tab.tsx");
const routesState = {
global_proxy: "direct",
routes: [],
containers: [
{
scope: "session",
owner_id: "conv-6",
container_name: "artex-sbx-session-conv-6",
state: "running",
ip: "172.30.0.3",
mode: "inherit",
effective_proxy: "direct",
},
{
scope: "task",
owner_id: "42",
container_name: "artex-sbx-task-42",
state: "inactive",
mode: "inherit",
effective_proxy: "direct (全局)",
},
],
gateway: { connected: true, embedded: false, udp_policy: "block_on_proxy", dns_upstream: "" },
};
await i18n.changeLanguage("en");
const enHtml = visible(render(ContainerRoutesTab, { proxyPool: [], routesState, onRefresh: async () => undefined }));
assert.doesNotMatch(enHtml, /[\p{Script=Han}]/u, enHtml);
assert.match(enHtml, /Effective Egress/);
assert.match(enHtml, /Direct \(Global\)/);
await i18n.changeLanguage("zh-CN");
const zhHtml = visible(render(ContainerRoutesTab, { proxyPool: [], routesState, onRefresh: async () => undefined }));
assert.match(zhHtml, /当前生效出口/);
assert.match(zhHtml, /直连 \(全局\)/);
});
+5
View File
@@ -168,6 +168,11 @@ export const settingsMessages = {
"沙箱 容器 隔离 docker 镜像 内存 cpu 进程 生命周期 停机 清理",
"sandbox container isolation docker image memory cpu pids lifecycle stop prune",
],
"settings.proxyMovedDesc": [
"全局出口代理、代理池轮换、出口黑名单与拦截审计已迁移至独立的「代理与出口」管理页。",
"Global egress proxy, proxy pool rotation, egress blacklist and block audit have moved to the dedicated Proxy & Egress page.",
],
"settings.openProxyPage": ["前往代理与出口", "Open Proxy & Egress"],
"settings.trafficCapture": ["流量捕获", "Traffic capture"],
"settings.trafficCaptureHelp": [
"开启后,所有 Agent 的 HTTP 流量经记录代理全量落库,并向 Agent 注入 traffic_search / traffic_get 工具与代理配置(提示词含代理说明)。",
+2 -4
View File
@@ -2,13 +2,11 @@
import { enUS } from "date-fns/locale/en-US";
import { zhCN } from "date-fns/locale/zh-CN";
import { useTranslation } from "react-i18next";
import { resolveLocale } from "./config";
import { useLiveTranslation } from "./use-live-translation";
export function useDateLocale() {
const { i18n } = useTranslation();
const locale = resolveLocale(i18n.resolvedLanguage);
const { locale } = useLiveTranslation();
return {
locale,
dateLocale: locale === "en" ? enUS : zhCN,
+5 -2
View File
@@ -9,7 +9,10 @@ import { useTranslation } from "react-i18next";
// language change; it reads the current language when each callback runs.
export function useLiveTranslation() {
const translation = useTranslation();
const { i18n } = translation;
const { t, i18n } = translation;
const liveT = useMemo(() => i18n.t.bind(i18n), [i18n]);
return { ...translation, liveT };
// Read reactive `t` so React Compiler invalidates memo caches on language switches.
const isEn = t.length >= 0 && /^en(?:-|$)/i.test(i18n.resolvedLanguage ?? i18n.language ?? "");
const locale = isEn ? "en" : "zh-CN";
return { ...translation, liveT, locale, isEn };
}