Files
mirror-3x-ui/frontend/src/api/inboundInfo.ts
T
Hamed fda676e62a fix(inbounds): page inbound info and stream peer exports (#7341)
Replace full inbound hydration in Show Info with owner-scoped, no-store reads of one display client or up to 50 WireGuard/AmneziaWG peers. Preserve absolute peer numbering, Host/node endpoint projection, selected tab and IP logs across live traffic updates; keep edit and clone on full detail.

Stream ordered NDJSON pages from a single stored inbound snapshot for explicit Export All Peers. Generate an ordered ZIP64 archive with existing client config/link generators; validate page offsets, protocol and total, and reject incomplete or cancelled exports. Renew the per-page HTTP write deadline through the original response writer before gzip wrapping, keeping ordinary endpoint timeouts unchanged.

Validated on head 0f853351: all 12 CI jobs and Docs CI passed, including 2,350 frontend tests, bounded-info Chromium stories, live-traffic and archive regressions, Go/race, PostgreSQL, and node/Xray E2E. The final review also verified a conflict-free test merge with main 38452eac, matching regenerated API contracts and passing focused controller tests, including the real HTTP deadline regression for identity and gzip.

The author's synthetic 50,000-peer fixture reduces the uncompressed Show Info response from 2,650,526 to 3,184 bytes. Stored JSON still requires a linear scan per page; explicit ZIP export retains archive data in browser memory. Slow individual writes and reverse-proxy timeouts remain operational limits. No production latency or memory guarantee is implied.

Fixes #7330.
2026-12-03 04:57:45 +03:30

29 lines
934 B
TypeScript

import { z } from 'zod';
import { withBasePath } from '@/api/http-init';
import { InboundDetailSchema } from '@/schemas/inbound';
import { HttpUtil } from '@/utils';
import { parseMsg } from '@/utils/zodValidate';
export const INBOUND_PEER_PAGE_SIZE = 50;
export const InboundInfoPageSchema = z.object({
inbound: InboundDetailSchema,
totalPeers: z.number().int().nonnegative(),
peerOffset: z.number().int().nonnegative(),
});
export async function fetchInboundInfo(id: number, page: number, signal: AbortSignal) {
const response = await HttpUtil.get(
`/panel/api/inbounds/${id}/info`,
{ page },
{ signal, silent: true },
);
const result = parseMsg(response, InboundInfoPageSchema, 'inbounds/info');
if (!result.success || !result.obj) throw new Error(result.msg);
return result.obj;
}
export function inboundPeerExportPath(id: number) {
return withBasePath(`/panel/api/inbounds/${id}/peerExport`);
}