feat(mcp): добавить отдельный режим шифрования для пары туннелей
Docker images / prepare-release (push) Successful in 15s
Docker images / backend-test (push) Successful in 11m43s
Docker images / frontend-image (push) Successful in 2m34s
Docker images / updater-image (push) Successful in 54s
Docker images / netflow-agent-image (push) Successful in 40s
Docker images / backend-image (push) Successful in 2m29s
Docker images / publish-release (push) Successful in 12s
Docker images / notify-webhook (push) Successful in 2s

This commit is contained in:
Denozordec committed 2026-11-30 17:50:41 +07:00
1 parent 5233a9f194
commit 0a568f1640
7 files changed
+292 -11

No files matched your search

@@ -0,0 +1,25 @@
export const greIpsecPaths = {
filter: "/ip/firewall/filter",
profile: "/ip/ipsec/profile",
proposal: "/ip/ipsec/proposal",
peer: "/ip/ipsec/peer",
identity: "/ip/ipsec/identity",
policy: "/ip/ipsec/policy",
} as const
export function greIpsecPlaintextDrops(local: string, remote: string) {
return [
{ chain: "input", protocol: "gre", "src-address": `${remote}/32`, "dst-address": `${local}/32`, "ipsec-policy": "in,none", action: "drop" },
{ chain: "output", protocol: "gre", "src-address": `${local}/32`, "dst-address": `${remote}/32`, "ipsec-policy": "out,none", action: "drop" },
]
}
export function greIke2TransportFields(name: string, local: string, remote: string, passive: boolean, secret: string, disabled: boolean) {
return {
profile: { name, "enc-algorithm": "aes-256", "hash-algorithm": "sha256", "dh-group": "modp2048" },
proposal: { name, "enc-algorithms": "aes-256-cbc", "auth-algorithms": "sha256", "pfs-group": "modp2048" },
peer: { name, address: `${remote}/32`, "local-address": local, profile: name, "exchange-mode": "ike2", passive: String(passive) },
identity: { peer: name, "auth-method": "pre-shared-key", secret, disabled: String(disabled) },
policy: { peer: name, "src-address": `${local}/32`, "dst-address": `${remote}/32`, protocol: "gre", action: "encrypt", level: "require", tunnel: "false", proposal: name },
}
}
+8 -10
View File
@@ -3,6 +3,7 @@ import { createHash } from "node:crypto"
import type { IxConfiguration, IxRouterObject, IxSite } from "@mmapp/contracts/internet-exchange"
import { canonicalBgpPolicyPrefix } from "./bgp-community-policy-model.js"
import { compileIxTransit, ixTransitSourceObjects } from "./internet-exchange-transit.js"
import { greIke2TransportFields, greIpsecPaths, greIpsecPlaintextDrops } from "./gre-ipsec-transport.js"
export class IxConflict extends Error {
constructor(message: string, readonly statusCode = 409) { super(message) }
@@ -282,8 +283,9 @@ export function compileIxConfiguration(id: string, configuration: IxConfiguratio
result.push({ serverId: site.serverId, path, fields: nameOnly ? fields : { ...fields, comment: namespace + ":" + key } })
}
const protectGre = (binding: IxSite["interfaces"][number], key: string) => {
add("/ip/firewall/filter", "gre-in-" + key, { chain: "input", protocol: "gre", "src-address": host(binding.endpoint!), "dst-address": host(binding.localEndpoint!), "ipsec-policy": "in,none", action: "drop" })
add("/ip/firewall/filter", "gre-out-" + key, { chain: "output", protocol: "gre", "src-address": host(binding.localEndpoint!), "dst-address": host(binding.endpoint!), "ipsec-policy": "out,none", action: "drop" })
const [inbound, outbound] = greIpsecPlaintextDrops(binding.localEndpoint!, binding.endpoint!)
add(greIpsecPaths.filter, "gre-in-" + key, inbound)
add(greIpsecPaths.filter, "gre-out-" + key, outbound)
}
const dropInterface = ixDiscardInterface(id)
for (const [index, binding] of site.interfaces.entries()) {
@@ -296,14 +298,10 @@ export function compileIxConfiguration(id: string, configuration: IxConfiguratio
if (gre) {
const transport = namespace + "-" + key
protectGre(binding, key)
add("/ip/ipsec/profile", key, { name: transport, "enc-algorithm": "aes-256", "hash-algorithm": "sha256", "dh-group": "modp2048" })
add("/ip/ipsec/proposal", key, { name: transport, "enc-algorithms": "aes-256-cbc", "auth-algorithms": "sha256", "pfs-group": "modp2048" })
add("/ip/ipsec/peer", key, { name: transport, address: host(binding.endpoint!), "local-address": binding.localEndpoint!,
profile: transport, "exchange-mode": "ike2", passive: "true" })
add("/ip/ipsec/identity", "gre-identity-" + key, { peer: transport, "auth-method": "pre-shared-key",
secret: "ix-credential:" + gre.credentialId, disabled: String(!binding.linux!.enabled) })
add("/ip/ipsec/policy", "gre-policy-" + key, { peer: transport, "src-address": host(binding.localEndpoint!),
"dst-address": host(binding.endpoint!), protocol: "gre", action: "encrypt", level: "require", tunnel: "false", proposal: transport })
const fields = greIke2TransportFields(transport, binding.localEndpoint!, binding.endpoint!, true, "ix-credential:" + gre.credentialId, !binding.linux!.enabled)
for (const kind of ["profile", "proposal", "peer"] as const) add(greIpsecPaths[kind], key, fields[kind])
add(greIpsecPaths.identity, "gre-identity-" + key, fields.identity)
add(greIpsecPaths.policy, "gre-policy-" + key, fields.policy)
add("/interface/gre", "gre-" + key, { name: binding.name, "local-address": binding.localEndpoint!,
"remote-address": binding.endpoint!, "allow-fast-path": "false", disabled: String(!binding.linux!.enabled) })
}