fix(NetworkConfigManager): improve IPSec password validation and handling; ensure non-empty passwords are processed and add warnings for empty responses
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m40s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m40s
This commit is contained in:
@@ -1030,15 +1030,20 @@ function NetworkConfigManager() {
|
||||
|
||||
// Загружаем пароли для интерфейсов с IPSec
|
||||
const passwordIds = [...new Set(interfacesWithBothServers
|
||||
.filter(i => i.ipsecPasswordId)
|
||||
.map(i => i.ipsecPasswordId)
|
||||
.filter(i => i.ipsecPasswordId && i.ipsecPasswordId.trim() !== '')
|
||||
.map(i => i.ipsecPasswordId.trim())
|
||||
)];
|
||||
|
||||
const passwordMap = {};
|
||||
for (const passwordId of passwordIds) {
|
||||
try {
|
||||
const response = await api.get(`/ipsec-passwords/${passwordId}`);
|
||||
passwordMap[passwordId] = response.data?.password || '';
|
||||
const password = response.data?.password || '';
|
||||
if (password) {
|
||||
passwordMap[passwordId] = password;
|
||||
} else {
|
||||
console.warn(`IPSec password ${passwordId} loaded but empty`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error loading IPSec password ${passwordId}:`, error);
|
||||
passwordMap[passwordId] = '';
|
||||
@@ -1075,8 +1080,8 @@ function NetworkConfigManager() {
|
||||
type: iface.type,
|
||||
server2Name,
|
||||
server2Info: server2,
|
||||
ipsecPasswordId: iface.ipsecPasswordId || null,
|
||||
ipsecPassword: iface.ipsecPasswordId ? passwordMap[iface.ipsecPasswordId] : null
|
||||
ipsecPasswordId: (iface.ipsecPasswordId && iface.ipsecPasswordId.trim() !== '') ? iface.ipsecPasswordId.trim() : null,
|
||||
ipsecPassword: (iface.ipsecPasswordId && iface.ipsecPasswordId.trim() !== '') ? (passwordMap[iface.ipsecPasswordId.trim()] || null) : null
|
||||
});
|
||||
|
||||
// Для второго сервера - МЕНЯЕМ МЕСТАМИ: remoteIp становится localIp, localIp становится remoteIp
|
||||
@@ -1094,8 +1099,8 @@ function NetworkConfigManager() {
|
||||
type: iface.type,
|
||||
server2Name: server1Name,
|
||||
server2Info: server1,
|
||||
ipsecPasswordId: iface.ipsecPasswordId || null,
|
||||
ipsecPassword: iface.ipsecPasswordId ? passwordMap[iface.ipsecPasswordId] : null
|
||||
ipsecPasswordId: (iface.ipsecPasswordId && iface.ipsecPasswordId.trim() !== '') ? iface.ipsecPasswordId.trim() : null,
|
||||
ipsecPassword: (iface.ipsecPasswordId && iface.ipsecPasswordId.trim() !== '') ? (passwordMap[iface.ipsecPasswordId.trim()] || null) : null
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1129,7 +1134,13 @@ function NetworkConfigManager() {
|
||||
const remoteServerIp = iface.server2Info?.ip || iface.server2Name;
|
||||
const localServerIp = server.ip || serverName;
|
||||
|
||||
if (iface.ipsecPasswordId && iface.ipsecPassword) {
|
||||
// Проверяем наличие пароля: ipsecPasswordId должен быть не пустым и пароль должен быть загружен
|
||||
const hasIpsecPassword = iface.ipsecPasswordId &&
|
||||
iface.ipsecPasswordId.trim() !== '' &&
|
||||
iface.ipsecPassword &&
|
||||
iface.ipsecPassword.trim() !== '';
|
||||
|
||||
if (hasIpsecPassword) {
|
||||
// GRE туннель с IPSec
|
||||
code += `# Создание GRE туннеля с IPSec\n`;
|
||||
code += `/interface gre add name="${iface.interfaceName}" remote-address=${remoteServerIp} local-address=${localServerIp} keepalive=10s\n`;
|
||||
|
||||
Reference in New Issue
Block a user