@@ -48,6 +48,25 @@ class EmailServiceType(str, Enum):
4848APP_NAME = "OpenAI/Codex CLI 自动注册系统"
4949APP_VERSION = "2.0.0"
5050APP_DESCRIPTION = "自动注册 OpenAI/Codex CLI 账号的系统"
51+ DEFAULT_WEBUI_HOST = "0.0.0.0"
52+ DEFAULT_WEBUI_PORT = 15555
53+ DEFAULT_WEBUI_LOCAL_HOST = "127.0.0.1"
54+
55+
56+ def build_http_url (host : str , port : int , path : str = "" ) -> str :
57+ """构造本地 HTTP URL。"""
58+ normalized_path = path if not path or path .startswith ("/" ) else f"/{ path } "
59+ return f"http://{ host } :{ port } { normalized_path } "
60+
61+
62+ def build_ws_url (host : str , port : int , path : str = "" ) -> str :
63+ """构造本地 WebSocket URL。"""
64+ normalized_path = path if not path or path .startswith ("/" ) else f"/{ path } "
65+ return f"ws://{ host } :{ port } { normalized_path } "
66+
67+
68+ DEFAULT_WEBUI_BASE_URL = build_http_url (DEFAULT_WEBUI_LOCAL_HOST , DEFAULT_WEBUI_PORT )
69+ DEFAULT_WEBUI_WS_BASE_URL = build_ws_url (DEFAULT_WEBUI_LOCAL_HOST , DEFAULT_WEBUI_PORT )
5170
5271# ============================================================================
5372# OpenAI OAuth 相关常量
@@ -57,7 +76,7 @@ class EmailServiceType(str, Enum):
5776OAUTH_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann"
5877OAUTH_AUTH_URL = "https://auth.openai.com/oauth/authorize"
5978OAUTH_TOKEN_URL = "https://auth.openai.com/oauth/token"
60- OAUTH_REDIRECT_URI = "http:// localhost:15555 /auth/callback"
79+ OAUTH_REDIRECT_URI = build_http_url ( " localhost" , DEFAULT_WEBUI_PORT , " /auth/callback")
6180OAUTH_SCOPE = "openid email profile offline_access"
6281
6382# Codex CLI 专用 OAuth 参数(用于生成 Codex 兼容的 auth.json)
@@ -280,8 +299,8 @@ def generate_random_user_info() -> dict:
280299 ("registration.max_retries" , "3" , "最大重试次数" , "registration" ),
281300 ("registration.timeout" , "120" , "超时时间(秒)" , "registration" ),
282301 ("registration.default_password_length" , "12" , "默认密码长度" , "registration" ),
283- ("webui.host" , "0.0.0.0" , "Web UI 监听主机" , "webui" ),
284- ("webui.port" , "15555" , "Web UI 监听端口" , "webui" ),
302+ ("webui.host" , DEFAULT_WEBUI_HOST , "Web UI 监听主机" , "webui" ),
303+ ("webui.port" , str ( DEFAULT_WEBUI_PORT ) , "Web UI 监听端口" , "webui" ),
285304 ("webui.debug" , "true" , "调试模式" , "webui" ),
286305]
287306
0 commit comments