My Blog https://wordpress.curtitvonline.top/ My WordPress Blog Thu, 22 Oct 2026 12:34:55 +0000 pt-BR hourly 1 https://wordpress.org/?v=7.1.3 TEST https://wordpress.curtitvonline.top/2026/10/22/test/ https://wordpress.curtitvonline.top/2026/10/22/test/#respond Thu, 22 Oct 2026 12:34:55 +0000 https://wordpress.curtitvonline.top/?p=8 import type { Express } from “express”; import { Readable } from “node:stream”; import { pipeline } from “node:stream/promises”; import type { ReadableStream as NodeReadableStream } from “node:stream/web”; const MPEG_TS_CONTENT_TYPE = “video/mp2t”; /** * Streams one server-configured live source through the site’s own HTTPS origin. * The source URL is never accepted from request parameters […]

The post TEST appeared first on My Blog.

]]>
import type { Express } from “express”;
import { Readable } from “node:stream”;
import { pipeline } from “node:stream/promises”;
import type { ReadableStream as NodeReadableStream } from “node:stream/web”;

const MPEG_TS_CONTENT_TYPE = “video/mp2t”;

/**
* Streams one server-configured live source through the site’s own HTTPS origin.
* The source URL is never accepted from request parameters and must be stored in
* the LIVE_STREAM_URL server environment variable.
*/
export function registerLiveProxy(app: Express) {
app.get(“/api/live”, async (_req, res) => {
const sourceUrl = process.env.LIVE_STREAM_URL?.trim();
if (!sourceUrl) {
res.status(503).json({ error: “Live stream source is not configured.” });
return;
}

let parsedSource: URL;
try {
parsedSource = new URL(sourceUrl);
} catch {
res.status(500).json({ error: “Live stream source configuration is invalid.” });
return;
}

if (parsedSource.protocol !== “http:” && parsedSource.protocol !== “https:”) {
res.status(500).json({ error: “Live stream source must use HTTP or HTTPS.” });
return;
}

const controller = new AbortController();
res.on(“close”, () => {
if (!res.writableEnded) controller.abort();
});

try {
const upstream = await fetch(parsedSource, {
method: “GET”,
redirect: “follow”,
signal: controller.signal,
headers: {
accept: “*/*”,
“user-agent”: “Mozilla/5.0”,
},
});

if (!upstream.ok || !upstream.body) {
await upstream.body?.cancel().catch(() => undefined);
if (!res.destroyed) {
res.status(502).json({ error: “The live stream source is unavailable.” });
}
return;
}

const upstreamType = upstream.headers.get(“content-type”)?.toLowerCase() ?? “”;
if (
upstreamType &&
!upstreamType.includes(“mp2t”) &&
!upstreamType.includes(“mpeg”) &&
!upstreamType.includes(“octet-stream”)
) {
await upstream.body.cancel().catch(() => undefined);
res.status(502).json({ error: “The upstream did not return an MPEG-TS stream.” });
return;
}

res.status(200);
res.setHeader(“Content-Type”, MPEG_TS_CONTENT_TYPE);
res.setHeader(“Cache-Control”, “no-store, no-transform”);
res.setHeader(“X-Accel-Buffering”, “no”);
res.flushHeaders();

await pipeline(
Readable.fromWeb(upstream.body as unknown as NodeReadableStream),
res,
);
} catch {
if (controller.signal.aborted || res.destroyed) return;

// Never log the upstream URL: stream URLs commonly contain credentials.
console.error(“[LiveProxy] The upstream stream request failed.”);
if (!res.headersSent) {
res.status(502).json({ error: “The live stream could not be opened.” });
} else {
res.destroy();
}
}
});
}

The post TEST appeared first on My Blog.

]]>
https://wordpress.curtitvonline.top/2026/10/22/test/feed/ 0
Hello world! https://wordpress.curtitvonline.top/2026/10/22/hello-world/ https://wordpress.curtitvonline.top/2026/10/22/hello-world/#comments Thu, 22 Oct 2026 11:48:17 +0000 https://wordpress.curtitvonline.top/?p=1 Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

The post Hello world! appeared first on My Blog.

]]>
Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

The post Hello world! appeared first on My Blog.

]]>
https://wordpress.curtitvonline.top/2026/10/22/hello-world/feed/ 1