fix(mcp): исправить проверку зависимостей туннеля на больших таблицах маршрутов
Docker images / prepare-release (push) Successful in 11s
Docker images / backend-test (push) Successful in 10m41s
Docker images / frontend-image (push) Successful in 2m13s
Docker images / updater-image (push) Successful in 1m17s
Docker images / netflow-agent-image (push) Successful in 33s
Docker images / backend-image (push) Successful in 1m58s
Docker images / publish-release (push) Successful in 11s
Docker images / notify-webhook (push) Successful in 2s
Docker images / prepare-release (push) Successful in 11s
Docker images / backend-test (push) Successful in 10m41s
Docker images / frontend-image (push) Successful in 2m13s
Docker images / updater-image (push) Successful in 1m17s
Docker images / netflow-agent-image (push) Successful in 33s
Docker images / backend-image (push) Successful in 1m58s
Docker images / publish-release (push) Successful in 11s
Docker images / notify-webhook (push) Successful in 2s
This commit is contained in:
1 parent
e85e347cbe
commit
d255694cda
13 files changed
+137
-31
No files matched your search
@@ -17,11 +17,15 @@ export async function acceptOspfRouteProofMcp(actor: AuthUser) {
|
||||
const router = createServer(async (req, res) => {
|
||||
res.setHeader("content-type", "application/json")
|
||||
if (req.method === "GET" && req.url === tablePath) { reads++; res.end(JSON.stringify(tables)); return }
|
||||
if (!["/rest/routing/route", "/rest/routing/route/get"].includes(req.url ?? "")) { res.statusCode = 404; res.end("{}"); return }
|
||||
const url = new URL(req.url ?? "/", "http://fixture.invalid")
|
||||
if (!["/rest/routing/route", "/rest/routing/route/get"].includes(url.pathname)) { res.statusCode = 404; res.end("{}"); return }
|
||||
reads++
|
||||
if (beforeReply) { const hook = beforeReply; beforeReply = undefined; await hook() }
|
||||
if (nativeError) { res.statusCode = 400; res.end('{"message":"NEVER_ROUTE_PROVIDER_TOKEN"}'); return }
|
||||
if (req.method === "GET") { res.end(JSON.stringify(rows)); return }
|
||||
if (req.method === "GET") {
|
||||
if (url.searchParams.get("dst-address") !== selection.prefix || url.searchParams.get("routing-table") !== selection.table) { res.statusCode = 400; res.end("{}"); return }
|
||||
res.end(JSON.stringify(rows)); return
|
||||
}
|
||||
let body = ""; for await (const chunk of req) body += chunk
|
||||
const key = JSON.parse(body)["value-name"]
|
||||
if (key === "ospf.metric" && afterMetric) { const hook = afterMetric; afterMetric = undefined; await hook() }
|
||||
|
||||
@@ -36,7 +36,7 @@ export function registerOspfRouteProofActions(register: typeof add) {
|
||||
if (error instanceof McpError) throw error
|
||||
throw new McpError("STATE_UNAVAILABLE", input.expectAbsent === true
|
||||
? "Отсутствие точного префикса во всей выбранной таблице не подтверждено"
|
||||
: "Активный OSPF-маршрут, его метрика или выбранный выход не подтверждены; предел источника 10000 строк и 1 МиБ", 409)
|
||||
: "Активный OSPF-маршрут, его метрика или выход через указанный интерфейс не подтверждены", 409)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -35,9 +35,11 @@ export async function acceptWireguardImport(actor: AuthUser) {
|
||||
for (const hidden of [privateKey, peerOne, peerTwo, generated, content, "NEVER_IMPORT_"]) assert.equal(text.includes(hidden), false, "Public response must omit raw imported/native keys and configuration")
|
||||
}
|
||||
const router = createServer((req, res) => {
|
||||
const path = decodeURIComponent((req.url ?? "").replace(/^\/rest/, ""))
|
||||
const [pathname, query] = (req.url ?? "").slice(5).split("?")
|
||||
const path = decodeURIComponent(pathname)
|
||||
const selectedRows = () => rows[path].filter(row => !query || (row.dynamic === "true") === query.startsWith("dynamic=true"))
|
||||
res.setHeader("content-type", "application/json")
|
||||
if (req.method === "GET") { reads++; if (!Object.hasOwn(rows, path)) { res.statusCode = 404; res.end("{}"); return }; res.end(JSON.stringify(rows[path])); return }
|
||||
if (req.method === "GET") { reads++; if (!Object.hasOwn(rows, path)) { res.statusCode = 404; res.end("{}"); return }; res.end(JSON.stringify(selectedRows())); return }
|
||||
if (!["PUT", "PATCH"].includes(req.method ?? "")) { res.statusCode = 400; res.end("{}"); return }
|
||||
let raw = ""
|
||||
req.on("data", chunk => { raw += chunk }); req.on("end", () => {
|
||||
|
||||
@@ -24,18 +24,23 @@ export async function acceptWireguardInterfaceCreation(actor: AuthUser) {
|
||||
initial["/interface"] = [{ ".id": "*af", name: "wg-foreign", type: "wg" }]
|
||||
initial["/ip/address"] = [{ ".id": "*vf", address: "203.0.113.2/24", interface: "ether1", dynamic: "false", disabled: "false" }]
|
||||
initial["/ipv6/address"] = []
|
||||
initial["/ip/route"] = Array.from({ length: 12_608 }, (_, index) => ({
|
||||
".id": `*r${index.toString(16)}`, dynamic: "true", bgp: "true", gateway: "192.0.2.1", "immediate-gw": "192.0.2.1%ether1",
|
||||
}))
|
||||
let rows = structuredClone(initial), mode = "normal", reads = 0, commands: string[] = [], counter = 0
|
||||
let afterWrite: (() => Promise<unknown>) | undefined
|
||||
const reset = () => { rows = structuredClone(initial); mode = "normal"; commands = []; counter = 0; afterWrite = undefined }
|
||||
const router = createServer((req, res) => {
|
||||
res.setHeader("content-type", "application/json")
|
||||
const path = decodeURIComponent((req.url ?? "").slice(5))
|
||||
const [pathname, query] = (req.url ?? "").slice(5).split("?")
|
||||
const path = decodeURIComponent(pathname)
|
||||
const selectedRows = () => rows[path].filter(row => !query || (row.dynamic === "true") === query.startsWith("dynamic=true"))
|
||||
if (req.method === "GET") {
|
||||
reads++
|
||||
if (mode === "provider-error") { res.statusCode = 400; res.end('{"message":"NEVER_PROVIDER_SECRET"}'); return }
|
||||
if (!Object.hasOwn(rows, path)) { res.statusCode = 404; res.end("{}"); return }
|
||||
rows["/interface/wireguard/peers"][0].rx = String(reads)
|
||||
res.end(JSON.stringify(rows[path])); return
|
||||
res.end(JSON.stringify(selectedRows())); return
|
||||
}
|
||||
const base = ["/interface/wireguard/peers", "/interface/wireguard", "/ip/address", "/ipv6/address"].find(base => path === base || path.startsWith(base + "/"))
|
||||
if (!base || !["PUT", "PATCH"].includes(req.method ?? "")) { res.statusCode = 400; res.end("{}"); return }
|
||||
|
||||
@@ -26,7 +26,9 @@ export async function acceptWireguardInterfaceDeletion(actor: AuthUser) {
|
||||
let duringRead: (() => Promise<unknown>) | undefined
|
||||
const router = createServer((req, res) => {
|
||||
res.setHeader("content-type", "application/json")
|
||||
const path = decodeURIComponent((req.url ?? "").slice(5))
|
||||
const [pathname, query] = (req.url ?? "").slice(5).split("?")
|
||||
const path = decodeURIComponent(pathname)
|
||||
const selectedRows = () => rows[path].filter(row => !query || (row.dynamic === "true") === query.startsWith("dynamic=true"))
|
||||
if (req.method === "GET") {
|
||||
gets++
|
||||
const respond = () => {
|
||||
@@ -34,7 +36,7 @@ export async function acceptWireguardInterfaceDeletion(actor: AuthUser) {
|
||||
if (!Object.hasOwn(rows, path)) { res.statusCode = 404; res.end("{}"); return }
|
||||
// Runtime traffic and DHCP lease clocks must not become configuration drift.
|
||||
rows["/interface/wireguard/peers"].find(row => row[".id"] === "*pf")!.rx = String(gets)
|
||||
res.end(JSON.stringify(rows[path]))
|
||||
res.end(JSON.stringify(selectedRows()))
|
||||
}
|
||||
if (duringRead) { const hook = duringRead; duringRead = undefined; void hook().then(respond, () => { res.statusCode = 503; res.end("{}"); }); return }
|
||||
respond(); return
|
||||
@@ -89,7 +91,8 @@ export async function acceptWireguardInterfaceDeletion(actor: AuthUser) {
|
||||
await assert.rejects(prepare(true), (error: { code?: string }) => error.code === "DEPENDENCY_CONFLICT")
|
||||
assert.equal(commands.length, 0, "Native alias must not acquire cascade permission")
|
||||
for (const [path, row] of [
|
||||
["/interface/list/member", { interface: "wg-cascade", list: "LAN" }], ["/interface/vxlan", { interface: "wg-cascade" }], ["/ip/route", { gateway: "198.19.244.2%wg-cascade" }],
|
||||
["/interface/list/member", { interface: "wg-cascade", list: "LAN" }], ["/interface/vxlan", { interface: "wg-cascade" }],
|
||||
["/ip/route", { gateway: "wg-cascade" }], ["/ip/route", { dynamic: "true", "immediate-gw": "198.19.244.2%wg-cascade" }],
|
||||
["/routing/filter/rule", { rule: 'set gw "wg-cascade";' }], ["/ip/firewall/filter", { "in-interface": "wg-cascade" }], ["/ip/dhcp-server", { interface: "wg-cascade" }],
|
||||
["/routing/filter/rule", { rule: 'set gw "wg\\2dcascade";' }],
|
||||
["/ip/ipsec/peer", { "local-address": "198.19.244.1" }], ["/routing/bgp/session", { dynamic: "true", "local.address": "2001:0db8:0244:0:0:0:0:1" }],
|
||||
|
||||
@@ -31,13 +31,15 @@ export async function acceptWireguardInterfaceUpdate(actor: AuthUser) {
|
||||
const reset = () => { rows = structuredClone(initial); commands = []; mode = "normal"; afterWrite = undefined }
|
||||
const router = createServer((req, res) => {
|
||||
res.setHeader("content-type", "application/json")
|
||||
const path = decodeURIComponent((req.url ?? "").slice(5))
|
||||
const [pathname, query] = (req.url ?? "").slice(5).split("?")
|
||||
const path = decodeURIComponent(pathname)
|
||||
const selectedRows = () => rows[path].filter(row => !query || (row.dynamic === "true") === query.startsWith("dynamic=true"))
|
||||
if (req.method === "GET") {
|
||||
reads++
|
||||
if (mode === "provider-error") { res.statusCode = 500; res.end('{"message":"NEVER_PROVIDER_SECRET"}'); return }
|
||||
if (!Object.hasOwn(rows, path)) { res.statusCode = 404; res.end("{}"); return }
|
||||
rows["/interface/wireguard/peers"][0].rx = String(reads)
|
||||
res.end(JSON.stringify(rows[path])); return
|
||||
res.end(JSON.stringify(selectedRows())); return
|
||||
}
|
||||
const base = ["/interface/wireguard", "/ip/address", "/ipv6/address"].find(base => path === base || path.startsWith(base + "/"))
|
||||
if (!base || !["PUT", "PATCH", "DELETE"].includes(req.method ?? "")) { res.statusCode = 400; res.end("{}"); return }
|
||||
|
||||
@@ -33,13 +33,15 @@ export async function acceptWireguardPeerCreation(actor: AuthUser) {
|
||||
const reset = () => { rows = structuredClone(initial); mode = "normal"; commands = []; afterWrite = undefined }
|
||||
const router = createServer((req, res) => {
|
||||
res.setHeader("content-type", "application/json")
|
||||
const path = decodeURIComponent((req.url ?? "").slice(5)), base = "/interface/wireguard/peers"
|
||||
const [pathname, query] = (req.url ?? "").slice(5).split("?")
|
||||
const path = decodeURIComponent(pathname), base = "/interface/wireguard/peers"
|
||||
const selectedRows = () => rows[path].filter(row => !query || (row.dynamic === "true") === query.startsWith("dynamic=true"))
|
||||
if (req.method === "GET") {
|
||||
reads++
|
||||
if (mode === "provider-error" || mode === "dependency-error" && path === "/ip/address") { res.statusCode = 400; res.end('{"message":"NEVER_PROVIDER_SECRET"}'); return }
|
||||
if (!Object.hasOwn(rows, path)) { res.statusCode = 404; res.end("{}"); return }
|
||||
rows[base][0].rx = String(reads)
|
||||
res.end(JSON.stringify(rows[path])); return
|
||||
res.end(JSON.stringify(selectedRows())); return
|
||||
}
|
||||
if (!["PUT", "PATCH"].includes(req.method ?? "") || !(path === base || path === base + "/*c")) { res.statusCode = 400; res.end("{}"); return }
|
||||
let raw = ""
|
||||
|
||||
@@ -32,8 +32,10 @@ export async function acceptWireguardRevisionRestore(actor:AuthUser){
|
||||
const reset=()=>{rows=structuredClone(initial);commands=[];mode="normal";afterWrite=undefined}
|
||||
const router=createServer(async(req,res)=>{
|
||||
res.setHeader("content-type","application/json")
|
||||
const path=decodeURIComponent((req.url??"").slice(5))
|
||||
if(req.method==="GET"){reads++;if(!Object.hasOwn(rows,path)){res.statusCode=404;res.end("{}");return}res.end(JSON.stringify(rows[path]));return}
|
||||
const [pathname, query] = (req.url ?? "").slice(5).split("?")
|
||||
const path = decodeURIComponent(pathname)
|
||||
const selectedRows = () => rows[path].filter(row => !query || (row.dynamic === "true") === query.startsWith("dynamic=true"))
|
||||
if(req.method==="GET"){reads++;if(!Object.hasOwn(rows,path)){res.statusCode=404;res.end("{}");return}res.end(JSON.stringify(selectedRows()));return}
|
||||
let raw="";for await(const chunk of req)raw+=chunk
|
||||
const body=raw?JSON.parse(raw)as Record<string,string>:{},base=["/interface/wireguard/peers","/interface/wireguard","/ip/address","/ipv6/address"].find(p=>path===p||path.startsWith(p+"/"))
|
||||
if(!base||!["PUT","PATCH","DELETE"].includes(req.method??"")){res.statusCode=400;res.end("{}");return}
|
||||
|
||||
Reference in new issue
Block a user