feat(ping): add fallback mechanism for interface resolution by querying MikroTik routes based on gateway IP
Publish Fast Tabler Docker image / build-and-push-fast (push) Failing after 1m8s

This commit is contained in:
2026-02-10 23:03:55 +07:00
parent de6fd2dddb
commit e914b0003c
+24
View File
@@ -366,6 +366,30 @@ async function pingViaInterface(req, res) {
}
}
}
// 3) Если даже из /network-config не смогли получить interface —
// пробуем вытащить его напрямую из маршрутов MikroTik по полю gateway.
if (!ifaceName) {
try {
const routeRes = await client.command('ip/route/print', {
'.proplist': ['gateway'],
'.query': [`gateway~${gatewayIp}`],
});
const data = routeRes?.data;
const routes = Array.isArray(data) ? data : (data ? [data] : []);
const match = routes.find((r) => typeof r.gateway === 'string' && r.gateway.includes(gatewayIp));
if (match && typeof match.gateway === 'string') {
const gwStr = match.gateway;
const percentIdx = gwStr.indexOf('%');
if (percentIdx >= 0 && percentIdx < gwStr.length - 1) {
ifaceName = gwStr.slice(percentIdx + 1);
}
}
} catch (_) {
// Если чтение маршрутов не удалось — просто продолжаем без interface,
// чтобы не ломать сам ping.
}
}
}
const body = {};