mirror of
https://github.com/Viren070/AIOStreams.git
synced 2025-12-01 23:14:04 +01:00
feat: allow forcing public proxy urls, make password requirements less strict and use server logger type for server.ts, add /configure redirect
This commit is contained in:
@@ -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
|
||||
# ==============================================================================
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)}`
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
logStartupInfo,
|
||||
} from '@aiostreams/core';
|
||||
|
||||
const logger = createLogger('startup');
|
||||
const logger = createLogger('server');
|
||||
|
||||
async function initialiseDatabase() {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user