Files
boss_dp/server/config.py
Your Name 51ae0756e0 哈哈
2026-02-12 17:10:05 +08:00

31 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
"""
服务器配置。
可通过环境变量或直接修改此文件调整。
"""
import os
# ─── 服务 ───
HOST: str = os.getenv("SERVER_HOST", "0.0.0.0")
PORT: int = int(os.getenv("SERVER_PORT", "9000")) # 云服务器主端口
# ─── WebSocket ───
WS_PATH: str = "/ws" # Worker 连接端点
HEARTBEAT_INTERVAL: int = 30 # 期望 Worker 心跳间隔(秒)
HEARTBEAT_TIMEOUT: int = 90 # 超时未收到心跳视为离线(秒)
# ─── 安全(可选) ───
API_TOKEN: str = os.getenv("API_TOKEN", "") # 非空时校验 Header: Authorization: Bearer <token>
# ─── 数据库MySQL ───
DB_HOST: str = os.getenv("DB_HOST", "8.137.99.82")
DB_PORT: int = int(os.getenv("DB_PORT", "3306"))
DB_USER: str = os.getenv("DB_USER", "boss_dp")
DB_PASSWORD: str = os.getenv("DB_PASSWORD", "H7sEY3t4YbF6Jp2h")
DB_NAME: str = os.getenv("DB_NAME", "boss_dp")
# ─── 隧道(内网穿透) ───
TUNNEL_CONTROL_PORT: int = int(os.getenv("TUNNEL_CONTROL_PORT", "9090")) # 隧道控制端口(客户端连接)
TUNNEL_STREAM_PORT: int = int(os.getenv("TUNNEL_STREAM_PORT", "9091")) # 隧道流端口(桥接用)
TUNNEL_PROXY_BASE_PORT: int = int(os.getenv("TUNNEL_PROXY_BASE_PORT", "9001")) # 代理端口起始9001=第一台, 9002=第二台, 依次递增)