From 082ca98e16ef32c36ceb4c7b346f9e0d4e69d33e Mon Sep 17 00:00:00 2001 From: drakce-dev Date: Tue, 11 Mar 2025 16:24:07 +0100 Subject: [PATCH] Add static domain arg for ngrok --- modules/cmd_args.py | 1 + modules/ngrok.py | 5 +++-- modules/ui.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/cmd_args.py b/modules/cmd_args.py index d71982b2c..45d0fde4b 100644 --- a/modules/cmd_args.py +++ b/modules/cmd_args.py @@ -48,6 +48,7 @@ parser.add_argument("--share", action='store_true', help="use share=True for gra parser.add_argument("--ngrok", type=str, help="ngrok authtoken, alternative to gradio --share", default=None) parser.add_argument("--ngrok-region", type=str, help="does not do anything.", default="") parser.add_argument("--ngrok-options", type=json.loads, help='The options to pass to ngrok in JSON format, e.g.: \'{"authtoken_from_env":true, "basic_auth":"user:password", "oauth_provider":"google", "oauth_allow_emails":"user@asdf.com"}\'', default=dict()) +parser.add_argument("--ngrok-static-domain", type=str, help="Add a static domain for the ngrok tunnel", default=None) parser.add_argument("--enable-insecure-extension-access", action='store_true', help="enable extensions tab regardless of other options") parser.add_argument("--codeformer-models-path", type=normalized_filepath, help="Path to directory with codeformer model file(s).", default=os.path.join(models_path, 'Codeformer')) parser.add_argument("--gfpgan-models-path", type=normalized_filepath, help="Path to directory with GFPGAN model file(s).", default=os.path.join(models_path, 'GFPGAN')) diff --git a/modules/ngrok.py b/modules/ngrok.py index 0c713e276..17f090a48 100644 --- a/modules/ngrok.py +++ b/modules/ngrok.py @@ -1,7 +1,7 @@ import ngrok # Connect to ngrok for ingress -def connect(token, port, options): +def connect(token, port, options, domain): account = None if token is None: token = 'None' @@ -18,7 +18,8 @@ def connect(token, port, options): options['basic_auth'] = account if not options.get('session_metadata'): options['session_metadata'] = 'stable-diffusion-webui' - + if domain: + options['domain'] = domain try: public_url = ngrok.connect(f"127.0.0.1:{port}", **options).url() diff --git a/modules/ui.py b/modules/ui.py index f48638f69..fe9ba4ae1 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -55,7 +55,8 @@ if cmd_opts.ngrok is not None: ngrok.connect( cmd_opts.ngrok, cmd_opts.port if cmd_opts.port is not None else 7860, - cmd_opts.ngrok_options + cmd_opts.ngrok_options, + cmd_opts.ngrok_static_domain )