fix(network): скрыть GRE PSK и сохранить признак IPsec

This commit is contained in:
Denozordec committed 2026-10-13 20:45:27 +07:00
1 parent a404da768d
commit 3f3f06f147
24 files changed
+1570 -23

No files matched your search

+5
View File
@@ -19,3 +19,8 @@ assert.ok(noInner.includes('local-address="192.0.2.10"'))
assert.ok(noInner.includes("keepalive=0 dscp=12"))
assert.ok(!noInner.includes("ipsec-secret="))
console.log("gre-export: escaped strings, observed GRE/PSK only, optional IP and no duplicate IPsec passed")
const masked = generateGreRsc({ ...tunnel, ipsec: { secret: '' } }, {})
assert.ok(masked.includes('ipsec-secret="<IPSEC_PSK>"'))
assert.ok(masked.includes('# Шаблон: ключ IPsec не раскрыт.'))
assert.ok(!masked.includes('ipsec-secret=""'))
console.log('gre-export: hidden configured PSK produces an explicitly labelled template, never an empty live key')
+4 -1
View File
@@ -17,7 +17,10 @@ export function generateGreRsc(t: GreTunnel, servers: Record<string, Server>): s
"comment=" + quoteRosString(t.comment),
]
if (t.localAddress && t.localAddress !== "0.0.0.0") args.push("local-address=" + quoteRosString(t.localAddress))
if (t.ipsec) args.push("ipsec-secret=" + quoteRosString(t.ipsec.secret))
if (t.ipsec) {
if (!t.ipsec.secret) lines.push("# Шаблон: ключ IPsec не раскрыт. Перед применением замените <IPSEC_PSK> своим ключом.")
args.push("ipsec-secret=" + quoteRosString(t.ipsec.secret || "<IPSEC_PSK>"))
}
lines.push("/interface/gre/add " + args.join(" "))
if (t.localInnerIp) lines.push("/ip/address/add address=" + quoteRosString(t.localInnerIp) + " interface=" + quoteRosString(t.name))
if (t.ipsec) lines.push("# Peer/policy создаёт RouterOS по ipsec-secret; ручные объекты IPsec не экспортируются")