@usex/mikrotik-mcp 6.7.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/dist/cli.js +2 -1
- package/dist/index.js +1 -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/observability.html +71 -69
- package/package.json +1 -1
- 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
|
@@ -10618,8 +10618,7 @@ class SafeModeManager2 {
|
|
|
10618
10618
|
if (this.uncertain)
|
|
10619
10619
|
throw new Error(UNCERTAIN_SESSION);
|
|
10620
10620
|
const response = this.readUntilPrompt(this.idleTimeoutMs, undefined, this.commandTimeoutMs, true);
|
|
10621
|
-
this.channel.write(`${command}
|
|
10622
|
-
`);
|
|
10621
|
+
this.channel.write(`${command}\r`);
|
|
10623
10622
|
const { text, timedOut } = await response;
|
|
10624
10623
|
if (timedOut) {
|
|
10625
10624
|
this.uncertain = true;
|
|
@@ -10757,8 +10756,7 @@ class SafeModeManager2 {
|
|
|
10757
10756
|
return i >= 0 && PROMPT_RE.test(lines.slice(i + 1).join(`
|
|
10758
10757
|
`));
|
|
10759
10758
|
});
|
|
10760
|
-
this.channel.write(`:put "${token}"
|
|
10761
|
-
`);
|
|
10759
|
+
this.channel.write(`:put "${token}"\r`);
|
|
10762
10760
|
const { text, timedOut } = await response;
|
|
10763
10761
|
return timedOut ? "unknown" : classifyPrompt(text);
|
|
10764
10762
|
}
|
|
@@ -15608,13 +15606,13 @@ async function undoMigration(id, confirm, selected) {
|
|
|
15608
15606
|
throw new Error("Undo lost Safe Mode or exceeded its time budget.");
|
|
15609
15607
|
await checkedRead(item.undo, createContext(undefined, device));
|
|
15610
15608
|
}
|
|
15611
|
-
const beforeTarget = (await import("./library-
|
|
15612
|
-
const db = await beforeTarget((await import("./library-
|
|
15609
|
+
const beforeTarget = (await import("./library-g8fvds7b.js")).openSnapshotStore;
|
|
15610
|
+
const db = await beforeTarget((await import("./library-qdh9kmg5.js")).DEFAULT_SNAPSHOT_DB);
|
|
15613
15611
|
try {
|
|
15614
15612
|
const original = db.get(p.snapshots.target);
|
|
15615
15613
|
if (!original)
|
|
15616
15614
|
throw new Error("Original target snapshot unavailable.");
|
|
15617
|
-
const { normalizeExport } = await import("./library-
|
|
15615
|
+
const { normalizeExport } = await import("./library-5ejy1n1c.js");
|
|
15618
15616
|
if (normalizeExport((await migrationInventory(device)).export) !== normalizeExport(original.body))
|
|
15619
15617
|
throw new Error("Target differs from its backup. Undo verification failed.");
|
|
15620
15618
|
} finally {
|
|
@@ -26470,6 +26468,68 @@ ${lines.join(`
|
|
|
26470
26468
|
})
|
|
26471
26469
|
];
|
|
26472
26470
|
|
|
26471
|
+
// src/tools/device-mode.ts
|
|
26472
|
+
var deviceModeTools = [
|
|
26473
|
+
defineTool2({
|
|
26474
|
+
name: "get_device_mode",
|
|
26475
|
+
title: "Get RouterOS Device Mode",
|
|
26476
|
+
annotations: READ,
|
|
26477
|
+
description: "Read `/system device-mode print` to see which restricted RouterOS features are available and whether physical confirmation is pending.",
|
|
26478
|
+
async handler(_a, ctx) {
|
|
26479
|
+
const result = await executeMikrotikCommand2("/system device-mode print", ctx);
|
|
26480
|
+
return isEmpty(result) ? "Device mode unavailable on this RouterOS version." : result;
|
|
26481
|
+
}
|
|
26482
|
+
}),
|
|
26483
|
+
defineTool2({
|
|
26484
|
+
name: "update_device_mode_features",
|
|
26485
|
+
title: "Request Device Mode Feature Update",
|
|
26486
|
+
annotations: DANGEROUS,
|
|
26487
|
+
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.",
|
|
26488
|
+
inputSchema: {
|
|
26489
|
+
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."),
|
|
26490
|
+
scheduler: boolean().optional(),
|
|
26491
|
+
socks: boolean().optional(),
|
|
26492
|
+
fetch: boolean().optional(),
|
|
26493
|
+
pptp: boolean().optional(),
|
|
26494
|
+
l2tp: boolean().optional(),
|
|
26495
|
+
bandwidth_test: boolean().optional(),
|
|
26496
|
+
traffic_gen: boolean().optional(),
|
|
26497
|
+
sniffer: boolean().optional(),
|
|
26498
|
+
ipsec: boolean().optional(),
|
|
26499
|
+
romon: boolean().optional(),
|
|
26500
|
+
proxy: boolean().optional(),
|
|
26501
|
+
hotspot: boolean().optional(),
|
|
26502
|
+
smb: boolean().optional(),
|
|
26503
|
+
email: boolean().optional(),
|
|
26504
|
+
zerotier: boolean().optional(),
|
|
26505
|
+
container: boolean().optional(),
|
|
26506
|
+
install_any_version: boolean().optional(),
|
|
26507
|
+
partitions: boolean().optional(),
|
|
26508
|
+
routerboard: boolean().optional(),
|
|
26509
|
+
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)."),
|
|
26510
|
+
flagging_enabled: boolean().optional(),
|
|
26511
|
+
flagged: boolean().optional().describe("Set false only after a security audit of the router configuration."),
|
|
26512
|
+
confirm_mode_resets_overrides: literal(true).optional().describe("Required with mode: existing per-feature overrides will be reset unless included in this request."),
|
|
26513
|
+
confirm_flagged_audit_complete: literal(true).optional().describe("Required to clear flagged after auditing configuration, passwords, and RouterOS version."),
|
|
26514
|
+
physical_confirmation_available: literal(true).describe("Operator is physically present and has authorized the device-mode change.")
|
|
26515
|
+
},
|
|
26516
|
+
async handler(a, ctx) {
|
|
26517
|
+
if (a.mode && !a.confirm_mode_resets_overrides)
|
|
26518
|
+
return "Refusing mode change: confirm_mode_resets_overrides=true is required because mode resets prior per-feature overrides.";
|
|
26519
|
+
if (a.flagged === false && !a.confirm_flagged_audit_complete)
|
|
26520
|
+
return "Refusing to clear flagged: confirm_flagged_audit_complete=true is required after a security audit.";
|
|
26521
|
+
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);
|
|
26522
|
+
if (cmd.build() === "/system device-mode update")
|
|
26523
|
+
return "No feature changes specified.";
|
|
26524
|
+
const result = await executeMikrotikCommand2(cmd.build(), ctx);
|
|
26525
|
+
if (looksLikeError(result))
|
|
26526
|
+
return `Failed to request device-mode update: ${result}`;
|
|
26527
|
+
return `Device-mode update requested; physical confirmation is required before treating it as active. Router response:
|
|
26528
|
+
${result}`;
|
|
26529
|
+
}
|
|
26530
|
+
})
|
|
26531
|
+
];
|
|
26532
|
+
|
|
26473
26533
|
// src/tools/dhcp.ts
|
|
26474
26534
|
var Authoritative = _enum(["yes", "no", "after-2sec-delay"]);
|
|
26475
26535
|
var dhcpTools = [
|
|
@@ -27986,6 +28046,7 @@ var SYNONYMS = {
|
|
|
27986
28046
|
show: ["list", "print", "get"],
|
|
27987
28047
|
print: ["list", "show"],
|
|
27988
28048
|
get: ["show", "fetch"],
|
|
28049
|
+
read: ["get", "list", "show"],
|
|
27989
28050
|
fetch: ["get"],
|
|
27990
28051
|
update: ["set", "modify", "change", "edit"],
|
|
27991
28052
|
set: ["update", "modify", "change"],
|
|
@@ -28080,7 +28141,7 @@ var cache3 = null;
|
|
|
28080
28141
|
async function gateway() {
|
|
28081
28142
|
if (cache3)
|
|
28082
28143
|
return cache3;
|
|
28083
|
-
const { moduleCatalog } = await import("./library-
|
|
28144
|
+
const { moduleCatalog } = await import("./library-r8m6ftrj.js");
|
|
28084
28145
|
const forIndex = [];
|
|
28085
28146
|
const byName = new Map;
|
|
28086
28147
|
for (const mod of moduleCatalog) {
|
|
@@ -32909,11 +32970,17 @@ ${result}`;
|
|
|
32909
32970
|
if (!id)
|
|
32910
32971
|
return `Firewall filter rule '${a.rule_id}' not found.`;
|
|
32911
32972
|
const before = await listItemIds("/ip firewall filter", ctx);
|
|
32912
|
-
const
|
|
32973
|
+
const from = before.indexOf(id);
|
|
32974
|
+
if (a.destination < 0 || a.destination >= before.length) {
|
|
32975
|
+
return `NO CHANGE: destination ${a.destination} is outside the ${before.length} rule positions.`;
|
|
32976
|
+
}
|
|
32977
|
+
if (from === a.destination)
|
|
32978
|
+
return `NO CHANGE: firewall filter rule ${id} is already at position ${from}.`;
|
|
32979
|
+
const target = before[a.destination];
|
|
32980
|
+
const result = await executeMikrotikCommand2(`/ip firewall filter move ${id} ${target}`, ctx);
|
|
32913
32981
|
if (looksLikeError(result))
|
|
32914
32982
|
return `Failed to move firewall filter rule: ${result}`;
|
|
32915
32983
|
const after = await listItemIds("/ip firewall filter", ctx);
|
|
32916
|
-
const from = before.indexOf(id);
|
|
32917
32984
|
const to = after.indexOf(id);
|
|
32918
32985
|
if (to === -1) {
|
|
32919
32986
|
return `Firewall filter rule ${id} moved, but it could not be located afterwards \u2014 verify with list_filter_rules.`;
|
|
@@ -34716,6 +34783,124 @@ ${details}`;
|
|
|
34716
34783
|
})
|
|
34717
34784
|
];
|
|
34718
34785
|
|
|
34786
|
+
// src/tools/web-proxy.ts
|
|
34787
|
+
var scope = "/ip proxy access";
|
|
34788
|
+
var resolveAccessId = ruleResolver(scope);
|
|
34789
|
+
var webProxyTools = [
|
|
34790
|
+
defineTool2({
|
|
34791
|
+
name: "get_web_proxy",
|
|
34792
|
+
title: "Get Web Proxy Settings",
|
|
34793
|
+
annotations: READ,
|
|
34794
|
+
description: "Read RouterOS `/ip proxy` settings, including enabled, port, outgoing source and cache.",
|
|
34795
|
+
async handler(_a, ctx) {
|
|
34796
|
+
const result = await executeMikrotikCommand2("/ip proxy print", ctx);
|
|
34797
|
+
return isEmpty(result) ? "Web proxy settings unavailable." : result;
|
|
34798
|
+
}
|
|
34799
|
+
}),
|
|
34800
|
+
defineTool2({
|
|
34801
|
+
name: "update_web_proxy",
|
|
34802
|
+
title: "Update Web Proxy Settings",
|
|
34803
|
+
annotations: DANGEROUS,
|
|
34804
|
+
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.",
|
|
34805
|
+
inputSchema: {
|
|
34806
|
+
enabled: boolean().optional(),
|
|
34807
|
+
port: number().int().min(1).max(65535).optional(),
|
|
34808
|
+
src_address: string().optional(),
|
|
34809
|
+
anonymous: boolean().optional(),
|
|
34810
|
+
max_cache_size: string().optional(),
|
|
34811
|
+
confirm_firewall_ready: boolean().optional().describe("Required when enabling: IPv4 and IPv6 input firewall access has been verified.")
|
|
34812
|
+
},
|
|
34813
|
+
async handler(a, ctx) {
|
|
34814
|
+
if (a.enabled === true && !a.confirm_firewall_ready) {
|
|
34815
|
+
return "Refusing to enable web proxy until confirm_firewall_ready=true: verify both IPv4 and IPv6 input firewall restrictions first.";
|
|
34816
|
+
}
|
|
34817
|
+
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);
|
|
34818
|
+
if (cmd.build() === "/ip proxy set")
|
|
34819
|
+
return "No updates specified.";
|
|
34820
|
+
const result = await executeMikrotikCommand2(cmd.build(), ctx);
|
|
34821
|
+
if (looksLikeError(result))
|
|
34822
|
+
return `Failed to update web proxy: ${result}`;
|
|
34823
|
+
return `Web proxy update sent. Current settings:
|
|
34824
|
+
${await executeMikrotikCommand2("/ip proxy print", ctx)}`;
|
|
34825
|
+
}
|
|
34826
|
+
}),
|
|
34827
|
+
defineTool2({
|
|
34828
|
+
name: "monitor_web_proxy",
|
|
34829
|
+
title: "Monitor Web Proxy",
|
|
34830
|
+
annotations: READ,
|
|
34831
|
+
description: "Read one `/ip proxy monitor once` sample, including connection and request counters.",
|
|
34832
|
+
async handler(_a, ctx) {
|
|
34833
|
+
return executeMikrotikCommand2("/ip proxy monitor once", ctx);
|
|
34834
|
+
}
|
|
34835
|
+
}),
|
|
34836
|
+
defineTool2({
|
|
34837
|
+
name: "list_web_proxy_access_rules",
|
|
34838
|
+
title: "List Web Proxy Access Rules",
|
|
34839
|
+
annotations: READ,
|
|
34840
|
+
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.",
|
|
34841
|
+
async handler(_a, ctx) {
|
|
34842
|
+
const result = await executeMikrotikCommand2(`${scope} print detail`, ctx);
|
|
34843
|
+
return isEmpty(result) ? "No web proxy access rules (unmatched requests are allowed)." : result;
|
|
34844
|
+
}
|
|
34845
|
+
}),
|
|
34846
|
+
defineTool2({
|
|
34847
|
+
name: "add_web_proxy_access_rule",
|
|
34848
|
+
title: "Add Web Proxy Access Rule",
|
|
34849
|
+
annotations: WRITE,
|
|
34850
|
+
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.",
|
|
34851
|
+
inputSchema: {
|
|
34852
|
+
action: _enum(["allow", "deny"]),
|
|
34853
|
+
src_address: string().optional(),
|
|
34854
|
+
dst_address: string().optional(),
|
|
34855
|
+
comment: string().optional(),
|
|
34856
|
+
place_before: string().optional()
|
|
34857
|
+
},
|
|
34858
|
+
async handler(a, ctx) {
|
|
34859
|
+
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);
|
|
34860
|
+
const result = await executeRuleCreate(scope, cmd, ctx, a.place_before);
|
|
34861
|
+
if (looksLikeError(result))
|
|
34862
|
+
return `Failed to add web proxy access rule: ${result}`;
|
|
34863
|
+
return readCreatedRule(scope, result, "Web proxy access rule", ctx);
|
|
34864
|
+
}
|
|
34865
|
+
}),
|
|
34866
|
+
defineTool2({
|
|
34867
|
+
name: "remove_web_proxy_access_rule",
|
|
34868
|
+
title: "Remove Web Proxy Access Rule",
|
|
34869
|
+
annotations: DESTRUCTIVE,
|
|
34870
|
+
description: "Remove one `/ip proxy access` rule by `.id` or zero-based row, after inspecting the ordered list.",
|
|
34871
|
+
inputSchema: { rule_id: string() },
|
|
34872
|
+
async handler(a, ctx) {
|
|
34873
|
+
const id = await resolveAccessId(a.rule_id, ctx);
|
|
34874
|
+
if (!id)
|
|
34875
|
+
return `Web proxy access rule '${a.rule_id}' not found.`;
|
|
34876
|
+
const result = await executeMikrotikCommand2(`${scope} remove ${id}`, ctx);
|
|
34877
|
+
return looksLikeError(result) ? `Failed to remove web proxy access rule: ${result}` : `Removed web proxy access rule ${id}.`;
|
|
34878
|
+
}
|
|
34879
|
+
}),
|
|
34880
|
+
defineTool2({
|
|
34881
|
+
name: "move_web_proxy_access_rule",
|
|
34882
|
+
title: "Move Web Proxy Access Rule",
|
|
34883
|
+
annotations: WRITE_IDEMPOTENT,
|
|
34884
|
+
description: "Move one `/ip proxy access` rule before the item at a zero-based destination position; reads back the resulting order.",
|
|
34885
|
+
inputSchema: { rule_id: string(), destination: number().int().min(0) },
|
|
34886
|
+
async handler(a, ctx) {
|
|
34887
|
+
const id = await resolveAccessId(a.rule_id, ctx);
|
|
34888
|
+
if (!id)
|
|
34889
|
+
return `Web proxy access rule '${a.rule_id}' not found.`;
|
|
34890
|
+
const before = await listItemIds(scope, ctx);
|
|
34891
|
+
if (a.destination >= before.length)
|
|
34892
|
+
return `NO CHANGE: destination ${a.destination} is outside the ${before.length} rule positions.`;
|
|
34893
|
+
if (before.indexOf(id) === a.destination)
|
|
34894
|
+
return `NO CHANGE: web proxy access rule ${id} is already at position ${a.destination}.`;
|
|
34895
|
+
const result = await executeMikrotikCommand2(`${scope} move ${id} ${before[a.destination]}`, ctx);
|
|
34896
|
+
if (looksLikeError(result))
|
|
34897
|
+
return `Failed to move web proxy access rule: ${result}`;
|
|
34898
|
+
const to = (await listItemIds(scope, ctx)).indexOf(id);
|
|
34899
|
+
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.`;
|
|
34900
|
+
}
|
|
34901
|
+
})
|
|
34902
|
+
];
|
|
34903
|
+
|
|
34719
34904
|
// src/tools/ip-ssh.ts
|
|
34720
34905
|
var ipSshTools = [
|
|
34721
34906
|
defineTool2({
|
|
@@ -35983,10 +36168,19 @@ ${result}`;
|
|
|
35983
36168
|
const id = await resolveRuleId(a.rule_id, ctx);
|
|
35984
36169
|
if (!id)
|
|
35985
36170
|
return `IPv6 firewall filter rule '${a.rule_id}' not found.`;
|
|
35986
|
-
const
|
|
36171
|
+
const before = await listItemIds("/ipv6 firewall filter", ctx);
|
|
36172
|
+
const from = before.indexOf(id);
|
|
36173
|
+
if (a.destination < 0 || a.destination >= before.length) {
|
|
36174
|
+
return `NO CHANGE: destination ${a.destination} is outside the ${before.length} rule positions.`;
|
|
36175
|
+
}
|
|
36176
|
+
if (from === a.destination)
|
|
36177
|
+
return `NO CHANGE: IPv6 firewall filter rule ${id} is already at position ${from}.`;
|
|
36178
|
+
const result = await executeMikrotikCommand2(`/ipv6 firewall filter move ${id} ${before[a.destination]}`, ctx);
|
|
35987
36179
|
if (looksLikeError(result))
|
|
35988
36180
|
return `Failed to move IPv6 firewall filter rule: ${result}`;
|
|
35989
|
-
|
|
36181
|
+
const after = await listItemIds("/ipv6 firewall filter", ctx);
|
|
36182
|
+
const to = after.indexOf(id);
|
|
36183
|
+
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.`;
|
|
35990
36184
|
}
|
|
35991
36185
|
}),
|
|
35992
36186
|
defineTool2({
|
|
@@ -44069,7 +44263,14 @@ function access5(ctx, write = false) {
|
|
|
44069
44263
|
function openVpnSessionsCommand() {
|
|
44070
44264
|
const find = new Cmd("/ppp active find where").set("service", "ovpn").build();
|
|
44071
44265
|
const read = new Cmd("/ppp active print").raw("detail as-value").raw("where").set("service", "ovpn").build();
|
|
44072
|
-
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] }`;
|
|
44266
|
+
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] }`;
|
|
44267
|
+
}
|
|
44268
|
+
function openVpnClientBytes(tx, rx) {
|
|
44269
|
+
if (typeof tx !== "number" && (typeof tx !== "string" || !/^\d+$/.test(tx)) || typeof rx !== "number" && (typeof rx !== "string" || !/^\d+$/.test(rx)))
|
|
44270
|
+
return [null, null];
|
|
44271
|
+
const download = Number(tx);
|
|
44272
|
+
const upload = Number(rx);
|
|
44273
|
+
return Number.isSafeInteger(download) && Number.isSafeInteger(upload) ? [download, upload] : [null, null];
|
|
44073
44274
|
}
|
|
44074
44275
|
function parseOpenVpnSessions(output) {
|
|
44075
44276
|
if (output.length > 1e6)
|
|
@@ -44083,6 +44284,7 @@ function parseOpenVpnSessions(output) {
|
|
|
44083
44284
|
if (!Array.isArray(rows) || rows.length > SESSION_LIMIT)
|
|
44084
44285
|
throw new Error("Invalid OpenVPN session snapshot.");
|
|
44085
44286
|
const ids = new Set;
|
|
44287
|
+
const names = rows.map((row) => row && typeof row === "object" ? row.name : undefined);
|
|
44086
44288
|
return rows.map((row) => {
|
|
44087
44289
|
const r = object({
|
|
44088
44290
|
".id": string().regex(/^\*[A-Fa-f0-9]+$/),
|
|
@@ -44093,11 +44295,14 @@ function parseOpenVpnSessions(output) {
|
|
|
44093
44295
|
"session-id": string().default(""),
|
|
44094
44296
|
uptime: string().default(""),
|
|
44095
44297
|
encoding: string().default(""),
|
|
44096
|
-
radius: union([boolean(), string()]).optional()
|
|
44298
|
+
radius: union([boolean(), string()]).optional(),
|
|
44299
|
+
"tx-byte": union([number(), string()]).optional(),
|
|
44300
|
+
"rx-byte": union([number(), string()]).optional()
|
|
44097
44301
|
}).parse(row);
|
|
44098
44302
|
if (ids.has(r[".id"]))
|
|
44099
44303
|
throw new Error("Duplicate OpenVPN session identifier; refresh required.");
|
|
44100
44304
|
ids.add(r[".id"]);
|
|
44305
|
+
const [downloadBytes, uploadBytes] = names.filter((name) => name === r.name).length === 1 ? openVpnClientBytes(r["tx-byte"], r["rx-byte"]) : [null, null];
|
|
44101
44306
|
return {
|
|
44102
44307
|
id: r[".id"],
|
|
44103
44308
|
name: r.name,
|
|
@@ -44107,7 +44312,9 @@ function parseOpenVpnSessions(output) {
|
|
|
44107
44312
|
encoding: r.encoding,
|
|
44108
44313
|
radius: r.radius === true || r.radius === "yes" || r.radius === "true",
|
|
44109
44314
|
uptime: r.uptime,
|
|
44110
|
-
uptimeSeconds: openVpnUptime(r.uptime)
|
|
44315
|
+
uptimeSeconds: openVpnUptime(r.uptime),
|
|
44316
|
+
downloadBytes,
|
|
44317
|
+
uploadBytes
|
|
44111
44318
|
};
|
|
44112
44319
|
});
|
|
44113
44320
|
}
|
|
@@ -53110,7 +53317,7 @@ var riskByTool = null;
|
|
|
53110
53317
|
async function riskIndex() {
|
|
53111
53318
|
if (riskByTool)
|
|
53112
53319
|
return riskByTool;
|
|
53113
|
-
const { moduleCatalog } = await import("./library-
|
|
53320
|
+
const { moduleCatalog } = await import("./library-r8m6ftrj.js");
|
|
53114
53321
|
const index = new Map;
|
|
53115
53322
|
for (const mod of moduleCatalog) {
|
|
53116
53323
|
for (const tool of mod.tools)
|
|
@@ -63066,6 +63273,13 @@ var moduleCatalog2 = [
|
|
|
63066
63273
|
description: "Filter rules and a guided basic setup (`/ip firewall filter`).",
|
|
63067
63274
|
tools: firewallFilterTools
|
|
63068
63275
|
},
|
|
63276
|
+
{
|
|
63277
|
+
label: "Web Proxy",
|
|
63278
|
+
slug: "web-proxy",
|
|
63279
|
+
group: "Security",
|
|
63280
|
+
description: "HTTP/HTTPS CONNECT proxy settings, live status and ordered access rules (`/ip proxy`).",
|
|
63281
|
+
tools: webProxyTools
|
|
63282
|
+
},
|
|
63069
63283
|
{
|
|
63070
63284
|
label: "Firewall \u2014 NAT",
|
|
63071
63285
|
slug: "firewall-nat",
|
|
@@ -63346,6 +63560,13 @@ var moduleCatalog2 = [
|
|
|
63346
63560
|
description: "Identity, resources, health, clock/NTP, packages, reboot/shutdown.",
|
|
63347
63561
|
tools: systemTools
|
|
63348
63562
|
},
|
|
63563
|
+
{
|
|
63564
|
+
label: "Device Mode",
|
|
63565
|
+
slug: "device-mode",
|
|
63566
|
+
group: "System & Ops",
|
|
63567
|
+
description: "Read device-mode capabilities and request physically confirmed feature changes.",
|
|
63568
|
+
tools: deviceModeTools
|
|
63569
|
+
},
|
|
63349
63570
|
{
|
|
63350
63571
|
label: "System Config",
|
|
63351
63572
|
slug: "system-config",
|