diff --git a/.github/test.sh b/.github/test.sh index c3bc1fb7..e46f4ad6 100755 --- a/.github/test.sh +++ b/.github/test.sh @@ -23,7 +23,7 @@ test_api() { echo "API_RESPONSE=$API_RESPONSE" STATUS=$(echo "$API_RESPONSE" | jq -r .status) STREAM_URL=$(echo "$API_RESPONSE" | jq -r .url) - [ "$STATUS" = stream ] || exit 1; + [ "$STATUS" = tunnel ] || exit 1; S=$(curl -I -m 3 "$STREAM_URL") CONTENT_LENGTH=$(echo "$S" \ diff --git a/api/src/core/api.js b/api/src/core/api.js index 5b0d6efd..8b0faa4d 100644 --- a/api/src/core/api.js +++ b/api/src/core/api.js @@ -141,7 +141,7 @@ export const runAPI = (express, app, __dirname) => { }); app.post('/', apiLimiter); - app.use('/stream', apiLimiterStream); + app.use('/tunnel', apiLimiterStream); app.use('/', express.json({ limit: 1024 })); app.use('/', (err, _, res, next) => { @@ -225,7 +225,7 @@ export const runAPI = (express, app, __dirname) => { } }) - app.get('/stream', (req, res) => { + app.get('/tunnel', (req, res) => { const id = String(req.query.id); const exp = String(req.query.exp); const sig = String(req.query.sig); @@ -256,7 +256,7 @@ export const runAPI = (express, app, __dirname) => { return stream(res, streamInfo); }) - app.get('/istream', (req, res) => { + app.get('/itunnel', (req, res) => { if (!req.ip.endsWith('127.0.0.1')) { return res.sendStatus(403); } diff --git a/api/src/misc/run-test.js b/api/src/misc/run-test.js index 9ac4dbcb..10d19aef 100644 --- a/api/src/misc/run-test.js +++ b/api/src/misc/run-test.js @@ -38,7 +38,7 @@ export async function runTest(url, params, expect) { throw error.join('\n'); } - if (result.body.status === 'stream') { + if (result.body.status === 'tunnel') { // TODO: stream testing } } \ No newline at end of file diff --git a/api/src/processing/match-action.js b/api/src/processing/match-action.js index 0fd2b32b..b8e39355 100644 --- a/api/src/processing/match-action.js +++ b/api/src/processing/match-action.js @@ -6,7 +6,7 @@ import { createStream } from "../stream/manage.js"; export default function({ r, host, audioFormat, isAudioOnly, isAudioMuted, disableMetadata, filenameStyle, twitterGif, requestIP, audioBitrate, alwaysProxy }) { let action, - responseType = "stream", + responseType = "tunnel", defaultParams = { u: r.urls, headers: r.headers, @@ -197,7 +197,7 @@ export default function({ r, host, audioFormat, isAudioOnly, isAudioMuted, disab } if (alwaysProxy && responseType === "redirect") { - responseType = "stream"; + responseType = "tunnel"; params.type = "proxy"; } diff --git a/api/src/processing/request.js b/api/src/processing/request.js index 404821db..7add3006 100644 --- a/api/src/processing/request.js +++ b/api/src/processing/request.js @@ -41,7 +41,7 @@ export function createResponse(responseType, responseData) { } break; - case "stream": + case "tunnel": response = { url: createStream(responseData), } diff --git a/api/src/processing/services/reddit.js b/api/src/processing/services/reddit.js index 30084599..701db236 100644 --- a/api/src/processing/services/reddit.js +++ b/api/src/processing/services/reddit.js @@ -118,7 +118,7 @@ export default async function(obj) { } return { - typeId: "stream", + typeId: "tunnel", type: "merge", urls: [video, audioFileLink], audioFilename: `reddit_${id}_audio`, diff --git a/api/src/stream/manage.js b/api/src/stream/manage.js index fcac78ac..a842256f 100644 --- a/api/src/stream/manage.js +++ b/api/src/stream/manage.js @@ -53,7 +53,7 @@ export function createStream(obj) { encryptStream(streamData, iv, secret) ) - let streamLink = new URL('/stream', env.apiURL); + let streamLink = new URL('/tunnel', env.apiURL); const params = { 'id': streamID, @@ -103,7 +103,7 @@ export function createInternalStream(url, obj = {}) { dispatcher }; - let streamLink = new URL('/istream', `http://127.0.0.1:${env.apiPort}`); + let streamLink = new URL('/itunnel', `http://127.0.0.1:${env.apiPort}`); streamLink.searchParams.set('id', streamID); const cleanup = () => { diff --git a/api/src/util/tests.json b/api/src/util/tests.json index dcf11757..2b20759b 100644 --- a/api/src/util/tests.json +++ b/api/src/util/tests.json @@ -62,7 +62,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -74,7 +74,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -86,7 +86,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -98,7 +98,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -168,7 +168,7 @@ "canFail": true, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -203,7 +203,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -215,7 +215,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -226,7 +226,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -238,7 +238,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -250,7 +250,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -259,7 +259,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -268,7 +268,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -277,7 +277,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } } ], @@ -291,7 +291,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -303,7 +303,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -315,7 +315,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -327,7 +327,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -340,7 +340,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -353,7 +353,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -367,7 +367,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -381,7 +381,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -393,7 +393,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -404,7 +404,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -416,7 +416,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -436,7 +436,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -448,7 +448,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -457,7 +457,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -477,7 +477,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -488,7 +488,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -499,7 +499,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -508,7 +508,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -519,7 +519,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -528,7 +528,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -548,7 +548,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -586,7 +586,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -597,7 +597,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -606,7 +606,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -617,7 +617,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -626,7 +626,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -635,7 +635,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } } ], @@ -673,7 +673,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -684,7 +684,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } } ], @@ -759,7 +759,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -770,7 +770,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -781,7 +781,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -808,7 +808,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } } ], @@ -857,7 +857,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -868,7 +868,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -953,7 +953,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -964,7 +964,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } } ], @@ -986,7 +986,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -997,7 +997,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -1082,7 +1082,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -1093,7 +1093,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -1113,7 +1113,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -1124,7 +1124,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -1135,7 +1135,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } } ], @@ -1146,7 +1146,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -1157,7 +1157,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -1175,7 +1175,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -1185,7 +1185,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -1194,7 +1194,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -1205,7 +1205,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -1216,7 +1216,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -1225,7 +1225,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } } ], @@ -1236,7 +1236,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } } ], @@ -1247,7 +1247,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -1256,7 +1256,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -1265,7 +1265,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } } ], @@ -1316,7 +1316,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -1405,7 +1405,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -1414,7 +1414,7 @@ "params": {}, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -1425,7 +1425,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { @@ -1436,7 +1436,7 @@ }, "expected": { "code": 200, - "status": "stream" + "status": "tunnel" } }, { diff --git a/docs/api.md b/docs/api.md index 1c9b880f..2e7958ac 100644 --- a/docs/api.md +++ b/docs/api.md @@ -39,13 +39,13 @@ the response will always be a JSON object containing the `status` key, which wil - `error` - something went wrong - `picker` - we have multiple items to choose from - `redirect` - you are being redirected to the direct service URL -- `stream` - cobalt is proxying the download for you +- `tunnel` - cobalt is proxying the download for you -### stream/redirect response +### tunnel/redirect response | key | type | values | |:-------------|:---------|:------------------------------------------------------------| -| `status` | `string` | `stream / redirect` | -| `url` | `string` | url for the cobalt stream, or redirect to an external link | +| `status` | `string` | `tunnel / redirect` | +| `url` | `string` | url for the cobalt tunnel, or redirect to an external link | ### picker response | key | type | values | diff --git a/web/i18n/en/error.json b/web/i18n/en/error.json index ababc687..9776db20 100644 --- a/web/i18n/en/error.json +++ b/web/i18n/en/error.json @@ -4,7 +4,7 @@ "import.unknown": "couldn't load data from the file. it may be corrupted or of wrong format. here's the error i got:\n\n{{ value }}", "remux.corrupted": "couldn't read the metadata from this file, it may be corrupted.", - "stream.probe": "couldn't verify whether you can download this file. try again in a few seconds!", + "tunnel.probe": "couldn't verify whether you can download this file. try again in a few seconds!", "api.auth.jwt.missing": "couldn't confirm whether you're not a robot because the processing server didn't receive the human access token. try again in a few seconds or reload the page!", "api.auth.jwt.invalid": "couldn't confirm whether you're not a robot because your human access token expired and wasn't renewed. try again in a few seconds or reload the page!", diff --git a/web/src/components/save/buttons/DownloadButton.svelte b/web/src/components/save/buttons/DownloadButton.svelte index a75f7823..c8424494 100644 --- a/web/src/components/save/buttons/DownloadButton.svelte +++ b/web/src/components/save/buttons/DownloadButton.svelte @@ -87,10 +87,10 @@ return downloadFile(response.url); } - if (response.status === "stream") { + if (response.status === "tunnel") { changeDownloadButton("check"); - const probeResult = await API.probeCobaltStream(response.url); + const probeResult = await API.probeCobaltTunnel(response.url); if (probeResult === 200) { changeDownloadButton("done"); @@ -101,7 +101,7 @@ return createDialog({ ...defaultErrorPopup, - bodyText: $t("error.stream.failed_probe"), + bodyText: $t("error.tunnel.probe"), }); } } diff --git a/web/src/lib/api/api.ts b/web/src/lib/api/api.ts index ee8f5f0c..6d73390e 100644 --- a/web/src/lib/api/api.ts +++ b/web/src/lib/api/api.ts @@ -79,7 +79,7 @@ const request = async (url: string) => { return response; } -const probeCobaltStream = async (url: string) => { +const probeCobaltTunnel = async (url: string) => { const request = await fetch(`${url}&p=1`).catch(() => {}); if (request?.status === 200) { return request?.status; @@ -89,5 +89,5 @@ const probeCobaltStream = async (url: string) => { export default { request, - probeCobaltStream, + probeCobaltTunnel, } diff --git a/web/src/lib/types/api.ts b/web/src/lib/types/api.ts index 7ffae099..c7823639 100644 --- a/web/src/lib/types/api.ts +++ b/web/src/lib/types/api.ts @@ -2,7 +2,7 @@ enum CobaltResponseType { Error = 'error', Picker = 'picker', Redirect = 'redirect', - Stream = 'stream', + Tunnel = 'tunnel', } export type CobaltErrorResponse = { @@ -34,8 +34,8 @@ type CobaltRedirectResponse = { status: CobaltResponseType.Redirect, } & CobaltPartialURLResponse; -type CobaltStreamResponse = { - status: CobaltResponseType.Stream, +type CobaltTunnelResponse = { + status: CobaltResponseType.Tunnel, } & CobaltPartialURLResponse; export type CobaltSession = { @@ -64,4 +64,4 @@ export type CobaltServerInfoResponse = CobaltServerInfo | CobaltErrorResponse; export type CobaltAPIResponse = CobaltErrorResponse | CobaltPickerResponse | CobaltRedirectResponse - | CobaltStreamResponse; + | CobaltTunnelResponse;