@usex/mikrotik-mcp 6.7.0 → 6.9.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-y5txdsgq.js → cli-0ckmf678.js} +1 -1
- package/dist/shared/{cli-kwsg0vb4.js → cli-7en5gay6.js} +1 -1
- package/dist/shared/{cli-w3tjpdhk.js → cli-amd43kc5.js} +1 -1
- package/dist/shared/{cli-hp8w45f1.js → cli-fb8k4p45.js} +1 -1
- package/dist/shared/{cli-v3ytyep0.js → cli-v5tym2a3.js} +323 -28
- package/dist/shared/{library-36y6v8ks.js → library-3hjxj4ph.js} +323 -28
- package/dist/shared/{library-aw8wrqbg.js → library-5mbnzvye.js} +1 -1
- package/dist/shared/{library-bty0a0n3.js → library-8fxp8mc8.js} +1 -1
- package/dist/shared/{library-j5qk3cvp.js → library-j1ptdg4x.js} +1 -1
- package/dist/shared/{library-j6pdmv0m.js → library-znv72s94.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 +131 -1
- package/schemas/tool-catalog.json +445 -5
- package/schemas/tools/add_bridge_port.json +4 -0
- package/schemas/tools/add_dot1x_server.json +4 -0
- package/schemas/tools/add_web_proxy_access_rule.json +25 -0
- package/schemas/tools/add_wireguard_peer.json +6 -0
- package/schemas/tools/create_bridge.json +21 -0
- package/schemas/tools/create_dhcp_server.json +4 -0
- package/schemas/tools/create_ipv6_dhcp_server.json +8 -0
- package/schemas/tools/create_vlan_interface.json +4 -0
- package/schemas/tools/get_device_mode.json +7 -0
- package/schemas/tools/get_web_proxy.json +7 -0
- package/schemas/tools/list_bgp_instances.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_bgp_instance_med_comparison.json +22 -0
- package/schemas/tools/update_bridge.json +21 -0
- package/schemas/tools/update_device_mode_features.json +99 -0
- package/schemas/tools/update_dot1x_server.json +4 -0
- package/schemas/tools/update_vlan_interface.json +4 -0
- package/schemas/tools/update_web_proxy.json +29 -0
- package/schemas/tools/update_wireguard_peer.json +17 -3
|
@@ -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-fb8k4p45.js")).openSnapshotStore;
|
|
16692
|
+
const db = await beforeTarget((await import("./cli-0ckmf678.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-amd43kc5.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 {
|
|
@@ -24195,6 +24193,11 @@ var bridgeTools = [
|
|
|
24195
24193
|
frame_types: FrameTypes.optional().describe("Default accepted frame types for ports"),
|
|
24196
24194
|
ingress_filtering: boolean().optional().describe("Default ingress VLAN filtering for ports"),
|
|
24197
24195
|
dhcp_snooping: boolean().optional().describe("Enable DHCP snooping"),
|
|
24196
|
+
arp_inspection: boolean().optional().describe("RouterOS 7.25+ validate ARP against DHCP snooping bindings"),
|
|
24197
|
+
ip_source_guard: boolean().optional().describe("RouterOS 7.25+ validate IPv4 source against DHCP snooping bindings"),
|
|
24198
|
+
mlag_init_delay: string().optional().describe("RouterOS 7.25+ MLAG LACP initialization delay"),
|
|
24199
|
+
mlag_lacp_fallback: boolean().optional().describe("RouterOS 7.25+ MLAG LACP fallback after peer loss"),
|
|
24200
|
+
confirm_security_disruption: literal(true).optional().describe("Required when enabling ARP inspection or IP source guard; DHCP bindings may be cleared and traffic interrupted"),
|
|
24198
24201
|
igmp_snooping: boolean().optional().describe("Enable IGMP/MLD snooping"),
|
|
24199
24202
|
fast_forward: boolean().optional().describe("Enable Fast Forward optimization"),
|
|
24200
24203
|
mvrp: boolean().optional().describe("Enable Multiple VLAN Registration Protocol"),
|
|
@@ -24203,8 +24206,10 @@ var bridgeTools = [
|
|
|
24203
24206
|
transmit_hold_count: number().int().optional().describe("STP transmit hold count")
|
|
24204
24207
|
},
|
|
24205
24208
|
async handler(a, ctx) {
|
|
24209
|
+
if ((a.arp_inspection || a.ip_source_guard) && !a.confirm_security_disruption)
|
|
24210
|
+
return "Enabling ARP inspection or IP source guard can clear DHCP bindings and interrupt clients. Review DHCP snooping and trusted ports, then set confirm_security_disruption=true.";
|
|
24206
24211
|
ctx.info(`Creating bridge: name=${a.name}, vlan_filtering=${a.vlan_filtering}`);
|
|
24207
|
-
const cmd = new Cmd("/interface bridge add").set("name", a.name).opt("comment", a.comment).flag("vlan-filtering", a.vlan_filtering).opt("protocol-mode", a.protocol_mode).opt("mtu", a.mtu).opt("ageing-time", a.ageing_time).opt("arp", a.arp).opt("arp-timeout", a.arp_timeout).bool("auto-mac", a.auto_mac).opt("admin-mac", a.admin_mac).opt("priority", a.priority).opt("ether-type", a.ether_type).opt("pvid", a.pvid).opt("frame-types", a.frame_types).bool("ingress-filtering", a.ingress_filtering).bool("dhcp-snooping", a.dhcp_snooping).bool("igmp-snooping", a.igmp_snooping).bool("fast-forward", a.fast_forward).bool("mvrp", a.mvrp).opt("forward-delay", a.forward_delay).opt("max-message-age", a.max_message_age).opt("transmit-hold-count", a.transmit_hold_count).flag("disabled", a.disabled).build();
|
|
24212
|
+
const cmd = new Cmd("/interface bridge add").set("name", a.name).opt("comment", a.comment).flag("vlan-filtering", a.vlan_filtering).opt("protocol-mode", a.protocol_mode).opt("mtu", a.mtu).opt("ageing-time", a.ageing_time).opt("arp", a.arp).opt("arp-timeout", a.arp_timeout).bool("auto-mac", a.auto_mac).opt("admin-mac", a.admin_mac).opt("priority", a.priority).opt("ether-type", a.ether_type).opt("pvid", a.pvid).opt("frame-types", a.frame_types).bool("ingress-filtering", a.ingress_filtering).bool("dhcp-snooping", a.dhcp_snooping).bool("arp-inspection", a.arp_inspection).bool("ip-source-guard", a.ip_source_guard).opt("mlag-init-delay", a.mlag_init_delay).bool("mlag-lacp-fallback", a.mlag_lacp_fallback).bool("igmp-snooping", a.igmp_snooping).bool("fast-forward", a.fast_forward).bool("mvrp", a.mvrp).opt("forward-delay", a.forward_delay).opt("max-message-age", a.max_message_age).opt("transmit-hold-count", a.transmit_hold_count).flag("disabled", a.disabled).build();
|
|
24208
24213
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
24209
24214
|
if (looksLikeError(result))
|
|
24210
24215
|
return `Failed to create bridge: ${result}`;
|
|
@@ -24271,6 +24276,11 @@ ${result}`;
|
|
|
24271
24276
|
frame_types: FrameTypes.optional().describe("Default accepted frame types for ports"),
|
|
24272
24277
|
ingress_filtering: boolean().optional().describe("Default ingress VLAN filtering for ports"),
|
|
24273
24278
|
dhcp_snooping: boolean().optional().describe("Enable DHCP snooping"),
|
|
24279
|
+
arp_inspection: boolean().optional().describe("RouterOS 7.25+ validate ARP against DHCP snooping bindings"),
|
|
24280
|
+
ip_source_guard: boolean().optional().describe("RouterOS 7.25+ validate IPv4 source against DHCP snooping bindings"),
|
|
24281
|
+
mlag_init_delay: string().optional().describe("RouterOS 7.25+ MLAG LACP initialization delay"),
|
|
24282
|
+
mlag_lacp_fallback: boolean().optional().describe("RouterOS 7.25+ MLAG LACP fallback after peer loss"),
|
|
24283
|
+
confirm_security_disruption: literal(true).optional().describe("Required when enabling ARP inspection or IP source guard; DHCP bindings may be cleared and traffic interrupted"),
|
|
24274
24284
|
igmp_snooping: boolean().optional().describe("Enable IGMP/MLD snooping"),
|
|
24275
24285
|
fast_forward: boolean().optional().describe("Enable Fast Forward optimization"),
|
|
24276
24286
|
mvrp: boolean().optional().describe("Enable Multiple VLAN Registration Protocol"),
|
|
@@ -24279,15 +24289,17 @@ ${result}`;
|
|
|
24279
24289
|
transmit_hold_count: number().int().optional().describe("STP transmit hold count")
|
|
24280
24290
|
},
|
|
24281
24291
|
async handler(a, ctx) {
|
|
24292
|
+
if ((a.arp_inspection || a.ip_source_guard) && !a.confirm_security_disruption)
|
|
24293
|
+
return "Enabling ARP inspection or IP source guard can clear DHCP bindings and interrupt clients. Review DHCP snooping and trusted ports, then set confirm_security_disruption=true.";
|
|
24282
24294
|
ctx.info(`Updating bridge: name=${a.name}`);
|
|
24283
|
-
const cmd = new Cmd(`/interface bridge set [find name
|
|
24295
|
+
const cmd = new Cmd(`/interface bridge set [find name=${quoteValue(a.name)}]`).opt("name", a.new_name).opt("comment", a.comment).bool("vlan-filtering", a.vlan_filtering).opt("protocol-mode", a.protocol_mode).bool("disabled", a.disabled).opt("mtu", a.mtu).opt("ageing-time", a.ageing_time).opt("arp", a.arp).opt("arp-timeout", a.arp_timeout).bool("auto-mac", a.auto_mac).opt("admin-mac", a.admin_mac).opt("priority", a.priority).opt("ether-type", a.ether_type).opt("pvid", a.pvid).opt("frame-types", a.frame_types).bool("ingress-filtering", a.ingress_filtering).bool("dhcp-snooping", a.dhcp_snooping).bool("arp-inspection", a.arp_inspection).bool("ip-source-guard", a.ip_source_guard).opt("mlag-init-delay", a.mlag_init_delay).bool("mlag-lacp-fallback", a.mlag_lacp_fallback).bool("igmp-snooping", a.igmp_snooping).bool("fast-forward", a.fast_forward).bool("mvrp", a.mvrp).opt("forward-delay", a.forward_delay).opt("max-message-age", a.max_message_age).opt("transmit-hold-count", a.transmit_hold_count).build();
|
|
24284
24296
|
if (!cmd.includes("=", cmd.indexOf("]")))
|
|
24285
24297
|
return "No updates specified.";
|
|
24286
24298
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
24287
24299
|
if (looksLikeError(result))
|
|
24288
24300
|
return `Failed to update bridge: ${result}`;
|
|
24289
24301
|
const target = a.new_name ?? a.name;
|
|
24290
|
-
const details = await executeMikrotikCommand(
|
|
24302
|
+
const details = await executeMikrotikCommand(new Cmd("/interface bridge print detail where").set("name", target).build(), ctx);
|
|
24291
24303
|
return `Bridge updated successfully:
|
|
24292
24304
|
|
|
24293
24305
|
${details}`;
|
|
@@ -24337,6 +24349,7 @@ ${details}`;
|
|
|
24337
24349
|
restricted_role: boolean().optional().describe("Exclude port from becoming the root port"),
|
|
24338
24350
|
restricted_tcn: boolean().optional().describe("Block topology change notifications from this port"),
|
|
24339
24351
|
trusted: boolean().optional().describe("Trust DHCP server replies on this port (DHCP snooping)"),
|
|
24352
|
+
trusted_arp: boolean().optional().describe("RouterOS 7.25+ exempt this port from ARP inspection"),
|
|
24340
24353
|
multicast_router: MulticastRouter.optional().describe("IGMP-snooping multicast router state"),
|
|
24341
24354
|
fast_leave: boolean().optional().describe("IGMP-snooping fast leave"),
|
|
24342
24355
|
unknown_unicast_flood: boolean().optional().describe("Flood unknown-unicast frames to this port"),
|
|
@@ -24345,7 +24358,7 @@ ${details}`;
|
|
|
24345
24358
|
},
|
|
24346
24359
|
async handler(a, ctx) {
|
|
24347
24360
|
ctx.info(`Adding bridge port: bridge=${a.bridge}, interface=${a.interface}`);
|
|
24348
|
-
const cmd = new Cmd("/interface bridge port add").set("bridge", a.bridge).set("interface", a.interface).opt("pvid", a.pvid).opt("comment", a.comment).bool("hw", a.hw).bool("disabled", a.disabled).opt("frame-types", a.frame_types).bool("ingress-filtering", a.ingress_filtering).bool("tag-stacking", a.tag_stacking).opt("priority", a.priority).opt("path-cost", a.path_cost).opt("internal-path-cost", a.internal_path_cost).opt("horizon", a.horizon).opt("learn", a.learn).opt("edge", a.edge).opt("point-to-point", a.point_to_point).bool("auto-isolate", a.auto_isolate).bool("bpdu-guard", a.bpdu_guard).bool("restricted-role", a.restricted_role).bool("restricted-tcn", a.restricted_tcn).bool("trusted", a.trusted).opt("multicast-router", a.multicast_router).bool("fast-leave", a.fast_leave).bool("unknown-unicast-flood", a.unknown_unicast_flood).bool("unknown-multicast-flood", a.unknown_multicast_flood).bool("broadcast-flood", a.broadcast_flood).build();
|
|
24361
|
+
const cmd = new Cmd("/interface bridge port add").set("bridge", a.bridge).set("interface", a.interface).opt("pvid", a.pvid).opt("comment", a.comment).bool("hw", a.hw).bool("disabled", a.disabled).opt("frame-types", a.frame_types).bool("ingress-filtering", a.ingress_filtering).bool("tag-stacking", a.tag_stacking).opt("priority", a.priority).opt("path-cost", a.path_cost).opt("internal-path-cost", a.internal_path_cost).opt("horizon", a.horizon).opt("learn", a.learn).opt("edge", a.edge).opt("point-to-point", a.point_to_point).bool("auto-isolate", a.auto_isolate).bool("bpdu-guard", a.bpdu_guard).bool("restricted-role", a.restricted_role).bool("restricted-tcn", a.restricted_tcn).bool("trusted", a.trusted).bool("trusted-arp", a.trusted_arp).opt("multicast-router", a.multicast_router).bool("fast-leave", a.fast_leave).bool("unknown-unicast-flood", a.unknown_unicast_flood).bool("unknown-multicast-flood", a.unknown_multicast_flood).bool("broadcast-flood", a.broadcast_flood).build();
|
|
24349
24362
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
24350
24363
|
if (looksLikeError(result))
|
|
24351
24364
|
return `Failed to add bridge port: ${result}`;
|
|
@@ -26906,6 +26919,68 @@ ${lines.join(`
|
|
|
26906
26919
|
})
|
|
26907
26920
|
];
|
|
26908
26921
|
|
|
26922
|
+
// src/tools/device-mode.ts
|
|
26923
|
+
var deviceModeTools = [
|
|
26924
|
+
defineTool({
|
|
26925
|
+
name: "get_device_mode",
|
|
26926
|
+
title: "Get RouterOS Device Mode",
|
|
26927
|
+
annotations: READ,
|
|
26928
|
+
description: "Read `/system device-mode print` to see which restricted RouterOS features are available and whether physical confirmation is pending.",
|
|
26929
|
+
async handler(_a, ctx) {
|
|
26930
|
+
const result = await executeMikrotikCommand("/system device-mode print", ctx);
|
|
26931
|
+
return isEmpty(result) ? "Device mode unavailable on this RouterOS version." : result;
|
|
26932
|
+
}
|
|
26933
|
+
}),
|
|
26934
|
+
defineTool({
|
|
26935
|
+
name: "update_device_mode_features",
|
|
26936
|
+
title: "Request Device Mode Feature Update",
|
|
26937
|
+
annotations: DANGEROUS,
|
|
26938
|
+
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.",
|
|
26939
|
+
inputSchema: {
|
|
26940
|
+
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."),
|
|
26941
|
+
scheduler: boolean().optional(),
|
|
26942
|
+
socks: boolean().optional(),
|
|
26943
|
+
fetch: boolean().optional(),
|
|
26944
|
+
pptp: boolean().optional(),
|
|
26945
|
+
l2tp: boolean().optional(),
|
|
26946
|
+
bandwidth_test: boolean().optional(),
|
|
26947
|
+
traffic_gen: boolean().optional(),
|
|
26948
|
+
sniffer: boolean().optional(),
|
|
26949
|
+
ipsec: boolean().optional(),
|
|
26950
|
+
romon: boolean().optional(),
|
|
26951
|
+
proxy: boolean().optional(),
|
|
26952
|
+
hotspot: boolean().optional(),
|
|
26953
|
+
smb: boolean().optional(),
|
|
26954
|
+
email: boolean().optional(),
|
|
26955
|
+
zerotier: boolean().optional(),
|
|
26956
|
+
container: boolean().optional(),
|
|
26957
|
+
install_any_version: boolean().optional(),
|
|
26958
|
+
partitions: boolean().optional(),
|
|
26959
|
+
routerboard: boolean().optional(),
|
|
26960
|
+
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)."),
|
|
26961
|
+
flagging_enabled: boolean().optional(),
|
|
26962
|
+
flagged: boolean().optional().describe("Set false only after a security audit of the router configuration."),
|
|
26963
|
+
confirm_mode_resets_overrides: literal(true).optional().describe("Required with mode: existing per-feature overrides will be reset unless included in this request."),
|
|
26964
|
+
confirm_flagged_audit_complete: literal(true).optional().describe("Required to clear flagged after auditing configuration, passwords, and RouterOS version."),
|
|
26965
|
+
physical_confirmation_available: literal(true).describe("Operator is physically present and has authorized the device-mode change.")
|
|
26966
|
+
},
|
|
26967
|
+
async handler(a, ctx) {
|
|
26968
|
+
if (a.mode && !a.confirm_mode_resets_overrides)
|
|
26969
|
+
return "Refusing mode change: confirm_mode_resets_overrides=true is required because mode resets prior per-feature overrides.";
|
|
26970
|
+
if (a.flagged === false && !a.confirm_flagged_audit_complete)
|
|
26971
|
+
return "Refusing to clear flagged: confirm_flagged_audit_complete=true is required after a security audit.";
|
|
26972
|
+
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);
|
|
26973
|
+
if (cmd.build() === "/system device-mode update")
|
|
26974
|
+
return "No feature changes specified.";
|
|
26975
|
+
const result = await executeMikrotikCommand(cmd.build(), ctx);
|
|
26976
|
+
if (looksLikeError(result))
|
|
26977
|
+
return `Failed to request device-mode update: ${result}`;
|
|
26978
|
+
return `Device-mode update requested; physical confirmation is required before treating it as active. Router response:
|
|
26979
|
+
${result}`;
|
|
26980
|
+
}
|
|
26981
|
+
})
|
|
26982
|
+
];
|
|
26983
|
+
|
|
26909
26984
|
// src/tools/dhcp.ts
|
|
26910
26985
|
var Authoritative = _enum(["yes", "no", "after-2sec-delay"]);
|
|
26911
26986
|
var dhcpTools = [
|
|
@@ -26926,6 +27001,7 @@ var dhcpTools = [
|
|
|
26926
27001
|
delay_threshold: string().optional(),
|
|
26927
27002
|
add_arp: boolean().optional().describe("Add dynamic ARP entry for each lease (use with reply-only ARP on the interface)"),
|
|
26928
27003
|
always_broadcast: boolean().optional().describe("Always send replies as broadcast"),
|
|
27004
|
+
ipv6_only_preferred: boolean().optional().describe("RouterOS 7.25+ advertise DHCP option 108 for IPv6-only preferred clients"),
|
|
26929
27005
|
bootp_support: _enum(["none", "static", "dynamic"]).optional().describe("Which BOOTP requests to answer"),
|
|
26930
27006
|
conflict_detection: boolean().optional().describe("Ping/ARP-probe an address before offering it to detect conflicts"),
|
|
26931
27007
|
use_radius: _enum(["yes", "no", "accounting"]).optional().describe("Use RADIUS for leases (accounting = RADIUS accounting only)"),
|
|
@@ -26936,7 +27012,7 @@ var dhcpTools = [
|
|
|
26936
27012
|
},
|
|
26937
27013
|
async handler(a, ctx) {
|
|
26938
27014
|
ctx.info(`Creating DHCP server: name=${a.name}, interface=${a.interface}`);
|
|
26939
|
-
const cmd = new Cmd("/ip dhcp-server add").set("name", a.name).set("interface", a.interface).set("lease-time", a.lease_time).opt("address-pool", a.address_pool).flag("disabled", a.disabled).raw(a.authoritative !== "yes" ? `authoritative=${a.authoritative}` : null).opt("delay-threshold", a.delay_threshold).bool("add-arp", a.add_arp).bool("always-broadcast", a.always_broadcast).opt("bootp-support", a.bootp_support).bool("conflict-detection", a.conflict_detection).opt("use-radius", a.use_radius).opt("relay", a.relay).opt("server-address", a.server_address).opt("lease-script", a.lease_script).opt("comment", a.comment).build();
|
|
27015
|
+
const cmd = new Cmd("/ip dhcp-server add").set("name", a.name).set("interface", a.interface).set("lease-time", a.lease_time).opt("address-pool", a.address_pool).flag("disabled", a.disabled).raw(a.authoritative !== "yes" ? `authoritative=${a.authoritative}` : null).opt("delay-threshold", a.delay_threshold).bool("add-arp", a.add_arp).bool("always-broadcast", a.always_broadcast).bool("ipv6-only-preferred", a.ipv6_only_preferred).opt("bootp-support", a.bootp_support).bool("conflict-detection", a.conflict_detection).opt("use-radius", a.use_radius).opt("relay", a.relay).opt("server-address", a.server_address).opt("lease-script", a.lease_script).opt("comment", a.comment).build();
|
|
26940
27016
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
26941
27017
|
if (looksLikeError(result))
|
|
26942
27018
|
return `Failed to create DHCP server: ${result}`;
|
|
@@ -28576,6 +28652,7 @@ var SYNONYMS = {
|
|
|
28576
28652
|
show: ["list", "print", "get"],
|
|
28577
28653
|
print: ["list", "show"],
|
|
28578
28654
|
get: ["show", "fetch"],
|
|
28655
|
+
read: ["get", "list", "show"],
|
|
28579
28656
|
fetch: ["get"],
|
|
28580
28657
|
update: ["set", "modify", "change", "edit"],
|
|
28581
28658
|
set: ["update", "modify", "change"],
|
|
@@ -28670,7 +28747,7 @@ var cache3 = null;
|
|
|
28670
28747
|
async function gateway() {
|
|
28671
28748
|
if (cache3)
|
|
28672
28749
|
return cache3;
|
|
28673
|
-
const { moduleCatalog } = await import("./cli-
|
|
28750
|
+
const { moduleCatalog } = await import("./cli-7en5gay6.js");
|
|
28674
28751
|
const forIndex = [];
|
|
28675
28752
|
const byName = new Map;
|
|
28676
28753
|
for (const mod of moduleCatalog) {
|
|
@@ -29392,12 +29469,15 @@ var dot1xServerTools = [
|
|
|
29392
29469
|
reject_vlan_id: string().optional().describe("VLAN id or 'none'"),
|
|
29393
29470
|
server_fail_vlan_id: string().optional().describe("VLAN id or 'none'"),
|
|
29394
29471
|
reauth_timeout: string().optional().describe("Re-auth period or 'none'"),
|
|
29472
|
+
reauth_period: string().optional().describe("RouterOS 7.25+ re-authentication period"),
|
|
29395
29473
|
comment: string().optional(),
|
|
29396
29474
|
disabled: boolean().default(false)
|
|
29397
29475
|
},
|
|
29398
29476
|
async handler(a, ctx) {
|
|
29477
|
+
if (a.reauth_period !== undefined && a.reauth_timeout !== undefined)
|
|
29478
|
+
return "Specify either reauth_period (RouterOS 7.25+) or reauth_timeout (older RouterOS), not both.";
|
|
29399
29479
|
ctx.info(`Adding dot1x server: interface=${a.interface}`);
|
|
29400
|
-
const cmd = new Cmd("/interface dot1x server add").set("interface", a.interface).opt("auth-types", a.auth_types).bool("accounting", a.accounting).opt("interim-update", a.interim_update).opt("mac-auth-mode", a.mac_auth_mode).opt("guest-vlan-id", a.guest_vlan_id).opt("reject-vlan-id", a.reject_vlan_id).opt("server-fail-vlan-id", a.server_fail_vlan_id).opt("reauth-timeout", a.reauth_timeout).opt("comment", a.comment).flag("disabled", a.disabled).build();
|
|
29480
|
+
const cmd = new Cmd("/interface dot1x server add").set("interface", a.interface).opt("auth-types", a.auth_types).bool("accounting", a.accounting).opt("interim-update", a.interim_update).opt("mac-auth-mode", a.mac_auth_mode).opt("guest-vlan-id", a.guest_vlan_id).opt("reject-vlan-id", a.reject_vlan_id).opt("server-fail-vlan-id", a.server_fail_vlan_id).opt("reauth-timeout", a.reauth_timeout).opt("reauth-period", a.reauth_period).opt("comment", a.comment).flag("disabled", a.disabled).build();
|
|
29401
29481
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
29402
29482
|
if (looksLikeError(result))
|
|
29403
29483
|
return `Failed to add dot1x server: ${result}`;
|
|
@@ -29463,14 +29543,18 @@ ${result}`;
|
|
|
29463
29543
|
reject_vlan_id: string().optional(),
|
|
29464
29544
|
server_fail_vlan_id: string().optional(),
|
|
29465
29545
|
reauth_timeout: string().optional(),
|
|
29546
|
+
reauth_period: string().optional().describe("RouterOS 7.25+ re-authentication period"),
|
|
29466
29547
|
comment: string().optional(),
|
|
29467
29548
|
disabled: boolean().optional()
|
|
29468
29549
|
},
|
|
29469
29550
|
async handler(a, ctx) {
|
|
29551
|
+
if (a.reauth_period !== undefined && a.reauth_timeout !== undefined)
|
|
29552
|
+
return "Specify either reauth_period (RouterOS 7.25+) or reauth_timeout (older RouterOS), not both.";
|
|
29470
29553
|
ctx.info(`Updating dot1x server: server_id=${a.server_id}`);
|
|
29471
29554
|
const selector = a.server_id.startsWith("*") ? `.id="${a.server_id}"` : `interface="${a.server_id}"`;
|
|
29472
29555
|
const base = `/interface dot1x server set [find ${selector}]`;
|
|
29473
29556
|
const cmd = new Cmd(base).opt("auth-types", a.auth_types).bool("accounting", a.accounting).opt("interim-update", a.interim_update).opt("mac-auth-mode", a.mac_auth_mode).opt("guest-vlan-id", a.guest_vlan_id).opt("reject-vlan-id", a.reject_vlan_id).opt("server-fail-vlan-id", a.server_fail_vlan_id).opt("reauth-timeout", a.reauth_timeout);
|
|
29557
|
+
cmd.opt("reauth-period", a.reauth_period);
|
|
29474
29558
|
if (a.comment !== undefined)
|
|
29475
29559
|
cmd.raw(`comment=${quoteValue(a.comment)}`);
|
|
29476
29560
|
if (a.disabled !== undefined)
|
|
@@ -33499,11 +33583,17 @@ ${result}`;
|
|
|
33499
33583
|
if (!id)
|
|
33500
33584
|
return `Firewall filter rule '${a.rule_id}' not found.`;
|
|
33501
33585
|
const before = await listItemIds("/ip firewall filter", ctx);
|
|
33502
|
-
const
|
|
33586
|
+
const from = before.indexOf(id);
|
|
33587
|
+
if (a.destination < 0 || a.destination >= before.length) {
|
|
33588
|
+
return `NO CHANGE: destination ${a.destination} is outside the ${before.length} rule positions.`;
|
|
33589
|
+
}
|
|
33590
|
+
if (from === a.destination)
|
|
33591
|
+
return `NO CHANGE: firewall filter rule ${id} is already at position ${from}.`;
|
|
33592
|
+
const target = before[a.destination];
|
|
33593
|
+
const result = await executeMikrotikCommand(`/ip firewall filter move ${id} ${target}`, ctx);
|
|
33503
33594
|
if (looksLikeError(result))
|
|
33504
33595
|
return `Failed to move firewall filter rule: ${result}`;
|
|
33505
33596
|
const after = await listItemIds("/ip firewall filter", ctx);
|
|
33506
|
-
const from = before.indexOf(id);
|
|
33507
33597
|
const to = after.indexOf(id);
|
|
33508
33598
|
if (to === -1) {
|
|
33509
33599
|
return `Firewall filter rule ${id} moved, but it could not be located afterwards \u2014 verify with list_filter_rules.`;
|
|
@@ -35306,6 +35396,124 @@ ${details}`;
|
|
|
35306
35396
|
})
|
|
35307
35397
|
];
|
|
35308
35398
|
|
|
35399
|
+
// src/tools/web-proxy.ts
|
|
35400
|
+
var scope = "/ip proxy access";
|
|
35401
|
+
var resolveAccessId = ruleResolver(scope);
|
|
35402
|
+
var webProxyTools = [
|
|
35403
|
+
defineTool({
|
|
35404
|
+
name: "get_web_proxy",
|
|
35405
|
+
title: "Get Web Proxy Settings",
|
|
35406
|
+
annotations: READ,
|
|
35407
|
+
description: "Read RouterOS `/ip proxy` settings, including enabled, port, outgoing source and cache.",
|
|
35408
|
+
async handler(_a, ctx) {
|
|
35409
|
+
const result = await executeMikrotikCommand("/ip proxy print", ctx);
|
|
35410
|
+
return isEmpty(result) ? "Web proxy settings unavailable." : result;
|
|
35411
|
+
}
|
|
35412
|
+
}),
|
|
35413
|
+
defineTool({
|
|
35414
|
+
name: "update_web_proxy",
|
|
35415
|
+
title: "Update Web Proxy Settings",
|
|
35416
|
+
annotations: DANGEROUS,
|
|
35417
|
+
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.",
|
|
35418
|
+
inputSchema: {
|
|
35419
|
+
enabled: boolean().optional(),
|
|
35420
|
+
port: number().int().min(1).max(65535).optional(),
|
|
35421
|
+
src_address: string().optional(),
|
|
35422
|
+
anonymous: boolean().optional(),
|
|
35423
|
+
max_cache_size: string().optional(),
|
|
35424
|
+
confirm_firewall_ready: boolean().optional().describe("Required when enabling: IPv4 and IPv6 input firewall access has been verified.")
|
|
35425
|
+
},
|
|
35426
|
+
async handler(a, ctx) {
|
|
35427
|
+
if (a.enabled === true && !a.confirm_firewall_ready) {
|
|
35428
|
+
return "Refusing to enable web proxy until confirm_firewall_ready=true: verify both IPv4 and IPv6 input firewall restrictions first.";
|
|
35429
|
+
}
|
|
35430
|
+
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);
|
|
35431
|
+
if (cmd.build() === "/ip proxy set")
|
|
35432
|
+
return "No updates specified.";
|
|
35433
|
+
const result = await executeMikrotikCommand(cmd.build(), ctx);
|
|
35434
|
+
if (looksLikeError(result))
|
|
35435
|
+
return `Failed to update web proxy: ${result}`;
|
|
35436
|
+
return `Web proxy update sent. Current settings:
|
|
35437
|
+
${await executeMikrotikCommand("/ip proxy print", ctx)}`;
|
|
35438
|
+
}
|
|
35439
|
+
}),
|
|
35440
|
+
defineTool({
|
|
35441
|
+
name: "monitor_web_proxy",
|
|
35442
|
+
title: "Monitor Web Proxy",
|
|
35443
|
+
annotations: READ,
|
|
35444
|
+
description: "Read one `/ip proxy monitor once` sample, including connection and request counters.",
|
|
35445
|
+
async handler(_a, ctx) {
|
|
35446
|
+
return executeMikrotikCommand("/ip proxy monitor once", ctx);
|
|
35447
|
+
}
|
|
35448
|
+
}),
|
|
35449
|
+
defineTool({
|
|
35450
|
+
name: "list_web_proxy_access_rules",
|
|
35451
|
+
title: "List Web Proxy Access Rules",
|
|
35452
|
+
annotations: READ,
|
|
35453
|
+
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.",
|
|
35454
|
+
async handler(_a, ctx) {
|
|
35455
|
+
const result = await executeMikrotikCommand(`${scope} print detail`, ctx);
|
|
35456
|
+
return isEmpty(result) ? "No web proxy access rules (unmatched requests are allowed)." : result;
|
|
35457
|
+
}
|
|
35458
|
+
}),
|
|
35459
|
+
defineTool({
|
|
35460
|
+
name: "add_web_proxy_access_rule",
|
|
35461
|
+
title: "Add Web Proxy Access Rule",
|
|
35462
|
+
annotations: WRITE,
|
|
35463
|
+
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.",
|
|
35464
|
+
inputSchema: {
|
|
35465
|
+
action: _enum(["allow", "deny"]),
|
|
35466
|
+
src_address: string().optional(),
|
|
35467
|
+
dst_address: string().optional(),
|
|
35468
|
+
comment: string().optional(),
|
|
35469
|
+
place_before: string().optional()
|
|
35470
|
+
},
|
|
35471
|
+
async handler(a, ctx) {
|
|
35472
|
+
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);
|
|
35473
|
+
const result = await executeRuleCreate(scope, cmd, ctx, a.place_before);
|
|
35474
|
+
if (looksLikeError(result))
|
|
35475
|
+
return `Failed to add web proxy access rule: ${result}`;
|
|
35476
|
+
return readCreatedRule(scope, result, "Web proxy access rule", ctx);
|
|
35477
|
+
}
|
|
35478
|
+
}),
|
|
35479
|
+
defineTool({
|
|
35480
|
+
name: "remove_web_proxy_access_rule",
|
|
35481
|
+
title: "Remove Web Proxy Access Rule",
|
|
35482
|
+
annotations: DESTRUCTIVE,
|
|
35483
|
+
description: "Remove one `/ip proxy access` rule by `.id` or zero-based row, after inspecting the ordered list.",
|
|
35484
|
+
inputSchema: { rule_id: string() },
|
|
35485
|
+
async handler(a, ctx) {
|
|
35486
|
+
const id = await resolveAccessId(a.rule_id, ctx);
|
|
35487
|
+
if (!id)
|
|
35488
|
+
return `Web proxy access rule '${a.rule_id}' not found.`;
|
|
35489
|
+
const result = await executeMikrotikCommand(`${scope} remove ${id}`, ctx);
|
|
35490
|
+
return looksLikeError(result) ? `Failed to remove web proxy access rule: ${result}` : `Removed web proxy access rule ${id}.`;
|
|
35491
|
+
}
|
|
35492
|
+
}),
|
|
35493
|
+
defineTool({
|
|
35494
|
+
name: "move_web_proxy_access_rule",
|
|
35495
|
+
title: "Move Web Proxy Access Rule",
|
|
35496
|
+
annotations: WRITE_IDEMPOTENT,
|
|
35497
|
+
description: "Move one `/ip proxy access` rule before the item at a zero-based destination position; reads back the resulting order.",
|
|
35498
|
+
inputSchema: { rule_id: string(), destination: number().int().min(0) },
|
|
35499
|
+
async handler(a, ctx) {
|
|
35500
|
+
const id = await resolveAccessId(a.rule_id, ctx);
|
|
35501
|
+
if (!id)
|
|
35502
|
+
return `Web proxy access rule '${a.rule_id}' not found.`;
|
|
35503
|
+
const before = await listItemIds(scope, ctx);
|
|
35504
|
+
if (a.destination >= before.length)
|
|
35505
|
+
return `NO CHANGE: destination ${a.destination} is outside the ${before.length} rule positions.`;
|
|
35506
|
+
if (before.indexOf(id) === a.destination)
|
|
35507
|
+
return `NO CHANGE: web proxy access rule ${id} is already at position ${a.destination}.`;
|
|
35508
|
+
const result = await executeMikrotikCommand(`${scope} move ${id} ${before[a.destination]}`, ctx);
|
|
35509
|
+
if (looksLikeError(result))
|
|
35510
|
+
return `Failed to move web proxy access rule: ${result}`;
|
|
35511
|
+
const to = (await listItemIds(scope, ctx)).indexOf(id);
|
|
35512
|
+
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.`;
|
|
35513
|
+
}
|
|
35514
|
+
})
|
|
35515
|
+
];
|
|
35516
|
+
|
|
35309
35517
|
// src/tools/ip-ssh.ts
|
|
35310
35518
|
var ipSshTools = [
|
|
35311
35519
|
defineTool({
|
|
@@ -36023,6 +36231,8 @@ var ipv6DhcpServerTools = [
|
|
|
36023
36231
|
lease_time: string().default("3d").describe("Lease duration e.g. '1d', '12h', '30m'"),
|
|
36024
36232
|
binding_script: string().optional(),
|
|
36025
36233
|
rapid_commit: boolean().optional(),
|
|
36234
|
+
add_dns_entries: boolean().optional().describe("RouterOS 7.25+ create AAAA DNS entries for client FQDNs"),
|
|
36235
|
+
add_dns_entries_suffix: string().optional().describe("Suffix for dynamically created DHCPv6 DNS entries"),
|
|
36026
36236
|
preference: number().int().min(0).max(255).optional(),
|
|
36027
36237
|
route_distance: number().int().optional(),
|
|
36028
36238
|
use_radius: boolean().optional().describe("Authenticate clients via RADIUS"),
|
|
@@ -36034,7 +36244,7 @@ var ipv6DhcpServerTools = [
|
|
|
36034
36244
|
},
|
|
36035
36245
|
async handler(a, ctx) {
|
|
36036
36246
|
ctx.info(`Creating DHCPv6 server: name=${a.name}, interface=${a.interface}`);
|
|
36037
|
-
const cmd = new Cmd("/ipv6 dhcp-server add").set("name", a.name).set("interface", a.interface).set("address-pool", a.address_pool).set("lease-time", a.lease_time).opt("binding-script", a.binding_script).bool("rapid-commit", a.rapid_commit).opt("preference", a.preference).opt("route-distance", a.route_distance).bool("use-radius", a.use_radius).bool("allow-dual-stack-queue", a.allow_dual_stack_queue).opt("parent-queue", a.parent_queue).opt("dhcp-option", a.dhcp_option?.length ? a.dhcp_option.join(",") : undefined).opt("comment", a.comment).flag("disabled", a.disabled).build();
|
|
36247
|
+
const cmd = new Cmd("/ipv6 dhcp-server add").set("name", a.name).set("interface", a.interface).set("address-pool", a.address_pool).set("lease-time", a.lease_time).opt("binding-script", a.binding_script).bool("rapid-commit", a.rapid_commit).bool("add-dns-entries", a.add_dns_entries).opt("add-dns-entries-suffix", a.add_dns_entries_suffix).opt("preference", a.preference).opt("route-distance", a.route_distance).bool("use-radius", a.use_radius).bool("allow-dual-stack-queue", a.allow_dual_stack_queue).opt("parent-queue", a.parent_queue).opt("dhcp-option", a.dhcp_option?.length ? a.dhcp_option.join(",") : undefined).opt("comment", a.comment).flag("disabled", a.disabled).build();
|
|
36038
36248
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
36039
36249
|
if (looksLikeError(result))
|
|
36040
36250
|
return `Failed to create DHCPv6 server: ${result}`;
|
|
@@ -36573,10 +36783,19 @@ ${result}`;
|
|
|
36573
36783
|
const id = await resolveRuleId(a.rule_id, ctx);
|
|
36574
36784
|
if (!id)
|
|
36575
36785
|
return `IPv6 firewall filter rule '${a.rule_id}' not found.`;
|
|
36576
|
-
const
|
|
36786
|
+
const before = await listItemIds("/ipv6 firewall filter", ctx);
|
|
36787
|
+
const from = before.indexOf(id);
|
|
36788
|
+
if (a.destination < 0 || a.destination >= before.length) {
|
|
36789
|
+
return `NO CHANGE: destination ${a.destination} is outside the ${before.length} rule positions.`;
|
|
36790
|
+
}
|
|
36791
|
+
if (from === a.destination)
|
|
36792
|
+
return `NO CHANGE: IPv6 firewall filter rule ${id} is already at position ${from}.`;
|
|
36793
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall filter move ${id} ${before[a.destination]}`, ctx);
|
|
36577
36794
|
if (looksLikeError(result))
|
|
36578
36795
|
return `Failed to move IPv6 firewall filter rule: ${result}`;
|
|
36579
|
-
|
|
36796
|
+
const after = await listItemIds("/ipv6 firewall filter", ctx);
|
|
36797
|
+
const to = after.indexOf(id);
|
|
36798
|
+
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
36799
|
}
|
|
36581
36800
|
}),
|
|
36582
36801
|
defineTool({
|
|
@@ -44840,7 +45059,14 @@ function access5(ctx, write = false) {
|
|
|
44840
45059
|
function openVpnSessionsCommand() {
|
|
44841
45060
|
const find = new Cmd("/ppp active find where").set("service", "ovpn").build();
|
|
44842
45061
|
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] }`;
|
|
45062
|
+
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] }`;
|
|
45063
|
+
}
|
|
45064
|
+
function openVpnClientBytes(tx, rx) {
|
|
45065
|
+
if (typeof tx !== "number" && (typeof tx !== "string" || !/^\d+$/.test(tx)) || typeof rx !== "number" && (typeof rx !== "string" || !/^\d+$/.test(rx)))
|
|
45066
|
+
return [null, null];
|
|
45067
|
+
const download = Number(tx);
|
|
45068
|
+
const upload = Number(rx);
|
|
45069
|
+
return Number.isSafeInteger(download) && Number.isSafeInteger(upload) ? [download, upload] : [null, null];
|
|
44844
45070
|
}
|
|
44845
45071
|
function parseOpenVpnSessions(output) {
|
|
44846
45072
|
if (output.length > 1e6)
|
|
@@ -44854,6 +45080,7 @@ function parseOpenVpnSessions(output) {
|
|
|
44854
45080
|
if (!Array.isArray(rows) || rows.length > SESSION_LIMIT)
|
|
44855
45081
|
throw new Error("Invalid OpenVPN session snapshot.");
|
|
44856
45082
|
const ids = new Set;
|
|
45083
|
+
const names = rows.map((row) => row && typeof row === "object" ? row.name : undefined);
|
|
44857
45084
|
return rows.map((row) => {
|
|
44858
45085
|
const r = object({
|
|
44859
45086
|
".id": string().regex(/^\*[A-Fa-f0-9]+$/),
|
|
@@ -44864,11 +45091,14 @@ function parseOpenVpnSessions(output) {
|
|
|
44864
45091
|
"session-id": string().default(""),
|
|
44865
45092
|
uptime: string().default(""),
|
|
44866
45093
|
encoding: string().default(""),
|
|
44867
|
-
radius: union([boolean(), string()]).optional()
|
|
45094
|
+
radius: union([boolean(), string()]).optional(),
|
|
45095
|
+
"tx-byte": union([number(), string()]).optional(),
|
|
45096
|
+
"rx-byte": union([number(), string()]).optional()
|
|
44868
45097
|
}).parse(row);
|
|
44869
45098
|
if (ids.has(r[".id"]))
|
|
44870
45099
|
throw new Error("Duplicate OpenVPN session identifier; refresh required.");
|
|
44871
45100
|
ids.add(r[".id"]);
|
|
45101
|
+
const [downloadBytes, uploadBytes] = names.filter((name) => name === r.name).length === 1 ? openVpnClientBytes(r["tx-byte"], r["rx-byte"]) : [null, null];
|
|
44872
45102
|
return {
|
|
44873
45103
|
id: r[".id"],
|
|
44874
45104
|
name: r.name,
|
|
@@ -44878,7 +45108,9 @@ function parseOpenVpnSessions(output) {
|
|
|
44878
45108
|
encoding: r.encoding,
|
|
44879
45109
|
radius: r.radius === true || r.radius === "yes" || r.radius === "true",
|
|
44880
45110
|
uptime: r.uptime,
|
|
44881
|
-
uptimeSeconds: openVpnUptime(r.uptime)
|
|
45111
|
+
uptimeSeconds: openVpnUptime(r.uptime),
|
|
45112
|
+
downloadBytes,
|
|
45113
|
+
uploadBytes
|
|
44882
45114
|
};
|
|
44883
45115
|
});
|
|
44884
45116
|
}
|
|
@@ -49072,6 +49304,51 @@ ${result}`;
|
|
|
49072
49304
|
// src/tools/routing-bgp.ts
|
|
49073
49305
|
var UNSUPPORTED2 = "BGP is not available on this device (requires RouterOS v7 with the routing package).";
|
|
49074
49306
|
var routingBgpTools = [
|
|
49307
|
+
defineTool({
|
|
49308
|
+
name: "list_bgp_instances",
|
|
49309
|
+
title: "List BGP Instances",
|
|
49310
|
+
annotations: READ,
|
|
49311
|
+
description: "Read BGP instances and their best-path selection settings, including RouterOS 7.25+ always-compare-med. Use before changing an instance.",
|
|
49312
|
+
async handler(_a, ctx) {
|
|
49313
|
+
const result = await executeMikrotikCommand("/routing bgp instance print detail", ctx);
|
|
49314
|
+
if (commandUnsupported(result))
|
|
49315
|
+
return UNSUPPORTED2;
|
|
49316
|
+
return isEmpty(result) ? "No BGP instances found." : `BGP INSTANCES:
|
|
49317
|
+
|
|
49318
|
+
${result}`;
|
|
49319
|
+
}
|
|
49320
|
+
}),
|
|
49321
|
+
defineTool({
|
|
49322
|
+
name: "update_bgp_instance_med_comparison",
|
|
49323
|
+
title: "Set BGP Instance MED Comparison",
|
|
49324
|
+
annotations: WRITE_IDEMPOTENT,
|
|
49325
|
+
description: "Set RouterOS 7.25+ always-compare-med on one named BGP instance. This changes best-path selection and can reroute traffic; inspect list_bgp_instances and obtain operator approval first.",
|
|
49326
|
+
inputSchema: {
|
|
49327
|
+
name: string().min(1).describe("Exact BGP instance name"),
|
|
49328
|
+
always_compare_med: boolean(),
|
|
49329
|
+
confirm_routing_change: literal(true).describe("Operator approved the best-path behavior change")
|
|
49330
|
+
},
|
|
49331
|
+
async handler(a, ctx) {
|
|
49332
|
+
const selector = new Cmd("/routing bgp instance print count-only where").set("name", a.name).build();
|
|
49333
|
+
const count = await executeMikrotikCommand(selector, ctx);
|
|
49334
|
+
if (commandUnsupported(count))
|
|
49335
|
+
return UNSUPPORTED2;
|
|
49336
|
+
if (looksLikeError(count))
|
|
49337
|
+
return `Failed to inspect BGP instance: ${count}`;
|
|
49338
|
+
if (isEmpty(count) || count.trim() === "0")
|
|
49339
|
+
return `BGP instance '${a.name}' not found.`;
|
|
49340
|
+
const cmd = new Cmd(`/routing bgp instance set [find name=${quoteValue(a.name)}]`).bool("always-compare-med", a.always_compare_med).build();
|
|
49341
|
+
const result = await executeMikrotikCommand(cmd, ctx);
|
|
49342
|
+
if (looksLikeError(result))
|
|
49343
|
+
return `Failed to update BGP instance: ${result}`;
|
|
49344
|
+
const details = await executeMikrotikCommand(new Cmd("/routing bgp instance print detail where").set("name", a.name).build(), ctx);
|
|
49345
|
+
if (looksLikeError(details) || isEmpty(details))
|
|
49346
|
+
return `BGP instance update was sent, but read-back failed: ${details || "no details returned"}`;
|
|
49347
|
+
return `BGP instance '${a.name}' MED comparison updated:
|
|
49348
|
+
|
|
49349
|
+
${details}`;
|
|
49350
|
+
}
|
|
49351
|
+
}),
|
|
49075
49352
|
defineTool({
|
|
49076
49353
|
name: "list_bgp_connections",
|
|
49077
49354
|
title: "List BGP Connections",
|
|
@@ -54129,7 +54406,7 @@ var riskByTool = null;
|
|
|
54129
54406
|
async function riskIndex() {
|
|
54130
54407
|
if (riskByTool)
|
|
54131
54408
|
return riskByTool;
|
|
54132
|
-
const { moduleCatalog } = await import("./cli-
|
|
54409
|
+
const { moduleCatalog } = await import("./cli-7en5gay6.js");
|
|
54133
54410
|
const index = new Map;
|
|
54134
54411
|
for (const mod of moduleCatalog) {
|
|
54135
54412
|
for (const tool of mod.tools)
|
|
@@ -61535,6 +61812,7 @@ var vlanTools = [
|
|
|
61535
61812
|
comment: string().optional(),
|
|
61536
61813
|
disabled: boolean().default(false),
|
|
61537
61814
|
mtu: number().int().optional(),
|
|
61815
|
+
forced_mac_address: string().optional().describe("RouterOS 7.25+ forced VLAN interface MAC address"),
|
|
61538
61816
|
use_service_tag: boolean().default(false).describe("Use 802.1ad service tag (QinQ)"),
|
|
61539
61817
|
arp: ArpMode2.default("enabled"),
|
|
61540
61818
|
arp_timeout: string().optional(),
|
|
@@ -61544,7 +61822,7 @@ var vlanTools = [
|
|
|
61544
61822
|
},
|
|
61545
61823
|
async handler(a, ctx) {
|
|
61546
61824
|
ctx.info(`Creating VLAN interface: name=${a.name}, vlan_id=${a.vlan_id}, interface=${a.interface}`);
|
|
61547
|
-
const cmd = new Cmd("/interface vlan add").set("name", a.name).set("vlan-id", a.vlan_id).set("interface", a.interface).opt("comment", a.comment).flag("disabled", a.disabled).opt("mtu", a.mtu).flag("use-service-tag", a.use_service_tag).raw(a.arp !== "enabled" ? `arp=${a.arp}` : null).opt("arp-timeout", a.arp_timeout).opt("loop-protect", a.loop_protect).opt("loop-protect-disable-time", a.loop_protect_disable_time).opt("loop-protect-send-interval", a.loop_protect_send_interval).build();
|
|
61825
|
+
const cmd = new Cmd("/interface vlan add").set("name", a.name).set("vlan-id", a.vlan_id).set("interface", a.interface).opt("comment", a.comment).flag("disabled", a.disabled).opt("mtu", a.mtu).opt("forced-mac-address", a.forced_mac_address).flag("use-service-tag", a.use_service_tag).raw(a.arp !== "enabled" ? `arp=${a.arp}` : null).opt("arp-timeout", a.arp_timeout).opt("loop-protect", a.loop_protect).opt("loop-protect-disable-time", a.loop_protect_disable_time).opt("loop-protect-send-interval", a.loop_protect_send_interval).build();
|
|
61548
61826
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
61549
61827
|
if (looksLikeError(result))
|
|
61550
61828
|
return `Failed to create VLAN interface: ${result}`;
|
|
@@ -61609,6 +61887,7 @@ ${result}`;
|
|
|
61609
61887
|
comment: string().optional(),
|
|
61610
61888
|
disabled: boolean().optional(),
|
|
61611
61889
|
mtu: number().int().optional(),
|
|
61890
|
+
forced_mac_address: string().optional().describe("RouterOS 7.25+ forced VLAN interface MAC address"),
|
|
61612
61891
|
use_service_tag: boolean().optional(),
|
|
61613
61892
|
arp: ArpMode2.optional(),
|
|
61614
61893
|
arp_timeout: string().optional(),
|
|
@@ -61618,7 +61897,7 @@ ${result}`;
|
|
|
61618
61897
|
},
|
|
61619
61898
|
async handler(a, ctx) {
|
|
61620
61899
|
ctx.info(`Updating VLAN interface: name=${a.name}`);
|
|
61621
|
-
const cmd = new Cmd(`/interface vlan set [find name="${a.name}"]`).opt("name", a.new_name).opt("vlan-id", a.vlan_id).opt("interface", a.interface).opt("comment", a.comment).bool("disabled", a.disabled).opt("mtu", a.mtu).bool("use-service-tag", a.use_service_tag).opt("arp", a.arp).opt("arp-timeout", a.arp_timeout).opt("loop-protect", a.loop_protect).opt("loop-protect-disable-time", a.loop_protect_disable_time).opt("loop-protect-send-interval", a.loop_protect_send_interval).build();
|
|
61900
|
+
const cmd = new Cmd(`/interface vlan set [find name="${a.name}"]`).opt("name", a.new_name).opt("vlan-id", a.vlan_id).opt("interface", a.interface).opt("comment", a.comment).bool("disabled", a.disabled).opt("mtu", a.mtu).opt("forced-mac-address", a.forced_mac_address).bool("use-service-tag", a.use_service_tag).opt("arp", a.arp).opt("arp-timeout", a.arp_timeout).opt("loop-protect", a.loop_protect).opt("loop-protect-disable-time", a.loop_protect_disable_time).opt("loop-protect-send-interval", a.loop_protect_send_interval).build();
|
|
61622
61901
|
if (!cmd.includes("=", cmd.indexOf("]")))
|
|
61623
61902
|
return "No updates specified.";
|
|
61624
61903
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
@@ -62043,12 +62322,13 @@ ${details}`;
|
|
|
62043
62322
|
client_endpoint: string().optional().describe("server endpoint host[:port] written into the generated client config"),
|
|
62044
62323
|
client_keepalive: string().optional().describe('client persistent-keepalive for the generated config e.g. "25s"'),
|
|
62045
62324
|
client_listen_port: number().int().optional().describe("listen-port written into the generated client config"),
|
|
62325
|
+
client_mtu: number().int().min(576).max(65535).optional().describe("RouterOS 7.25+ MTU in generated client configuration"),
|
|
62046
62326
|
comment: string().optional(),
|
|
62047
62327
|
disabled: boolean().default(false)
|
|
62048
62328
|
},
|
|
62049
62329
|
async handler(a, ctx) {
|
|
62050
62330
|
ctx.info(`Adding WireGuard peer: interface=${a.interface}, public_key=${a.public_key.slice(0, 12)}...`);
|
|
62051
|
-
const cmd = new Cmd("/interface wireguard peers add").set("interface", a.interface).set("public-key", a.public_key).set("allowed-address", a.allowed_address).opt("endpoint-address", a.endpoint_address).opt("endpoint-port", a.endpoint_port).opt("preshared-key", a.preshared_key).opt("persistent-keepalive", a.persistent_keepalive).opt("name", a.name).opt("private-key", a.private_key).bool("responder", a.responder).opt("client-address", a.client_address).opt("client-dns", a.client_dns).opt("client-endpoint", a.client_endpoint).opt("client-keepalive", a.client_keepalive).opt("client-listen-port", a.client_listen_port).opt("comment", a.comment).flag("disabled", a.disabled).build();
|
|
62331
|
+
const cmd = new Cmd("/interface wireguard peers add").set("interface", a.interface).set("public-key", a.public_key).set("allowed-address", a.allowed_address).opt("endpoint-address", a.endpoint_address).opt("endpoint-port", a.endpoint_port).opt("preshared-key", a.preshared_key).opt("persistent-keepalive", a.persistent_keepalive).opt("name", a.name).opt("private-key", a.private_key).bool("responder", a.responder).opt("client-address", a.client_address).opt("client-dns", a.client_dns).opt("client-endpoint", a.client_endpoint).opt("client-keepalive", a.client_keepalive).opt("client-listen-port", a.client_listen_port).opt("client-mtu", a.client_mtu).opt("comment", a.comment).flag("disabled", a.disabled).build();
|
|
62052
62332
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
62053
62333
|
if (looksLikeError(result))
|
|
62054
62334
|
return `Failed to add WireGuard peer: ${result}`;
|
|
@@ -62128,7 +62408,8 @@ ${result}`;
|
|
|
62128
62408
|
client_dns: string().optional().describe("DNS server(s) written into the generated client config"),
|
|
62129
62409
|
client_endpoint: string().optional().describe("server endpoint host[:port] written into the generated client config"),
|
|
62130
62410
|
client_keepalive: string().optional().describe('client persistent-keepalive for the generated config e.g. "25s"'),
|
|
62131
|
-
client_listen_port: number().int().optional().describe("listen
|
|
62411
|
+
client_listen_port: union([number().int(), literal("")]).optional().describe("Client listen port; empty string unsets it on RouterOS 7.25+"),
|
|
62412
|
+
client_mtu: number().int().min(576).max(65535).optional().describe("RouterOS 7.25+ MTU in generated client configuration"),
|
|
62132
62413
|
comment: string().optional(),
|
|
62133
62414
|
disabled: boolean().optional()
|
|
62134
62415
|
},
|
|
@@ -62138,7 +62419,7 @@ ${result}`;
|
|
|
62138
62419
|
if (!id)
|
|
62139
62420
|
return peerNotFound(a.peer_id);
|
|
62140
62421
|
const base = `/interface wireguard peers set ${id}`;
|
|
62141
|
-
const cmd = new Cmd(base).raw(a.public_key !== undefined ? `public-key=${quoteValue(a.public_key)}` : null).raw(a.allowed_address !== undefined ? `allowed-address=${quoteValue(a.allowed_address)}` : null).raw(a.endpoint_address !== undefined ? a.endpoint_address === "" ? "!endpoint-address" : `endpoint-address=${quoteValue(a.endpoint_address)}` : null).opt("endpoint-port", a.endpoint_port).raw(a.preshared_key !== undefined ? a.preshared_key === "" ? "!preshared-key" : `preshared-key=${quoteValue(a.preshared_key)}` : null).raw(a.persistent_keepalive !== undefined ? `persistent-keepalive=${a.persistent_keepalive}` : null).opt("name", a.name).opt("private-key", a.private_key).bool("responder", a.responder).raw(a.client_address !== undefined ? a.client_address === "" ? "!client-address" : `client-address=${quoteValue(a.client_address)}` : null).raw(a.client_dns !== undefined ? a.client_dns === "" ? "!client-dns" : `client-dns=${quoteValue(a.client_dns)}` : null).raw(a.client_endpoint !== undefined ? a.client_endpoint === "" ? "!client-endpoint" : `client-endpoint=${quoteValue(a.client_endpoint)}` : null).opt("client-keepalive", a.client_keepalive).opt("client-listen-port", a.client_listen_port).raw(a.comment !== undefined ? `comment=${quoteValue(a.comment)}` : null).bool("disabled", a.disabled).build();
|
|
62422
|
+
const cmd = new Cmd(base).raw(a.public_key !== undefined ? `public-key=${quoteValue(a.public_key)}` : null).raw(a.allowed_address !== undefined ? `allowed-address=${quoteValue(a.allowed_address)}` : null).raw(a.endpoint_address !== undefined ? a.endpoint_address === "" ? "!endpoint-address" : `endpoint-address=${quoteValue(a.endpoint_address)}` : null).opt("endpoint-port", a.endpoint_port).raw(a.preshared_key !== undefined ? a.preshared_key === "" ? "!preshared-key" : `preshared-key=${quoteValue(a.preshared_key)}` : null).raw(a.persistent_keepalive !== undefined ? `persistent-keepalive=${a.persistent_keepalive}` : null).opt("name", a.name).opt("private-key", a.private_key).bool("responder", a.responder).raw(a.client_address !== undefined ? a.client_address === "" ? "!client-address" : `client-address=${quoteValue(a.client_address)}` : null).raw(a.client_dns !== undefined ? a.client_dns === "" ? "!client-dns" : `client-dns=${quoteValue(a.client_dns)}` : null).raw(a.client_endpoint !== undefined ? a.client_endpoint === "" ? "!client-endpoint" : `client-endpoint=${quoteValue(a.client_endpoint)}` : null).opt("client-keepalive", a.client_keepalive).raw(a.client_listen_port === "" ? "!client-listen-port" : null).opt("client-listen-port", a.client_listen_port === "" ? undefined : a.client_listen_port).opt("client-mtu", a.client_mtu).raw(a.comment !== undefined ? `comment=${quoteValue(a.comment)}` : null).bool("disabled", a.disabled).build();
|
|
62142
62423
|
if (cmd === base)
|
|
62143
62424
|
return "No updates specified.";
|
|
62144
62425
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
@@ -64657,6 +64938,13 @@ var moduleCatalog2 = [
|
|
|
64657
64938
|
description: "Filter rules and a guided basic setup (`/ip firewall filter`).",
|
|
64658
64939
|
tools: firewallFilterTools
|
|
64659
64940
|
},
|
|
64941
|
+
{
|
|
64942
|
+
label: "Web Proxy",
|
|
64943
|
+
slug: "web-proxy",
|
|
64944
|
+
group: "Security",
|
|
64945
|
+
description: "HTTP/HTTPS CONNECT proxy settings, live status and ordered access rules (`/ip proxy`).",
|
|
64946
|
+
tools: webProxyTools
|
|
64947
|
+
},
|
|
64660
64948
|
{
|
|
64661
64949
|
label: "Firewall \u2014 NAT",
|
|
64662
64950
|
slug: "firewall-nat",
|
|
@@ -64937,6 +65225,13 @@ var moduleCatalog2 = [
|
|
|
64937
65225
|
description: "Identity, resources, health, clock/NTP, packages, reboot/shutdown.",
|
|
64938
65226
|
tools: systemTools
|
|
64939
65227
|
},
|
|
65228
|
+
{
|
|
65229
|
+
label: "Device Mode",
|
|
65230
|
+
slug: "device-mode",
|
|
65231
|
+
group: "System & Ops",
|
|
65232
|
+
description: "Read device-mode capabilities and request physically confirmed feature changes.",
|
|
65233
|
+
tools: deviceModeTools
|
|
65234
|
+
},
|
|
64940
65235
|
{
|
|
64941
65236
|
label: "System Config",
|
|
64942
65237
|
slug: "system-config",
|