feat(ping): implement additional fallback for interface resolution by selecting the first 'ether' interface if none is specified
Publish Fast Tabler Docker image / build-and-push-fast (push) Failing after 3m9s

This commit is contained in:
2026-02-10 23:15:21 +07:00
parent e914b0003c
commit fc66c7db0b
+22
View File
@@ -392,6 +392,28 @@ async function pingViaInterface(req, res) {
}
}
// 4) Последний фоллбек: если ifaceName до сих пор не определён,
// пробуем взять первый интерфейс, имя которого начинается с "ether"
// (обычно это основной WAN/LAN-порт).
if (!ifaceName) {
try {
const ifRes = await client.command('interface/print', {
'.proplist': ['name'],
'.query': ['name~^ether'],
});
const data = ifRes?.data;
const interfaces = Array.isArray(data) ? data : (data ? [data] : []);
const firstEther = interfaces.find(
(it) => typeof it.name === 'string' && it.name.toLowerCase().startsWith('ether'),
);
if (firstEther && typeof firstEther.name === 'string') {
ifaceName = firstEther.name;
}
} catch (_) {
// Если не получилось прочитать интерфейсы — просто продолжаем без interface.
}
}
const body = {};
body.address = target;
body.count = Number(count) > 0 ? Number(count) : 5;