@usex/mikrotik-mcp 3.59.0 → 3.60.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 +1 -1
- package/dist/index.js +1 -1
- package/dist/shared/{cli-2dyvnv9v.js → cli-7yjsmkwg.js} +1 -1
- package/dist/shared/{cli-jq168zrj.js → cli-ghatyv7e.js} +148 -84
- package/dist/shared/{library-0zd2tej9.js → library-1hs18tmh.js} +1 -1
- package/dist/shared/{library-21t1cncr.js → library-7j22z9a8.js} +148 -84
- package/package.json +1 -1
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
selectToolModules,
|
|
30
30
|
setConfig,
|
|
31
31
|
updateSummaryLine
|
|
32
|
-
} from "./shared/library-
|
|
32
|
+
} from "./shared/library-7j22z9a8.js";
|
|
33
33
|
// src/server.ts
|
|
34
34
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
35
35
|
import { ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
@@ -8208,7 +8208,7 @@ var rawCommandTools = [
|
|
|
8208
8208
|
if (!cmd)
|
|
8209
8209
|
return "Provide a RouterOS command to run.";
|
|
8210
8210
|
ctx.info(`Running raw RouterOS command: ${cmd}`);
|
|
8211
|
-
const result = await executeMikrotikCommand(cmd, ctx);
|
|
8211
|
+
const result = await executeMikrotikCommand(cmd, ctx, { maxMs: 30000 });
|
|
8212
8212
|
if (looksLikeError(result))
|
|
8213
8213
|
return `RouterOS command error: ${result}`;
|
|
8214
8214
|
return result.trim() ? result : "(command completed with no output)";
|
|
@@ -8330,7 +8330,7 @@ var cache = null;
|
|
|
8330
8330
|
async function gateway() {
|
|
8331
8331
|
if (cache)
|
|
8332
8332
|
return cache;
|
|
8333
|
-
const { moduleCatalog } = await import("./cli-
|
|
8333
|
+
const { moduleCatalog } = await import("./cli-7yjsmkwg.js");
|
|
8334
8334
|
const forIndex = [];
|
|
8335
8335
|
const byName = new Map;
|
|
8336
8336
|
for (const mod of moduleCatalog) {
|
|
@@ -10527,7 +10527,30 @@ ${results.join(`
|
|
|
10527
10527
|
|
|
10528
10528
|
// src/tools/firewall-nat.ts
|
|
10529
10529
|
import { z as z29 } from "zod";
|
|
10530
|
+
|
|
10531
|
+
// src/tools/_resolve-rule-id.ts
|
|
10532
|
+
function ruleResolver(scope) {
|
|
10533
|
+
return async function resolveRuleId(ruleId, ctx) {
|
|
10534
|
+
if (/^\d+$/.test(ruleId)) {
|
|
10535
|
+
const id = `*${ruleId}`;
|
|
10536
|
+
const byId = await executeMikrotikCommand(`${scope} print count-only where .id=${id}`, ctx);
|
|
10537
|
+
if (byId.trim() !== "0")
|
|
10538
|
+
return id;
|
|
10539
|
+
const idsRaw = await executeMikrotikCommand(`:foreach i in=[${scope} find] do={:put $i}`, ctx);
|
|
10540
|
+
if (isEmpty(idsRaw))
|
|
10541
|
+
return null;
|
|
10542
|
+
const ids = idsRaw.trim().split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
|
|
10543
|
+
const pos = Number.parseInt(ruleId, 10);
|
|
10544
|
+
return pos >= 0 && pos < ids.length ? ids[pos] : null;
|
|
10545
|
+
}
|
|
10546
|
+
const count = await executeMikrotikCommand(`${scope} print count-only where .id=${ruleId}`, ctx);
|
|
10547
|
+
return count.trim() !== "0" ? ruleId : null;
|
|
10548
|
+
};
|
|
10549
|
+
}
|
|
10550
|
+
|
|
10551
|
+
// src/tools/firewall-nat.ts
|
|
10530
10552
|
var isDigits2 = (s) => /^\d+$/.test(s);
|
|
10553
|
+
var resolveNatRuleId = ruleResolver("/ip firewall nat");
|
|
10531
10554
|
async function updateNatRule(a, ctx) {
|
|
10532
10555
|
ctx.info(`Updating NAT rule: rule_id=${a.rule_id}`);
|
|
10533
10556
|
const updates = [];
|
|
@@ -10603,11 +10626,14 @@ async function updateNatRule(a, ctx) {
|
|
|
10603
10626
|
}
|
|
10604
10627
|
if (updates.length === 0)
|
|
10605
10628
|
return "No updates specified.";
|
|
10606
|
-
const
|
|
10629
|
+
const id = await resolveNatRuleId(a.rule_id, ctx);
|
|
10630
|
+
if (!id)
|
|
10631
|
+
return `NAT rule '${a.rule_id}' not found.`;
|
|
10632
|
+
const cmd = `/ip firewall nat set ${id} ${updates.join(" ")}`;
|
|
10607
10633
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
10608
10634
|
if (looksLikeError(result))
|
|
10609
10635
|
return `Failed to update NAT rule: ${result}`;
|
|
10610
|
-
const details = await executeMikrotikCommand(`/ip firewall nat print detail where .id=${
|
|
10636
|
+
const details = await executeMikrotikCommand(`/ip firewall nat print detail where .id=${id}`, ctx);
|
|
10611
10637
|
return `NAT rule updated successfully:
|
|
10612
10638
|
|
|
10613
10639
|
${details}`;
|
|
@@ -10785,8 +10811,11 @@ ${result}`;
|
|
|
10785
10811
|
},
|
|
10786
10812
|
async handler(a, ctx) {
|
|
10787
10813
|
ctx.info(`Getting NAT rule details: rule_id=${a.rule_id}`);
|
|
10788
|
-
const
|
|
10789
|
-
|
|
10814
|
+
const id = await resolveNatRuleId(a.rule_id, ctx);
|
|
10815
|
+
if (!id)
|
|
10816
|
+
return `NAT rule '${a.rule_id}' not found.`;
|
|
10817
|
+
const result = await executeMikrotikCommand(`/ip firewall nat print detail where .id=${id}`, ctx);
|
|
10818
|
+
return isEmpty(result) ? `NAT rule '${a.rule_id}' not found.` : `NAT RULE DETAILS:
|
|
10790
10819
|
|
|
10791
10820
|
${result}`;
|
|
10792
10821
|
}
|
|
@@ -10868,13 +10897,13 @@ ${result}`;
|
|
|
10868
10897
|
inputSchema: { rule_id: z29.string() },
|
|
10869
10898
|
async handler(a, ctx) {
|
|
10870
10899
|
ctx.info(`Removing NAT rule: rule_id=${a.rule_id}`);
|
|
10871
|
-
const
|
|
10872
|
-
if (
|
|
10873
|
-
return `NAT rule
|
|
10874
|
-
const result = await executeMikrotikCommand(`/ip firewall nat remove ${
|
|
10900
|
+
const id = await resolveNatRuleId(a.rule_id, ctx);
|
|
10901
|
+
if (!id)
|
|
10902
|
+
return `NAT rule '${a.rule_id}' not found.`;
|
|
10903
|
+
const result = await executeMikrotikCommand(`/ip firewall nat remove ${id}`, ctx);
|
|
10875
10904
|
if (looksLikeError(result))
|
|
10876
10905
|
return `Failed to remove NAT rule: ${result}`;
|
|
10877
|
-
return `NAT rule
|
|
10906
|
+
return `NAT rule '${a.rule_id}' (${id}) removed successfully.`;
|
|
10878
10907
|
}
|
|
10879
10908
|
}),
|
|
10880
10909
|
defineTool({
|
|
@@ -10888,13 +10917,13 @@ ${result}`;
|
|
|
10888
10917
|
},
|
|
10889
10918
|
async handler(a, ctx) {
|
|
10890
10919
|
ctx.info(`Moving NAT rule: rule_id=${a.rule_id} to position ${a.destination}`);
|
|
10891
|
-
const
|
|
10892
|
-
if (
|
|
10893
|
-
return `NAT rule
|
|
10894
|
-
const result = await executeMikrotikCommand(`/ip firewall nat move ${
|
|
10920
|
+
const id = await resolveNatRuleId(a.rule_id, ctx);
|
|
10921
|
+
if (!id)
|
|
10922
|
+
return `NAT rule '${a.rule_id}' not found.`;
|
|
10923
|
+
const result = await executeMikrotikCommand(`/ip firewall nat move ${id} destination=${a.destination}`, ctx);
|
|
10895
10924
|
if (looksLikeError(result))
|
|
10896
10925
|
return `Failed to move NAT rule: ${result}`;
|
|
10897
|
-
return `NAT rule
|
|
10926
|
+
return `NAT rule '${a.rule_id}' (${id}) moved to position ${a.destination}.`;
|
|
10898
10927
|
}
|
|
10899
10928
|
}),
|
|
10900
10929
|
defineTool({
|
|
@@ -10922,6 +10951,7 @@ ${result}`;
|
|
|
10922
10951
|
// src/tools/firewall-mangle.ts
|
|
10923
10952
|
import { z as z30 } from "zod";
|
|
10924
10953
|
var isDigits3 = (s) => /^\d+$/.test(s);
|
|
10954
|
+
var resolveMangleRuleId = ruleResolver("/ip firewall mangle");
|
|
10925
10955
|
async function updateMangleRule(a, ctx) {
|
|
10926
10956
|
ctx.info(`Updating mangle rule: rule_id=${a.rule_id}`);
|
|
10927
10957
|
const updates = [];
|
|
@@ -11007,11 +11037,14 @@ async function updateMangleRule(a, ctx) {
|
|
|
11007
11037
|
}
|
|
11008
11038
|
if (updates.length === 0)
|
|
11009
11039
|
return "No updates specified.";
|
|
11010
|
-
const
|
|
11040
|
+
const id = await resolveMangleRuleId(a.rule_id, ctx);
|
|
11041
|
+
if (!id)
|
|
11042
|
+
return `Mangle rule '${a.rule_id}' not found.`;
|
|
11043
|
+
const cmd = `/ip firewall mangle set ${id} ${updates.join(" ")}`;
|
|
11011
11044
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
11012
11045
|
if (looksLikeError(result))
|
|
11013
11046
|
return `Failed to update mangle rule: ${result}`;
|
|
11014
|
-
const details = await executeMikrotikCommand(`/ip firewall mangle print detail where .id=${
|
|
11047
|
+
const details = await executeMikrotikCommand(`/ip firewall mangle print detail where .id=${id}`, ctx);
|
|
11015
11048
|
return `Mangle rule updated successfully:
|
|
11016
11049
|
|
|
11017
11050
|
${details}`;
|
|
@@ -11186,8 +11219,11 @@ ${result}`;
|
|
|
11186
11219
|
},
|
|
11187
11220
|
async handler(a, ctx) {
|
|
11188
11221
|
ctx.info(`Getting mangle rule details: rule_id=${a.rule_id}`);
|
|
11189
|
-
const
|
|
11190
|
-
|
|
11222
|
+
const id = await resolveMangleRuleId(a.rule_id, ctx);
|
|
11223
|
+
if (!id)
|
|
11224
|
+
return `Mangle rule '${a.rule_id}' not found.`;
|
|
11225
|
+
const result = await executeMikrotikCommand(`/ip firewall mangle print detail where .id=${id}`, ctx);
|
|
11226
|
+
return isEmpty(result) ? `Mangle rule '${a.rule_id}' not found.` : `MANGLE RULE DETAILS:
|
|
11191
11227
|
|
|
11192
11228
|
${result}`;
|
|
11193
11229
|
}
|
|
@@ -11278,13 +11314,13 @@ ${result}`;
|
|
|
11278
11314
|
inputSchema: { rule_id: z30.string() },
|
|
11279
11315
|
async handler(a, ctx) {
|
|
11280
11316
|
ctx.info(`Removing mangle rule: rule_id=${a.rule_id}`);
|
|
11281
|
-
const
|
|
11282
|
-
if (
|
|
11283
|
-
return `Mangle rule
|
|
11284
|
-
const result = await executeMikrotikCommand(`/ip firewall mangle remove ${
|
|
11317
|
+
const id = await resolveMangleRuleId(a.rule_id, ctx);
|
|
11318
|
+
if (!id)
|
|
11319
|
+
return `Mangle rule '${a.rule_id}' not found.`;
|
|
11320
|
+
const result = await executeMikrotikCommand(`/ip firewall mangle remove ${id}`, ctx);
|
|
11285
11321
|
if (looksLikeError(result))
|
|
11286
11322
|
return `Failed to remove mangle rule: ${result}`;
|
|
11287
|
-
return `Mangle rule
|
|
11323
|
+
return `Mangle rule '${a.rule_id}' (${id}) removed successfully.`;
|
|
11288
11324
|
}
|
|
11289
11325
|
}),
|
|
11290
11326
|
defineTool({
|
|
@@ -11298,13 +11334,13 @@ ${result}`;
|
|
|
11298
11334
|
},
|
|
11299
11335
|
async handler(a, ctx) {
|
|
11300
11336
|
ctx.info(`Moving mangle rule: rule_id=${a.rule_id} to position ${a.destination}`);
|
|
11301
|
-
const
|
|
11302
|
-
if (
|
|
11303
|
-
return `Mangle rule
|
|
11304
|
-
const result = await executeMikrotikCommand(`/ip firewall mangle move ${
|
|
11337
|
+
const id = await resolveMangleRuleId(a.rule_id, ctx);
|
|
11338
|
+
if (!id)
|
|
11339
|
+
return `Mangle rule '${a.rule_id}' not found.`;
|
|
11340
|
+
const result = await executeMikrotikCommand(`/ip firewall mangle move ${id} destination=${a.destination}`, ctx);
|
|
11305
11341
|
if (looksLikeError(result))
|
|
11306
11342
|
return `Failed to move mangle rule: ${result}`;
|
|
11307
|
-
return `Mangle rule
|
|
11343
|
+
return `Mangle rule '${a.rule_id}' (${id}) moved to position ${a.destination}.`;
|
|
11308
11344
|
}
|
|
11309
11345
|
}),
|
|
11310
11346
|
defineTool({
|
|
@@ -13440,6 +13476,7 @@ ${result}`;
|
|
|
13440
13476
|
// src/tools/ipv6-firewall-filter.ts
|
|
13441
13477
|
import { z as z44 } from "zod";
|
|
13442
13478
|
var isDigits4 = (s) => /^\d+$/.test(s);
|
|
13479
|
+
var resolveRuleId = ruleResolver("/ipv6 firewall filter");
|
|
13443
13480
|
async function updateFilterRule2(a, ctx) {
|
|
13444
13481
|
ctx.info(`Updating IPv6 firewall filter rule: rule_id=${a.rule_id}`);
|
|
13445
13482
|
const updates = [];
|
|
@@ -13508,11 +13545,14 @@ async function updateFilterRule2(a, ctx) {
|
|
|
13508
13545
|
}
|
|
13509
13546
|
if (updates.length === 0)
|
|
13510
13547
|
return "No updates specified.";
|
|
13511
|
-
const
|
|
13548
|
+
const id = await resolveRuleId(a.rule_id, ctx);
|
|
13549
|
+
if (!id)
|
|
13550
|
+
return `IPv6 firewall filter rule '${a.rule_id}' not found.`;
|
|
13551
|
+
const cmd = `/ipv6 firewall filter set ${id} ${updates.join(" ")}`;
|
|
13512
13552
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
13513
13553
|
if (looksLikeError(result))
|
|
13514
13554
|
return `Failed to update IPv6 firewall filter rule: ${result}`;
|
|
13515
|
-
const details = await executeMikrotikCommand(`/ipv6 firewall filter print detail where .id=${
|
|
13555
|
+
const details = await executeMikrotikCommand(`/ipv6 firewall filter print detail where .id=${id}`, ctx);
|
|
13516
13556
|
return `IPv6 firewall filter rule updated successfully:
|
|
13517
13557
|
|
|
13518
13558
|
${details}`;
|
|
@@ -13669,8 +13709,11 @@ ${result}`;
|
|
|
13669
13709
|
},
|
|
13670
13710
|
async handler(a, ctx) {
|
|
13671
13711
|
ctx.info(`Getting IPv6 firewall filter rule details: rule_id=${a.rule_id}`);
|
|
13672
|
-
const
|
|
13673
|
-
|
|
13712
|
+
const id = await resolveRuleId(a.rule_id, ctx);
|
|
13713
|
+
if (!id)
|
|
13714
|
+
return `IPv6 firewall filter rule '${a.rule_id}' not found.`;
|
|
13715
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall filter print detail where .id=${id}`, ctx);
|
|
13716
|
+
return isEmpty(result) ? `IPv6 firewall filter rule '${a.rule_id}' not found.` : `IPV6 FIREWALL FILTER RULE DETAILS:
|
|
13674
13717
|
|
|
13675
13718
|
${result}`;
|
|
13676
13719
|
}
|
|
@@ -13746,13 +13789,13 @@ ${result}`;
|
|
|
13746
13789
|
inputSchema: { rule_id: z44.string() },
|
|
13747
13790
|
async handler(a, ctx) {
|
|
13748
13791
|
ctx.info(`Removing IPv6 firewall filter rule: rule_id=${a.rule_id}`);
|
|
13749
|
-
const
|
|
13750
|
-
if (
|
|
13751
|
-
return `IPv6 firewall filter rule
|
|
13752
|
-
const result = await executeMikrotikCommand(`/ipv6 firewall filter remove ${
|
|
13792
|
+
const id = await resolveRuleId(a.rule_id, ctx);
|
|
13793
|
+
if (!id)
|
|
13794
|
+
return `IPv6 firewall filter rule '${a.rule_id}' not found.`;
|
|
13795
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall filter remove ${id}`, ctx);
|
|
13753
13796
|
if (looksLikeError(result))
|
|
13754
13797
|
return `Failed to remove IPv6 firewall filter rule: ${result}`;
|
|
13755
|
-
return `IPv6 firewall filter rule
|
|
13798
|
+
return `IPv6 firewall filter rule '${a.rule_id}' (${id}) removed successfully.`;
|
|
13756
13799
|
}
|
|
13757
13800
|
}),
|
|
13758
13801
|
defineTool({
|
|
@@ -13766,13 +13809,13 @@ ${result}`;
|
|
|
13766
13809
|
},
|
|
13767
13810
|
async handler(a, ctx) {
|
|
13768
13811
|
ctx.info(`Moving IPv6 firewall filter rule: rule_id=${a.rule_id} to position ${a.destination}`);
|
|
13769
|
-
const
|
|
13770
|
-
if (
|
|
13771
|
-
return `IPv6 firewall filter rule
|
|
13772
|
-
const result = await executeMikrotikCommand(`/ipv6 firewall filter move ${
|
|
13812
|
+
const id = await resolveRuleId(a.rule_id, ctx);
|
|
13813
|
+
if (!id)
|
|
13814
|
+
return `IPv6 firewall filter rule '${a.rule_id}' not found.`;
|
|
13815
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall filter move ${id} destination=${a.destination}`, ctx);
|
|
13773
13816
|
if (looksLikeError(result))
|
|
13774
13817
|
return `Failed to move IPv6 firewall filter rule: ${result}`;
|
|
13775
|
-
return `IPv6 firewall filter rule
|
|
13818
|
+
return `IPv6 firewall filter rule '${a.rule_id}' (${id}) moved to position ${a.destination}.`;
|
|
13776
13819
|
}
|
|
13777
13820
|
}),
|
|
13778
13821
|
defineTool({
|
|
@@ -13800,6 +13843,7 @@ ${result}`;
|
|
|
13800
13843
|
// src/tools/ipv6-firewall-nat.ts
|
|
13801
13844
|
import { z as z45 } from "zod";
|
|
13802
13845
|
var isDigits5 = (s) => /^\d+$/.test(s);
|
|
13846
|
+
var resolveRuleId2 = ruleResolver("/ipv6 firewall nat");
|
|
13803
13847
|
async function updateNatRule2(a, ctx) {
|
|
13804
13848
|
ctx.info(`Updating IPv6 firewall NAT rule: rule_id=${a.rule_id}`);
|
|
13805
13849
|
const updates = [];
|
|
@@ -13867,11 +13911,14 @@ async function updateNatRule2(a, ctx) {
|
|
|
13867
13911
|
}
|
|
13868
13912
|
if (updates.length === 0)
|
|
13869
13913
|
return "No updates specified.";
|
|
13870
|
-
const
|
|
13914
|
+
const id = await resolveRuleId2(a.rule_id, ctx);
|
|
13915
|
+
if (!id)
|
|
13916
|
+
return `IPv6 NAT rule '${a.rule_id}' not found.`;
|
|
13917
|
+
const cmd = `/ipv6 firewall nat set ${id} ${updates.join(" ")}`;
|
|
13871
13918
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
13872
13919
|
if (looksLikeError(result))
|
|
13873
13920
|
return `Failed to update IPv6 firewall NAT rule: ${result}`;
|
|
13874
|
-
const details = await executeMikrotikCommand(`/ipv6 firewall nat print detail where .id=${
|
|
13921
|
+
const details = await executeMikrotikCommand(`/ipv6 firewall nat print detail where .id=${id}`, ctx);
|
|
13875
13922
|
return `IPv6 firewall NAT rule updated successfully:
|
|
13876
13923
|
|
|
13877
13924
|
${details}`;
|
|
@@ -14022,8 +14069,11 @@ ${result}`;
|
|
|
14022
14069
|
},
|
|
14023
14070
|
async handler(a, ctx) {
|
|
14024
14071
|
ctx.info(`Getting IPv6 firewall NAT rule details: rule_id=${a.rule_id}`);
|
|
14025
|
-
const
|
|
14026
|
-
|
|
14072
|
+
const id = await resolveRuleId2(a.rule_id, ctx);
|
|
14073
|
+
if (!id)
|
|
14074
|
+
return `IPv6 firewall NAT rule '${a.rule_id}' not found.`;
|
|
14075
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall nat print detail where .id=${id}`, ctx);
|
|
14076
|
+
return isEmpty(result) ? `IPv6 firewall NAT rule '${a.rule_id}' not found.` : `IPV6 FIREWALL NAT RULE DETAILS:
|
|
14027
14077
|
|
|
14028
14078
|
${result}`;
|
|
14029
14079
|
}
|
|
@@ -14098,13 +14148,13 @@ ${result}`;
|
|
|
14098
14148
|
inputSchema: { rule_id: z45.string() },
|
|
14099
14149
|
async handler(a, ctx) {
|
|
14100
14150
|
ctx.info(`Removing IPv6 firewall NAT rule: rule_id=${a.rule_id}`);
|
|
14101
|
-
const
|
|
14102
|
-
if (
|
|
14103
|
-
return `IPv6 firewall NAT rule
|
|
14104
|
-
const result = await executeMikrotikCommand(`/ipv6 firewall nat remove ${
|
|
14151
|
+
const id = await resolveRuleId2(a.rule_id, ctx);
|
|
14152
|
+
if (!id)
|
|
14153
|
+
return `IPv6 firewall NAT rule '${a.rule_id}' not found.`;
|
|
14154
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall nat remove ${id}`, ctx);
|
|
14105
14155
|
if (looksLikeError(result))
|
|
14106
14156
|
return `Failed to remove IPv6 firewall NAT rule: ${result}`;
|
|
14107
|
-
return `IPv6 firewall NAT rule
|
|
14157
|
+
return `IPv6 firewall NAT rule '${a.rule_id}' (${id}) removed successfully.`;
|
|
14108
14158
|
}
|
|
14109
14159
|
}),
|
|
14110
14160
|
defineTool({
|
|
@@ -14118,13 +14168,13 @@ ${result}`;
|
|
|
14118
14168
|
},
|
|
14119
14169
|
async handler(a, ctx) {
|
|
14120
14170
|
ctx.info(`Moving IPv6 firewall NAT rule: rule_id=${a.rule_id} to position ${a.destination}`);
|
|
14121
|
-
const
|
|
14122
|
-
if (
|
|
14123
|
-
return `IPv6 firewall NAT rule
|
|
14124
|
-
const result = await executeMikrotikCommand(`/ipv6 firewall nat move ${
|
|
14171
|
+
const id = await resolveRuleId2(a.rule_id, ctx);
|
|
14172
|
+
if (!id)
|
|
14173
|
+
return `IPv6 firewall NAT rule '${a.rule_id}' not found.`;
|
|
14174
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall nat move ${id} destination=${a.destination}`, ctx);
|
|
14125
14175
|
if (looksLikeError(result))
|
|
14126
14176
|
return `Failed to move IPv6 firewall NAT rule: ${result}`;
|
|
14127
|
-
return `IPv6 firewall NAT rule
|
|
14177
|
+
return `IPv6 firewall NAT rule '${a.rule_id}' (${id}) moved to position ${a.destination}.`;
|
|
14128
14178
|
}
|
|
14129
14179
|
}),
|
|
14130
14180
|
defineTool({
|
|
@@ -14152,6 +14202,7 @@ ${result}`;
|
|
|
14152
14202
|
// src/tools/ipv6-firewall-mangle.ts
|
|
14153
14203
|
import { z as z46 } from "zod";
|
|
14154
14204
|
var isDigits6 = (s) => /^\d+$/.test(s);
|
|
14205
|
+
var resolveRuleId3 = ruleResolver("/ipv6 firewall mangle");
|
|
14155
14206
|
async function updateMangleRule2(a, ctx) {
|
|
14156
14207
|
ctx.info(`Updating IPv6 firewall mangle rule: rule_id=${a.rule_id}`);
|
|
14157
14208
|
const updates = [];
|
|
@@ -14227,11 +14278,14 @@ async function updateMangleRule2(a, ctx) {
|
|
|
14227
14278
|
}
|
|
14228
14279
|
if (updates.length === 0)
|
|
14229
14280
|
return "No updates specified.";
|
|
14230
|
-
const
|
|
14281
|
+
const id = await resolveRuleId3(a.rule_id, ctx);
|
|
14282
|
+
if (!id)
|
|
14283
|
+
return `IPv6 mangle rule '${a.rule_id}' not found.`;
|
|
14284
|
+
const cmd = `/ipv6 firewall mangle set ${id} ${updates.join(" ")}`;
|
|
14231
14285
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
14232
14286
|
if (looksLikeError(result))
|
|
14233
14287
|
return `Failed to update IPv6 firewall mangle rule: ${result}`;
|
|
14234
|
-
const details = await executeMikrotikCommand(`/ipv6 firewall mangle print detail where .id=${
|
|
14288
|
+
const details = await executeMikrotikCommand(`/ipv6 firewall mangle print detail where .id=${id}`, ctx);
|
|
14235
14289
|
return `IPv6 firewall mangle rule updated successfully:
|
|
14236
14290
|
|
|
14237
14291
|
${details}`;
|
|
@@ -14390,8 +14444,11 @@ ${result}`;
|
|
|
14390
14444
|
},
|
|
14391
14445
|
async handler(a, ctx) {
|
|
14392
14446
|
ctx.info(`Getting IPv6 firewall mangle rule details: rule_id=${a.rule_id}`);
|
|
14393
|
-
const
|
|
14394
|
-
|
|
14447
|
+
const id = await resolveRuleId3(a.rule_id, ctx);
|
|
14448
|
+
if (!id)
|
|
14449
|
+
return `IPv6 mangle rule '${a.rule_id}' not found.`;
|
|
14450
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall mangle print detail where .id=${id}`, ctx);
|
|
14451
|
+
return isEmpty(result) ? `IPv6 mangle rule '${a.rule_id}' not found.` : `IPV6 FIREWALL MANGLE RULE DETAILS:
|
|
14395
14452
|
|
|
14396
14453
|
${result}`;
|
|
14397
14454
|
}
|
|
@@ -14473,13 +14530,13 @@ ${result}`;
|
|
|
14473
14530
|
inputSchema: { rule_id: z46.string() },
|
|
14474
14531
|
async handler(a, ctx) {
|
|
14475
14532
|
ctx.info(`Removing IPv6 firewall mangle rule: rule_id=${a.rule_id}`);
|
|
14476
|
-
const
|
|
14477
|
-
if (
|
|
14478
|
-
return `IPv6
|
|
14479
|
-
const result = await executeMikrotikCommand(`/ipv6 firewall mangle remove ${
|
|
14533
|
+
const id = await resolveRuleId3(a.rule_id, ctx);
|
|
14534
|
+
if (!id)
|
|
14535
|
+
return `IPv6 mangle rule '${a.rule_id}' not found.`;
|
|
14536
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall mangle remove ${id}`, ctx);
|
|
14480
14537
|
if (looksLikeError(result))
|
|
14481
14538
|
return `Failed to remove IPv6 firewall mangle rule: ${result}`;
|
|
14482
|
-
return `IPv6
|
|
14539
|
+
return `IPv6 mangle rule '${a.rule_id}' (${id}) removed successfully.`;
|
|
14483
14540
|
}
|
|
14484
14541
|
}),
|
|
14485
14542
|
defineTool({
|
|
@@ -14493,13 +14550,13 @@ ${result}`;
|
|
|
14493
14550
|
},
|
|
14494
14551
|
async handler(a, ctx) {
|
|
14495
14552
|
ctx.info(`Moving IPv6 firewall mangle rule: rule_id=${a.rule_id} to position ${a.destination}`);
|
|
14496
|
-
const
|
|
14497
|
-
if (
|
|
14498
|
-
return `IPv6
|
|
14499
|
-
const result = await executeMikrotikCommand(`/ipv6 firewall mangle move ${
|
|
14553
|
+
const id = await resolveRuleId3(a.rule_id, ctx);
|
|
14554
|
+
if (!id)
|
|
14555
|
+
return `IPv6 mangle rule '${a.rule_id}' not found.`;
|
|
14556
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall mangle move ${id} destination=${a.destination}`, ctx);
|
|
14500
14557
|
if (looksLikeError(result))
|
|
14501
14558
|
return `Failed to move IPv6 firewall mangle rule: ${result}`;
|
|
14502
|
-
return `IPv6
|
|
14559
|
+
return `IPv6 mangle rule '${a.rule_id}' (${id}) moved to position ${a.destination}.`;
|
|
14503
14560
|
}
|
|
14504
14561
|
}),
|
|
14505
14562
|
defineTool({
|
|
@@ -14527,6 +14584,7 @@ ${result}`;
|
|
|
14527
14584
|
// src/tools/ipv6-firewall-raw.ts
|
|
14528
14585
|
import { z as z47 } from "zod";
|
|
14529
14586
|
var isDigits7 = (s) => /^\d+$/.test(s);
|
|
14587
|
+
var resolveRuleId4 = ruleResolver("/ipv6 firewall raw");
|
|
14530
14588
|
async function updateRawRule(a, ctx) {
|
|
14531
14589
|
ctx.info(`Updating IPv6 firewall raw rule: rule_id=${a.rule_id}`);
|
|
14532
14590
|
const updates = [];
|
|
@@ -14572,11 +14630,14 @@ async function updateRawRule(a, ctx) {
|
|
|
14572
14630
|
}
|
|
14573
14631
|
if (updates.length === 0)
|
|
14574
14632
|
return "No updates specified.";
|
|
14575
|
-
const
|
|
14633
|
+
const id = await resolveRuleId4(a.rule_id, ctx);
|
|
14634
|
+
if (!id)
|
|
14635
|
+
return `IPv6 raw rule '${a.rule_id}' not found.`;
|
|
14636
|
+
const cmd = `/ipv6 firewall raw set ${id} ${updates.join(" ")}`;
|
|
14576
14637
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
14577
14638
|
if (looksLikeError(result))
|
|
14578
14639
|
return `Failed to update IPv6 firewall raw rule: ${result}`;
|
|
14579
|
-
const details = await executeMikrotikCommand(`/ipv6 firewall raw print detail where .id=${
|
|
14640
|
+
const details = await executeMikrotikCommand(`/ipv6 firewall raw print detail where .id=${id}`, ctx);
|
|
14580
14641
|
return `IPv6 firewall raw rule updated successfully:
|
|
14581
14642
|
|
|
14582
14643
|
${details}`;
|
|
@@ -14691,7 +14752,10 @@ ${result}`;
|
|
|
14691
14752
|
},
|
|
14692
14753
|
async handler(a, ctx) {
|
|
14693
14754
|
ctx.info(`Getting IPv6 firewall raw rule details: rule_id=${a.rule_id}`);
|
|
14694
|
-
const
|
|
14755
|
+
const id = await resolveRuleId4(a.rule_id, ctx);
|
|
14756
|
+
if (!id)
|
|
14757
|
+
return `IPv6 firewall raw rule with ID '${a.rule_id}' not found.`;
|
|
14758
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall raw print detail where .id=${id}`, ctx);
|
|
14695
14759
|
return isEmpty(result) ? `IPv6 firewall raw rule with ID '${a.rule_id}' not found.` : `IPV6 FIREWALL RAW RULE DETAILS:
|
|
14696
14760
|
|
|
14697
14761
|
${result}`;
|
|
@@ -14745,13 +14809,13 @@ ${result}`;
|
|
|
14745
14809
|
inputSchema: { rule_id: z47.string() },
|
|
14746
14810
|
async handler(a, ctx) {
|
|
14747
14811
|
ctx.info(`Removing IPv6 firewall raw rule: rule_id=${a.rule_id}`);
|
|
14748
|
-
const
|
|
14749
|
-
if (
|
|
14812
|
+
const id = await resolveRuleId4(a.rule_id, ctx);
|
|
14813
|
+
if (!id)
|
|
14750
14814
|
return `IPv6 firewall raw rule with ID '${a.rule_id}' not found.`;
|
|
14751
|
-
const result = await executeMikrotikCommand(`/ipv6 firewall raw remove ${
|
|
14815
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall raw remove ${id}`, ctx);
|
|
14752
14816
|
if (looksLikeError(result))
|
|
14753
14817
|
return `Failed to remove IPv6 firewall raw rule: ${result}`;
|
|
14754
|
-
return `IPv6 firewall raw rule
|
|
14818
|
+
return `IPv6 firewall raw rule '${a.rule_id}' (${id}) removed successfully.`;
|
|
14755
14819
|
}
|
|
14756
14820
|
}),
|
|
14757
14821
|
defineTool({
|
|
@@ -14765,13 +14829,13 @@ ${result}`;
|
|
|
14765
14829
|
},
|
|
14766
14830
|
async handler(a, ctx) {
|
|
14767
14831
|
ctx.info(`Moving IPv6 firewall raw rule: rule_id=${a.rule_id} to position ${a.destination}`);
|
|
14768
|
-
const
|
|
14769
|
-
if (
|
|
14832
|
+
const id = await resolveRuleId4(a.rule_id, ctx);
|
|
14833
|
+
if (!id)
|
|
14770
14834
|
return `IPv6 firewall raw rule with ID '${a.rule_id}' not found.`;
|
|
14771
|
-
const result = await executeMikrotikCommand(`/ipv6 firewall raw move ${
|
|
14835
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall raw move ${id} destination=${a.destination}`, ctx);
|
|
14772
14836
|
if (looksLikeError(result))
|
|
14773
14837
|
return `Failed to move IPv6 firewall raw rule: ${result}`;
|
|
14774
|
-
return `IPv6 firewall raw rule
|
|
14838
|
+
return `IPv6 firewall raw rule '${a.rule_id}' (${id}) moved to position ${a.destination}.`;
|
|
14775
14839
|
}
|
|
14776
14840
|
}),
|
|
14777
14841
|
defineTool({
|
|
@@ -22133,7 +22197,7 @@ ${result}`;
|
|
|
22133
22197
|
${v6Result}`;
|
|
22134
22198
|
}
|
|
22135
22199
|
const where = [`dst-address in ${a.destination}`, "active=yes"];
|
|
22136
|
-
if (table)
|
|
22200
|
+
if (table && table !== "main")
|
|
22137
22201
|
where.push(`routing-table=${quoteValue(table)}`);
|
|
22138
22202
|
const v7Cmd = `/ip route print detail where ${where.join(" ")}`;
|
|
22139
22203
|
const v7Result = await executeMikrotikCommand(v7Cmd, ctx);
|
|
@@ -8138,7 +8138,7 @@ var rawCommandTools = [
|
|
|
8138
8138
|
if (!cmd)
|
|
8139
8139
|
return "Provide a RouterOS command to run.";
|
|
8140
8140
|
ctx.info(`Running raw RouterOS command: ${cmd}`);
|
|
8141
|
-
const result = await executeMikrotikCommand(cmd, ctx);
|
|
8141
|
+
const result = await executeMikrotikCommand(cmd, ctx, { maxMs: 30000 });
|
|
8142
8142
|
if (looksLikeError(result))
|
|
8143
8143
|
return `RouterOS command error: ${result}`;
|
|
8144
8144
|
return result.trim() ? result : "(command completed with no output)";
|
|
@@ -8260,7 +8260,7 @@ var cache = null;
|
|
|
8260
8260
|
async function gateway() {
|
|
8261
8261
|
if (cache)
|
|
8262
8262
|
return cache;
|
|
8263
|
-
const { moduleCatalog } = await import("./library-
|
|
8263
|
+
const { moduleCatalog } = await import("./library-1hs18tmh.js");
|
|
8264
8264
|
const forIndex = [];
|
|
8265
8265
|
const byName = new Map;
|
|
8266
8266
|
for (const mod of moduleCatalog) {
|
|
@@ -10457,7 +10457,30 @@ ${results.join(`
|
|
|
10457
10457
|
|
|
10458
10458
|
// src/tools/firewall-nat.ts
|
|
10459
10459
|
import { z as z29 } from "zod";
|
|
10460
|
+
|
|
10461
|
+
// src/tools/_resolve-rule-id.ts
|
|
10462
|
+
function ruleResolver(scope) {
|
|
10463
|
+
return async function resolveRuleId(ruleId, ctx) {
|
|
10464
|
+
if (/^\d+$/.test(ruleId)) {
|
|
10465
|
+
const id = `*${ruleId}`;
|
|
10466
|
+
const byId = await executeMikrotikCommand(`${scope} print count-only where .id=${id}`, ctx);
|
|
10467
|
+
if (byId.trim() !== "0")
|
|
10468
|
+
return id;
|
|
10469
|
+
const idsRaw = await executeMikrotikCommand(`:foreach i in=[${scope} find] do={:put $i}`, ctx);
|
|
10470
|
+
if (isEmpty(idsRaw))
|
|
10471
|
+
return null;
|
|
10472
|
+
const ids = idsRaw.trim().split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
|
|
10473
|
+
const pos = Number.parseInt(ruleId, 10);
|
|
10474
|
+
return pos >= 0 && pos < ids.length ? ids[pos] : null;
|
|
10475
|
+
}
|
|
10476
|
+
const count = await executeMikrotikCommand(`${scope} print count-only where .id=${ruleId}`, ctx);
|
|
10477
|
+
return count.trim() !== "0" ? ruleId : null;
|
|
10478
|
+
};
|
|
10479
|
+
}
|
|
10480
|
+
|
|
10481
|
+
// src/tools/firewall-nat.ts
|
|
10460
10482
|
var isDigits2 = (s) => /^\d+$/.test(s);
|
|
10483
|
+
var resolveNatRuleId = ruleResolver("/ip firewall nat");
|
|
10461
10484
|
async function updateNatRule(a, ctx) {
|
|
10462
10485
|
ctx.info(`Updating NAT rule: rule_id=${a.rule_id}`);
|
|
10463
10486
|
const updates = [];
|
|
@@ -10533,11 +10556,14 @@ async function updateNatRule(a, ctx) {
|
|
|
10533
10556
|
}
|
|
10534
10557
|
if (updates.length === 0)
|
|
10535
10558
|
return "No updates specified.";
|
|
10536
|
-
const
|
|
10559
|
+
const id = await resolveNatRuleId(a.rule_id, ctx);
|
|
10560
|
+
if (!id)
|
|
10561
|
+
return `NAT rule '${a.rule_id}' not found.`;
|
|
10562
|
+
const cmd = `/ip firewall nat set ${id} ${updates.join(" ")}`;
|
|
10537
10563
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
10538
10564
|
if (looksLikeError(result))
|
|
10539
10565
|
return `Failed to update NAT rule: ${result}`;
|
|
10540
|
-
const details = await executeMikrotikCommand(`/ip firewall nat print detail where .id=${
|
|
10566
|
+
const details = await executeMikrotikCommand(`/ip firewall nat print detail where .id=${id}`, ctx);
|
|
10541
10567
|
return `NAT rule updated successfully:
|
|
10542
10568
|
|
|
10543
10569
|
${details}`;
|
|
@@ -10715,8 +10741,11 @@ ${result}`;
|
|
|
10715
10741
|
},
|
|
10716
10742
|
async handler(a, ctx) {
|
|
10717
10743
|
ctx.info(`Getting NAT rule details: rule_id=${a.rule_id}`);
|
|
10718
|
-
const
|
|
10719
|
-
|
|
10744
|
+
const id = await resolveNatRuleId(a.rule_id, ctx);
|
|
10745
|
+
if (!id)
|
|
10746
|
+
return `NAT rule '${a.rule_id}' not found.`;
|
|
10747
|
+
const result = await executeMikrotikCommand(`/ip firewall nat print detail where .id=${id}`, ctx);
|
|
10748
|
+
return isEmpty(result) ? `NAT rule '${a.rule_id}' not found.` : `NAT RULE DETAILS:
|
|
10720
10749
|
|
|
10721
10750
|
${result}`;
|
|
10722
10751
|
}
|
|
@@ -10798,13 +10827,13 @@ ${result}`;
|
|
|
10798
10827
|
inputSchema: { rule_id: z29.string() },
|
|
10799
10828
|
async handler(a, ctx) {
|
|
10800
10829
|
ctx.info(`Removing NAT rule: rule_id=${a.rule_id}`);
|
|
10801
|
-
const
|
|
10802
|
-
if (
|
|
10803
|
-
return `NAT rule
|
|
10804
|
-
const result = await executeMikrotikCommand(`/ip firewall nat remove ${
|
|
10830
|
+
const id = await resolveNatRuleId(a.rule_id, ctx);
|
|
10831
|
+
if (!id)
|
|
10832
|
+
return `NAT rule '${a.rule_id}' not found.`;
|
|
10833
|
+
const result = await executeMikrotikCommand(`/ip firewall nat remove ${id}`, ctx);
|
|
10805
10834
|
if (looksLikeError(result))
|
|
10806
10835
|
return `Failed to remove NAT rule: ${result}`;
|
|
10807
|
-
return `NAT rule
|
|
10836
|
+
return `NAT rule '${a.rule_id}' (${id}) removed successfully.`;
|
|
10808
10837
|
}
|
|
10809
10838
|
}),
|
|
10810
10839
|
defineTool({
|
|
@@ -10818,13 +10847,13 @@ ${result}`;
|
|
|
10818
10847
|
},
|
|
10819
10848
|
async handler(a, ctx) {
|
|
10820
10849
|
ctx.info(`Moving NAT rule: rule_id=${a.rule_id} to position ${a.destination}`);
|
|
10821
|
-
const
|
|
10822
|
-
if (
|
|
10823
|
-
return `NAT rule
|
|
10824
|
-
const result = await executeMikrotikCommand(`/ip firewall nat move ${
|
|
10850
|
+
const id = await resolveNatRuleId(a.rule_id, ctx);
|
|
10851
|
+
if (!id)
|
|
10852
|
+
return `NAT rule '${a.rule_id}' not found.`;
|
|
10853
|
+
const result = await executeMikrotikCommand(`/ip firewall nat move ${id} destination=${a.destination}`, ctx);
|
|
10825
10854
|
if (looksLikeError(result))
|
|
10826
10855
|
return `Failed to move NAT rule: ${result}`;
|
|
10827
|
-
return `NAT rule
|
|
10856
|
+
return `NAT rule '${a.rule_id}' (${id}) moved to position ${a.destination}.`;
|
|
10828
10857
|
}
|
|
10829
10858
|
}),
|
|
10830
10859
|
defineTool({
|
|
@@ -10852,6 +10881,7 @@ ${result}`;
|
|
|
10852
10881
|
// src/tools/firewall-mangle.ts
|
|
10853
10882
|
import { z as z30 } from "zod";
|
|
10854
10883
|
var isDigits3 = (s) => /^\d+$/.test(s);
|
|
10884
|
+
var resolveMangleRuleId = ruleResolver("/ip firewall mangle");
|
|
10855
10885
|
async function updateMangleRule(a, ctx) {
|
|
10856
10886
|
ctx.info(`Updating mangle rule: rule_id=${a.rule_id}`);
|
|
10857
10887
|
const updates = [];
|
|
@@ -10937,11 +10967,14 @@ async function updateMangleRule(a, ctx) {
|
|
|
10937
10967
|
}
|
|
10938
10968
|
if (updates.length === 0)
|
|
10939
10969
|
return "No updates specified.";
|
|
10940
|
-
const
|
|
10970
|
+
const id = await resolveMangleRuleId(a.rule_id, ctx);
|
|
10971
|
+
if (!id)
|
|
10972
|
+
return `Mangle rule '${a.rule_id}' not found.`;
|
|
10973
|
+
const cmd = `/ip firewall mangle set ${id} ${updates.join(" ")}`;
|
|
10941
10974
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
10942
10975
|
if (looksLikeError(result))
|
|
10943
10976
|
return `Failed to update mangle rule: ${result}`;
|
|
10944
|
-
const details = await executeMikrotikCommand(`/ip firewall mangle print detail where .id=${
|
|
10977
|
+
const details = await executeMikrotikCommand(`/ip firewall mangle print detail where .id=${id}`, ctx);
|
|
10945
10978
|
return `Mangle rule updated successfully:
|
|
10946
10979
|
|
|
10947
10980
|
${details}`;
|
|
@@ -11116,8 +11149,11 @@ ${result}`;
|
|
|
11116
11149
|
},
|
|
11117
11150
|
async handler(a, ctx) {
|
|
11118
11151
|
ctx.info(`Getting mangle rule details: rule_id=${a.rule_id}`);
|
|
11119
|
-
const
|
|
11120
|
-
|
|
11152
|
+
const id = await resolveMangleRuleId(a.rule_id, ctx);
|
|
11153
|
+
if (!id)
|
|
11154
|
+
return `Mangle rule '${a.rule_id}' not found.`;
|
|
11155
|
+
const result = await executeMikrotikCommand(`/ip firewall mangle print detail where .id=${id}`, ctx);
|
|
11156
|
+
return isEmpty(result) ? `Mangle rule '${a.rule_id}' not found.` : `MANGLE RULE DETAILS:
|
|
11121
11157
|
|
|
11122
11158
|
${result}`;
|
|
11123
11159
|
}
|
|
@@ -11208,13 +11244,13 @@ ${result}`;
|
|
|
11208
11244
|
inputSchema: { rule_id: z30.string() },
|
|
11209
11245
|
async handler(a, ctx) {
|
|
11210
11246
|
ctx.info(`Removing mangle rule: rule_id=${a.rule_id}`);
|
|
11211
|
-
const
|
|
11212
|
-
if (
|
|
11213
|
-
return `Mangle rule
|
|
11214
|
-
const result = await executeMikrotikCommand(`/ip firewall mangle remove ${
|
|
11247
|
+
const id = await resolveMangleRuleId(a.rule_id, ctx);
|
|
11248
|
+
if (!id)
|
|
11249
|
+
return `Mangle rule '${a.rule_id}' not found.`;
|
|
11250
|
+
const result = await executeMikrotikCommand(`/ip firewall mangle remove ${id}`, ctx);
|
|
11215
11251
|
if (looksLikeError(result))
|
|
11216
11252
|
return `Failed to remove mangle rule: ${result}`;
|
|
11217
|
-
return `Mangle rule
|
|
11253
|
+
return `Mangle rule '${a.rule_id}' (${id}) removed successfully.`;
|
|
11218
11254
|
}
|
|
11219
11255
|
}),
|
|
11220
11256
|
defineTool({
|
|
@@ -11228,13 +11264,13 @@ ${result}`;
|
|
|
11228
11264
|
},
|
|
11229
11265
|
async handler(a, ctx) {
|
|
11230
11266
|
ctx.info(`Moving mangle rule: rule_id=${a.rule_id} to position ${a.destination}`);
|
|
11231
|
-
const
|
|
11232
|
-
if (
|
|
11233
|
-
return `Mangle rule
|
|
11234
|
-
const result = await executeMikrotikCommand(`/ip firewall mangle move ${
|
|
11267
|
+
const id = await resolveMangleRuleId(a.rule_id, ctx);
|
|
11268
|
+
if (!id)
|
|
11269
|
+
return `Mangle rule '${a.rule_id}' not found.`;
|
|
11270
|
+
const result = await executeMikrotikCommand(`/ip firewall mangle move ${id} destination=${a.destination}`, ctx);
|
|
11235
11271
|
if (looksLikeError(result))
|
|
11236
11272
|
return `Failed to move mangle rule: ${result}`;
|
|
11237
|
-
return `Mangle rule
|
|
11273
|
+
return `Mangle rule '${a.rule_id}' (${id}) moved to position ${a.destination}.`;
|
|
11238
11274
|
}
|
|
11239
11275
|
}),
|
|
11240
11276
|
defineTool({
|
|
@@ -13370,6 +13406,7 @@ ${result}`;
|
|
|
13370
13406
|
// src/tools/ipv6-firewall-filter.ts
|
|
13371
13407
|
import { z as z44 } from "zod";
|
|
13372
13408
|
var isDigits4 = (s) => /^\d+$/.test(s);
|
|
13409
|
+
var resolveRuleId = ruleResolver("/ipv6 firewall filter");
|
|
13373
13410
|
async function updateFilterRule2(a, ctx) {
|
|
13374
13411
|
ctx.info(`Updating IPv6 firewall filter rule: rule_id=${a.rule_id}`);
|
|
13375
13412
|
const updates = [];
|
|
@@ -13438,11 +13475,14 @@ async function updateFilterRule2(a, ctx) {
|
|
|
13438
13475
|
}
|
|
13439
13476
|
if (updates.length === 0)
|
|
13440
13477
|
return "No updates specified.";
|
|
13441
|
-
const
|
|
13478
|
+
const id = await resolveRuleId(a.rule_id, ctx);
|
|
13479
|
+
if (!id)
|
|
13480
|
+
return `IPv6 firewall filter rule '${a.rule_id}' not found.`;
|
|
13481
|
+
const cmd = `/ipv6 firewall filter set ${id} ${updates.join(" ")}`;
|
|
13442
13482
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
13443
13483
|
if (looksLikeError(result))
|
|
13444
13484
|
return `Failed to update IPv6 firewall filter rule: ${result}`;
|
|
13445
|
-
const details = await executeMikrotikCommand(`/ipv6 firewall filter print detail where .id=${
|
|
13485
|
+
const details = await executeMikrotikCommand(`/ipv6 firewall filter print detail where .id=${id}`, ctx);
|
|
13446
13486
|
return `IPv6 firewall filter rule updated successfully:
|
|
13447
13487
|
|
|
13448
13488
|
${details}`;
|
|
@@ -13599,8 +13639,11 @@ ${result}`;
|
|
|
13599
13639
|
},
|
|
13600
13640
|
async handler(a, ctx) {
|
|
13601
13641
|
ctx.info(`Getting IPv6 firewall filter rule details: rule_id=${a.rule_id}`);
|
|
13602
|
-
const
|
|
13603
|
-
|
|
13642
|
+
const id = await resolveRuleId(a.rule_id, ctx);
|
|
13643
|
+
if (!id)
|
|
13644
|
+
return `IPv6 firewall filter rule '${a.rule_id}' not found.`;
|
|
13645
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall filter print detail where .id=${id}`, ctx);
|
|
13646
|
+
return isEmpty(result) ? `IPv6 firewall filter rule '${a.rule_id}' not found.` : `IPV6 FIREWALL FILTER RULE DETAILS:
|
|
13604
13647
|
|
|
13605
13648
|
${result}`;
|
|
13606
13649
|
}
|
|
@@ -13676,13 +13719,13 @@ ${result}`;
|
|
|
13676
13719
|
inputSchema: { rule_id: z44.string() },
|
|
13677
13720
|
async handler(a, ctx) {
|
|
13678
13721
|
ctx.info(`Removing IPv6 firewall filter rule: rule_id=${a.rule_id}`);
|
|
13679
|
-
const
|
|
13680
|
-
if (
|
|
13681
|
-
return `IPv6 firewall filter rule
|
|
13682
|
-
const result = await executeMikrotikCommand(`/ipv6 firewall filter remove ${
|
|
13722
|
+
const id = await resolveRuleId(a.rule_id, ctx);
|
|
13723
|
+
if (!id)
|
|
13724
|
+
return `IPv6 firewall filter rule '${a.rule_id}' not found.`;
|
|
13725
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall filter remove ${id}`, ctx);
|
|
13683
13726
|
if (looksLikeError(result))
|
|
13684
13727
|
return `Failed to remove IPv6 firewall filter rule: ${result}`;
|
|
13685
|
-
return `IPv6 firewall filter rule
|
|
13728
|
+
return `IPv6 firewall filter rule '${a.rule_id}' (${id}) removed successfully.`;
|
|
13686
13729
|
}
|
|
13687
13730
|
}),
|
|
13688
13731
|
defineTool({
|
|
@@ -13696,13 +13739,13 @@ ${result}`;
|
|
|
13696
13739
|
},
|
|
13697
13740
|
async handler(a, ctx) {
|
|
13698
13741
|
ctx.info(`Moving IPv6 firewall filter rule: rule_id=${a.rule_id} to position ${a.destination}`);
|
|
13699
|
-
const
|
|
13700
|
-
if (
|
|
13701
|
-
return `IPv6 firewall filter rule
|
|
13702
|
-
const result = await executeMikrotikCommand(`/ipv6 firewall filter move ${
|
|
13742
|
+
const id = await resolveRuleId(a.rule_id, ctx);
|
|
13743
|
+
if (!id)
|
|
13744
|
+
return `IPv6 firewall filter rule '${a.rule_id}' not found.`;
|
|
13745
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall filter move ${id} destination=${a.destination}`, ctx);
|
|
13703
13746
|
if (looksLikeError(result))
|
|
13704
13747
|
return `Failed to move IPv6 firewall filter rule: ${result}`;
|
|
13705
|
-
return `IPv6 firewall filter rule
|
|
13748
|
+
return `IPv6 firewall filter rule '${a.rule_id}' (${id}) moved to position ${a.destination}.`;
|
|
13706
13749
|
}
|
|
13707
13750
|
}),
|
|
13708
13751
|
defineTool({
|
|
@@ -13730,6 +13773,7 @@ ${result}`;
|
|
|
13730
13773
|
// src/tools/ipv6-firewall-nat.ts
|
|
13731
13774
|
import { z as z45 } from "zod";
|
|
13732
13775
|
var isDigits5 = (s) => /^\d+$/.test(s);
|
|
13776
|
+
var resolveRuleId2 = ruleResolver("/ipv6 firewall nat");
|
|
13733
13777
|
async function updateNatRule2(a, ctx) {
|
|
13734
13778
|
ctx.info(`Updating IPv6 firewall NAT rule: rule_id=${a.rule_id}`);
|
|
13735
13779
|
const updates = [];
|
|
@@ -13797,11 +13841,14 @@ async function updateNatRule2(a, ctx) {
|
|
|
13797
13841
|
}
|
|
13798
13842
|
if (updates.length === 0)
|
|
13799
13843
|
return "No updates specified.";
|
|
13800
|
-
const
|
|
13844
|
+
const id = await resolveRuleId2(a.rule_id, ctx);
|
|
13845
|
+
if (!id)
|
|
13846
|
+
return `IPv6 NAT rule '${a.rule_id}' not found.`;
|
|
13847
|
+
const cmd = `/ipv6 firewall nat set ${id} ${updates.join(" ")}`;
|
|
13801
13848
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
13802
13849
|
if (looksLikeError(result))
|
|
13803
13850
|
return `Failed to update IPv6 firewall NAT rule: ${result}`;
|
|
13804
|
-
const details = await executeMikrotikCommand(`/ipv6 firewall nat print detail where .id=${
|
|
13851
|
+
const details = await executeMikrotikCommand(`/ipv6 firewall nat print detail where .id=${id}`, ctx);
|
|
13805
13852
|
return `IPv6 firewall NAT rule updated successfully:
|
|
13806
13853
|
|
|
13807
13854
|
${details}`;
|
|
@@ -13952,8 +13999,11 @@ ${result}`;
|
|
|
13952
13999
|
},
|
|
13953
14000
|
async handler(a, ctx) {
|
|
13954
14001
|
ctx.info(`Getting IPv6 firewall NAT rule details: rule_id=${a.rule_id}`);
|
|
13955
|
-
const
|
|
13956
|
-
|
|
14002
|
+
const id = await resolveRuleId2(a.rule_id, ctx);
|
|
14003
|
+
if (!id)
|
|
14004
|
+
return `IPv6 firewall NAT rule '${a.rule_id}' not found.`;
|
|
14005
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall nat print detail where .id=${id}`, ctx);
|
|
14006
|
+
return isEmpty(result) ? `IPv6 firewall NAT rule '${a.rule_id}' not found.` : `IPV6 FIREWALL NAT RULE DETAILS:
|
|
13957
14007
|
|
|
13958
14008
|
${result}`;
|
|
13959
14009
|
}
|
|
@@ -14028,13 +14078,13 @@ ${result}`;
|
|
|
14028
14078
|
inputSchema: { rule_id: z45.string() },
|
|
14029
14079
|
async handler(a, ctx) {
|
|
14030
14080
|
ctx.info(`Removing IPv6 firewall NAT rule: rule_id=${a.rule_id}`);
|
|
14031
|
-
const
|
|
14032
|
-
if (
|
|
14033
|
-
return `IPv6 firewall NAT rule
|
|
14034
|
-
const result = await executeMikrotikCommand(`/ipv6 firewall nat remove ${
|
|
14081
|
+
const id = await resolveRuleId2(a.rule_id, ctx);
|
|
14082
|
+
if (!id)
|
|
14083
|
+
return `IPv6 firewall NAT rule '${a.rule_id}' not found.`;
|
|
14084
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall nat remove ${id}`, ctx);
|
|
14035
14085
|
if (looksLikeError(result))
|
|
14036
14086
|
return `Failed to remove IPv6 firewall NAT rule: ${result}`;
|
|
14037
|
-
return `IPv6 firewall NAT rule
|
|
14087
|
+
return `IPv6 firewall NAT rule '${a.rule_id}' (${id}) removed successfully.`;
|
|
14038
14088
|
}
|
|
14039
14089
|
}),
|
|
14040
14090
|
defineTool({
|
|
@@ -14048,13 +14098,13 @@ ${result}`;
|
|
|
14048
14098
|
},
|
|
14049
14099
|
async handler(a, ctx) {
|
|
14050
14100
|
ctx.info(`Moving IPv6 firewall NAT rule: rule_id=${a.rule_id} to position ${a.destination}`);
|
|
14051
|
-
const
|
|
14052
|
-
if (
|
|
14053
|
-
return `IPv6 firewall NAT rule
|
|
14054
|
-
const result = await executeMikrotikCommand(`/ipv6 firewall nat move ${
|
|
14101
|
+
const id = await resolveRuleId2(a.rule_id, ctx);
|
|
14102
|
+
if (!id)
|
|
14103
|
+
return `IPv6 firewall NAT rule '${a.rule_id}' not found.`;
|
|
14104
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall nat move ${id} destination=${a.destination}`, ctx);
|
|
14055
14105
|
if (looksLikeError(result))
|
|
14056
14106
|
return `Failed to move IPv6 firewall NAT rule: ${result}`;
|
|
14057
|
-
return `IPv6 firewall NAT rule
|
|
14107
|
+
return `IPv6 firewall NAT rule '${a.rule_id}' (${id}) moved to position ${a.destination}.`;
|
|
14058
14108
|
}
|
|
14059
14109
|
}),
|
|
14060
14110
|
defineTool({
|
|
@@ -14082,6 +14132,7 @@ ${result}`;
|
|
|
14082
14132
|
// src/tools/ipv6-firewall-mangle.ts
|
|
14083
14133
|
import { z as z46 } from "zod";
|
|
14084
14134
|
var isDigits6 = (s) => /^\d+$/.test(s);
|
|
14135
|
+
var resolveRuleId3 = ruleResolver("/ipv6 firewall mangle");
|
|
14085
14136
|
async function updateMangleRule2(a, ctx) {
|
|
14086
14137
|
ctx.info(`Updating IPv6 firewall mangle rule: rule_id=${a.rule_id}`);
|
|
14087
14138
|
const updates = [];
|
|
@@ -14157,11 +14208,14 @@ async function updateMangleRule2(a, ctx) {
|
|
|
14157
14208
|
}
|
|
14158
14209
|
if (updates.length === 0)
|
|
14159
14210
|
return "No updates specified.";
|
|
14160
|
-
const
|
|
14211
|
+
const id = await resolveRuleId3(a.rule_id, ctx);
|
|
14212
|
+
if (!id)
|
|
14213
|
+
return `IPv6 mangle rule '${a.rule_id}' not found.`;
|
|
14214
|
+
const cmd = `/ipv6 firewall mangle set ${id} ${updates.join(" ")}`;
|
|
14161
14215
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
14162
14216
|
if (looksLikeError(result))
|
|
14163
14217
|
return `Failed to update IPv6 firewall mangle rule: ${result}`;
|
|
14164
|
-
const details = await executeMikrotikCommand(`/ipv6 firewall mangle print detail where .id=${
|
|
14218
|
+
const details = await executeMikrotikCommand(`/ipv6 firewall mangle print detail where .id=${id}`, ctx);
|
|
14165
14219
|
return `IPv6 firewall mangle rule updated successfully:
|
|
14166
14220
|
|
|
14167
14221
|
${details}`;
|
|
@@ -14320,8 +14374,11 @@ ${result}`;
|
|
|
14320
14374
|
},
|
|
14321
14375
|
async handler(a, ctx) {
|
|
14322
14376
|
ctx.info(`Getting IPv6 firewall mangle rule details: rule_id=${a.rule_id}`);
|
|
14323
|
-
const
|
|
14324
|
-
|
|
14377
|
+
const id = await resolveRuleId3(a.rule_id, ctx);
|
|
14378
|
+
if (!id)
|
|
14379
|
+
return `IPv6 mangle rule '${a.rule_id}' not found.`;
|
|
14380
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall mangle print detail where .id=${id}`, ctx);
|
|
14381
|
+
return isEmpty(result) ? `IPv6 mangle rule '${a.rule_id}' not found.` : `IPV6 FIREWALL MANGLE RULE DETAILS:
|
|
14325
14382
|
|
|
14326
14383
|
${result}`;
|
|
14327
14384
|
}
|
|
@@ -14403,13 +14460,13 @@ ${result}`;
|
|
|
14403
14460
|
inputSchema: { rule_id: z46.string() },
|
|
14404
14461
|
async handler(a, ctx) {
|
|
14405
14462
|
ctx.info(`Removing IPv6 firewall mangle rule: rule_id=${a.rule_id}`);
|
|
14406
|
-
const
|
|
14407
|
-
if (
|
|
14408
|
-
return `IPv6
|
|
14409
|
-
const result = await executeMikrotikCommand(`/ipv6 firewall mangle remove ${
|
|
14463
|
+
const id = await resolveRuleId3(a.rule_id, ctx);
|
|
14464
|
+
if (!id)
|
|
14465
|
+
return `IPv6 mangle rule '${a.rule_id}' not found.`;
|
|
14466
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall mangle remove ${id}`, ctx);
|
|
14410
14467
|
if (looksLikeError(result))
|
|
14411
14468
|
return `Failed to remove IPv6 firewall mangle rule: ${result}`;
|
|
14412
|
-
return `IPv6
|
|
14469
|
+
return `IPv6 mangle rule '${a.rule_id}' (${id}) removed successfully.`;
|
|
14413
14470
|
}
|
|
14414
14471
|
}),
|
|
14415
14472
|
defineTool({
|
|
@@ -14423,13 +14480,13 @@ ${result}`;
|
|
|
14423
14480
|
},
|
|
14424
14481
|
async handler(a, ctx) {
|
|
14425
14482
|
ctx.info(`Moving IPv6 firewall mangle rule: rule_id=${a.rule_id} to position ${a.destination}`);
|
|
14426
|
-
const
|
|
14427
|
-
if (
|
|
14428
|
-
return `IPv6
|
|
14429
|
-
const result = await executeMikrotikCommand(`/ipv6 firewall mangle move ${
|
|
14483
|
+
const id = await resolveRuleId3(a.rule_id, ctx);
|
|
14484
|
+
if (!id)
|
|
14485
|
+
return `IPv6 mangle rule '${a.rule_id}' not found.`;
|
|
14486
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall mangle move ${id} destination=${a.destination}`, ctx);
|
|
14430
14487
|
if (looksLikeError(result))
|
|
14431
14488
|
return `Failed to move IPv6 firewall mangle rule: ${result}`;
|
|
14432
|
-
return `IPv6
|
|
14489
|
+
return `IPv6 mangle rule '${a.rule_id}' (${id}) moved to position ${a.destination}.`;
|
|
14433
14490
|
}
|
|
14434
14491
|
}),
|
|
14435
14492
|
defineTool({
|
|
@@ -14457,6 +14514,7 @@ ${result}`;
|
|
|
14457
14514
|
// src/tools/ipv6-firewall-raw.ts
|
|
14458
14515
|
import { z as z47 } from "zod";
|
|
14459
14516
|
var isDigits7 = (s) => /^\d+$/.test(s);
|
|
14517
|
+
var resolveRuleId4 = ruleResolver("/ipv6 firewall raw");
|
|
14460
14518
|
async function updateRawRule(a, ctx) {
|
|
14461
14519
|
ctx.info(`Updating IPv6 firewall raw rule: rule_id=${a.rule_id}`);
|
|
14462
14520
|
const updates = [];
|
|
@@ -14502,11 +14560,14 @@ async function updateRawRule(a, ctx) {
|
|
|
14502
14560
|
}
|
|
14503
14561
|
if (updates.length === 0)
|
|
14504
14562
|
return "No updates specified.";
|
|
14505
|
-
const
|
|
14563
|
+
const id = await resolveRuleId4(a.rule_id, ctx);
|
|
14564
|
+
if (!id)
|
|
14565
|
+
return `IPv6 raw rule '${a.rule_id}' not found.`;
|
|
14566
|
+
const cmd = `/ipv6 firewall raw set ${id} ${updates.join(" ")}`;
|
|
14506
14567
|
const result = await executeMikrotikCommand(cmd, ctx);
|
|
14507
14568
|
if (looksLikeError(result))
|
|
14508
14569
|
return `Failed to update IPv6 firewall raw rule: ${result}`;
|
|
14509
|
-
const details = await executeMikrotikCommand(`/ipv6 firewall raw print detail where .id=${
|
|
14570
|
+
const details = await executeMikrotikCommand(`/ipv6 firewall raw print detail where .id=${id}`, ctx);
|
|
14510
14571
|
return `IPv6 firewall raw rule updated successfully:
|
|
14511
14572
|
|
|
14512
14573
|
${details}`;
|
|
@@ -14621,7 +14682,10 @@ ${result}`;
|
|
|
14621
14682
|
},
|
|
14622
14683
|
async handler(a, ctx) {
|
|
14623
14684
|
ctx.info(`Getting IPv6 firewall raw rule details: rule_id=${a.rule_id}`);
|
|
14624
|
-
const
|
|
14685
|
+
const id = await resolveRuleId4(a.rule_id, ctx);
|
|
14686
|
+
if (!id)
|
|
14687
|
+
return `IPv6 firewall raw rule with ID '${a.rule_id}' not found.`;
|
|
14688
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall raw print detail where .id=${id}`, ctx);
|
|
14625
14689
|
return isEmpty(result) ? `IPv6 firewall raw rule with ID '${a.rule_id}' not found.` : `IPV6 FIREWALL RAW RULE DETAILS:
|
|
14626
14690
|
|
|
14627
14691
|
${result}`;
|
|
@@ -14675,13 +14739,13 @@ ${result}`;
|
|
|
14675
14739
|
inputSchema: { rule_id: z47.string() },
|
|
14676
14740
|
async handler(a, ctx) {
|
|
14677
14741
|
ctx.info(`Removing IPv6 firewall raw rule: rule_id=${a.rule_id}`);
|
|
14678
|
-
const
|
|
14679
|
-
if (
|
|
14742
|
+
const id = await resolveRuleId4(a.rule_id, ctx);
|
|
14743
|
+
if (!id)
|
|
14680
14744
|
return `IPv6 firewall raw rule with ID '${a.rule_id}' not found.`;
|
|
14681
|
-
const result = await executeMikrotikCommand(`/ipv6 firewall raw remove ${
|
|
14745
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall raw remove ${id}`, ctx);
|
|
14682
14746
|
if (looksLikeError(result))
|
|
14683
14747
|
return `Failed to remove IPv6 firewall raw rule: ${result}`;
|
|
14684
|
-
return `IPv6 firewall raw rule
|
|
14748
|
+
return `IPv6 firewall raw rule '${a.rule_id}' (${id}) removed successfully.`;
|
|
14685
14749
|
}
|
|
14686
14750
|
}),
|
|
14687
14751
|
defineTool({
|
|
@@ -14695,13 +14759,13 @@ ${result}`;
|
|
|
14695
14759
|
},
|
|
14696
14760
|
async handler(a, ctx) {
|
|
14697
14761
|
ctx.info(`Moving IPv6 firewall raw rule: rule_id=${a.rule_id} to position ${a.destination}`);
|
|
14698
|
-
const
|
|
14699
|
-
if (
|
|
14762
|
+
const id = await resolveRuleId4(a.rule_id, ctx);
|
|
14763
|
+
if (!id)
|
|
14700
14764
|
return `IPv6 firewall raw rule with ID '${a.rule_id}' not found.`;
|
|
14701
|
-
const result = await executeMikrotikCommand(`/ipv6 firewall raw move ${
|
|
14765
|
+
const result = await executeMikrotikCommand(`/ipv6 firewall raw move ${id} destination=${a.destination}`, ctx);
|
|
14702
14766
|
if (looksLikeError(result))
|
|
14703
14767
|
return `Failed to move IPv6 firewall raw rule: ${result}`;
|
|
14704
|
-
return `IPv6 firewall raw rule
|
|
14768
|
+
return `IPv6 firewall raw rule '${a.rule_id}' (${id}) moved to position ${a.destination}.`;
|
|
14705
14769
|
}
|
|
14706
14770
|
}),
|
|
14707
14771
|
defineTool({
|
|
@@ -22063,7 +22127,7 @@ ${result}`;
|
|
|
22063
22127
|
${v6Result}`;
|
|
22064
22128
|
}
|
|
22065
22129
|
const where = [`dst-address in ${a.destination}`, "active=yes"];
|
|
22066
|
-
if (table)
|
|
22130
|
+
if (table && table !== "main")
|
|
22067
22131
|
where.push(`routing-table=${quoteValue(table)}`);
|
|
22068
22132
|
const v7Cmd = `/ip route print detail where ${where.join(" ")}`;
|
|
22069
22133
|
const v7Result = await executeMikrotikCommand(v7Cmd, ctx);
|
package/package.json
CHANGED