fix(vxlan): корректно экспортировать параметры RouterOS
This commit is contained in:
1 parent
d200e87e3d
commit
0e0f98e0f4
9 files changed
+82
-38
No files matched your search
@@ -54,3 +54,13 @@ const failed = await pollVxlanServers([server], async () => { throw new Error("a
|
||||
assert.equal(failed.tunnels.length, 0)
|
||||
assert.equal(failed.failures.length, 1)
|
||||
console.log("vxlan polling: mixed/empty/all-failed ok")
|
||||
|
||||
for (const arp of ["disabled", "enabled", "local-proxy-arp", "proxy-arp", "reply-only"] as const) {
|
||||
const mapped = mapVxlanRow(server, { ".id": "*4", name: "vx", arp, learning: "no" }, [], 0)
|
||||
assert.equal(mapped.arpMode, arp)
|
||||
assert.equal(mapped.arpProxy, arp === "proxy-arp" || arp === "local-proxy-arp")
|
||||
assert.equal(mapped.macLearning, false)
|
||||
}
|
||||
console.log("vxlan: exact ARP modes and RouterOS no-learning passed")
|
||||
|
||||
assert.equal(mapVxlanRow(server, { arp: "enabled", "arp-proxy": "true" }, [], 0).arpProxy, false)
|
||||
@@ -40,6 +40,7 @@ export type VxlanTunnelLive = {
|
||||
remoteVteps: string[]
|
||||
l2mtu: number
|
||||
arpProxy: boolean
|
||||
arpMode: "disabled" | "enabled" | "local-proxy-arp" | "proxy-arp" | "reply-only"
|
||||
macLearning: boolean
|
||||
comment: string
|
||||
enabled: boolean
|
||||
@@ -66,6 +67,7 @@ export function mapVxlanRow(
|
||||
const disabled = rosYes(vx.disabled)
|
||||
const running = rosYes(vx.running)
|
||||
const port = parseIntSafe(vx.port, 8472)
|
||||
const arpMode: VxlanTunnelLive["arpMode"] = (["disabled", "enabled", "local-proxy-arp", "proxy-arp", "reply-only"] as const).find(mode => mode === vx.arp) ?? (rosYes(vx["arp-proxy"]) ? "proxy-arp" : "enabled")
|
||||
const remoteVteps = vteps
|
||||
.filter((v) => (v.interface ?? "").trim() === name)
|
||||
.map((v) => (v["remote-ip"] ?? "").trim())
|
||||
@@ -81,8 +83,9 @@ export function mapVxlanRow(
|
||||
vtepIp: (vx["local-address"] ?? vx["vtep-address"] ?? "").trim(),
|
||||
remoteVteps,
|
||||
l2mtu: parseIntSafe(vx.l2mtu, 1500),
|
||||
arpProxy: rosYes(vx["arp-proxy"]) || vx.arp === "proxy-arp" || vx.arp === "enabled",
|
||||
macLearning: vx["mac-learning"] != null ? rosYes(vx["mac-learning"]) : vx.learning !== "false",
|
||||
arpProxy: arpMode === "proxy-arp" || arpMode === "local-proxy-arp",
|
||||
arpMode,
|
||||
macLearning: vx["mac-learning"] != null ? rosYes(vx["mac-learning"]) : vx.learning != null ? rosYes(vx.learning) : true,
|
||||
comment: vx.comment ?? "",
|
||||
enabled: !disabled,
|
||||
status: !disabled && running ? "up" : "down",
|
||||
|
||||
Reference in new issue
Block a user