Skip to content

Commit dc7425a

Browse files
committed
disable access to extension stuff for non-local servers
1 parent f17769c commit dc7425a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

modules/shared.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
parser.add_argument("--always-batch-cond-uncond", action='store_true', help="disables cond/uncond batching that is enabled to save memory with --medvram or --lowvram")
4141
parser.add_argument("--unload-gfpgan", action='store_true', help="does not do anything.")
4242
parser.add_argument("--precision", type=str, help="evaluate at this precision", choices=["full", "autocast"], default="autocast")
43-
parser.add_argument("--share", action='store_true', help="use share=True for gradio and make the UI accessible through their site (doesn't work for me but you might have better luck)")
43+
parser.add_argument("--share", action='store_true', help="use share=True for gradio and make the UI accessible through their site")
4444
parser.add_argument("--ngrok", type=str, help="ngrok authtoken, alternative to gradio --share", default=None)
4545
parser.add_argument("--ngrok-region", type=str, help="The region in which ngrok should start.", default="us")
4646
parser.add_argument("--codeformer-models-path", type=str, help="Path to directory with codeformer model file(s).", default=os.path.join(models_path, 'Codeformer'))
@@ -97,6 +97,9 @@
9797
"outdir_save",
9898
}
9999

100+
if cmd_opts.share or cmd_opts.listen:
101+
cmd_opts.disable_extension_access = True
102+
100103
devices.device, devices.device_interrogate, devices.device_gfpgan, devices.device_swinir, devices.device_esrgan, devices.device_scunet, devices.device_codeformer = \
101104
(devices.cpu if any(y in cmd_opts.use_cpu for y in [x, 'all']) else devices.get_optimal_device() for x in ['sd', 'interrogate', 'gfpgan', 'swinir', 'esrgan', 'scunet', 'codeformer'])
102105

modules/ui_extensions.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313
from modules import extensions, shared, paths
1414

1515

16+
def check_access():
17+
assert not shared.cmd_opts.disable_extension_access, "extension access disabed because of commandline flags"
18+
19+
1620
def apply_and_restart(disable_list, update_list):
21+
check_access()
22+
1723
disabled = json.loads(disable_list)
1824
assert type(disabled) == list, f"wrong disable_list data for apply_and_restart: {disable_list}"
1925

@@ -40,6 +46,8 @@ def apply_and_restart(disable_list, update_list):
4046

4147

4248
def check_updates():
49+
check_access()
50+
4351
for ext in extensions.extensions:
4452
if ext.remote is None:
4553
continue
@@ -89,6 +97,8 @@ def extension_table():
8997

9098

9199
def install_extension_from_url(dirname, url):
100+
check_access()
101+
92102
assert url, 'No URL specified'
93103

94104
if dirname is None or dirname == "":

0 commit comments

Comments
 (0)