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)
|
alpine)
|
||||||
PKG_MGR="apk"
|
PKG_MGR="apk"
|
||||||
;;
|
;;
|
||||||
centos|rhel|rocky|almalinux|fedora)
|
centos|rhel|rocky|almalinux|fedora|ol|amzn)
|
||||||
if command -v dnf >/dev/null 2>&1; then
|
if command -v dnf >/dev/null 2>&1; then
|
||||||
PKG_MGR="dnf"
|
PKG_MGR="dnf"
|
||||||
else
|
else
|
||||||
@@ -37,7 +37,7 @@ case "$OS_TYPE" in
|
|||||||
fi
|
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
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -71,7 +71,7 @@ elif [ "$PKG_MGR" = "apk" ]; then
|
|||||||
apk add openvpn curl git ca-certificates iptables iproute2 psmisc python3 bash
|
apk add openvpn curl git ca-certificates iptables iproute2 psmisc python3 bash
|
||||||
elif [ "$PKG_MGR" = "dnf" ] || [ "$PKG_MGR" = "yum" ]; then
|
elif [ "$PKG_MGR" = "dnf" ] || [ "$PKG_MGR" = "yum" ]; then
|
||||||
echo -e " -> 正在运行 $PKG_MGR 安装基础依赖包..."
|
echo -e " -> 正在运行 $PKG_MGR 安装基础依赖包..."
|
||||||
if [ "$OS_TYPE" != "fedora" ]; then
|
if [ "$OS_TYPE" != "fedora" ] && [ "$OS_TYPE" != "amzn" ]; then
|
||||||
echo -e " -> 正在安装 EPEL 软件源 (以支持 openvpn)..."
|
echo -e " -> 正在安装 EPEL 软件源 (以支持 openvpn)..."
|
||||||
$PKG_MGR install -y epel-release || true
|
$PKG_MGR install -y epel-release || true
|
||||||
fi
|
fi
|
||||||
|
|||||||
+39
-12
@@ -1023,7 +1023,7 @@ def test_multiple_nodes(node_ids: list[str]) -> list[dict[str, Any]]:
|
|||||||
return temp_node
|
return temp_node
|
||||||
|
|
||||||
updated_nodes_map = {}
|
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:
|
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)}
|
futures = {executor.submit(test_worker, (idx, n)): n["id"] for idx, n in enumerate(to_test)}
|
||||||
for future in concurrent.futures.as_completed(futures):
|
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()
|
ui_cfg = load_ui_config()
|
||||||
routing_mode = ui_cfg.get("routing_mode", "auto")
|
routing_mode = ui_cfg.get("routing_mode", "auto")
|
||||||
connection_enabled = ui_cfg.get("connection_enabled", True)
|
connection_enabled = ui_cfg.get("connection_enabled", True)
|
||||||
if connection_enabled and routing_mode != "fixed_ip":
|
if connection_enabled:
|
||||||
has_active_id = False
|
if routing_mode == "fixed_ip":
|
||||||
with lock:
|
target_id = active_openvpn_node_id or ui_cfg.get("fixed_node_id", "")
|
||||||
if active_openvpn_node_id:
|
if target_id:
|
||||||
has_active_id = True
|
nodes = read_json(NODES_FILE, [])
|
||||||
stop_active_openvpn()
|
if any(n.get("id") == target_id for n in nodes):
|
||||||
if has_active_id:
|
print(f"[维护线程] 检测到固定 IP 模式下 OpenVPN 未运行,正在重新拉起同一节点: {target_id}", flush=True)
|
||||||
print("[维护线程] 检测到当前 OpenVPN 进程已意外退出,准备自动切换节点", flush=True)
|
is_connecting = False
|
||||||
is_connecting = False
|
try:
|
||||||
auto_switch_node()
|
connect_node(target_id)
|
||||||
is_connecting = True
|
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:
|
try:
|
||||||
set_state(is_connecting=True, last_check_message="正在拉取最新的免费 VPN 节点列表...")
|
set_state(is_connecting=True, last_check_message="正在拉取最新的免费 VPN 节点列表...")
|
||||||
@@ -3486,6 +3499,13 @@ function updateHeaderRoutingControls() {
|
|||||||
selectCountry.value = "";
|
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";
|
selectIpType.value = state.routing_ip_type || "all";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4213,6 +4233,13 @@ def background_proxy_checker() -> None:
|
|||||||
active_node["probe_status"] = "unavailable"
|
active_node["probe_status"] = "unavailable"
|
||||||
write_json(NODES_FILE, nodes)
|
write_json(NODES_FILE, nodes)
|
||||||
auto_switch_node()
|
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:
|
except Exception as e:
|
||||||
print(f"[错误] 代理后台检测发生异常: {e}", flush=True)
|
print(f"[错误] 代理后台检测发生异常: {e}", flush=True)
|
||||||
log_to_json("ERROR", "Proxy", f"检测守护线程发生异常: {e}")
|
log_to_json("ERROR", "Proxy", f"检测守护线程发生异常: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user