fix(network): согласовать GRE PSK с FastPath и экспортом
This commit is contained in:
1 parent
7d86af7e8b
commit
1be4a490b5
20 files changed
+1460
-19
No files matched your search
+13
-2
@@ -2,6 +2,15 @@ import type { GreTunnel, Server } from "./data"
|
||||
import { quoteRosString } from "./vxlan-export"
|
||||
|
||||
const commentLine = (value: string) => value.replace(/[\r\n\x00-\x1f\x7f]/g, " ")
|
||||
const validKeepalive = (t: GreTunnel) => [t.keepaliveInterval, t.keepaliveRetries].every(value => Number.isInteger(value) && value >= 1 && value <= 4294967295)
|
||||
|
||||
export function greExportWarnings(t: GreTunnel): string[] {
|
||||
return [
|
||||
t.ipsec && !t.ipsec.secret ? "Шаблон: ключ IPsec скрыт. Укажите ключ перед применением." : "",
|
||||
!validKeepalive(t) ? "Шаблон: задайте допустимый интервал keepalive и число попыток перед применением." : "",
|
||||
t.ipsec && t.allowFastPath ? "Шаблон: IPsec несовместим с FastPath. Проверьте этот параметр перед применением." : "",
|
||||
].filter(Boolean)
|
||||
}
|
||||
|
||||
/** GRE/PSK fragment: https://help.mikrotik.com/docs/spaces/ROS/pages/24805531/GRE */
|
||||
export function generateGreRsc(t: GreTunnel, servers: Record<string, Server>): string {
|
||||
@@ -9,11 +18,13 @@ export function generateGreRsc(t: GreTunnel, servers: Record<string, Server>): s
|
||||
const lines = ["# GRE — " + commentLine(t.name)]
|
||||
if (server) lines.push("# Сервер: " + commentLine(server.name) + " (" + commentLine(server.host) + ")")
|
||||
lines.push("# Фрагмент интерфейса и локального IP; удалённая сторона и маршруты не включены", "")
|
||||
if (!validKeepalive(t)) lines.push("# Шаблон: задайте KEEPALIVE_SECONDS и KEEPALIVE_RETRIES — целые значения от 1 до 4294967295.")
|
||||
if (t.ipsec && t.allowFastPath) lines.push("# Шаблон: IPsec несовместим с FastPath. Проверьте ALLOW_FAST_PATH перед применением.")
|
||||
const args = [
|
||||
"name=" + quoteRosString(t.name), "remote-address=" + quoteRosString(t.remoteAddress),
|
||||
"mtu=" + t.mtu, "keepalive=" + (t.keepaliveInterval > 0 ? t.keepaliveInterval + "s," + t.keepaliveRetries : "0"),
|
||||
"mtu=" + t.mtu, "keepalive=" + (validKeepalive(t) ? t.keepaliveInterval + "s," + t.keepaliveRetries : "<KEEPALIVE_SECONDS>s,<KEEPALIVE_RETRIES>"),
|
||||
"dscp=" + t.dscp, "clamp-tcp-mss=" + (t.clampTcpMss ? "yes" : "no"),
|
||||
"allow-fast-path=" + (t.allowFastPath ? "yes" : "no"), "disabled=" + (t.enabled ? "no" : "yes"),
|
||||
"allow-fast-path=" + (t.ipsec && t.allowFastPath ? "<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))
|
||||
|
||||
Reference in new issue
Block a user