fix(proxy-node): tunnel 模式节点状态由连接管理,心跳不再覆盖

- resolver 中增加 tunnel 未连接节点的过滤,避免请求路由到不可达节点
- 心跳处理中 tunnel 模式节点仅更新指标,不改变在线状态
This commit is contained in:
fawney19
2026-02-26 12:50:08 +08:00
parent 27cef96789
commit 67b8eb5c2f
2 changed files with 9 additions and 1 deletions

View File

@@ -63,6 +63,11 @@ def _get_proxy_node_info(node_id: str) -> dict[str, Any] | None:
_proxy_node_cache[node_id] = (None, now + _PROXY_NODE_CACHE_TTL_SECONDS) _proxy_node_cache[node_id] = (None, now + _PROXY_NODE_CACHE_TTL_SECONDS)
return None return None
# tunnel 模式节点必须 tunnel 已连接才可用
if node.tunnel_mode and not node.tunnel_connected:
_proxy_node_cache[node_id] = (None, now + _PROXY_NODE_CACHE_TTL_SECONDS)
return None
if node.is_manual: if node.is_manual:
value: dict[str, Any] = { value: dict[str, Any] = {
"is_manual": True, "is_manual": True,

View File

@@ -273,7 +273,10 @@ class ProxyNodeService:
raise NotFoundException(f"ProxyNode {node_id} 不存在", "proxy_node") raise NotFoundException(f"ProxyNode {node_id} 不存在", "proxy_node")
now = datetime.now(timezone.utc) now = datetime.now(timezone.utc)
node.status = ProxyNodeStatus.ONLINE # tunnel 模式节点:心跳仅更新指标,不改变状态;
# 状态由 tunnel WebSocket 连接建立/断开时决定
if not node.tunnel_mode:
node.status = ProxyNodeStatus.ONLINE
node.last_heartbeat_at = now node.last_heartbeat_at = now
if heartbeat_interval is not None: if heartbeat_interval is not None:
node.heartbeat_interval = heartbeat_interval node.heartbeat_interval = heartbeat_interval