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;
|
if (!Number.isFinite(countNum) || countNum <= 0) countNum = 1;
|
||||||
body.count = countNum;
|
body.count = countNum;
|
||||||
|
|
||||||
|
// Включаем reverse DNS (как use-dns=yes), чтобы видеть имена
|
||||||
|
body['use-dns'] = 'yes';
|
||||||
|
|
||||||
const hopsNum = Number(maxHops);
|
const hopsNum = Number(maxHops);
|
||||||
if (Number.isFinite(hopsNum) && hopsNum > 0) {
|
if (Number.isFinite(hopsNum) && hopsNum > 0) {
|
||||||
body['max-hops'] = hopsNum;
|
body['max-hops'] = hopsNum;
|
||||||
@@ -744,7 +747,13 @@ async function tracerouteViaGateway(req, res) {
|
|||||||
const seen = new Set();
|
const seen = new Set();
|
||||||
|
|
||||||
for (const r of rows) {
|
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;
|
if (!host && !r.status) continue;
|
||||||
@@ -758,7 +767,9 @@ async function tracerouteViaGateway(req, res) {
|
|||||||
|
|
||||||
hops.push({
|
hops.push({
|
||||||
hop: null, // заполним ниже последовательной нумерацией
|
hop: null, // заполним ниже последовательной нумерацией
|
||||||
host,
|
host, // отображаемое значение по умолчанию
|
||||||
|
ip: ip || null,
|
||||||
|
dns: dns || null,
|
||||||
avgMs: parseMs(avgField),
|
avgMs: parseMs(avgField),
|
||||||
bestMs: parseMs(r.best || r['best-rtt'] || r['min-rtt']),
|
bestMs: parseMs(r.best || r['best-rtt'] || r['min-rtt']),
|
||||||
worstMs: parseMs(r.worst || r['worst-rtt'] || r['max-rtt']),
|
worstMs: parseMs(r.worst || r['worst-rtt'] || r['max-rtt']),
|
||||||
|
|||||||
@@ -270,15 +270,17 @@ function MikrotikTools() {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{hops.map((h) => (
|
{hops.map((h) => {
|
||||||
<tr key={h.hop || `${h.host}-${Math.random()}`}>
|
const ip = h.ip || '';
|
||||||
|
const dns = h.dns || '';
|
||||||
|
const mainLabel = dns
|
||||||
|
? `${dns}${ip ? ` (${ip})` : ''}`
|
||||||
|
: (ip || h.host || '—');
|
||||||
|
|
||||||
|
return (
|
||||||
|
<tr key={h.hop || `${ip || h.host}-${Math.random()}`}>
|
||||||
<td>{h.hop}</td>
|
<td>{h.hop}</td>
|
||||||
<td>
|
<td>{mainLabel}</td>
|
||||||
{h.host || '—'}
|
|
||||||
{h._label && (
|
|
||||||
<div className="text-muted small">{h._label}</div>
|
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
<td>{h.avgMs != null ? h.avgMs.toFixed(1) : '—'}</td>
|
<td>{h.avgMs != null ? h.avgMs.toFixed(1) : '—'}</td>
|
||||||
<td>
|
<td>
|
||||||
{h.bestMs != null ? h.bestMs.toFixed(1) : '—'} /{' '}
|
{h.bestMs != null ? h.bestMs.toFixed(1) : '—'} /{' '}
|
||||||
@@ -287,7 +289,7 @@ function MikrotikTools() {
|
|||||||
<td>{h.loss != null ? `${h.loss}%` : '—'}</td>
|
<td>{h.loss != null ? `${h.loss}%` : '—'}</td>
|
||||||
<td>{h.status || '—'}</td>
|
<td>{h.status || '—'}</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
);})}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@@ -344,11 +346,13 @@ function buildTracerouteAnalysis(hops, networkConfig, servers, target) {
|
|||||||
let worstLatencyHop = null;
|
let worstLatencyHop = null;
|
||||||
|
|
||||||
hops.forEach((hop, index) => {
|
hops.forEach((hop, index) => {
|
||||||
const host = hop.host || hop.address || '';
|
const ip = hop.ip || hop.host || hop.address || '';
|
||||||
|
const dns = hop.dns || null;
|
||||||
|
const hostDisplay = dns ? `${dns}${ip ? ` (${ip})` : ''}` : (ip || hop.host || '');
|
||||||
const avg = hop.avgMs;
|
const avg = hop.avgMs;
|
||||||
const loss = hop.loss;
|
const loss = hop.loss;
|
||||||
|
|
||||||
let descr = `Хоп ${hop.hop || index + 1}: ${host || 'неизвестный узел'}`;
|
let descr = `Хоп ${hop.hop || index + 1}: ${hostDisplay || 'неизвестный узел'}`;
|
||||||
const details = [];
|
const details = [];
|
||||||
|
|
||||||
if (avg != null) details.push(`среднее время ≈ ${avg.toFixed(1)} мс`);
|
if (avg != null) details.push(`среднее время ≈ ${avg.toFixed(1)} мс`);
|
||||||
@@ -357,15 +361,15 @@ function buildTracerouteAnalysis(hops, networkConfig, servers, target) {
|
|||||||
}
|
}
|
||||||
if (loss != null) details.push(`потеря пакетов ${loss}%`);
|
if (loss != null) details.push(`потеря пакетов ${loss}%`);
|
||||||
|
|
||||||
// Привязка к gateway
|
// Привязка к gateway (по IP)
|
||||||
const gw = gateways.find((g) => g.ip && g.ip === host);
|
const gw = gateways.find((g) => g.ip && g.ip === ip);
|
||||||
if (gw) {
|
if (gw) {
|
||||||
const srvLabel = findServerLabel(gw.serverId);
|
const srvLabel = findServerLabel(gw.serverId);
|
||||||
details.push(`gateway "${gw.description || gw.ip}" на сервере ${srvLabel || gw.serverId}`);
|
details.push(`gateway "${gw.description || gw.ip}" на сервере ${srvLabel || gw.serverId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Привязка к туннельному интерфейсу
|
// Привязка к туннельному интерфейсу (по IP)
|
||||||
const iface = ifaces.find((i) => i.localIp === host || i.remoteIp === host);
|
const iface = ifaces.find((i) => i.localIp === ip || i.remoteIp === ip);
|
||||||
if (iface) {
|
if (iface) {
|
||||||
const s1 = findServerLabel(iface.serverId);
|
const s1 = findServerLabel(iface.serverId);
|
||||||
const s2 = findServerLabel(iface.serverId2);
|
const s2 = findServerLabel(iface.serverId2);
|
||||||
@@ -407,7 +411,7 @@ function buildTracerouteAnalysis(hops, networkConfig, servers, target) {
|
|||||||
|
|
||||||
if (firstTimeoutHop) {
|
if (firstTimeoutHop) {
|
||||||
lines.push(
|
lines.push(
|
||||||
`Начиная с хопа ${firstTimeoutHop.hop} (${firstTimeoutHop.host || 'неизвестный узел'}) наблюдаются таймауты — цель может быть недоступна или где-то по пути фильтруется ICMP.`
|
`Начиная с хопа ${firstTimeoutHop.hop} (${firstTimeoutHop.dns ? `${firstTimeoutHop.dns}${firstTimeoutHop.ip ? ` (${firstTimeoutHop.ip})` : ''}` : (firstTimeoutHop.ip || firstTimeoutHop.host || 'неизвестный узел')}) наблюдаются таймауты — цель может быть недоступна или где-то по пути фильтруется ICMP.`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
lines.push('Таймаутов или явной потери пакетов по пути не обнаружено (по данным MikroTik).');
|
lines.push('Таймаутов или явной потери пакетов по пути не обнаружено (по данным MikroTik).');
|
||||||
|
|||||||
Reference in New Issue
Block a user