web & api: rename stream to tunnel

- updated the endpoint to /tunnel
- updated status to tunnel
- fixed one incorrectly named error in web
This commit is contained in:
wukko 2024-09-05 00:26:48 +06:00
parent 49460bd16d
commit fff1c6c7a6
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2
13 changed files with 99 additions and 99 deletions

2
.github/test.sh vendored
View file

@ -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" \

View file

@ -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);
}

View file

@ -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
}
}

View file

@ -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";
}

View file

@ -41,7 +41,7 @@ export function createResponse(responseType, responseData) {
}
break;
case "stream":
case "tunnel":
response = {
url: createStream(responseData),
}

View file

@ -118,7 +118,7 @@ export default async function(obj) {
}
return {
typeId: "stream",
typeId: "tunnel",
type: "merge",
urls: [video, audioFileLink],
audioFilename: `reddit_${id}_audio`,

View file

@ -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 = () => {

View file

@ -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"
}
},
{

View file

@ -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 |

View file

@ -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!",

View file

@ -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"),
});
}
}

View file

@ -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,
}

View file

@ -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;