feat(MikrotikTools): enhance traceroute output with reverse DNS support and improved IP handling
Publish Fast Tabler Docker image / build-and-push-fast (push) Failing after 2m28s
Publish Fast Tabler Docker image / build-and-push-fast (push) Failing after 2m28s
This commit is contained in:
@@ -705,6 +705,9 @@ async function tracerouteViaGateway(req, res) {
|
||||
if (!Number.isFinite(countNum) || countNum <= 0) countNum = 1;
|
||||
body.count = countNum;
|
||||
|
||||
// Включаем reverse DNS (как use-dns=yes), чтобы видеть имена
|
||||
body['use-dns'] = 'yes';
|
||||
|
||||
const hopsNum = Number(maxHops);
|
||||
if (Number.isFinite(hopsNum) && hopsNum > 0) {
|
||||
body['max-hops'] = hopsNum;
|
||||
@@ -744,7 +747,13 @@ async function tracerouteViaGateway(req, res) {
|
||||
const seen = new Set();
|
||||
|
||||
for (const r of rows) {
|
||||
const host = r.host || r.address || '';
|
||||
const ip = (r.address && String(r.address).trim()) || '';
|
||||
const hostField = (r.host && String(r.host).trim()) || '';
|
||||
|
||||
// Если host есть и отличается от IP, считаем его DNS-именем,
|
||||
// иначе всё, что есть, считаем IP.
|
||||
const dns = hostField && hostField !== ip ? hostField : '';
|
||||
const host = dns || ip;
|
||||
|
||||
// Пропускаем полностью пустые строки без адреса и статуса
|
||||
if (!host && !r.status) continue;
|
||||
@@ -758,7 +767,9 @@ async function tracerouteViaGateway(req, res) {
|
||||
|
||||
hops.push({
|
||||
hop: null, // заполним ниже последовательной нумерацией
|
||||
host,
|
||||
host, // отображаемое значение по умолчанию
|
||||
ip: ip || null,
|
||||
dns: dns || null,
|
||||
avgMs: parseMs(avgField),
|
||||
bestMs: parseMs(r.best || r['best-rtt'] || r['min-rtt']),
|
||||
worstMs: parseMs(r.worst || r['worst-rtt'] || r['max-rtt']),
|
||||
|
||||
Reference in New Issue
Block a user