From 0c2f3a84f08cb737646b231d874ffcab9d6386d1 Mon Sep 17 00:00:00 2001 From: baoweise-bot Date: Fri, 5 Jun 2026 00:18:34 +0800 Subject: [PATCH] Fix Fixed IP reconnection, cap concurrent workers, and add Oracle/Amazon Linux support --- install.sh | 6 +++--- vpngate_manager.py | 51 +++++++++++++++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/install.sh b/install.sh index 3620084..845f0dc 100644 --- a/install.sh +++ b/install.sh @@ -29,7 +29,7 @@ case "$OS_TYPE" in alpine) PKG_MGR="apk" ;; - centos|rhel|rocky|almalinux|fedora) + centos|rhel|rocky|almalinux|fedora|ol|amzn) if command -v dnf >/dev/null 2>&1; then PKG_MGR="dnf" else @@ -37,7 +37,7 @@ case "$OS_TYPE" in fi ;; *) - echo -e "${RED}错误: 不支持的操作系统 ($OS_TYPE)!目前仅支持 Ubuntu/Debian/Alpine/CentOS/RHEL/Rocky/AlmaLinux/Fedora。${PLAIN}" + echo -e "${RED}错误: 不支持的操作系统 ($OS_TYPE)!目前仅支持 Ubuntu/Debian/Alpine/CentOS/RHEL/Rocky/AlmaLinux/Fedora/OracleLinux/AmazonLinux。${PLAIN}" exit 1 ;; esac @@ -71,7 +71,7 @@ elif [ "$PKG_MGR" = "apk" ]; then apk add openvpn curl git ca-certificates iptables iproute2 psmisc python3 bash elif [ "$PKG_MGR" = "dnf" ] || [ "$PKG_MGR" = "yum" ]; then echo -e " -> 正在运行 $PKG_MGR 安装基础依赖包..." - if [ "$OS_TYPE" != "fedora" ]; then + if [ "$OS_TYPE" != "fedora" ] && [ "$OS_TYPE" != "amzn" ]; then echo -e " -> 正在安装 EPEL 软件源 (以支持 openvpn)..." $PKG_MGR install -y epel-release || true fi diff --git a/vpngate_manager.py b/vpngate_manager.py index 035d5b0..e98e2ec 100644 --- a/vpngate_manager.py +++ b/vpngate_manager.py @@ -1023,7 +1023,7 @@ def test_multiple_nodes(node_ids: list[str]) -> list[dict[str, Any]]: return temp_node updated_nodes_map = {} - max_workers = min(80, max(1, len(to_test))) + max_workers = min(30, max(1, len(to_test))) with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor: futures = {executor.submit(test_worker, (idx, n)): n["id"] for idx, n in enumerate(to_test)} for future in concurrent.futures.as_completed(futures): @@ -1247,17 +1247,30 @@ def maintain_valid_nodes(force: bool = False) -> str: ui_cfg = load_ui_config() routing_mode = ui_cfg.get("routing_mode", "auto") connection_enabled = ui_cfg.get("connection_enabled", True) - if connection_enabled and routing_mode != "fixed_ip": - has_active_id = False - with lock: - if active_openvpn_node_id: - has_active_id = True - stop_active_openvpn() - if has_active_id: - print("[维护线程] 检测到当前 OpenVPN 进程已意外退出,准备自动切换节点", flush=True) - is_connecting = False - auto_switch_node() - is_connecting = True + if connection_enabled: + if routing_mode == "fixed_ip": + target_id = active_openvpn_node_id or ui_cfg.get("fixed_node_id", "") + if target_id: + nodes = read_json(NODES_FILE, []) + if any(n.get("id") == target_id for n in nodes): + print(f"[维护线程] 检测到固定 IP 模式下 OpenVPN 未运行,正在重新拉起同一节点: {target_id}", flush=True) + is_connecting = False + try: + connect_node(target_id) + except Exception as e: + print(f"[维护线程] 重新拉起固定节点 {target_id} 失败: {e}", flush=True) + is_connecting = True + else: + has_active_id = False + with lock: + if active_openvpn_node_id: + has_active_id = True + stop_active_openvpn() + if has_active_id: + print("[维护线程] 检测到当前 OpenVPN 进程已意外退出,准备自动切换节点", flush=True) + is_connecting = False + auto_switch_node() + is_connecting = True try: set_state(is_connecting=True, last_check_message="正在拉取最新的免费 VPN 节点列表...") @@ -3486,6 +3499,13 @@ function updateHeaderRoutingControls() { selectCountry.value = ""; } + if (state.routing_mode !== "fixed_ip") { + const fixedIpOpt = selectCountry.querySelector('option[value="fixed_ip_mode"]'); + if (fixedIpOpt) { + fixedIpOpt.remove(); + } + } + selectIpType.value = state.routing_ip_type || "all"; } @@ -4213,6 +4233,13 @@ def background_proxy_checker() -> None: active_node["probe_status"] = "unavailable" write_json(NODES_FILE, nodes) auto_switch_node() + else: + print(f"[代理守护线程] 固定 IP 模式下代理不可用,正在尝试重启连接同一节点: {active_openvpn_node_id}", flush=True) + is_connecting = False + try: + connect_node(active_openvpn_node_id) + except Exception as e: + print(f"[代理守护线程] 重启固定节点失败: {e}", flush=True) except Exception as e: print(f"[错误] 代理后台检测发生异常: {e}", flush=True) log_to_json("ERROR", "Proxy", f"检测守护线程发生异常: {e}")