feat(ping): refine interface selection logic to prioritize 'ether1' and 'ether2' before falling back to other 'ether' interfaces
Publish Fast Tabler Docker image / build-and-push-fast (push) Failing after 2m49s
Publish Fast Tabler Docker image / build-and-push-fast (push) Failing after 2m49s
This commit is contained in:
@@ -393,21 +393,28 @@ async function pingViaInterface(req, res) {
|
||||
}
|
||||
|
||||
// 4) Последний фоллбек: если ifaceName до сих пор не определён,
|
||||
// пробуем взять первый интерфейс, имя которого начинается с "ether"
|
||||
// (обычно это основной WAN/LAN-порт).
|
||||
// пробуем взять первый физический порт ether1/ether2 (если есть),
|
||||
// иначе любой интерфейс с префиксом "ether".
|
||||
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;
|
||||
const names = interfaces
|
||||
.map((it) => (typeof it.name === 'string' ? it.name : null))
|
||||
.filter(Boolean);
|
||||
|
||||
let candidate = null;
|
||||
if (names.includes('ether1')) candidate = 'ether1';
|
||||
else if (names.includes('ether2')) candidate = 'ether2';
|
||||
else {
|
||||
candidate = names.find((n) => n.toLowerCase().startsWith('ether')) || null;
|
||||
}
|
||||
|
||||
if (candidate) {
|
||||
ifaceName = candidate;
|
||||
}
|
||||
} catch (_) {
|
||||
// Если не получилось прочитать интерфейсы — просто продолжаем без interface.
|
||||
|
||||
Reference in New Issue
Block a user