@usex/mikrotik-mcp 6.6.0 → 6.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +134 -0
- package/dist/cli.js +158 -43
- package/dist/index.js +10 -1
- package/dist/shared/{cli-w3tjpdhk.js → cli-4a4dxv04.js} +1 -1
- package/dist/shared/{cli-kwsg0vb4.js → cli-ksq2qr7d.js} +1 -1
- package/dist/shared/{cli-v3ytyep0.js → cli-mh3kf1gx.js} +237 -16
- package/dist/shared/{cli-hp8w45f1.js → cli-pan4hpjf.js} +1 -1
- package/dist/shared/{cli-y5txdsgq.js → cli-qszw8tv2.js} +1 -1
- package/dist/shared/{library-j6pdmv0m.js → library-5ejy1n1c.js} +1 -1
- package/dist/shared/{library-aw8wrqbg.js → library-g8fvds7b.js} +1 -1
- package/dist/shared/{library-bty0a0n3.js → library-qdh9kmg5.js} +1 -1
- package/dist/shared/{library-36y6v8ks.js → library-qwkp17zf.js} +237 -16
- package/dist/shared/{library-j5qk3cvp.js → library-r8m6ftrj.js} +1 -1
- package/dist/ui/aaa.html +8 -8
- package/dist/ui/connected-devices.html +8 -8
- package/dist/ui/dashboard.html +8 -8
- package/dist/ui/fabric.html +11 -11
- package/dist/ui/firewall-audit.html +8 -8
- package/dist/ui/firewall.html +9 -9
- package/dist/ui/interfaces.html +8 -8
- package/dist/ui/investigations.html +11 -11
- package/dist/ui/observability.html +72 -70
- package/dist/ui/operations.html +11 -11
- package/dist/ui/records.html +9 -9
- package/dist/ui/reports.html +11 -11
- package/dist/ui/round-trip.html +11 -11
- package/dist/ui/service-health.html +11 -11
- package/package.json +14 -10
- package/schemas/README.md +1 -1
- package/schemas/devtools-manifest.json +109 -1
- package/schemas/tool-catalog.json +299 -2
- package/schemas/tools/add_web_proxy_access_rule.json +25 -0
- package/schemas/tools/get_device_mode.json +7 -0
- package/schemas/tools/get_web_proxy.json +7 -0
- package/schemas/tools/list_web_proxy_access_rules.json +7 -0
- package/schemas/tools/monitor_web_proxy.json +7 -0
- package/schemas/tools/move_web_proxy_access_rule.json +17 -0
- package/schemas/tools/remove_web_proxy_access_rule.json +12 -0
- package/schemas/tools/update_device_mode_features.json +99 -0
- package/schemas/tools/update_web_proxy.json +29 -0
|
@@ -11915,8 +11915,7 @@ class SafeModeManager {
|
|
|
11915
11915
|
if (this.uncertain)
|
|
11916
11916
|
throw new Error(UNCERTAIN_SESSION);
|
|
11917
11917
|
const response = this.readUntilPrompt(this.idleTimeoutMs, undefined, this.commandTimeoutMs, true);
|
|
11918
|
-
this.channel.write(`${command}
|
|
11919
|
-
`);
|
|
11918
|
+
this.channel.write(`${command}\r`);
|
|
11920
11919
|
const { text, timedOut } = await response;
|
|
11921
11920
|
if (timedOut) {
|
|
11922
11921
|
this.uncertain = true;
|
|
@@ -12054,8 +12053,7 @@ class SafeModeManager {
|
|
|
12054
12053
|
return i >= 0 && PROMPT_RE.test(lines.slice(i + 1).join(`
|
|
12055
12054
|
`));
|
|
12056
12055
|
});
|
|
12057
|
-
this.channel.write(`:put "${token}"
|
|
12058
|
-
`);
|
|
12056
|
+
this.channel.write(`:put "${token}"\r`);
|
|
12059
12057
|
const { text, timedOut } = await response;
|
|
12060
12058
|
return timedOut ? "unknown" : classifyPrompt(text);
|
|
12061
12059
|
}
|
|
@@ -16690,13 +16688,13 @@ async function undoMigration(id, confirm, selected) {
|
|
|
16690
16688
|
throw new Error("Undo lost Safe Mode or exceeded its time budget.");
|
|
16691
16689
|
await checkedRead(item.undo, createContext(undefined, device));
|
|
16692
16690
|
}
|
|
16693
|
-
const beforeTarget = (await import("./cli-
|
|
16694
|
-
const db = await beforeTarget((await import("./cli-
|
|
16691
|
+
const beforeTarget = (await import("./cli-pan4hpjf.js")).openSnapshotStore;
|
|
16692
|
+
const db = await beforeTarget((await import("./cli-qszw8tv2.js")).DEFAULT_SNAPSHOT_DB);
|
|
16695
16693
|
try {
|
|
16696
16694
|
const original = db.get(p.snapshots.target);
|
|
16697
16695
|
if (!original)
|
|
16698
16696
|
throw new Error("Original target snapshot unavailable.");
|
|
16699
|
-
const { normalizeExport } = await import("./cli-
|
|
16697
|
+
const { normalizeExport } = await import("./cli-4a4dxv04.js");
|
|
16700
16698
|
if (normalizeExport((await migrationInventory(device)).export) !== normalizeExport(original.body))
|
|
16701
16699
|
throw new Error("Target differs from its backup. Undo verification failed.");
|
|
16702
16700
|
} finally {
|
|
@@ -26906,6 +26904,68 @@ ${lines.join(`
|
|
|
26906
26904
|
})
|
|
26907
26905
|
];
|
|
26908
26906
|
|
|
26907
|
+
// src/tools/device-mode.ts
|
|
26908
|
+
var deviceModeTools = [
|
|
26909
|
+
defineTool({
|
|
26910
|
+
name: "get_device_mode",
|
|
26911
|
+
title: "Get RouterOS Device Mode",
|
|
26912
|
+
annotations: READ,
|
|
26913
|
+
description: "Read `/system device-mode print` to see which restricted RouterOS features are available and whether physical confirmation is pending.",
|
|
26914
|
+
async handler(_a, ctx) {
|
|
26915
|
+
const result = await executeMikrotikCommand("/system device-mode print", ctx);
|
|
26916
|
+
return isEmpty(result) ? "Device mode unavailable on this RouterOS version." : result;
|
|
26917
|
+
}
|
|
26918
|
+
}),
|
|
26919
|
+
defineTool({
|
|
26920
|
+
name: "update_device_mode_features",
|
|
26921
|
+
title: "Request Device Mode Feature Update",
|
|
26922
|
+
annotations: DANGEROUS,
|
|
26923
|
+
description: "Request any RouterOS device-mode feature or mode setting. Changing mode replaces existing per-feature overrides; inspect get_device_mode first. Clearing flagged requires a security audit. Every update needs physical confirmation and a reboot; the command response only confirms a pending request. Read back after confirmation. Unsupported properties depend on RouterOS version and hardware.",
|
|
26924
|
+
inputSchema: {
|
|
26925
|
+
mode: _enum(["home", "basic", "advanced", "rose"]).optional().describe("Changes the entire mode and resets prior per-feature overrides; include any overrides to keep in this request."),
|
|
26926
|
+
scheduler: boolean().optional(),
|
|
26927
|
+
socks: boolean().optional(),
|
|
26928
|
+
fetch: boolean().optional(),
|
|
26929
|
+
pptp: boolean().optional(),
|
|
26930
|
+
l2tp: boolean().optional(),
|
|
26931
|
+
bandwidth_test: boolean().optional(),
|
|
26932
|
+
traffic_gen: boolean().optional(),
|
|
26933
|
+
sniffer: boolean().optional(),
|
|
26934
|
+
ipsec: boolean().optional(),
|
|
26935
|
+
romon: boolean().optional(),
|
|
26936
|
+
proxy: boolean().optional(),
|
|
26937
|
+
hotspot: boolean().optional(),
|
|
26938
|
+
smb: boolean().optional(),
|
|
26939
|
+
email: boolean().optional(),
|
|
26940
|
+
zerotier: boolean().optional(),
|
|
26941
|
+
container: boolean().optional(),
|
|
26942
|
+
install_any_version: boolean().optional(),
|
|
26943
|
+
partitions: boolean().optional(),
|
|
26944
|
+
routerboard: boolean().optional(),
|
|
26945
|
+
activation_timeout: string().min(1).max(20).optional().describe("Physical confirmation window, 10 seconds to 1 day (RouterOS duration, e.g. 5m or 00:05:00)."),
|
|
26946
|
+
flagging_enabled: boolean().optional(),
|
|
26947
|
+
flagged: boolean().optional().describe("Set false only after a security audit of the router configuration."),
|
|
26948
|
+
confirm_mode_resets_overrides: literal(true).optional().describe("Required with mode: existing per-feature overrides will be reset unless included in this request."),
|
|
26949
|
+
confirm_flagged_audit_complete: literal(true).optional().describe("Required to clear flagged after auditing configuration, passwords, and RouterOS version."),
|
|
26950
|
+
physical_confirmation_available: literal(true).describe("Operator is physically present and has authorized the device-mode change.")
|
|
26951
|
+
},
|
|
26952
|
+
async handler(a, ctx) {
|
|
26953
|
+
if (a.mode && !a.confirm_mode_resets_overrides)
|
|
26954
|
+
return "Refusing mode change: confirm_mode_resets_overrides=true is required because mode resets prior per-feature overrides.";
|
|
26955
|
+
if (a.flagged === false && !a.confirm_flagged_audit_complete)
|
|
26956
|
+
return "Refusing to clear flagged: confirm_flagged_audit_complete=true is required after a security audit.";
|
|
26957
|
+
const cmd = new Cmd("/system device-mode update").opt("mode", a.mode).bool("scheduler", a.scheduler).bool("socks", a.socks).bool("fetch", a.fetch).bool("pptp", a.pptp).bool("l2tp", a.l2tp).bool("bandwidth-test", a.bandwidth_test).bool("traffic-gen", a.traffic_gen).bool("sniffer", a.sniffer).bool("ipsec", a.ipsec).bool("romon", a.romon).bool("proxy", a.proxy).bool("hotspot", a.hotspot).bool("smb", a.smb).bool("email", a.email).bool("zerotier", a.zerotier).bool("container", a.container).bool("install-any-version", a.install_any_version).bool("partitions", a.partitions).bool("routerboard", a.routerboard).opt("activation-timeout", a.activation_timeout).bool("flagging-enabled", a.flagging_enabled).bool("flagged", a.flagged);
|
|
26958
|
+
if (cmd.build() === "/system device-mode update")
|
|
26959
|
+
return "No feature changes specified.";
|
|
26960
|
+
const result = await executeMikrotikCommand(cmd.build(), ctx);
|
|
26961
|
+
if (looksLikeError(result))
|
|
26962
|
+
return `Failed to request device-mode update: ${result}`;
|
|
26963
|
+
return `Device-mode update requested; physical confirmation is required before treating it as active. Router response:
|
|
26964
|
+
${result}`;
|
|
26965
|
+
}
|
|
26966
|
+
})
|
|
26967
|
+
];
|
|
26968
|
+
|
|
26909
26969
|
// src/tools/dhcp.ts
|
|
26910
26970
|
var Authoritative = _enum(["yes", "no", "after-2sec-delay"]);
|
|
26911
26971
|
var dhcpTools = [
|
|
@@ -28576,6 +28636,7 @@ var SYNONYMS = {
|
|
|
28576
28636
|
show: ["list", "print", "get"],
|
|
28577
28637
|
print: ["list", "show"],
|
|
28578
28638
|
get: ["show", "fetch"],
|
|
28639
|
+
read: ["get", "list", "show"],
|
|
28579
28640
|
fetch: ["get"],
|
|
28580
28641
|
update: ["set", "modify", "change", "edit"],
|
|
28581
28642
|
set: ["update", "modify", "change"],
|
|
@@ -28670,7 +28731,7 @@ var cache3 = null;
|
|
|
28670
28731
|
async function gateway() {
|
|
28671
28732
|
if (cache3)
|
|
28672
28733
|
return cache3;
|
|
28673
|
-
const { moduleCatalog } = await import("./cli-
|
|
28734
|
+
const { moduleCatalog } = await import("./cli-ksq2qr7d.js");
|
|
28674
28735
|
const forIndex = [];
|
|
28675
28736
|
const byName = new Map;
|
|
28676
28737
|
for (const mod of moduleCatalog) {
|
|
@@ -33499,11 +33560,17 @@ ${result}`;
|
|
|
33499
33560
|
if (!id)
|
|
33500
33561
|
return `Firewall filter rule '${a.rule_id}' not found.`;
|
|
33501
33562
|
const before = await listItemIds("/ip firewall filter", ctx);
|
|
33502
|
-
const
|
|
33563
|
+
const from = before.indexOf(id);
|
|
33564
|
+
if (a.destination < 0 || a.destination >= before.length) {
|
|
33565
|
+
return `NO CHANGE: destination ${a.destination} is outside the ${before.length} rule positions.`;
|
|
33566
|
+
}
|
|
33567
|
+
if (from === a.destination)
|
|
33568
|
+
return `NO CHANGE: firewall filter rule ${id} is already at position ${from}.`;
|
|
33569
|
+
const target = before[a.destination];
|
|
33570
|
+
const result = await executeMikrotikCommand(`/ip firewall filter move ${id} ${target}`, ctx);
|
|
33503
33571
|
if (looksLikeError(result))
|
|
33504
33572
|
return `Failed to move firewall filter rule: ${result}`;
|
|
33505
33573
|
const after = await listItemIds("/ip firewall filter", ctx);
|
|
33506
|
-
const from = before.indexOf(id);
|
|
33507
33574
|
const to = after.indexOf(id);
|
|
33508
33575
|
if (to === -1) {
|
|
33509
33576
|
return `Firewall filter rule ${id} moved, but it could not be located afterwards \u2014 verify with list_filter_rules.`;
|
|
@@ -35306,6 +35373,124 @@ ${details}`;
|
|
|
35306
35373
|
})
|
|
35307
35374
|
];
|
|
35308
35375
|
|
|
35376
|
+
// src/tools/web-proxy.ts
|
|
35377
|
+
var scope = "/ip proxy access";
|
|
35378
|
+
var resolveAccessId = ruleResolver(scope);
|
|
35379
|
+
var webProxyTools = [
|
|
35380
|
+
defineTool({
|
|
35381
|
+
name: "get_web_proxy",
|
|
35382
|
+
title: "Get Web Proxy Settings",
|
|
35383
|
+
annotations: READ,
|
|
35384
|
+
description: "Read RouterOS `/ip proxy` settings, including enabled, port, outgoing source and cache.",
|
|
35385
|
+
async handler(_a, ctx) {
|
|
35386
|
+
const result = await executeMikrotikCommand("/ip proxy print", ctx);
|
|
35387
|
+
return isEmpty(result) ? "Web proxy settings unavailable." : result;
|
|
35388
|
+
}
|
|
35389
|
+
}),
|
|
35390
|
+
defineTool({
|
|
35391
|
+
name: "update_web_proxy",
|
|
35392
|
+
title: "Update Web Proxy Settings",
|
|
35393
|
+
annotations: DANGEROUS,
|
|
35394
|
+
description: "Configure RouterOS `/ip proxy`. Enabling a listener does not restrict who may connect: " + "configure IPv4/IPv6 input firewall rules and inspect web proxy access rules first. " + "The outgoing src_address can select existing source-based policy routing; verify the route and NAT separately.",
|
|
35395
|
+
inputSchema: {
|
|
35396
|
+
enabled: boolean().optional(),
|
|
35397
|
+
port: number().int().min(1).max(65535).optional(),
|
|
35398
|
+
src_address: string().optional(),
|
|
35399
|
+
anonymous: boolean().optional(),
|
|
35400
|
+
max_cache_size: string().optional(),
|
|
35401
|
+
confirm_firewall_ready: boolean().optional().describe("Required when enabling: IPv4 and IPv6 input firewall access has been verified.")
|
|
35402
|
+
},
|
|
35403
|
+
async handler(a, ctx) {
|
|
35404
|
+
if (a.enabled === true && !a.confirm_firewall_ready) {
|
|
35405
|
+
return "Refusing to enable web proxy until confirm_firewall_ready=true: verify both IPv4 and IPv6 input firewall restrictions first.";
|
|
35406
|
+
}
|
|
35407
|
+
const cmd = new Cmd("/ip proxy set").bool("enabled", a.enabled).opt("port", a.port).opt("src-address", a.src_address).bool("anonymous", a.anonymous).opt("max-cache-size", a.max_cache_size);
|
|
35408
|
+
if (cmd.build() === "/ip proxy set")
|
|
35409
|
+
return "No updates specified.";
|
|
35410
|
+
const result = await executeMikrotikCommand(cmd.build(), ctx);
|
|
35411
|
+
if (looksLikeError(result))
|
|
35412
|
+
return `Failed to update web proxy: ${result}`;
|
|
35413
|
+
return `Web proxy update sent. Current settings:
|
|
35414
|
+
${await executeMikrotikCommand("/ip proxy print", ctx)}`;
|
|
35415
|
+
}
|
|
35416
|
+
}),
|
|
35417
|
+
defineTool({
|
|
35418
|
+
name: "monitor_web_proxy",
|
|
35419
|
+
title: "Monitor Web Proxy",
|
|
35420
|
+
annotations: READ,
|
|
35421
|
+
description: "Read one `/ip proxy monitor once` sample, including connection and request counters.",
|
|
35422
|
+
async handler(_a, ctx) {
|
|
35423
|
+
return executeMikrotikCommand("/ip proxy monitor once", ctx);
|
|
35424
|
+
}
|
|
35425
|
+
}),
|
|
35426
|
+
defineTool({
|
|
35427
|
+
name: "list_web_proxy_access_rules",
|
|
35428
|
+
title: "List Web Proxy Access Rules",
|
|
35429
|
+
annotations: READ,
|
|
35430
|
+
description: "Read ordered `/ip proxy access` rules and their `.id`s. An unmatched request is allowed by RouterOS; use firewall input rules to control source address lists.",
|
|
35431
|
+
async handler(_a, ctx) {
|
|
35432
|
+
const result = await executeMikrotikCommand(`${scope} print detail`, ctx);
|
|
35433
|
+
return isEmpty(result) ? "No web proxy access rules (unmatched requests are allowed)." : result;
|
|
35434
|
+
}
|
|
35435
|
+
}),
|
|
35436
|
+
defineTool({
|
|
35437
|
+
name: "add_web_proxy_access_rule",
|
|
35438
|
+
title: "Add Web Proxy Access Rule",
|
|
35439
|
+
annotations: WRITE,
|
|
35440
|
+
description: "Add an allow/deny rule to `/ip proxy access`. Order matters; place_before is an existing `.id` or zero-based row. Use dst_address to block private targets; the proxy firewall controls client sources.",
|
|
35441
|
+
inputSchema: {
|
|
35442
|
+
action: _enum(["allow", "deny"]),
|
|
35443
|
+
src_address: string().optional(),
|
|
35444
|
+
dst_address: string().optional(),
|
|
35445
|
+
comment: string().optional(),
|
|
35446
|
+
place_before: string().optional()
|
|
35447
|
+
},
|
|
35448
|
+
async handler(a, ctx) {
|
|
35449
|
+
const cmd = new Cmd(`${scope} add`).set("action", a.action).opt("src-address", a.src_address).opt("dst-address", a.dst_address).opt("comment", a.comment);
|
|
35450
|
+
const result = await executeRuleCreate(scope, cmd, ctx, a.place_before);
|
|
35451
|
+
if (looksLikeError(result))
|
|
35452
|
+
return `Failed to add web proxy access rule: ${result}`;
|
|
35453
|
+
return readCreatedRule(scope, result, "Web proxy access rule", ctx);
|
|
35454
|
+
}
|
|
35455
|
+
}),
|
|
35456
|
+
defineTool({
|
|
35457
|
+
name: "remove_web_proxy_access_rule",
|
|
35458
|
+
title: "Remove Web Proxy Access Rule",
|
|
35459
|
+
annotations: DESTRUCTIVE,
|
|
35460
|
+
description: "Remove one `/ip proxy access` rule by `.id` or zero-based row, after inspecting the ordered list.",
|
|
35461
|
+
inputSchema: { rule_id: string() },
|
|
35462
|
+
async handler(a, ctx) {
|
|
35463
|
+
const id = await resolveAccessId(a.rule_id, ctx);
|
|
35464
|
+
if (!id)
|
|
35465
|
+
return `Web proxy access rule '${a.rule_id}' not found.`;
|
|
35466
|
+
const result = await executeMikrotikCommand(`${scope} remove ${id}`, ctx);
|
|
35467
|
+
return looksLikeError(result) ? `Failed to remove web proxy access rule: ${result}` : `Removed web proxy access rule ${id}.`;
|
|
35468
|
+
}
|
|
35469
|
+
}),
|
|
35470
|
+
defineTool({
|
|
35471
|
+
name: "move_web_proxy_access_rule",
|
|
35472
|
+
title: "Move Web Proxy Access Rule",
|
|
35473
|
+
annotations: WRITE_IDEMPOTENT,
|
|
35474
|
+
description: "Move one `/ip proxy access` rule before the item at a zero-based destination position; reads back the resulting order.",
|
|
35475
|
+
inputSchema: { rule_id: string(), destination: number().int().min(0) },
|
|
35476
|
+
async handler(a, ctx) {
|
|
35477
|
+
const id = await resolveAccessId(a.rule_id, ctx);
|
|
35478
|
+
if (!id)
|
|
35479
|
+
return `Web proxy access rule '${a.rule_id}' not found.`;
|
|
35480
|
+
const before = await listItemIds(scope, ctx);
|
|
35481
|
+
if (a.destination >= before.length)
|
|
35482
|
+
return `NO CHANGE: destination ${a.destination} is outside the ${before.length} rule positions.`;
|
|
35483
|
+
if (before.indexOf(id) === a.destination)
|
|
35484
|
+
return `NO CHANGE: web proxy access rule ${id} is already at position ${a.destination}.`;
|
|
35485
|
+
const result = await executeMikrotikCommand(`${scope} move ${id} ${before[a.destination]}`, ctx);
|
|
35486
|
+
if (looksLikeError(result))
|
|
35487
|
+
return `Failed to move web proxy access rule: ${result}`;
|
|
35488
|
+
const to = (await listItemIds(scope, ctx)).indexOf(id);
|
|
35489
|
+
return to === a.destination ? `Web proxy access rule ${id} moved to position ${to}.` : `Web proxy access rule ${id} is at position ${to} (requested ${a.destination}); inspect the ordered list.`;
|
|
35490
|
+
}
|
|
35491
|
+
})
|
|
35492
|
+
];
|
|
35493
|
+
|
|
35309
35494
|
// src/tools/ip-ssh.ts
|
|
35310
35495
|
var ipSshTools = [
|
|
35311
35496
|
defineTool({
|
|
@@ -36573,10 +36758,19 @@ ${result}`;
|
|
|
36573
36758
|
const id = await resolveRuleId(a.rule_id, ctx);
|
|
36574
36759
|
if (!id)
|
|
36575
36760
|
return `IPv6 firewall filter rule '${a.rule_id}' not found.`;
|
|
36576
|
-
const
|
|
36761
|
+
const before = await listItemIds("/ipv6 firewall filter", ctx);
|
|
36762
|
+
const from = before.indexOf(id);
|
|
36763
|
+
if (a.destination < 0 || a.destination >= before.length) {
|
|
36764
|
+
return `NO CHANGE: destination ${a.destination} is outside the ${before.length} rule positions.`;
|
|
36765
|
+
}
|
|
36766
|
+
if (from === a.destination)
|
|
36767
|
+
return `NO CHANGE: IPv6 firewall filter rule ${id} is already at position ${from}.`;
|
|
36768
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall filter move ${id} ${before[a.destination]}`, ctx);
|
|
36577
36769
|
if (looksLikeError(result))
|
|
36578
36770
|
return `Failed to move IPv6 firewall filter rule: ${result}`;
|
|
36579
|
-
|
|
36771
|
+
const after = await listItemIds("/ipv6 firewall filter", ctx);
|
|
36772
|
+
const to = after.indexOf(id);
|
|
36773
|
+
return to === a.destination ? `IPv6 firewall filter rule '${a.rule_id}' (${id}) moved to position ${to}.` : `NO CHANGE or different position: IPv6 firewall filter rule ${id} is at ${to} (requested ${a.destination}); inspect list_ipv6_filter_rules.`;
|
|
36580
36774
|
}
|
|
36581
36775
|
}),
|
|
36582
36776
|
defineTool({
|
|
@@ -44840,7 +45034,14 @@ function access5(ctx, write = false) {
|
|
|
44840
45034
|
function openVpnSessionsCommand() {
|
|
44841
45035
|
const find = new Cmd("/ppp active find where").set("service", "ovpn").build();
|
|
44842
45036
|
const read = new Cmd("/ppp active print").raw("detail as-value").raw("where").set("service", "ovpn").build();
|
|
44843
|
-
return `{ :if ([:len [${find}]] > ${SESSION_LIMIT}) do={ :error "OpenVPN session limit exceeded" }; :local rows [:toarray ""]; :foreach row in=[${read}] do={ :set ($row->"uptime") [:tostr ($row->"uptime")]; :set ($row->"session-id") [:tostr ($row->"session-id")]; :set ($rows->[:len $rows]) $row }; :put [:serialize to=json options=json.no-string-conversion value=$rows] }`;
|
|
45037
|
+
return `{ :if ([:len [${find}]] > ${SESSION_LIMIT}) do={ :error "OpenVPN session limit exceeded" }; :local stats [/interface print stats as-value where dynamic=yes]; :local rows [:toarray ""]; :foreach row in=[${read}] do={ :local target ("<ovpn-" . ($row->"name") . ">"); :foreach iface in=$stats do={ :if (($iface->"name") = $target) do={ :set ($row->"rx-byte") ($iface->"rx-byte"); :set ($row->"tx-byte") ($iface->"tx-byte") } }; :set ($row->"uptime") [:tostr ($row->"uptime")]; :set ($row->"session-id") [:tostr ($row->"session-id")]; :set ($rows->[:len $rows]) $row }; :put [:serialize to=json options=json.no-string-conversion value=$rows] }`;
|
|
45038
|
+
}
|
|
45039
|
+
function openVpnClientBytes(tx, rx) {
|
|
45040
|
+
if (typeof tx !== "number" && (typeof tx !== "string" || !/^\d+$/.test(tx)) || typeof rx !== "number" && (typeof rx !== "string" || !/^\d+$/.test(rx)))
|
|
45041
|
+
return [null, null];
|
|
45042
|
+
const download = Number(tx);
|
|
45043
|
+
const upload = Number(rx);
|
|
45044
|
+
return Number.isSafeInteger(download) && Number.isSafeInteger(upload) ? [download, upload] : [null, null];
|
|
44844
45045
|
}
|
|
44845
45046
|
function parseOpenVpnSessions(output) {
|
|
44846
45047
|
if (output.length > 1e6)
|
|
@@ -44854,6 +45055,7 @@ function parseOpenVpnSessions(output) {
|
|
|
44854
45055
|
if (!Array.isArray(rows) || rows.length > SESSION_LIMIT)
|
|
44855
45056
|
throw new Error("Invalid OpenVPN session snapshot.");
|
|
44856
45057
|
const ids = new Set;
|
|
45058
|
+
const names = rows.map((row) => row && typeof row === "object" ? row.name : undefined);
|
|
44857
45059
|
return rows.map((row) => {
|
|
44858
45060
|
const r = object({
|
|
44859
45061
|
".id": string().regex(/^\*[A-Fa-f0-9]+$/),
|
|
@@ -44864,11 +45066,14 @@ function parseOpenVpnSessions(output) {
|
|
|
44864
45066
|
"session-id": string().default(""),
|
|
44865
45067
|
uptime: string().default(""),
|
|
44866
45068
|
encoding: string().default(""),
|
|
44867
|
-
radius: union([boolean(), string()]).optional()
|
|
45069
|
+
radius: union([boolean(), string()]).optional(),
|
|
45070
|
+
"tx-byte": union([number(), string()]).optional(),
|
|
45071
|
+
"rx-byte": union([number(), string()]).optional()
|
|
44868
45072
|
}).parse(row);
|
|
44869
45073
|
if (ids.has(r[".id"]))
|
|
44870
45074
|
throw new Error("Duplicate OpenVPN session identifier; refresh required.");
|
|
44871
45075
|
ids.add(r[".id"]);
|
|
45076
|
+
const [downloadBytes, uploadBytes] = names.filter((name) => name === r.name).length === 1 ? openVpnClientBytes(r["tx-byte"], r["rx-byte"]) : [null, null];
|
|
44872
45077
|
return {
|
|
44873
45078
|
id: r[".id"],
|
|
44874
45079
|
name: r.name,
|
|
@@ -44878,7 +45083,9 @@ function parseOpenVpnSessions(output) {
|
|
|
44878
45083
|
encoding: r.encoding,
|
|
44879
45084
|
radius: r.radius === true || r.radius === "yes" || r.radius === "true",
|
|
44880
45085
|
uptime: r.uptime,
|
|
44881
|
-
uptimeSeconds: openVpnUptime(r.uptime)
|
|
45086
|
+
uptimeSeconds: openVpnUptime(r.uptime),
|
|
45087
|
+
downloadBytes,
|
|
45088
|
+
uploadBytes
|
|
44882
45089
|
};
|
|
44883
45090
|
});
|
|
44884
45091
|
}
|
|
@@ -54129,7 +54336,7 @@ var riskByTool = null;
|
|
|
54129
54336
|
async function riskIndex() {
|
|
54130
54337
|
if (riskByTool)
|
|
54131
54338
|
return riskByTool;
|
|
54132
|
-
const { moduleCatalog } = await import("./cli-
|
|
54339
|
+
const { moduleCatalog } = await import("./cli-ksq2qr7d.js");
|
|
54133
54340
|
const index = new Map;
|
|
54134
54341
|
for (const mod of moduleCatalog) {
|
|
54135
54342
|
for (const tool of mod.tools)
|
|
@@ -64657,6 +64864,13 @@ var moduleCatalog2 = [
|
|
|
64657
64864
|
description: "Filter rules and a guided basic setup (`/ip firewall filter`).",
|
|
64658
64865
|
tools: firewallFilterTools
|
|
64659
64866
|
},
|
|
64867
|
+
{
|
|
64868
|
+
label: "Web Proxy",
|
|
64869
|
+
slug: "web-proxy",
|
|
64870
|
+
group: "Security",
|
|
64871
|
+
description: "HTTP/HTTPS CONNECT proxy settings, live status and ordered access rules (`/ip proxy`).",
|
|
64872
|
+
tools: webProxyTools
|
|
64873
|
+
},
|
|
64660
64874
|
{
|
|
64661
64875
|
label: "Firewall \u2014 NAT",
|
|
64662
64876
|
slug: "firewall-nat",
|
|
@@ -64937,6 +65151,13 @@ var moduleCatalog2 = [
|
|
|
64937
65151
|
description: "Identity, resources, health, clock/NTP, packages, reboot/shutdown.",
|
|
64938
65152
|
tools: systemTools
|
|
64939
65153
|
},
|
|
65154
|
+
{
|
|
65155
|
+
label: "Device Mode",
|
|
65156
|
+
slug: "device-mode",
|
|
65157
|
+
group: "System & Ops",
|
|
65158
|
+
description: "Read device-mode capabilities and request physically confirmed feature changes.",
|
|
65159
|
+
tools: deviceModeTools
|
|
65160
|
+
},
|
|
64940
65161
|
{
|
|
64941
65162
|
label: "System Config",
|
|
64942
65163
|
slug: "system-config",
|