|
34 | 34 | import modules.hypernetworks.hypernetwork
|
35 | 35 |
|
36 | 36 | queue_lock = threading.Lock()
|
37 |
| - |
| 37 | +server_name = "0.0.0.0" if cmd_opts.listen else cmd_opts.server_name |
38 | 38 |
|
39 | 39 | def wrap_queued_call(func):
|
40 | 40 | def f(*args, **kwargs):
|
@@ -85,6 +85,22 @@ def initialize():
|
85 | 85 | shared.opts.onchange("sd_hypernetwork", wrap_queued_call(lambda: modules.hypernetworks.hypernetwork.load_hypernetwork(shared.opts.sd_hypernetwork)))
|
86 | 86 | shared.opts.onchange("sd_hypernetwork_strength", modules.hypernetworks.hypernetwork.apply_strength)
|
87 | 87 |
|
| 88 | + if cmd_opts.tls_keyfile is not None and cmd_opts.tls_keyfile is not None: |
| 89 | + |
| 90 | + try: |
| 91 | + if not os.path.exists(cmd_opts.tls_keyfile): |
| 92 | + print("Invalid path to TLS keyfile given") |
| 93 | + if not os.path.exists(cmd_opts.tls_certfile): |
| 94 | + print(f"Invalid path to TLS certfile: '{cmd_opts.tls_certfile}'") |
| 95 | + except TypeError: |
| 96 | + cmd_opts.tls_keyfile = cmd_opts.tls_certfile = None |
| 97 | + print(f"path: '{cmd_opts.tls_keyfile}' {type(cmd_opts.tls_keyfile)}") |
| 98 | + print(f"path: '{cmd_opts.tls_certfile}' {type(cmd_opts.tls_certfile)}") |
| 99 | + print("TLS setup invalid, running webui without TLS") |
| 100 | + else: |
| 101 | + print("Running with TLS") |
| 102 | + |
| 103 | + |
88 | 104 | # make the program just exit at ctrl+c without waiting for anything
|
89 | 105 | def sigint_handler(sig, frame):
|
90 | 106 | print(f'Interrupted with signal {sig} in {frame}')
|
@@ -131,8 +147,10 @@ def webui():
|
131 | 147 |
|
132 | 148 | app, local_url, share_url = demo.launch(
|
133 | 149 | share=cmd_opts.share,
|
134 |
| - server_name="0.0.0.0" if cmd_opts.listen else None, |
| 150 | + server_name=server_name, |
135 | 151 | server_port=cmd_opts.port,
|
| 152 | + ssl_keyfile=cmd_opts.tls_keyfile, |
| 153 | + ssl_certfile=cmd_opts.tls_certfile, |
136 | 154 | debug=cmd_opts.gradio_debug,
|
137 | 155 | auth=[tuple(cred.split(':')) for cred in cmd_opts.gradio_auth.strip('"').split(',')] if cmd_opts.gradio_auth else None,
|
138 | 156 | inbrowser=cmd_opts.autolaunch,
|
|
0 commit comments