Skip to content

一分钟搭建影视站,支持Docker等部署方式

fix(live): EPG 校验改用直播侧 SSRF 口径,内网自建 IPTV 节目单可拉取

bestZwei3cdbc8783cf0
diff --git a/src/app/api/live/epg/route.ts b/src/app/api/live/epg/route.ts
index c6edc33..3f91fc9 100644
--- a/src/app/api/live/epg/route.ts
+++ b/src/app/api/live/epg/route.ts
@@ -1,6 +1,6 @@
import { NextResponse } from 'next/server';
import { guardRequest, jsonError } from '@/lib/api-guard';
-import { checkUpstreamAllowed } from '@/lib/ssrf';
+import { checkLiveUrlAllowed } from '@/lib/ssrf';
import { fetchUpstream } from '@/lib/fetch-utils';
import { getLiveCache, setLiveCache } from '@/lib/live-cache';
import { currentAndNext, parseXmltv } from '@/lib/xmltv';
@@ -29,14 +29,16 @@ export async function GET(req: Request) {
if (!url || !channel) return jsonError('缺少 url 或 channel 参数', 400);
const force = sp.get('force') === '1';
- const verdict = await checkUpstreamAllowed(url);
+ // 直播专用校验 + allowPrivate:与 playlist/stream/probe 同一把尺子,
+ // LIVE_ALLOW_PRIVATE=1 时内网自建 IPTV 的 XMLTV 节目单才能拉取
+ const verdict = await checkLiveUrlAllowed(url);
if (!verdict.ok) return jsonError(verdict.reason, 403);
const key = `live:epg:${url}`;
let programMap: Map<string, EpgProgram[]> | undefined = force ? undefined : getLiveCache(key);
if (!programMap) {
try {
- const res = await fetchUpstream(url, { timeoutMs: FETCH_TIMEOUT_MS, retries: 0 });
+ const res = await fetchUpstream(url, { timeoutMs: FETCH_TIMEOUT_MS, retries: 0, allowPrivate: true });
if (!res.ok) {
return jsonError(`节目单地址请求失败: ${res.status}`, 502);
}