import Link from "next/link"; import { ActionForm } from "@/components/action-form"; import { Input } from "@/components/ui/input"; import { SubmitButton } from "@/components/submit-button"; import { buttonVariants } from "@/components/ui/button"; import { relayDesired, relayInventory, type RelayRoute } from "@/lib/relays"; import { ensureDb } from "@/lib/db"; import { listNodes } from "@/lib/store"; import { formatLocalDateTime } from "@/lib/datetime"; import { saveHostAction, saveRouteAction, deleteHostAction, deleteRouteAction, } from "./actions"; export default async function RelaysPage() { const [{ hosts, routes }, nodes, db] = await Promise.all([ relayInventory(), listNodes(), ensureDb(), ]); const targets = nodes.filter((n) => ["hy2", "anytls"].includes(n.node_type)); const now = new Date().getTime(); const states = new Map( hosts.map((h) => [ h.id, !h.enabled ? "已停用" : !h.last_seen_at ? "等待安装" : now - Date.parse(h.last_seen_at) > 90000 ? "离线" : h.error ? h.error === "port_conflict" ? "端口冲突" : "应用失败" : h.applied_hash !== relayDesired(db, h).hash ? "等待应用" : relayDesired(db, h).config.endpoints.length === 0 ? "待添加线路" : h.service_active ? "配置已应用" : "服务未运行", ]), ); const routeForm = (r?: RelayRoute) => ( {r && } {r ? "保存线路" : "创建线路"} ); return (

中转线路

入口主机透传 TCP / UDP,目标节点继续认证与计量,保留直连。

订阅排序与分组

新增中转主机

创建主机

中转主机

{hosts.length} 台
{hosts.map((h) => (
{h.name} {h.server_host} {states.get(h.id)}

最近上报: {h.last_seen_at ? formatLocalDateTime(h.last_seen_at) : "尚未上报"} 。状态代表配置和进程,不代表大陆线路质量。

保存主机
下载安装 SH 删除主机
))}

以 root 在入口主机执行脚本,使用独立 Realm 服务。脚本含管理凭据,请妥善保管。仅开放线路所需端口;不需要额外的公网管理端口或证书。

0 && !routes.length}>

新增中转线路

{routeForm()}

线路列表

{routes.length} 条

端口相同表示无 NAT 端口转换。配置约 15 秒同步,应用变更会中断该主机已有中转连接;服务失联超过 90 秒停止转发。仅配置已应用的线路进入订阅,SNI 和凭据继承目标节点。UDP 业务仍可通过 AnyTLS 的 TCP 隧道转发。

{routes.map((r) => { const h = hosts.find((h) => h.id === r.host_id), n = nodes.find((n) => n.id === r.node_id); return (
{r.name} {n?.node_type === "hy2" ? "UDP" : "TCP"} ·{" "} {r.enabled ? states.get(r.host_id) : "已停用"}

{h?.server_host}:{r.public_port} → 本机 :{r.listen_port} →{" "} {n?.server_host}:{n?.server_port} {!n?.enabled ? "(目标已停用)" : ""}

{routeForm(r)} 删除线路
); })}
); }