From 7cb00eac17866bed1c59f206bb1701f2ce9f1dcf Mon Sep 17 00:00:00 2001 From: Karasukaigan <80465610+Karasukaigan@users.noreply.github.com> Date: Sun, 4 May 2025 18:28:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9C=AC=E5=9C=B0=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E9=85=8D=E7=BD=AE=EF=BC=8C=E5=90=AF=E7=94=A8=E5=90=8E?= =?UTF-8?q?=E4=BB=85=E5=85=81=E8=AE=B8=E6=9C=AC=E6=9C=BA=E8=AE=BF=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在`config.py`新增`local_mode`本地模式开关,默认关闭,启用后服务仅限本机访问(127.0.0.1或localhost),可以提升开发调试时的安全性。 --- config.py | 3 +++ webui.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index 5f90c5cd..fe0bf4d1 100644 --- a/config.py +++ b/config.py @@ -30,6 +30,9 @@ webui_port_subfix = 9871 api_port = 9880 +# 设置为True可启用本地模式,该模式只允许本机访问,避免出现潜在安全问题。默认为False。 +local_mode = False + if infer_device == "cuda": gpu_name = torch.cuda.get_device_name(0) if ( diff --git a/webui.py b/webui.py index cddbb029..edaeafe8 100644 --- a/webui.py +++ b/webui.py @@ -74,6 +74,7 @@ from config import ( webui_port_main, webui_port_subfix, webui_port_uvr5, + local_mode, ) from tools import my_utils from tools.i18n.i18n import I18nAuto, scan_language_list @@ -1955,7 +1956,7 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app: gr.Markdown(value=i18n("施工中,请静候佳音")) app.queue().launch( # concurrency_count=511, max_size=1022 - server_name="0.0.0.0", + server_name="127.0.0.1" if local_mode else "0.0.0.0", inbrowser=True, share=is_share, server_port=webui_port_main,