From e0e63d61c4ded37ea1f4936ae769f4798c82a8ec Mon Sep 17 00:00:00 2001 From: ArabCoders Date: Fri, 7 Mar 2025 20:11:21 +0300 Subject: [PATCH] for some reason, people were exposing ytptube directly to internet without any authentication. therefore, we have disabled the console access by default. --- app/library/HttpSocket.py | 4 ++++ app/library/config.py | 7 +++++-- ui/assets/css/style.css | 4 ++++ ui/layouts/default.vue | 12 ++++++------ ui/pages/console.vue | 14 ++++++++++++++ ui/pages/presets.vue | 24 +++++++++++++++++++++++- ui/pages/tasks.vue | 18 ++++++++---------- ui/stores/ConfigStore.js | 1 + 8 files changed, 65 insertions(+), 19 deletions(-) diff --git a/app/library/HttpSocket.py b/app/library/HttpSocket.py index 4ba96b6f..30ca13fc 100644 --- a/app/library/HttpSocket.py +++ b/app/library/HttpSocket.py @@ -93,6 +93,10 @@ class HttpSocket(Common): @ws_event async def cli_post(self, sid: str, data): + if not self.config.console_enabled: + await self.emitter.error("Console is disabled.", to=sid) + return + if not data: await self.emitter.emit(Events.CLI_CLOSE, {"exitcode": 0}, to=sid) return diff --git a/app/library/config.py b/app/library/config.py index a331c1ca..bea45fc9 100644 --- a/app/library/config.py +++ b/app/library/config.py @@ -143,6 +143,9 @@ class Config: secret_key: str "The secret key to use for the application." + console_enabled: bool = False + "Enable direct access to yt-dlp console." + _manual_vars: tuple = ( "temp_path", "config_path", @@ -200,6 +203,7 @@ class Config: "default_preset", "instance_title", "sentry_dsn", + "console_enabled", ) "The variables that are relevant to the frontend." @@ -353,14 +357,13 @@ class Config: # save key as bytes. if os.path.exists(key_file) and os.path.getsize(key_file) > 5: - with open(key_file,"rb") as f: + with open(key_file, "rb") as f: self.secret_key = f.read().strip() else: self.secret_key = os.urandom(32) with open(key_file, "wb") as f: f.write(self.secret_key) - self.started = time.time() def _get_attributes(self) -> dict: diff --git a/ui/assets/css/style.css b/ui/assets/css/style.css index f166f27f..58aa328c 100644 --- a/ui/assets/css/style.css +++ b/ui/assets/css/style.css @@ -259,3 +259,7 @@ hr { .is-pre { white-space: pre; } + +.has-text-bold { + font-weight: bold; +} diff --git a/ui/layouts/default.vue b/ui/layouts/default.vue index 865e86fd..d65dff04 100644 --- a/ui/layouts/default.vue +++ b/ui/layouts/default.vue @@ -5,9 +5,9 @@ - - - YTPTube + + + YTPTube : {{ config.app.instance_title }} @@ -18,8 +18,8 @@ @@ -29,7 +29,7 @@ -