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
Publish Fast Tabler Docker image / build-and-push-fast (push) Failing after 3m9s
This commit is contained in:
@@ -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 = {};
|
const body = {};
|
||||||
body.address = target;
|
body.address = target;
|
||||||
body.count = Number(count) > 0 ? Number(count) : 5;
|
body.count = Number(count) > 0 ? Number(count) : 5;
|
||||||
|
|||||||
Reference in New Issue
Block a user