diff --git a/.env.sample b/.env.sample index 41d8695c..574fc03b 100644 --- a/.env.sample +++ b/.env.sample @@ -291,6 +291,14 @@ ENCRYPT_MEDIAFLOW_URLS=true ENCRYPT_STREMTHRU_URLS=true +# --- Forced Public proxy URL adjustments ---- +# If you'd like to force some adjustments to be made to the streaming urls generated by either proxy, you can do that here. +# This is useful when you want to use a local url for requests but have AIOStreams force the urls to use a specific host, port, and protocol. +# FORCE_PUBLIC_PROXY_HOST= +# FORCE_PUBLIC_PROXY_PORT= +# FORCE_PUBLIC_PROXY_PROTOCOL= + + # ============================================================================== # ADVANCED CONFIGURATION & LIMITS # ============================================================================== diff --git a/packages/core/src/db/users.ts b/packages/core/src/db/users.ts index 5f637e5b..7e26e56b 100644 --- a/packages/core/src/db/users.ts +++ b/packages/core/src/db/users.ts @@ -28,24 +28,11 @@ export class UserRepository { password: string ): Promise<{ uuid: string; encryptedPassword: string }> { return txQueue.enqueue(async () => { - if (password.length < 8) { + if (password.length < 6) { return Promise.reject( new APIError(constants.ErrorCode.USER_NEW_PASSWORD_TOO_SHORT) ); } - - // require at least one uppercase, one lowercase, one number, and one special character - // [@$!%*?&\-\._#~^()+=<>,;:'"`{}[\]|\\] - if ( - !/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&\-\._#~^()+=<>,;:'"`{}[\]|\\])[A-Za-z\d@$!%*?&\-\._#~^()+=<>,;:'"`{}[\]|\\]{8,}$/.test( - password - ) - ) { - return Promise.reject( - new APIError(constants.ErrorCode.USER_NEW_PASSWORD_TOO_SIMPLE) - ); - } - let validatedConfig: UserData; config.trusted = false; try { diff --git a/packages/core/src/proxy/base.ts b/packages/core/src/proxy/base.ts index 5aa25600..715d905b 100644 --- a/packages/core/src/proxy/base.ts +++ b/packages/core/src/proxy/base.ts @@ -121,7 +121,30 @@ export abstract class BaseProxy { } try { - return await this.generateStreamUrls(streams); + let urls = await this.generateStreamUrls(streams); + if ( + urls && + (Env.FORCE_PUBLIC_PROXY_HOST !== undefined || + Env.FORCE_PUBLIC_PROXY_PORT !== undefined || + Env.FORCE_PUBLIC_PROXY_PROTOCOL !== undefined) + ) { + urls = urls.map((url) => { + // modify the URL according to settings, needed when using a local URL for requests but a public stream URL is needed. + const urlObj = new URL(url); + + if (Env.FORCE_PUBLIC_PROXY_PROTOCOL !== undefined) { + urlObj.protocol = Env.FORCE_PUBLIC_PROXY_PROTOCOL; + } + if (Env.FORCE_PUBLIC_PROXY_PORT !== undefined) { + urlObj.port = Env.FORCE_PUBLIC_PROXY_PORT.toString(); + } + if (Env.FORCE_PUBLIC_PROXY_HOST !== undefined) { + urlObj.hostname = Env.FORCE_PUBLIC_PROXY_HOST; + } + return urlObj.toString(); + }); + } + return urls; } catch (error) { logger.error( `Failed to generate proxy URLs: ${error instanceof Error ? error.message : String(error)}` diff --git a/packages/core/src/utils/env.ts b/packages/core/src/utils/env.ts index 6f53d43e..29769860 100644 --- a/packages/core/src/utils/env.ts +++ b/packages/core/src/utils/env.ts @@ -378,6 +378,20 @@ export const Env = cleanEnv(process.env, { desc: 'Default timeout for the addon', }), + FORCE_PUBLIC_PROXY_HOST: host({ + default: undefined, + desc: 'Force public proxy host', + }), + FORCE_PUBLIC_PROXY_PORT: forcedPort({ + default: undefined, + desc: 'Force public proxy port', + }), + FORCE_PUBLIC_PROXY_PROTOCOL: str({ + default: undefined, + desc: 'Force public proxy protocol', + choices: ['http', 'https'], + }), + FORCE_PROXY_ENABLED: bool({ default: undefined, desc: 'Force proxy enabled', diff --git a/packages/frontend/src/components/menu/save-install.tsx b/packages/frontend/src/components/menu/save-install.tsx index ce183504..49d517cc 100644 --- a/packages/frontend/src/components/menu/save-install.tsx +++ b/packages/frontend/src/components/menu/save-install.tsx @@ -72,25 +72,8 @@ function Content() { return; } - if (newPassword.length < 8) { - requirements.push('Password must be at least 8 characters long'); - } - - if (!/[a-z]/.test(newPassword)) { - requirements.push('Password must contain at least one lowercase letter'); - } - - if (!/[A-Z]/.test(newPassword)) { - requirements.push('Password must contain at least one uppercase letter'); - } - - if (!/\d/.test(newPassword)) { - requirements.push('Password must contain at least one number'); - } - if (!/[@$!%*?&\-\._#~^()+=<>,;:'"`{}[\]|\\]/.test(newPassword)) { - requirements.push( - 'Password must contain at least one special character (@$!%*?&-._#~^()+=<>,;:\'"`{}[]|\\)' - ); + if (newPassword.length < 6) { + requirements.push('Password must be at least 6 characters long'); } setPasswordRequirements(requirements); diff --git a/packages/server/src/app.ts b/packages/server/src/app.ts index de88c2d2..ec0a23eb 100644 --- a/packages/server/src/app.ts +++ b/packages/server/src/app.ts @@ -98,7 +98,7 @@ app.get('/', (req, res) => { res.redirect('/stremio/configure'); }); -// legacy route handler +// legacy route handlers app.get('/:config?/stream/:type/:id.json', (req, res) => { const baseUrl = Env.BASE_URL || @@ -115,6 +115,9 @@ app.get('/:config?/stream/:type/:id.json', (req, res) => { ], }); }); +app.get('/:config?/configure', (req, res) => { + res.redirect('/stremio/configure'); +}); // 404 handler app.use((req, res) => { diff --git a/packages/server/src/server.ts b/packages/server/src/server.ts index 849697f6..44bfde34 100644 --- a/packages/server/src/server.ts +++ b/packages/server/src/server.ts @@ -8,7 +8,7 @@ import { logStartupInfo, } from '@aiostreams/core'; -const logger = createLogger('startup'); +const logger = createLogger('server'); async function initialiseDatabase() { try {