mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-16 05:47:23 +08:00
Add ssl support (#4840)
* Add: add ssl authentication * Fix: unify the format for ssl config --------- Co-authored-by: LmeSzinc <lmeszincsales@gmail.com>
This commit is contained in:
committed by
GitHub
parent
4172356a9a
commit
f9602be1ba
20
gui.py
20
gui.py
@@ -40,6 +40,12 @@ def func(ev: threading.Event):
|
||||
parser.add_argument(
|
||||
"--electron", action="store_true", help="Runs by electron client."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--ssl-key", dest="ssl_key", type=str, help="SSL key file path for HTTPS support"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--ssl-cert", type=str, help="SSL certificate file path for HTTPS support"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--run",
|
||||
nargs="+",
|
||||
@@ -50,11 +56,15 @@ def func(ev: threading.Event):
|
||||
|
||||
host = args.host or State.deploy_config.WebuiHost or "0.0.0.0"
|
||||
port = args.port or int(State.deploy_config.WebuiPort) or 22267
|
||||
ssl_key = args.ssl_key or State.deploy_config.WebuiSSLKey
|
||||
ssl_cert = args.ssl_cert or State.deploy_config.WebuiSSLCert
|
||||
ssl = ssl_key is not None and ssl_cert is not None
|
||||
State.electron = args.electron
|
||||
|
||||
logger.hr("Launcher config")
|
||||
logger.attr("Host", host)
|
||||
logger.attr("Port", port)
|
||||
logger.attr("SSL", ssl)
|
||||
logger.attr("Electron", args.electron)
|
||||
logger.attr("Reload", ev is not None)
|
||||
|
||||
@@ -64,7 +74,15 @@ def func(ev: threading.Event):
|
||||
from module.logger import console_hdlr
|
||||
logger.removeHandler(console_hdlr)
|
||||
|
||||
uvicorn.run("module.webui.app:app", host=host, port=port, factory=True)
|
||||
if ssl_cert is None and ssl_key is not None:
|
||||
logger.error("SSL key provided without certificate. Please provide both SSL key and certificate.")
|
||||
elif ssl_key is None and ssl_cert is not None:
|
||||
logger.error("SSL certificate provided without key. Please provide both SSL key and certificate.")
|
||||
|
||||
if ssl:
|
||||
uvicorn.run("module.webui.app:app", host=host, port=port, factory=True, ssl_keyfile=ssl_key, ssl_certfile=ssl_cert)
|
||||
else:
|
||||
uvicorn.run("module.webui.app:app", host=host, port=port, factory=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user