Skip to content

Commit

Permalink
feat: 网关模式支持配置,默认关闭
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxi committed Aug 1, 2024
1 parent 2a1fa9f commit 53f5e7d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions xiaomusic/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,12 @@ def signal_handler(sig, frame):
# 捕获主进程的退出信号
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
port = int(config.port)
if config.enable_gate:
run_gate()
run_server(config.port + 1)
run_server(port + 1)
else:
run_server(config.port)
run_server(port)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion xiaomusic/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class Config:
os.getenv("XIAOMUSIC_REMOVE_ID3TAG", "false").lower() == "true"
)
delay_sec: int = int(os.getenv("XIAOMUSIC_DELAY_SEC", 3)) # 下一首歌延迟播放秒数
enable_gate: bool = os.getenv("XIAOMUSIC_ENABLE_GATE", "true").lower() == "true"
enable_gate: bool = os.getenv("XIAOMUSIC_ENABLE_GATE", "false").lower() == "true"

def append_keyword(self, keys, action):
for key in keys.split(","):
Expand Down
6 changes: 6 additions & 0 deletions xiaomusic/static/setting.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ <h2>小爱音箱设置面板
<option value="false">false</option>
</select>

<label for="enable_gate">开启网关(重启生效):</label>
<select id="enable_gate">
<option value="true">true</option>
<option value="false" selected>false</option>
</select>

<label for="public_port">外网访问端口(0表示跟监听端口一致):</label>
<input id="public_port" type="number" value="0"></input>

Expand Down

0 comments on commit 53f5e7d

Please sign in to comment.