mirror of
https://github.com/FoxxMD/multi-scrobbler.git
synced 2026-09-03 05:10:00 +03:00
feat: Implement option for disabling web server #150
If a user does not need the dashboard or has security concerns about ingress and cannot control their hosting environment this enables reducing attack surface. Closes #150
This commit is contained in:
@@ -45,6 +45,13 @@ export interface AIOConfig {
|
||||
|
||||
logging?: LogOptions
|
||||
|
||||
/**
|
||||
* Disable web server from running/listening on port.
|
||||
*
|
||||
* This will also make any ingress sources (Plex, Jellyfin, Tautulli, etc...) unusable
|
||||
* */
|
||||
disableWeb?: boolean
|
||||
|
||||
/**
|
||||
* Enables ALL relevant logging and debug options for all sources/clients, when none are defined.
|
||||
*
|
||||
|
||||
@@ -47,19 +47,26 @@ export interface RootOptions {
|
||||
baseUrl?: string,
|
||||
port?: string | number
|
||||
logger: Logger
|
||||
disableWeb?: boolean
|
||||
}
|
||||
|
||||
const createRoot = (options?: RootOptions) => {
|
||||
const {
|
||||
port = 9078,
|
||||
baseUrl = process.env.BASE_URL,
|
||||
disableWeb: dw
|
||||
} = options || {};
|
||||
const configDir = process.env.CONFIG_DIR || path.resolve(projectDir, `./config`);
|
||||
let disableWeb = dw;
|
||||
if(disableWeb === undefined) {
|
||||
disableWeb = process.env.DISABLE_WEB === 'true';
|
||||
}
|
||||
return createContainer().add({
|
||||
version,
|
||||
configDir: configDir,
|
||||
isProd: process.env.NODE_ENV !== undefined && (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'prod'),
|
||||
port: process.env.PORT ?? port,
|
||||
disableWeb,
|
||||
clientEmitter: () => new WildcardEmitter(),
|
||||
sourceEmitter: () => new WildcardEmitter(),
|
||||
notifierEmitter: () => new EventEmitter(),
|
||||
|
||||
@@ -35,6 +35,11 @@ export const initServer = async (parentLogger: Logger, appLoggerStream: PassThro
|
||||
|
||||
const root = getRoot();
|
||||
|
||||
if(root.get('disableWeb')) {
|
||||
logger.warn('API and Dashboard have been DISABLED. Note that any ingress sources (Plex, Jellyfin, Tautulli, etc...) will be unusable');
|
||||
return;
|
||||
}
|
||||
|
||||
const isProd = root.get('isProd');
|
||||
const port = root.get('port');
|
||||
const local = root.get('localUrl');
|
||||
|
||||
Reference in New Issue
Block a user