@torrent-tv/proxy 2.5.11 → 2.5.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +5 -0
- package/package.json +1 -1
- package/server.js +3 -1
- package/services/webrtc-manager.js +3 -1
- package/utils/logger.js +14 -4
package/bin/cli.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { Command } from "commander";
|
|
12
12
|
import crypto from "node:crypto";
|
|
13
13
|
import { spawnSync } from "node:child_process";
|
|
14
|
+
import { createRequire } from "node:module";
|
|
14
15
|
import ffmpegStatic from "ffmpeg-static";
|
|
15
16
|
import { startProxyServer } from "../server.js";
|
|
16
17
|
import { registerClient } from "../services/registry-api.js";
|
|
@@ -20,6 +21,9 @@ import { createDataChannelHandler } from "../services/data-channel-handler.js";
|
|
|
20
21
|
import { collectHealthMetrics } from "../services/health-collector.js";
|
|
21
22
|
import { logger } from "../utils/logger.js";
|
|
22
23
|
|
|
24
|
+
const require = createRequire(import.meta.url);
|
|
25
|
+
const { version: PROXY_VERSION } = require("../package.json");
|
|
26
|
+
|
|
23
27
|
const program = new Command();
|
|
24
28
|
|
|
25
29
|
const HELP_EXAMPLES = `
|
|
@@ -205,6 +209,7 @@ try {
|
|
|
205
209
|
actualPort = started.port;
|
|
206
210
|
const directBaseUrl = explicitBaseUrl || `http://${bindHost}:${actualPort}`;
|
|
207
211
|
|
|
212
|
+
logger.info(`Starting @torrent-tv/proxy v${PROXY_VERSION}`);
|
|
208
213
|
logger.info(`Local stream endpoint: http://${bindHost}:${actualPort}/stream`);
|
|
209
214
|
logger.info(`Advertised direct URL: ${directBaseUrl}`);
|
|
210
215
|
if (transcodeAudio) {
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -62,7 +62,9 @@ function buildPortCandidates(startPort, maxAttempts = 51) {
|
|
|
62
62
|
*/
|
|
63
63
|
export async function startProxyServer({ host, port, transcodeAudio, ffmpegBin }) {
|
|
64
64
|
const app = Fastify({
|
|
65
|
-
|
|
65
|
+
// No practical body-size limit — the proxy server is localhost-only and
|
|
66
|
+
// receives torrent source payloads that may be arbitrarily large.
|
|
67
|
+
bodyLimit: 256 * 1024 * 1024 // 256 MB
|
|
66
68
|
});
|
|
67
69
|
|
|
68
70
|
await app.register(fastifyHelmet, {
|
|
@@ -147,7 +147,9 @@ export function createWebRtcManager({ sendSignal, onDataChannel, onLog }) {
|
|
|
147
147
|
|
|
148
148
|
pc.onStateChange((state) => {
|
|
149
149
|
log(`[webrtc] Session ${sessionId.slice(0, 8)}: state → ${state}`);
|
|
150
|
-
|
|
150
|
+
// "disconnected" is a transient state — ICE may recover on its own.
|
|
151
|
+
// Only tear down on terminal states: "failed" and "closed".
|
|
152
|
+
if (state === "failed" || state === "closed") {
|
|
151
153
|
closeSession(sessionId);
|
|
152
154
|
}
|
|
153
155
|
});
|
package/utils/logger.js
CHANGED
|
@@ -9,6 +9,16 @@ import chalk from "chalk";
|
|
|
9
9
|
|
|
10
10
|
const PREFIX = "[proxy-client]";
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Return the current time as a compact ISO-8601 string, e.g. `12:34:56.789`.
|
|
14
|
+
* Uses only the time portion to keep log lines short.
|
|
15
|
+
*
|
|
16
|
+
* @returns {string}
|
|
17
|
+
*/
|
|
18
|
+
function ts() {
|
|
19
|
+
return new Date().toISOString().slice(11, 23); // "HH:MM:SS.mmm"
|
|
20
|
+
}
|
|
21
|
+
|
|
12
22
|
/**
|
|
13
23
|
* @typedef {Object} ProxyLogger
|
|
14
24
|
* @property {(message: string) => void} info - Informational message (cyan).
|
|
@@ -23,8 +33,8 @@ const PREFIX = "[proxy-client]";
|
|
|
23
33
|
* @type {ProxyLogger}
|
|
24
34
|
*/
|
|
25
35
|
export const logger = {
|
|
26
|
-
info: (message) => console.log(chalk.cyan(`${PREFIX} ${message}`)),
|
|
27
|
-
success: (message) => console.log(chalk.green(`${PREFIX} ${message}`)),
|
|
28
|
-
warn: (message) => console.warn(chalk.yellow(`${PREFIX} ${message}`)),
|
|
29
|
-
error: (message) => console.error(chalk.red(`${PREFIX} ${message}`)),
|
|
36
|
+
info: (message) => console.log(chalk.cyan(`${PREFIX} [${ts()}] ${message}`)),
|
|
37
|
+
success: (message) => console.log(chalk.green(`${PREFIX} [${ts()}] ${message}`)),
|
|
38
|
+
warn: (message) => console.warn(chalk.yellow(`${PREFIX} [${ts()}] ${message}`)),
|
|
39
|
+
error: (message) => console.error(chalk.red(`${PREFIX} [${ts()}] ${message}`)),
|
|
30
40
|
};
|