fix(NetworkConfigManager): update parent type handling and improve IP assignment for gateways and interfaces; enhance logging for missing parent configurations
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m33s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m33s
This commit is contained in:
@@ -538,10 +538,10 @@ function NetworkConfigManager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Определяем IP родителя в зависимости от типа
|
// Определяем IP родителя в зависимости от типа
|
||||||
const parentIp = parent.type === 'interface' ? parent.remoteIp : parent.ip;
|
const parentIp = parent.parentType === 'interface' ? parent.remoteIp : parent.ip;
|
||||||
|
|
||||||
if (!parentIp) {
|
if (!parentIp) {
|
||||||
const parentType = parent.type === 'interface' ? 'интерфейс' : 'gateway';
|
const parentType = parent.parentType === 'interface' ? 'интерфейс' : 'gateway';
|
||||||
code += `\n# Gateway "${gw.ip}" - родительский ${parentType} не имеет IP, пропущен\n`;
|
code += `\n# Gateway "${gw.ip}" - родительский ${parentType} не имеет IP, пропущен\n`;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -549,8 +549,8 @@ function NetworkConfigManager() {
|
|||||||
validRoutesCount++;
|
validRoutesCount++;
|
||||||
|
|
||||||
// Создаём маршрут для рекурсивного gateway
|
// Создаём маршрут для рекурсивного gateway
|
||||||
const parentLabel = parent.type === 'interface'
|
const parentLabel = parent.parentType === 'interface'
|
||||||
? `интерфейс ${parent.name || parent.type} (${parent.remoteIp})`
|
? `интерфейс ${parent.name || parent.interfaceType || 'interface'} (${parent.remoteIp})`
|
||||||
: `gateway ${parent.ip}`;
|
: `gateway ${parent.ip}`;
|
||||||
|
|
||||||
code += `\n# Рекурсивный gateway: ${gw.ip}\n`;
|
code += `\n# Рекурсивный gateway: ${gw.ip}\n`;
|
||||||
@@ -691,11 +691,32 @@ function NetworkConfigManager() {
|
|||||||
|
|
||||||
// Сначала ищем в gateway
|
// Сначала ищем в gateway
|
||||||
const gateway = config.gateways?.find(g => g.id === parentId);
|
const gateway = config.gateways?.find(g => g.id === parentId);
|
||||||
if (gateway) return { type: 'gateway', ...gateway };
|
if (gateway) {
|
||||||
|
return {
|
||||||
|
parentType: 'gateway', // Используем parentType чтобы не конфликтовать с type интерфейса
|
||||||
|
...gateway,
|
||||||
|
ip: gateway.ip // Явно указываем IP для gateway
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Если не найден, ищем в интерфейсах
|
// Если не найден, ищем в интерфейсах
|
||||||
const iface = config.tunnelInterfaces?.find(i => i.id === parentId);
|
const iface = config.tunnelInterfaces?.find(i => i.id === parentId);
|
||||||
if (iface) return { type: 'interface', ...iface };
|
if (iface) {
|
||||||
|
return {
|
||||||
|
parentType: 'interface', // Используем parentType чтобы не конфликтовать с type интерфейса
|
||||||
|
...iface,
|
||||||
|
remoteIp: iface.remoteIp, // Явно указываем remoteIp для интерфейса
|
||||||
|
localIp: iface.localIp,
|
||||||
|
name: iface.name,
|
||||||
|
interfaceType: iface.type // Сохраняем тип интерфейса (GRE, WireGuard и т.д.) отдельно
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Если не найден ни gateway, ни интерфейс - логируем для отладки
|
||||||
|
console.warn('Parent gateway/interface not found:', parentId, {
|
||||||
|
availableGateways: config.gateways?.map(g => g.id),
|
||||||
|
availableInterfaces: config.tunnelInterfaces?.map(i => i.id)
|
||||||
|
});
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
@@ -775,9 +796,11 @@ function NetworkConfigManager() {
|
|||||||
<div className="d-flex align-items-center gap-1 text-muted small mb-1">
|
<div className="d-flex align-items-center gap-1 text-muted small mb-1">
|
||||||
<span className="text-muted">→</span>
|
<span className="text-muted">→</span>
|
||||||
<span>
|
<span>
|
||||||
Родитель: {parentGateway.type === 'interface'
|
Родитель: {parentGateway.parentType === 'interface'
|
||||||
? `Интерфейс ${parentGateway.name || parentGateway.type} (${parentGateway.remoteIp})`
|
? `Интерфейс ${parentGateway.name || parentGateway.interfaceType || 'interface'} (${parentGateway.remoteIp || '—'})`
|
||||||
: `Gateway ${parentGateway.ip}`
|
: parentGateway.ip
|
||||||
|
? `Gateway ${parentGateway.ip}`
|
||||||
|
: 'Gateway (не указан IP)'
|
||||||
}
|
}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -1171,9 +1194,11 @@ function NetworkConfigManager() {
|
|||||||
</span>
|
</span>
|
||||||
{parentGateway && (
|
{parentGateway && (
|
||||||
<div className="text-muted small mt-1">
|
<div className="text-muted small mt-1">
|
||||||
→ {parentGateway.type === 'interface'
|
→ {parentGateway.parentType === 'interface'
|
||||||
? `Интерфейс ${parentGateway.name || parentGateway.type} (${parentGateway.remoteIp})`
|
? `Интерфейс ${parentGateway.name || parentGateway.interfaceType || 'interface'} (${parentGateway.remoteIp || '—'})`
|
||||||
: `Gateway ${parentGateway.ip}`
|
: parentGateway.ip
|
||||||
|
? `Gateway ${parentGateway.ip}`
|
||||||
|
: 'Gateway (не указан IP)'
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user