fix(gre): экспортировать поддерживаемые параметры и очищать PSK
This commit is contained in:
1 parent
a21252fb02
commit
337d14abdf
7 files changed
+113
-132
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import type { GreTunnel, Server } from "./data"
|
||||
import { quoteRosString } from "./vxlan-export"
|
||||
|
||||
const commentLine = (value: string) => value.replace(/[\r\n\x00-\x1f\x7f]/g, " ")
|
||||
|
||||
/** GRE/PSK fragment: https://help.mikrotik.com/docs/spaces/ROS/pages/24805531/GRE */
|
||||
export function generateGreRsc(t: GreTunnel, servers: Record<string, Server>): string {
|
||||
const server = servers[t.serverId]
|
||||
const lines = ["# GRE — " + commentLine(t.name)]
|
||||
if (server) lines.push("# Сервер: " + commentLine(server.name) + " (" + commentLine(server.host) + ")")
|
||||
lines.push("# Фрагмент интерфейса и локального IP; удалённая сторона и маршруты не включены", "")
|
||||
const args = [
|
||||
"name=" + quoteRosString(t.name), "remote-address=" + quoteRosString(t.remoteAddress),
|
||||
"mtu=" + t.mtu, "keepalive=" + (t.keepaliveInterval > 0 ? t.keepaliveInterval + "s," + t.keepaliveRetries : "0"),
|
||||
"dscp=" + t.dscp, "clamp-tcp-mss=" + (t.clampTcpMss ? "yes" : "no"),
|
||||
"allow-fast-path=" + (t.allowFastPath ? "yes" : "no"), "disabled=" + (t.enabled ? "no" : "yes"),
|
||||
"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))
|
||||
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 не экспортируются")
|
||||
if (t.ipsec && t.allowFastPath) lines.push("# В снимке включён FastPath: для GRE с IPsec документация RouterOS требует allow-fast-path=no")
|
||||
return lines.join("\n") + "\n"
|
||||
}
|
||||
Reference in new issue
Block a user