fix(mesh): testUpstream dials via ensureBridge so proxy-mode targets are probeable (#1057)

testUpstream short-circuited on hasActiveTunnel + getBridge (pilot-only)
when probing a cross-node alias. Proxy-mode remotes never have a "pilot
tunnel" in the manager's sense, so any operator hitting "Test alias" on
a proxy-mode target returned tunnel_down even when the cross-node dial
via dialMeshTcpStream worked fine.

Replace with await ptm.ensureBridge(target.nodeId), matching the mode-
agnostic dispatch dialMeshTcpStream already uses. ensureBridge returns
an existing pilot tunnel, an existing proxy bridge, or asks
MeshProxyTunnelDialer to dial on demand. The 'no pilot tunnel' vs
'no bridge' distinction goes away (they meant the same thing).

Adds two test cases: probing a proxy-mode remote via on-demand bridge,
and the tunnel_down path when ensureBridge yields null.
This commit is contained in:
Anso
2026-05-15 09:00:39 -04:00
committed by GitHub
parent 3d5f0ffacd
commit 489aab4516
2 changed files with 83 additions and 4 deletions
+6 -4
View File
@@ -1604,11 +1604,13 @@ export class MeshService extends EventEmitter implements MeshForwarderHost {
}
if (target.nodeId !== sourceNodeId) {
// Use ensureBridge so proxy-mode remotes get a bridge dialed
// on demand. Pre-fix this called hasActiveTunnel + getBridge,
// which only checked the pilot-tunnel slot and returned
// tunnel_down for proxy-mode targets even when the regular
// dialMeshTcpStream path worked.
const ptm = PilotTunnelManager.getInstance();
if (!ptm.hasActiveTunnel(target.nodeId)) {
return { ok: false, where: 'pilot_tunnel', code: 'tunnel_down', message: 'no pilot tunnel' };
}
const bridge = ptm.getBridge(target.nodeId);
const bridge = await ptm.ensureBridge(target.nodeId);
if (!bridge) {
return { ok: false, where: 'pilot_tunnel', code: 'tunnel_down', message: 'no bridge' };
}