mirror of
https://github.com/baoweise-bot/aimili-vpngate.git
synced 2026-09-08 17:26:46 +08:00
Fix Fixed IP reconnection, cap concurrent workers, and add Oracle/Amazon Linux support
This commit is contained in:
+3
-3
@@ -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
|
||||
|
||||
+29
-2
@@ -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,7 +1247,20 @@ 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":
|
||||
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:
|
||||
@@ -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}")
|
||||
|
||||
Reference in New Issue
Block a user