@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
|
@@ -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-5mbnzvye.js")).openSnapshotStore;
|
|
15610
|
+
const db = await beforeTarget((await import("./library-8fxp8mc8.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-znv72s94.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 {
|
|
@@ -23759,6 +23757,11 @@ var bridgeTools = [
|
|
|
23759
23757
|
frame_types: FrameTypes.optional().describe("Default accepted frame types for ports"),
|
|
23760
23758
|
ingress_filtering: boolean().optional().describe("Default ingress VLAN filtering for ports"),
|
|
23761
23759
|
dhcp_snooping: boolean().optional().describe("Enable DHCP snooping"),
|
|
23760
|
+
arp_inspection: boolean().optional().describe("RouterOS 7.25+ validate ARP against DHCP snooping bindings"),
|
|
23761
|
+
ip_source_guard: boolean().optional().describe("RouterOS 7.25+ validate IPv4 source against DHCP snooping bindings"),
|
|
23762
|
+
mlag_init_delay: string().optional().describe("RouterOS 7.25+ MLAG LACP initialization delay"),
|
|
23763
|
+
mlag_lacp_fallback: boolean().optional().describe("RouterOS 7.25+ MLAG LACP fallback after peer loss"),
|
|
23764
|
+
confirm_security_disruption: literal(true).optional().describe("Required when enabling ARP inspection or IP source guard; DHCP bindings may be cleared and traffic interrupted"),
|
|
23762
23765
|
igmp_snooping: boolean().optional().describe("Enable IGMP/MLD snooping"),
|
|
23763
23766
|
fast_forward: boolean().optional().describe("Enable Fast Forward optimization"),
|
|
23764
23767
|
mvrp: boolean().optional().describe("Enable Multiple VLAN Registration Protocol"),
|
|
@@ -23767,8 +23770,10 @@ var bridgeTools = [
|
|
|
23767
23770
|
transmit_hold_count: number().int().optional().describe("STP transmit hold count")
|
|
23768
23771
|
},
|
|
23769
23772
|
async handler(a, ctx) {
|
|
23773
|
+
if ((a.arp_inspection || a.ip_source_guard) && !a.confirm_security_disruption)
|
|
23774
|
+
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.";
|
|
23770
23775
|
ctx.info(`Creating bridge: name=${a.name}, vlan_filtering=${a.vlan_filtering}`);
|
|
23771
|
-
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();
|
|
23776
|
+
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();
|
|
23772
23777
|
const result = await executeMikrotikCommand2(cmd, ctx);
|
|
23773
23778
|
if (looksLikeError(result))
|
|
23774
23779
|
return `Failed to create bridge: ${result}`;
|
|
@@ -23835,6 +23840,11 @@ ${result}`;
|
|
|
23835
23840
|
frame_types: FrameTypes.optional().describe("Default accepted frame types for ports"),
|
|
23836
23841
|
ingress_filtering: boolean().optional().describe("Default ingress VLAN filtering for ports"),
|
|
23837
23842
|
dhcp_snooping: boolean().optional().describe("Enable DHCP snooping"),
|
|
23843
|
+
arp_inspection: boolean().optional().describe("RouterOS 7.25+ validate ARP against DHCP snooping bindings"),
|
|
23844
|
+
ip_source_guard: boolean().optional().describe("RouterOS 7.25+ validate IPv4 source against DHCP snooping bindings"),
|
|
23845
|
+
mlag_init_delay: string().optional().describe("RouterOS 7.25+ MLAG LACP initialization delay"),
|
|
23846
|
+
mlag_lacp_fallback: boolean().optional().describe("RouterOS 7.25+ MLAG LACP fallback after peer loss"),
|
|
23847
|
+
confirm_security_disruption: literal(true).optional().describe("Required when enabling ARP inspection or IP source guard; DHCP bindings may be cleared and traffic interrupted"),
|
|
23838
23848
|
igmp_snooping: boolean().optional().describe("Enable IGMP/MLD snooping"),
|
|
23839
23849
|
fast_forward: boolean().optional().describe("Enable Fast Forward optimization"),
|
|
23840
23850
|
mvrp: boolean().optional().describe("Enable Multiple VLAN Registration Protocol"),
|
|
@@ -23843,15 +23853,17 @@ ${result}`;
|
|
|
23843
23853
|
transmit_hold_count: number().int().optional().describe("STP transmit hold count")
|
|
23844
23854
|
},
|
|
23845
23855
|
async handler(a, ctx) {
|
|
23856
|
+
if ((a.arp_inspection || a.ip_source_guard) && !a.confirm_security_disruption)
|
|
23857
|
+
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.";
|
|
23846
23858
|
ctx.info(`Updating bridge: name=${a.name}`);
|
|
23847
|
-
const cmd = new Cmd(`/interface bridge set [find name
|
|
23859
|
+
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();
|
|
23848
23860
|
if (!cmd.includes("=", cmd.indexOf("]")))
|
|
23849
23861
|
return "No updates specified.";
|
|
23850
23862
|
const result = await executeMikrotikCommand2(cmd, ctx);
|
|
23851
23863
|
if (looksLikeError(result))
|
|
23852
23864
|
return `Failed to update bridge: ${result}`;
|
|
23853
23865
|
const target = a.new_name ?? a.name;
|
|
23854
|
-
const details = await executeMikrotikCommand2(
|
|
23866
|
+
const details = await executeMikrotikCommand2(new Cmd("/interface bridge print detail where").set("name", target).build(), ctx);
|
|
23855
23867
|
return `Bridge updated successfully:
|
|
23856
23868
|
|
|
23857
23869
|
${details}`;
|
|
@@ -23901,6 +23913,7 @@ ${details}`;
|
|
|
23901
23913
|
restricted_role: boolean().optional().describe("Exclude port from becoming the root port"),
|
|
23902
23914
|
restricted_tcn: boolean().optional().describe("Block topology change notifications from this port"),
|
|
23903
23915
|
trusted: boolean().optional().describe("Trust DHCP server replies on this port (DHCP snooping)"),
|
|
23916
|
+
trusted_arp: boolean().optional().describe("RouterOS 7.25+ exempt this port from ARP inspection"),
|
|
23904
23917
|
multicast_router: MulticastRouter.optional().describe("IGMP-snooping multicast router state"),
|
|
23905
23918
|
fast_leave: boolean().optional().describe("IGMP-snooping fast leave"),
|
|
23906
23919
|
unknown_unicast_flood: boolean().optional().describe("Flood unknown-unicast frames to this port"),
|
|
@@ -23909,7 +23922,7 @@ ${details}`;
|
|
|
23909
23922
|
},
|
|
23910
23923
|
async handler(a, ctx) {
|
|
23911
23924
|
ctx.info(`Adding bridge port: bridge=${a.bridge}, interface=${a.interface}`);
|
|
23912
|
-
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();
|
|
23925
|
+
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();
|
|
23913
23926
|
const result = await executeMikrotikCommand2(cmd, ctx);
|
|
23914
23927
|
if (looksLikeError(result))
|
|
23915
23928
|
return `Failed to add bridge port: ${result}`;
|
|
@@ -26470,6 +26483,68 @@ ${lines.join(`
|
|
|
26470
26483
|
})
|
|
26471
26484
|
];
|
|
26472
26485
|
|
|
26486
|
+
// src/tools/device-mode.ts
|
|
26487
|
+
var deviceModeTools = [
|
|
26488
|
+
defineTool2({
|
|
26489
|
+
name: "get_device_mode",
|
|
26490
|
+
title: "Get RouterOS Device Mode",
|
|
26491
|
+
annotations: READ,
|
|
26492
|
+
description: "Read `/system device-mode print` to see which restricted RouterOS features are available and whether physical confirmation is pending.",
|
|
26493
|
+
async handler(_a, ctx) {
|
|
26494
|
+
const result = await executeMikrotikCommand2("/system device-mode print", ctx);
|
|
26495
|
+
return isEmpty(result) ? "Device mode unavailable on this RouterOS version." : result;
|
|
26496
|
+
}
|
|
26497
|
+
}),
|
|
26498
|
+
defineTool2({
|
|
26499
|
+
name: "update_device_mode_features",
|
|
26500
|
+
title: "Request Device Mode Feature Update",
|
|
26501
|
+
annotations: DANGEROUS,
|
|
26502
|
+
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.",
|
|
26503
|
+
inputSchema: {
|
|
26504
|
+
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."),
|
|
26505
|
+
scheduler: boolean().optional(),
|
|
26506
|
+
socks: boolean().optional(),
|
|
26507
|
+
fetch: boolean().optional(),
|
|
26508
|
+
pptp: boolean().optional(),
|
|
26509
|
+
l2tp: boolean().optional(),
|
|
26510
|
+
bandwidth_test: boolean().optional(),
|
|
26511
|
+
traffic_gen: boolean().optional(),
|
|
26512
|
+
sniffer: boolean().optional(),
|
|
26513
|
+
ipsec: boolean().optional(),
|
|
26514
|
+
romon: boolean().optional(),
|
|
26515
|
+
proxy: boolean().optional(),
|
|
26516
|
+
hotspot: boolean().optional(),
|
|
26517
|
+
smb: boolean().optional(),
|
|
26518
|
+
email: boolean().optional(),
|
|
26519
|
+
zerotier: boolean().optional(),
|
|
26520
|
+
container: boolean().optional(),
|
|
26521
|
+
install_any_version: boolean().optional(),
|
|
26522
|
+
partitions: boolean().optional(),
|
|
26523
|
+
routerboard: boolean().optional(),
|
|
26524
|
+
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)."),
|
|
26525
|
+
flagging_enabled: boolean().optional(),
|
|
26526
|
+
flagged: boolean().optional().describe("Set false only after a security audit of the router configuration."),
|
|
26527
|
+
confirm_mode_resets_overrides: literal(true).optional().describe("Required with mode: existing per-feature overrides will be reset unless included in this request."),
|
|
26528
|
+
confirm_flagged_audit_complete: literal(true).optional().describe("Required to clear flagged after auditing configuration, passwords, and RouterOS version."),
|
|
26529
|
+
physical_confirmation_available: literal(true).describe("Operator is physically present and has authorized the device-mode change.")
|
|
26530
|
+
},
|
|
26531
|
+
async handler(a, ctx) {
|
|
26532
|
+
if (a.mode && !a.confirm_mode_resets_overrides)
|
|
26533
|
+
return "Refusing mode change: confirm_mode_resets_overrides=true is required because mode resets prior per-feature overrides.";
|
|
26534
|
+
if (a.flagged === false && !a.confirm_flagged_audit_complete)
|
|
26535
|
+
return "Refusing to clear flagged: confirm_flagged_audit_complete=true is required after a security audit.";
|
|
26536
|
+
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);
|
|
26537
|
+
if (cmd.build() === "/system device-mode update")
|
|
26538
|
+
return "No feature changes specified.";
|
|
26539
|
+
const result = await executeMikrotikCommand2(cmd.build(), ctx);
|
|
26540
|
+
if (looksLikeError(result))
|
|
26541
|
+
return `Failed to request device-mode update: ${result}`;
|
|
26542
|
+
return `Device-mode update requested; physical confirmation is required before treating it as active. Router response:
|
|
26543
|
+
${result}`;
|
|
26544
|
+
}
|
|
26545
|
+
})
|
|
26546
|
+
];
|
|
26547
|
+
|
|
26473
26548
|
// src/tools/dhcp.ts
|
|
26474
26549
|
var Authoritative = _enum(["yes", "no", "after-2sec-delay"]);
|
|
26475
26550
|
var dhcpTools = [
|
|
@@ -26490,6 +26565,7 @@ var dhcpTools = [
|
|
|
26490
26565
|
delay_threshold: string().optional(),
|
|
26491
26566
|
add_arp: boolean().optional().describe("Add dynamic ARP entry for each lease (use with reply-only ARP on the interface)"),
|
|
26492
26567
|
always_broadcast: boolean().optional().describe("Always send replies as broadcast"),
|
|
26568
|
+
ipv6_only_preferred: boolean().optional().describe("RouterOS 7.25+ advertise DHCP option 108 for IPv6-only preferred clients"),
|
|
26493
26569
|
bootp_support: _enum(["none", "static", "dynamic"]).optional().describe("Which BOOTP requests to answer"),
|
|
26494
26570
|
conflict_detection: boolean().optional().describe("Ping/ARP-probe an address before offering it to detect conflicts"),
|
|
26495
26571
|
use_radius: _enum(["yes", "no", "accounting"]).optional().describe("Use RADIUS for leases (accounting = RADIUS accounting only)"),
|
|
@@ -26500,7 +26576,7 @@ var dhcpTools = [
|
|
|
26500
26576
|
},
|
|
26501
26577
|
async handler(a, ctx) {
|
|
26502
26578
|
ctx.info(`Creating DHCP server: name=${a.name}, interface=${a.interface}`);
|
|
26503
|
-
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();
|
|
26579
|
+
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();
|
|
26504
26580
|
const result = await executeMikrotikCommand2(cmd, ctx);
|
|
26505
26581
|
if (looksLikeError(result))
|
|
26506
26582
|
return `Failed to create DHCP server: ${result}`;
|
|
@@ -27986,6 +28062,7 @@ var SYNONYMS = {
|
|
|
27986
28062
|
show: ["list", "print", "get"],
|
|
27987
28063
|
print: ["list", "show"],
|
|
27988
28064
|
get: ["show", "fetch"],
|
|
28065
|
+
read: ["get", "list", "show"],
|
|
27989
28066
|
fetch: ["get"],
|
|
27990
28067
|
update: ["set", "modify", "change", "edit"],
|
|
27991
28068
|
set: ["update", "modify", "change"],
|
|
@@ -28080,7 +28157,7 @@ var cache3 = null;
|
|
|
28080
28157
|
async function gateway() {
|
|
28081
28158
|
if (cache3)
|
|
28082
28159
|
return cache3;
|
|
28083
|
-
const { moduleCatalog } = await import("./library-
|
|
28160
|
+
const { moduleCatalog } = await import("./library-j1ptdg4x.js");
|
|
28084
28161
|
const forIndex = [];
|
|
28085
28162
|
const byName = new Map;
|
|
28086
28163
|
for (const mod of moduleCatalog) {
|
|
@@ -28802,12 +28879,15 @@ var dot1xServerTools = [
|
|
|
28802
28879
|
reject_vlan_id: string().optional().describe("VLAN id or 'none'"),
|
|
28803
28880
|
server_fail_vlan_id: string().optional().describe("VLAN id or 'none'"),
|
|
28804
28881
|
reauth_timeout: string().optional().describe("Re-auth period or 'none'"),
|
|
28882
|
+
reauth_period: string().optional().describe("RouterOS 7.25+ re-authentication period"),
|
|
28805
28883
|
comment: string().optional(),
|
|
28806
28884
|
disabled: boolean().default(false)
|
|
28807
28885
|
},
|
|
28808
28886
|
async handler(a, ctx) {
|
|
28887
|
+
if (a.reauth_period !== undefined && a.reauth_timeout !== undefined)
|
|
28888
|
+
return "Specify either reauth_period (RouterOS 7.25+) or reauth_timeout (older RouterOS), not both.";
|
|
28809
28889
|
ctx.info(`Adding dot1x server: interface=${a.interface}`);
|
|
28810
|
-
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();
|
|
28890
|
+
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();
|
|
28811
28891
|
const result = await executeMikrotikCommand2(cmd, ctx);
|
|
28812
28892
|
if (looksLikeError(result))
|
|
28813
28893
|
return `Failed to add dot1x server: ${result}`;
|
|
@@ -28873,14 +28953,18 @@ ${result}`;
|
|
|
28873
28953
|
reject_vlan_id: string().optional(),
|
|
28874
28954
|
server_fail_vlan_id: string().optional(),
|
|
28875
28955
|
reauth_timeout: string().optional(),
|
|
28956
|
+
reauth_period: string().optional().describe("RouterOS 7.25+ re-authentication period"),
|
|
28876
28957
|
comment: string().optional(),
|
|
28877
28958
|
disabled: boolean().optional()
|
|
28878
28959
|
},
|
|
28879
28960
|
async handler(a, ctx) {
|
|
28961
|
+
if (a.reauth_period !== undefined && a.reauth_timeout !== undefined)
|
|
28962
|
+
return "Specify either reauth_period (RouterOS 7.25+) or reauth_timeout (older RouterOS), not both.";
|
|
28880
28963
|
ctx.info(`Updating dot1x server: server_id=${a.server_id}`);
|
|
28881
28964
|
const selector = a.server_id.startsWith("*") ? `.id="${a.server_id}"` : `interface="${a.server_id}"`;
|
|
28882
28965
|
const base = `/interface dot1x server set [find ${selector}]`;
|
|
28883
28966
|
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);
|
|
28967
|
+
cmd.opt("reauth-period", a.reauth_period);
|
|
28884
28968
|
if (a.comment !== undefined)
|
|
28885
28969
|
cmd.raw(`comment=${quoteValue(a.comment)}`);
|
|
28886
28970
|
if (a.disabled !== undefined)
|
|
@@ -32909,11 +32993,17 @@ ${result}`;
|
|
|
32909
32993
|
if (!id)
|
|
32910
32994
|
return `Firewall filter rule '${a.rule_id}' not found.`;
|
|
32911
32995
|
const before = await listItemIds("/ip firewall filter", ctx);
|
|
32912
|
-
const
|
|
32996
|
+
const from = before.indexOf(id);
|
|
32997
|
+
if (a.destination < 0 || a.destination >= before.length) {
|
|
32998
|
+
return `NO CHANGE: destination ${a.destination} is outside the ${before.length} rule positions.`;
|
|
32999
|
+
}
|
|
33000
|
+
if (from === a.destination)
|
|
33001
|
+
return `NO CHANGE: firewall filter rule ${id} is already at position ${from}.`;
|
|
33002
|
+
const target = before[a.destination];
|
|
33003
|
+
const result = await executeMikrotikCommand2(`/ip firewall filter move ${id} ${target}`, ctx);
|
|
32913
33004
|
if (looksLikeError(result))
|
|
32914
33005
|
return `Failed to move firewall filter rule: ${result}`;
|
|
32915
33006
|
const after = await listItemIds("/ip firewall filter", ctx);
|
|
32916
|
-
const from = before.indexOf(id);
|
|
32917
33007
|
const to = after.indexOf(id);
|
|
32918
33008
|
if (to === -1) {
|
|
32919
33009
|
return `Firewall filter rule ${id} moved, but it could not be located afterwards \u2014 verify with list_filter_rules.`;
|
|
@@ -34716,6 +34806,124 @@ ${details}`;
|
|
|
34716
34806
|
})
|
|
34717
34807
|
];
|
|
34718
34808
|
|
|
34809
|
+
// src/tools/web-proxy.ts
|
|
34810
|
+
var scope = "/ip proxy access";
|
|
34811
|
+
var resolveAccessId = ruleResolver(scope);
|
|
34812
|
+
var webProxyTools = [
|
|
34813
|
+
defineTool2({
|
|
34814
|
+
name: "get_web_proxy",
|
|
34815
|
+
title: "Get Web Proxy Settings",
|
|
34816
|
+
annotations: READ,
|
|
34817
|
+
description: "Read RouterOS `/ip proxy` settings, including enabled, port, outgoing source and cache.",
|
|
34818
|
+
async handler(_a, ctx) {
|
|
34819
|
+
const result = await executeMikrotikCommand2("/ip proxy print", ctx);
|
|
34820
|
+
return isEmpty(result) ? "Web proxy settings unavailable." : result;
|
|
34821
|
+
}
|
|
34822
|
+
}),
|
|
34823
|
+
defineTool2({
|
|
34824
|
+
name: "update_web_proxy",
|
|
34825
|
+
title: "Update Web Proxy Settings",
|
|
34826
|
+
annotations: DANGEROUS,
|
|
34827
|
+
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.",
|
|
34828
|
+
inputSchema: {
|
|
34829
|
+
enabled: boolean().optional(),
|
|
34830
|
+
port: number().int().min(1).max(65535).optional(),
|
|
34831
|
+
src_address: string().optional(),
|
|
34832
|
+
anonymous: boolean().optional(),
|
|
34833
|
+
max_cache_size: string().optional(),
|
|
34834
|
+
confirm_firewall_ready: boolean().optional().describe("Required when enabling: IPv4 and IPv6 input firewall access has been verified.")
|
|
34835
|
+
},
|
|
34836
|
+
async handler(a, ctx) {
|
|
34837
|
+
if (a.enabled === true && !a.confirm_firewall_ready) {
|
|
34838
|
+
return "Refusing to enable web proxy until confirm_firewall_ready=true: verify both IPv4 and IPv6 input firewall restrictions first.";
|
|
34839
|
+
}
|
|
34840
|
+
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);
|
|
34841
|
+
if (cmd.build() === "/ip proxy set")
|
|
34842
|
+
return "No updates specified.";
|
|
34843
|
+
const result = await executeMikrotikCommand2(cmd.build(), ctx);
|
|
34844
|
+
if (looksLikeError(result))
|
|
34845
|
+
return `Failed to update web proxy: ${result}`;
|
|
34846
|
+
return `Web proxy update sent. Current settings:
|
|
34847
|
+
${await executeMikrotikCommand2("/ip proxy print", ctx)}`;
|
|
34848
|
+
}
|
|
34849
|
+
}),
|
|
34850
|
+
defineTool2({
|
|
34851
|
+
name: "monitor_web_proxy",
|
|
34852
|
+
title: "Monitor Web Proxy",
|
|
34853
|
+
annotations: READ,
|
|
34854
|
+
description: "Read one `/ip proxy monitor once` sample, including connection and request counters.",
|
|
34855
|
+
async handler(_a, ctx) {
|
|
34856
|
+
return executeMikrotikCommand2("/ip proxy monitor once", ctx);
|
|
34857
|
+
}
|
|
34858
|
+
}),
|
|
34859
|
+
defineTool2({
|
|
34860
|
+
name: "list_web_proxy_access_rules",
|
|
34861
|
+
title: "List Web Proxy Access Rules",
|
|
34862
|
+
annotations: READ,
|
|
34863
|
+
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.",
|
|
34864
|
+
async handler(_a, ctx) {
|
|
34865
|
+
const result = await executeMikrotikCommand2(`${scope} print detail`, ctx);
|
|
34866
|
+
return isEmpty(result) ? "No web proxy access rules (unmatched requests are allowed)." : result;
|
|
34867
|
+
}
|
|
34868
|
+
}),
|
|
34869
|
+
defineTool2({
|
|
34870
|
+
name: "add_web_proxy_access_rule",
|
|
34871
|
+
title: "Add Web Proxy Access Rule",
|
|
34872
|
+
annotations: WRITE,
|
|
34873
|
+
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.",
|
|
34874
|
+
inputSchema: {
|
|
34875
|
+
action: _enum(["allow", "deny"]),
|
|
34876
|
+
src_address: string().optional(),
|
|
34877
|
+
dst_address: string().optional(),
|
|
34878
|
+
comment: string().optional(),
|
|
34879
|
+
place_before: string().optional()
|
|
34880
|
+
},
|
|
34881
|
+
async handler(a, ctx) {
|
|
34882
|
+
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);
|
|
34883
|
+
const result = await executeRuleCreate(scope, cmd, ctx, a.place_before);
|
|
34884
|
+
if (looksLikeError(result))
|
|
34885
|
+
return `Failed to add web proxy access rule: ${result}`;
|
|
34886
|
+
return readCreatedRule(scope, result, "Web proxy access rule", ctx);
|
|
34887
|
+
}
|
|
34888
|
+
}),
|
|
34889
|
+
defineTool2({
|
|
34890
|
+
name: "remove_web_proxy_access_rule",
|
|
34891
|
+
title: "Remove Web Proxy Access Rule",
|
|
34892
|
+
annotations: DESTRUCTIVE,
|
|
34893
|
+
description: "Remove one `/ip proxy access` rule by `.id` or zero-based row, after inspecting the ordered list.",
|
|
34894
|
+
inputSchema: { rule_id: string() },
|
|
34895
|
+
async handler(a, ctx) {
|
|
34896
|
+
const id = await resolveAccessId(a.rule_id, ctx);
|
|
34897
|
+
if (!id)
|
|
34898
|
+
return `Web proxy access rule '${a.rule_id}' not found.`;
|
|
34899
|
+
const result = await executeMikrotikCommand2(`${scope} remove ${id}`, ctx);
|
|
34900
|
+
return looksLikeError(result) ? `Failed to remove web proxy access rule: ${result}` : `Removed web proxy access rule ${id}.`;
|
|
34901
|
+
}
|
|
34902
|
+
}),
|
|
34903
|
+
defineTool2({
|
|
34904
|
+
name: "move_web_proxy_access_rule",
|
|
34905
|
+
title: "Move Web Proxy Access Rule",
|
|
34906
|
+
annotations: WRITE_IDEMPOTENT,
|
|
34907
|
+
description: "Move one `/ip proxy access` rule before the item at a zero-based destination position; reads back the resulting order.",
|
|
34908
|
+
inputSchema: { rule_id: string(), destination: number().int().min(0) },
|
|
34909
|
+
async handler(a, ctx) {
|
|
34910
|
+
const id = await resolveAccessId(a.rule_id, ctx);
|
|
34911
|
+
if (!id)
|
|
34912
|
+
return `Web proxy access rule '${a.rule_id}' not found.`;
|
|
34913
|
+
const before = await listItemIds(scope, ctx);
|
|
34914
|
+
if (a.destination >= before.length)
|
|
34915
|
+
return `NO CHANGE: destination ${a.destination} is outside the ${before.length} rule positions.`;
|
|
34916
|
+
if (before.indexOf(id) === a.destination)
|
|
34917
|
+
return `NO CHANGE: web proxy access rule ${id} is already at position ${a.destination}.`;
|
|
34918
|
+
const result = await executeMikrotikCommand2(`${scope} move ${id} ${before[a.destination]}`, ctx);
|
|
34919
|
+
if (looksLikeError(result))
|
|
34920
|
+
return `Failed to move web proxy access rule: ${result}`;
|
|
34921
|
+
const to = (await listItemIds(scope, ctx)).indexOf(id);
|
|
34922
|
+
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.`;
|
|
34923
|
+
}
|
|
34924
|
+
})
|
|
34925
|
+
];
|
|
34926
|
+
|
|
34719
34927
|
// src/tools/ip-ssh.ts
|
|
34720
34928
|
var ipSshTools = [
|
|
34721
34929
|
defineTool2({
|
|
@@ -35433,6 +35641,8 @@ var ipv6DhcpServerTools = [
|
|
|
35433
35641
|
lease_time: string().default("3d").describe("Lease duration e.g. '1d', '12h', '30m'"),
|
|
35434
35642
|
binding_script: string().optional(),
|
|
35435
35643
|
rapid_commit: boolean().optional(),
|
|
35644
|
+
add_dns_entries: boolean().optional().describe("RouterOS 7.25+ create AAAA DNS entries for client FQDNs"),
|
|
35645
|
+
add_dns_entries_suffix: string().optional().describe("Suffix for dynamically created DHCPv6 DNS entries"),
|
|
35436
35646
|
preference: number().int().min(0).max(255).optional(),
|
|
35437
35647
|
route_distance: number().int().optional(),
|
|
35438
35648
|
use_radius: boolean().optional().describe("Authenticate clients via RADIUS"),
|
|
@@ -35444,7 +35654,7 @@ var ipv6DhcpServerTools = [
|
|
|
35444
35654
|
},
|
|
35445
35655
|
async handler(a, ctx) {
|
|
35446
35656
|
ctx.info(`Creating DHCPv6 server: name=${a.name}, interface=${a.interface}`);
|
|
35447
|
-
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();
|
|
35657
|
+
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();
|
|
35448
35658
|
const result = await executeMikrotikCommand2(cmd, ctx);
|
|
35449
35659
|
if (looksLikeError(result))
|
|
35450
35660
|
return `Failed to create DHCPv6 server: ${result}`;
|
|
@@ -35983,10 +36193,19 @@ ${result}`;
|
|
|
35983
36193
|
const id = await resolveRuleId(a.rule_id, ctx);
|
|
35984
36194
|
if (!id)
|
|
35985
36195
|
return `IPv6 firewall filter rule '${a.rule_id}' not found.`;
|
|
35986
|
-
const
|
|
36196
|
+
const before = await listItemIds("/ipv6 firewall filter", ctx);
|
|
36197
|
+
const from = before.indexOf(id);
|
|
36198
|
+
if (a.destination < 0 || a.destination >= before.length) {
|
|
36199
|
+
return `NO CHANGE: destination ${a.destination} is outside the ${before.length} rule positions.`;
|
|
36200
|
+
}
|
|
36201
|
+
if (from === a.destination)
|
|
36202
|
+
return `NO CHANGE: IPv6 firewall filter rule ${id} is already at position ${from}.`;
|
|
36203
|
+
const result = await executeMikrotikCommand2(`/ipv6 firewall filter move ${id} ${before[a.destination]}`, ctx);
|
|
35987
36204
|
if (looksLikeError(result))
|
|
35988
36205
|
return `Failed to move IPv6 firewall filter rule: ${result}`;
|
|
35989
|
-
|
|
36206
|
+
const after = await listItemIds("/ipv6 firewall filter", ctx);
|
|
36207
|
+
const to = after.indexOf(id);
|
|
36208
|
+
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
36209
|
}
|
|
35991
36210
|
}),
|
|
35992
36211
|
defineTool2({
|
|
@@ -44069,7 +44288,14 @@ function access5(ctx, write = false) {
|
|
|
44069
44288
|
function openVpnSessionsCommand() {
|
|
44070
44289
|
const find = new Cmd("/ppp active find where").set("service", "ovpn").build();
|
|
44071
44290
|
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] }`;
|
|
44291
|
+
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] }`;
|
|
44292
|
+
}
|
|
44293
|
+
function openVpnClientBytes(tx, rx) {
|
|
44294
|
+
if (typeof tx !== "number" && (typeof tx !== "string" || !/^\d+$/.test(tx)) || typeof rx !== "number" && (typeof rx !== "string" || !/^\d+$/.test(rx)))
|
|
44295
|
+
return [null, null];
|
|
44296
|
+
const download = Number(tx);
|
|
44297
|
+
const upload = Number(rx);
|
|
44298
|
+
return Number.isSafeInteger(download) && Number.isSafeInteger(upload) ? [download, upload] : [null, null];
|
|
44073
44299
|
}
|
|
44074
44300
|
function parseOpenVpnSessions(output) {
|
|
44075
44301
|
if (output.length > 1e6)
|
|
@@ -44083,6 +44309,7 @@ function parseOpenVpnSessions(output) {
|
|
|
44083
44309
|
if (!Array.isArray(rows) || rows.length > SESSION_LIMIT)
|
|
44084
44310
|
throw new Error("Invalid OpenVPN session snapshot.");
|
|
44085
44311
|
const ids = new Set;
|
|
44312
|
+
const names = rows.map((row) => row && typeof row === "object" ? row.name : undefined);
|
|
44086
44313
|
return rows.map((row) => {
|
|
44087
44314
|
const r = object({
|
|
44088
44315
|
".id": string().regex(/^\*[A-Fa-f0-9]+$/),
|
|
@@ -44093,11 +44320,14 @@ function parseOpenVpnSessions(output) {
|
|
|
44093
44320
|
"session-id": string().default(""),
|
|
44094
44321
|
uptime: string().default(""),
|
|
44095
44322
|
encoding: string().default(""),
|
|
44096
|
-
radius: union([boolean(), string()]).optional()
|
|
44323
|
+
radius: union([boolean(), string()]).optional(),
|
|
44324
|
+
"tx-byte": union([number(), string()]).optional(),
|
|
44325
|
+
"rx-byte": union([number(), string()]).optional()
|
|
44097
44326
|
}).parse(row);
|
|
44098
44327
|
if (ids.has(r[".id"]))
|
|
44099
44328
|
throw new Error("Duplicate OpenVPN session identifier; refresh required.");
|
|
44100
44329
|
ids.add(r[".id"]);
|
|
44330
|
+
const [downloadBytes, uploadBytes] = names.filter((name) => name === r.name).length === 1 ? openVpnClientBytes(r["tx-byte"], r["rx-byte"]) : [null, null];
|
|
44101
44331
|
return {
|
|
44102
44332
|
id: r[".id"],
|
|
44103
44333
|
name: r.name,
|
|
@@ -44107,7 +44337,9 @@ function parseOpenVpnSessions(output) {
|
|
|
44107
44337
|
encoding: r.encoding,
|
|
44108
44338
|
radius: r.radius === true || r.radius === "yes" || r.radius === "true",
|
|
44109
44339
|
uptime: r.uptime,
|
|
44110
|
-
uptimeSeconds: openVpnUptime(r.uptime)
|
|
44340
|
+
uptimeSeconds: openVpnUptime(r.uptime),
|
|
44341
|
+
downloadBytes,
|
|
44342
|
+
uploadBytes
|
|
44111
44343
|
};
|
|
44112
44344
|
});
|
|
44113
44345
|
}
|
|
@@ -48301,6 +48533,51 @@ ${result}`;
|
|
|
48301
48533
|
// src/tools/routing-bgp.ts
|
|
48302
48534
|
var UNSUPPORTED2 = "BGP is not available on this device (requires RouterOS v7 with the routing package).";
|
|
48303
48535
|
var routingBgpTools = [
|
|
48536
|
+
defineTool2({
|
|
48537
|
+
name: "list_bgp_instances",
|
|
48538
|
+
title: "List BGP Instances",
|
|
48539
|
+
annotations: READ,
|
|
48540
|
+
description: "Read BGP instances and their best-path selection settings, including RouterOS 7.25+ always-compare-med. Use before changing an instance.",
|
|
48541
|
+
async handler(_a, ctx) {
|
|
48542
|
+
const result = await executeMikrotikCommand2("/routing bgp instance print detail", ctx);
|
|
48543
|
+
if (commandUnsupported(result))
|
|
48544
|
+
return UNSUPPORTED2;
|
|
48545
|
+
return isEmpty(result) ? "No BGP instances found." : `BGP INSTANCES:
|
|
48546
|
+
|
|
48547
|
+
${result}`;
|
|
48548
|
+
}
|
|
48549
|
+
}),
|
|
48550
|
+
defineTool2({
|
|
48551
|
+
name: "update_bgp_instance_med_comparison",
|
|
48552
|
+
title: "Set BGP Instance MED Comparison",
|
|
48553
|
+
annotations: WRITE_IDEMPOTENT,
|
|
48554
|
+
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.",
|
|
48555
|
+
inputSchema: {
|
|
48556
|
+
name: string().min(1).describe("Exact BGP instance name"),
|
|
48557
|
+
always_compare_med: boolean(),
|
|
48558
|
+
confirm_routing_change: literal(true).describe("Operator approved the best-path behavior change")
|
|
48559
|
+
},
|
|
48560
|
+
async handler(a, ctx) {
|
|
48561
|
+
const selector = new Cmd("/routing bgp instance print count-only where").set("name", a.name).build();
|
|
48562
|
+
const count = await executeMikrotikCommand2(selector, ctx);
|
|
48563
|
+
if (commandUnsupported(count))
|
|
48564
|
+
return UNSUPPORTED2;
|
|
48565
|
+
if (looksLikeError(count))
|
|
48566
|
+
return `Failed to inspect BGP instance: ${count}`;
|
|
48567
|
+
if (isEmpty(count) || count.trim() === "0")
|
|
48568
|
+
return `BGP instance '${a.name}' not found.`;
|
|
48569
|
+
const cmd = new Cmd(`/routing bgp instance set [find name=${quoteValue(a.name)}]`).bool("always-compare-med", a.always_compare_med).build();
|
|
48570
|
+
const result = await executeMikrotikCommand2(cmd, ctx);
|
|
48571
|
+
if (looksLikeError(result))
|
|
48572
|
+
return `Failed to update BGP instance: ${result}`;
|
|
48573
|
+
const details = await executeMikrotikCommand2(new Cmd("/routing bgp instance print detail where").set("name", a.name).build(), ctx);
|
|
48574
|
+
if (looksLikeError(details) || isEmpty(details))
|
|
48575
|
+
return `BGP instance update was sent, but read-back failed: ${details || "no details returned"}`;
|
|
48576
|
+
return `BGP instance '${a.name}' MED comparison updated:
|
|
48577
|
+
|
|
48578
|
+
${details}`;
|
|
48579
|
+
}
|
|
48580
|
+
}),
|
|
48304
48581
|
defineTool2({
|
|
48305
48582
|
name: "list_bgp_connections",
|
|
48306
48583
|
title: "List BGP Connections",
|
|
@@ -53110,7 +53387,7 @@ var riskByTool = null;
|
|
|
53110
53387
|
async function riskIndex() {
|
|
53111
53388
|
if (riskByTool)
|
|
53112
53389
|
return riskByTool;
|
|
53113
|
-
const { moduleCatalog } = await import("./library-
|
|
53390
|
+
const { moduleCatalog } = await import("./library-j1ptdg4x.js");
|
|
53114
53391
|
const index = new Map;
|
|
53115
53392
|
for (const mod of moduleCatalog) {
|
|
53116
53393
|
for (const tool of mod.tools)
|
|
@@ -59983,6 +60260,7 @@ var vlanTools = [
|
|
|
59983
60260
|
comment: string().optional(),
|
|
59984
60261
|
disabled: boolean().default(false),
|
|
59985
60262
|
mtu: number().int().optional(),
|
|
60263
|
+
forced_mac_address: string().optional().describe("RouterOS 7.25+ forced VLAN interface MAC address"),
|
|
59986
60264
|
use_service_tag: boolean().default(false).describe("Use 802.1ad service tag (QinQ)"),
|
|
59987
60265
|
arp: ArpMode2.default("enabled"),
|
|
59988
60266
|
arp_timeout: string().optional(),
|
|
@@ -59992,7 +60270,7 @@ var vlanTools = [
|
|
|
59992
60270
|
},
|
|
59993
60271
|
async handler(a, ctx) {
|
|
59994
60272
|
ctx.info(`Creating VLAN interface: name=${a.name}, vlan_id=${a.vlan_id}, interface=${a.interface}`);
|
|
59995
|
-
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();
|
|
60273
|
+
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();
|
|
59996
60274
|
const result = await executeMikrotikCommand2(cmd, ctx);
|
|
59997
60275
|
if (looksLikeError(result))
|
|
59998
60276
|
return `Failed to create VLAN interface: ${result}`;
|
|
@@ -60057,6 +60335,7 @@ ${result}`;
|
|
|
60057
60335
|
comment: string().optional(),
|
|
60058
60336
|
disabled: boolean().optional(),
|
|
60059
60337
|
mtu: number().int().optional(),
|
|
60338
|
+
forced_mac_address: string().optional().describe("RouterOS 7.25+ forced VLAN interface MAC address"),
|
|
60060
60339
|
use_service_tag: boolean().optional(),
|
|
60061
60340
|
arp: ArpMode2.optional(),
|
|
60062
60341
|
arp_timeout: string().optional(),
|
|
@@ -60066,7 +60345,7 @@ ${result}`;
|
|
|
60066
60345
|
},
|
|
60067
60346
|
async handler(a, ctx) {
|
|
60068
60347
|
ctx.info(`Updating VLAN interface: name=${a.name}`);
|
|
60069
|
-
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();
|
|
60348
|
+
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();
|
|
60070
60349
|
if (!cmd.includes("=", cmd.indexOf("]")))
|
|
60071
60350
|
return "No updates specified.";
|
|
60072
60351
|
const result = await executeMikrotikCommand2(cmd, ctx);
|
|
@@ -60491,12 +60770,13 @@ ${details}`;
|
|
|
60491
60770
|
client_endpoint: string().optional().describe("server endpoint host[:port] written into the generated client config"),
|
|
60492
60771
|
client_keepalive: string().optional().describe('client persistent-keepalive for the generated config e.g. "25s"'),
|
|
60493
60772
|
client_listen_port: number().int().optional().describe("listen-port written into the generated client config"),
|
|
60773
|
+
client_mtu: number().int().min(576).max(65535).optional().describe("RouterOS 7.25+ MTU in generated client configuration"),
|
|
60494
60774
|
comment: string().optional(),
|
|
60495
60775
|
disabled: boolean().default(false)
|
|
60496
60776
|
},
|
|
60497
60777
|
async handler(a, ctx) {
|
|
60498
60778
|
ctx.info(`Adding WireGuard peer: interface=${a.interface}, public_key=${a.public_key.slice(0, 12)}...`);
|
|
60499
|
-
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();
|
|
60779
|
+
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();
|
|
60500
60780
|
const result = await executeMikrotikCommand2(cmd, ctx);
|
|
60501
60781
|
if (looksLikeError(result))
|
|
60502
60782
|
return `Failed to add WireGuard peer: ${result}`;
|
|
@@ -60576,7 +60856,8 @@ ${result}`;
|
|
|
60576
60856
|
client_dns: string().optional().describe("DNS server(s) written into the generated client config"),
|
|
60577
60857
|
client_endpoint: string().optional().describe("server endpoint host[:port] written into the generated client config"),
|
|
60578
60858
|
client_keepalive: string().optional().describe('client persistent-keepalive for the generated config e.g. "25s"'),
|
|
60579
|
-
client_listen_port: number().int().optional().describe("listen
|
|
60859
|
+
client_listen_port: union([number().int(), literal("")]).optional().describe("Client listen port; empty string unsets it on RouterOS 7.25+"),
|
|
60860
|
+
client_mtu: number().int().min(576).max(65535).optional().describe("RouterOS 7.25+ MTU in generated client configuration"),
|
|
60580
60861
|
comment: string().optional(),
|
|
60581
60862
|
disabled: boolean().optional()
|
|
60582
60863
|
},
|
|
@@ -60586,7 +60867,7 @@ ${result}`;
|
|
|
60586
60867
|
if (!id)
|
|
60587
60868
|
return peerNotFound(a.peer_id);
|
|
60588
60869
|
const base = `/interface wireguard peers set ${id}`;
|
|
60589
|
-
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();
|
|
60870
|
+
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();
|
|
60590
60871
|
if (cmd === base)
|
|
60591
60872
|
return "No updates specified.";
|
|
60592
60873
|
const result = await executeMikrotikCommand2(cmd, ctx);
|
|
@@ -63066,6 +63347,13 @@ var moduleCatalog2 = [
|
|
|
63066
63347
|
description: "Filter rules and a guided basic setup (`/ip firewall filter`).",
|
|
63067
63348
|
tools: firewallFilterTools
|
|
63068
63349
|
},
|
|
63350
|
+
{
|
|
63351
|
+
label: "Web Proxy",
|
|
63352
|
+
slug: "web-proxy",
|
|
63353
|
+
group: "Security",
|
|
63354
|
+
description: "HTTP/HTTPS CONNECT proxy settings, live status and ordered access rules (`/ip proxy`).",
|
|
63355
|
+
tools: webProxyTools
|
|
63356
|
+
},
|
|
63069
63357
|
{
|
|
63070
63358
|
label: "Firewall \u2014 NAT",
|
|
63071
63359
|
slug: "firewall-nat",
|
|
@@ -63346,6 +63634,13 @@ var moduleCatalog2 = [
|
|
|
63346
63634
|
description: "Identity, resources, health, clock/NTP, packages, reboot/shutdown.",
|
|
63347
63635
|
tools: systemTools
|
|
63348
63636
|
},
|
|
63637
|
+
{
|
|
63638
|
+
label: "Device Mode",
|
|
63639
|
+
slug: "device-mode",
|
|
63640
|
+
group: "System & Ops",
|
|
63641
|
+
description: "Read device-mode capabilities and request physically confirmed feature changes.",
|
|
63642
|
+
tools: deviceModeTools
|
|
63643
|
+
},
|
|
63349
63644
|
{
|
|
63350
63645
|
label: "System Config",
|
|
63351
63646
|
slug: "system-config",
|