ciscollm-cli 1.1.4 → 1.3.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/LICENSE +21 -21
- package/README.md +137 -17
- package/dist/core/agent/AgentLoop.js +1 -0
- package/dist/core/agent/AgentLoop.js.map +1 -1
- package/dist/core/agent/AutoHealer.d.ts +27 -0
- package/dist/core/agent/AutoHealer.js +387 -0
- package/dist/core/agent/AutoHealer.js.map +1 -0
- package/dist/core/agent/HierarchicalAgentManager.js +5 -5
- package/dist/core/agent/MultiAgentCoordinator.d.ts +6 -1
- package/dist/core/agent/MultiAgentCoordinator.js +23 -1
- package/dist/core/agent/MultiAgentCoordinator.js.map +1 -1
- package/dist/core/agent/PromptEngine.js +67 -67
- package/dist/core/guardrails/AuditLogger.js +4 -4
- package/dist/core/guardrails/CommandFirewall.d.ts +2 -0
- package/dist/core/guardrails/CommandFirewall.js +112 -12
- package/dist/core/guardrails/CommandFirewall.js.map +1 -1
- package/dist/core/rollback/TransactionManager.js +17 -0
- package/dist/core/rollback/TransactionManager.js.map +1 -1
- package/dist/index.js +142 -0
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/llm/LLMClient.js +0 -1
- package/dist/infrastructure/llm/LLMClient.js.map +1 -1
- package/dist/infrastructure/protocols/BaseSession.d.ts +2 -1
- package/dist/infrastructure/protocols/BaseSession.js +2 -1
- package/dist/infrastructure/protocols/BaseSession.js.map +1 -1
- package/dist/infrastructure/protocols/PlinkSerial.d.ts +1 -0
- package/dist/infrastructure/protocols/PlinkSerial.js +67 -12
- package/dist/infrastructure/protocols/PlinkSerial.js.map +1 -1
- package/dist/server/dashboard.js +324 -224
- package/dist/server/dashboard.js.map +1 -1
- package/dist/server/index.js +8 -8
- package/dist/server/shell-simulator.d.ts +29 -1
- package/dist/server/shell-simulator.js +394 -59
- package/dist/server/shell-simulator.js.map +1 -1
- package/dist/server/ssh.js +31 -20
- package/dist/server/ssh.js.map +1 -1
- package/dist/server/telnet.js +11 -0
- package/dist/server/telnet.js.map +1 -1
- package/dist/shared/constants.js +1 -1
- package/dist/shared/constants.js.map +1 -1
- package/package.json +54 -52
- package/dist/infrastructure/llm/LocalLLMClient.d.ts +0 -7
- package/dist/infrastructure/llm/LocalLLMClient.js +0 -39
- package/dist/infrastructure/llm/LocalLLMClient.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard.js","sourceRoot":"","sources":["../../src/server/dashboard.ts"],"names":[],"mappings":";;;;;AAQA,
|
|
1
|
+
{"version":3,"file":"dashboard.js","sourceRoot":"","sources":["../../src/server/dashboard.ts"],"names":[],"mappings":";;;;;AAQA,oDAmHC;AA3HD,gDAAwB;AAExB,gEAA6D;AAC7D,0DAAuD;AACvD,kDAA0B;AAE1B,IAAI,YAAY,GAAuB,IAAI,CAAC;AAE5C,SAAgB,oBAAoB,CAAC,WAAkC,EAAE,IAAY;IACjF,IAAI,YAAY,EAAE,CAAC;QACf,IAAI,CAAC;YACD,YAAY,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACd,CAAC;IAED,MAAM,MAAM,GAAG,cAAI,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QAChD,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC;QAC1B,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,KAAK,CAAC;QAEnC,GAAG,CAAC,SAAS,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;QAClD,GAAG,CAAC,SAAS,CAAC,8BAA8B,EAAE,oBAAoB,CAAC,CAAC;QACpE,GAAG,CAAC,SAAS,CAAC,8BAA8B,EAAE,cAAc,CAAC,CAAC;QAE9D,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACvB,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACnB,GAAG,CAAC,GAAG,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAygCH,CAAC;AACT,CAAC"}
|
package/dist/server/index.js
CHANGED
|
@@ -20,14 +20,14 @@ function getTimestamp() {
|
|
|
20
20
|
}
|
|
21
21
|
function printDashboard(httpPort) {
|
|
22
22
|
console.clear();
|
|
23
|
-
console.log(chalk_1.default.bold.cyan(`
|
|
24
|
-
::::::::: :::::::: :::::::: :::::::: :::::::: :::: :::: :::: ::::
|
|
25
|
-
:+: :+: :+: :+: :+: :+: :+: :+: :+: :+: +:+:+: :+:+:+ +:+ +:+:+:
|
|
26
|
-
+:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+:+ +:+ +:+ +:+
|
|
27
|
-
+#++:++#+ +#+ +:+ +#++:++#++ +#++:++#++ +#+ +:+ +#+ +:+ +#+ +#+ +#++:++#+
|
|
28
|
-
+#+ +#+ +:+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+
|
|
29
|
-
#+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+#
|
|
30
|
-
### ######## ######## ######## ######## ### ### ######### ###
|
|
23
|
+
console.log(chalk_1.default.bold.cyan(`
|
|
24
|
+
::::::::: :::::::: :::::::: :::::::: :::::::: :::: :::: :::: ::::
|
|
25
|
+
:+: :+: :+: :+: :+: :+: :+: :+: :+: :+: +:+:+: :+:+:+ +:+ +:+:+:
|
|
26
|
+
+:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+:+ +:+ +:+ +:+
|
|
27
|
+
+#++:++#+ +#+ +:+ +#++:++#++ +#++:++#++ +#+ +:+ +#+ +:+ +#+ +#+ +#++:++#+
|
|
28
|
+
+#+ +#+ +:+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+
|
|
29
|
+
#+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+#
|
|
30
|
+
### ######## ######## ######## ######## ### ### ######### ###
|
|
31
31
|
`));
|
|
32
32
|
console.log(chalk_1.default.bold.yellow(' Cisco IOS Multi-Protocol Test Simulator \n'));
|
|
33
33
|
console.log(chalk_1.default.cyan('┌─────────────────────────────────────────────────────────────────────────────┐'));
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
export declare const simulatorEvents: EventEmitter<[never]>;
|
|
3
|
+
export type CliMode = 'USER_EXEC' | 'PRIVILEGED_EXEC' | 'GLOBAL_CONFIG' | 'INTERFACE_CONFIG' | 'OSPF_CONFIG' | 'RIP_CONFIG' | 'BGP_CONFIG' | 'EIGRP_CONFIG' | 'DHCP_CONFIG' | 'ACL_CONFIG' | 'VLAN_CONFIG';
|
|
2
4
|
export interface InterfaceState {
|
|
3
5
|
name: string;
|
|
4
6
|
ip: string | null;
|
|
@@ -9,6 +11,7 @@ export interface InterfaceState {
|
|
|
9
11
|
isSwitchport?: boolean;
|
|
10
12
|
switchportMode?: 'access' | 'trunk';
|
|
11
13
|
vlan?: number;
|
|
14
|
+
natType?: 'inside' | 'outside';
|
|
12
15
|
}
|
|
13
16
|
export interface RouteState {
|
|
14
17
|
network: string;
|
|
@@ -31,6 +34,31 @@ export declare class ShellSimulator {
|
|
|
31
34
|
shellFunctions: Record<string, string>;
|
|
32
35
|
ospfEnabled: boolean;
|
|
33
36
|
ospfProcessId: string | null;
|
|
37
|
+
ripEnabled: boolean;
|
|
38
|
+
ripVersion: number;
|
|
39
|
+
ripAutoSummary: boolean;
|
|
40
|
+
bgpEnabled: boolean;
|
|
41
|
+
bgpAsn: string | null;
|
|
42
|
+
eigrpEnabled: boolean;
|
|
43
|
+
eigrpAsn: string | null;
|
|
44
|
+
vtpMode: string;
|
|
45
|
+
vtpDomain: string | null;
|
|
46
|
+
vtpPassword: string | null;
|
|
47
|
+
hsrpGroups: Map<string, {
|
|
48
|
+
virtualIp: string;
|
|
49
|
+
priority: number;
|
|
50
|
+
preempt: boolean;
|
|
51
|
+
}>;
|
|
52
|
+
vrrpGroups: Map<string, {
|
|
53
|
+
virtualIp: string;
|
|
54
|
+
priority: number;
|
|
55
|
+
}>;
|
|
56
|
+
ntpServers: string[];
|
|
57
|
+
snmpCommunities: string[];
|
|
58
|
+
natInsideInterfaces: Set<string>;
|
|
59
|
+
natOutsideInterfaces: Set<string>;
|
|
60
|
+
natRules: string[];
|
|
61
|
+
acls: Map<string, string[]>;
|
|
34
62
|
ipRoutingEnabled: boolean;
|
|
35
63
|
flashFiles: Set<string>;
|
|
36
64
|
private pendingCopyDest;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ShellSimulator = void 0;
|
|
3
|
+
exports.ShellSimulator = exports.simulatorEvents = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
exports.simulatorEvents = new events_1.EventEmitter();
|
|
4
6
|
class ShellSimulator {
|
|
5
7
|
hostname = 'Switch1';
|
|
6
8
|
mode = 'USER_EXEC';
|
|
@@ -48,6 +50,24 @@ class ShellSimulator {
|
|
|
48
50
|
shellFunctions = {};
|
|
49
51
|
ospfEnabled = false;
|
|
50
52
|
ospfProcessId = null;
|
|
53
|
+
ripEnabled = false;
|
|
54
|
+
ripVersion = 2;
|
|
55
|
+
ripAutoSummary = false;
|
|
56
|
+
bgpEnabled = false;
|
|
57
|
+
bgpAsn = null;
|
|
58
|
+
eigrpEnabled = false;
|
|
59
|
+
eigrpAsn = null;
|
|
60
|
+
vtpMode = 'server';
|
|
61
|
+
vtpDomain = null;
|
|
62
|
+
vtpPassword = null;
|
|
63
|
+
hsrpGroups = new Map();
|
|
64
|
+
vrrpGroups = new Map();
|
|
65
|
+
ntpServers = [];
|
|
66
|
+
snmpCommunities = [];
|
|
67
|
+
natInsideInterfaces = new Set();
|
|
68
|
+
natOutsideInterfaces = new Set();
|
|
69
|
+
natRules = [];
|
|
70
|
+
acls = new Map();
|
|
51
71
|
ipRoutingEnabled = true;
|
|
52
72
|
flashFiles = new Set(['c2960-lanbasek9-mz.150-2.SE4.bin']);
|
|
53
73
|
pendingCopyDest = null;
|
|
@@ -93,6 +113,9 @@ class ShellSimulator {
|
|
|
93
113
|
case 'INTERFACE_CONFIG':
|
|
94
114
|
return `${this.hostname}(config-if)# `;
|
|
95
115
|
case 'OSPF_CONFIG':
|
|
116
|
+
case 'RIP_CONFIG':
|
|
117
|
+
case 'BGP_CONFIG':
|
|
118
|
+
case 'EIGRP_CONFIG':
|
|
96
119
|
return `${this.hostname}(config-router)# `;
|
|
97
120
|
case 'DHCP_CONFIG':
|
|
98
121
|
return `${this.hostname}(config-dhcp)# `;
|
|
@@ -143,54 +166,54 @@ class ShellSimulator {
|
|
|
143
166
|
const cmd = args[0].toLowerCase();
|
|
144
167
|
if (cmd === '?' || cmd === 'help') {
|
|
145
168
|
if (cmd === 'help') {
|
|
146
|
-
return `Help may be requested at any point in a command by entering
|
|
147
|
-
a question mark '?'. If nothing matches, the help list will
|
|
169
|
+
return `Help may be requested at any point in a command by entering
|
|
170
|
+
a question mark '?'. If nothing matches, the help list will
|
|
148
171
|
show the available options.`;
|
|
149
172
|
}
|
|
150
173
|
if (this.mode === 'USER_EXEC') {
|
|
151
|
-
return `Exec commands:
|
|
152
|
-
disable Turn off privileged commands
|
|
153
|
-
enable Turn on privileged commands
|
|
154
|
-
exit Exit from the EXEC
|
|
155
|
-
ping Send echo messages
|
|
174
|
+
return `Exec commands:
|
|
175
|
+
disable Turn off privileged commands
|
|
176
|
+
enable Turn on privileged commands
|
|
177
|
+
exit Exit from the EXEC
|
|
178
|
+
ping Send echo messages
|
|
156
179
|
show Show running system information`;
|
|
157
180
|
}
|
|
158
181
|
else if (this.mode === 'PRIVILEGED_EXEC') {
|
|
159
|
-
return `Exec commands:
|
|
160
|
-
clear Reset functions
|
|
161
|
-
configure Enter configuration mode
|
|
162
|
-
copy Copy from one file to another
|
|
163
|
-
dir List files on a filesystem
|
|
164
|
-
disable Turn off privileged commands
|
|
165
|
-
enable Turn on privileged commands
|
|
166
|
-
exit Exit from the EXEC
|
|
167
|
-
ping Send echo messages
|
|
168
|
-
show Show running system information
|
|
182
|
+
return `Exec commands:
|
|
183
|
+
clear Reset functions
|
|
184
|
+
configure Enter configuration mode
|
|
185
|
+
copy Copy from one file to another
|
|
186
|
+
dir List files on a filesystem
|
|
187
|
+
disable Turn off privileged commands
|
|
188
|
+
enable Turn on privileged commands
|
|
189
|
+
exit Exit from the EXEC
|
|
190
|
+
ping Send echo messages
|
|
191
|
+
show Show running system information
|
|
169
192
|
write Write running configuration to memory or terminal`;
|
|
170
193
|
}
|
|
171
194
|
else if (this.mode === 'GLOBAL_CONFIG') {
|
|
172
|
-
return `Configure commands:
|
|
173
|
-
do To run EXEC commands in config mode
|
|
174
|
-
end Exit from configure mode
|
|
175
|
-
exit Exit from configure mode
|
|
176
|
-
hostname Set system's network name
|
|
177
|
-
interface Select an interface to configure
|
|
178
|
-
ip Global IP configuration subcommands
|
|
179
|
-
no Negate a command or set defaults
|
|
180
|
-
router Enable a routing process
|
|
195
|
+
return `Configure commands:
|
|
196
|
+
do To run EXEC commands in config mode
|
|
197
|
+
end Exit from configure mode
|
|
198
|
+
exit Exit from configure mode
|
|
199
|
+
hostname Set system's network name
|
|
200
|
+
interface Select an interface to configure
|
|
201
|
+
ip Global IP configuration subcommands
|
|
202
|
+
no Negate a command or set defaults
|
|
203
|
+
router Enable a routing process
|
|
181
204
|
vlan Vlan configuration commands`;
|
|
182
205
|
}
|
|
183
206
|
else if (this.mode === 'INTERFACE_CONFIG') {
|
|
184
|
-
return `Interface configuration commands:
|
|
185
|
-
description Detailed description of this interface
|
|
186
|
-
exit Exit from interface configuration mode
|
|
187
|
-
ip IP interface configuration subcommands
|
|
188
|
-
no Negate a command or set defaults
|
|
207
|
+
return `Interface configuration commands:
|
|
208
|
+
description Detailed description of this interface
|
|
209
|
+
exit Exit from interface configuration mode
|
|
210
|
+
ip IP interface configuration subcommands
|
|
211
|
+
no Negate a command or set defaults
|
|
189
212
|
shutdown Shutdown this interface`;
|
|
190
213
|
}
|
|
191
214
|
else {
|
|
192
|
-
return `Commands:
|
|
193
|
-
exit Exit current mode
|
|
215
|
+
return `Commands:
|
|
216
|
+
exit Exit current mode
|
|
194
217
|
end Exit to privileged EXEC mode`;
|
|
195
218
|
}
|
|
196
219
|
}
|
|
@@ -201,7 +224,7 @@ show the available options.`;
|
|
|
201
224
|
return `% Incomplete command.`;
|
|
202
225
|
}
|
|
203
226
|
if (cmd === 'exit') {
|
|
204
|
-
if (this.mode === 'INTERFACE_CONFIG' || this.mode === 'OSPF_CONFIG' || this.mode === 'DHCP_CONFIG' || this.mode === 'ACL_CONFIG' || this.mode === 'VLAN_CONFIG') {
|
|
227
|
+
if (this.mode === 'INTERFACE_CONFIG' || this.mode === 'OSPF_CONFIG' || this.mode === 'RIP_CONFIG' || this.mode === 'BGP_CONFIG' || this.mode === 'EIGRP_CONFIG' || this.mode === 'DHCP_CONFIG' || this.mode === 'ACL_CONFIG' || this.mode === 'VLAN_CONFIG') {
|
|
205
228
|
this.mode = 'GLOBAL_CONFIG';
|
|
206
229
|
this.activeInterface = null;
|
|
207
230
|
this.activeVlan = null;
|
|
@@ -343,6 +366,81 @@ show the available options.`;
|
|
|
343
366
|
this.ospfProcessId = null;
|
|
344
367
|
return '';
|
|
345
368
|
}
|
|
369
|
+
if (cmd === 'router' && args[1] === 'rip') {
|
|
370
|
+
this.mode = 'RIP_CONFIG';
|
|
371
|
+
this.ripEnabled = true;
|
|
372
|
+
return '';
|
|
373
|
+
}
|
|
374
|
+
if (cmd === 'no' && args[1] === 'router' && args[2] === 'rip') {
|
|
375
|
+
this.ripEnabled = false;
|
|
376
|
+
return '';
|
|
377
|
+
}
|
|
378
|
+
if (cmd === 'router' && args[1] === 'bgp') {
|
|
379
|
+
this.mode = 'BGP_CONFIG';
|
|
380
|
+
this.bgpAsn = args[2] || null;
|
|
381
|
+
this.bgpEnabled = true;
|
|
382
|
+
return '';
|
|
383
|
+
}
|
|
384
|
+
if (cmd === 'no' && args[1] === 'router' && args[2] === 'bgp') {
|
|
385
|
+
this.bgpEnabled = false;
|
|
386
|
+
this.bgpAsn = null;
|
|
387
|
+
return '';
|
|
388
|
+
}
|
|
389
|
+
if (cmd === 'spanning-tree' && args[1]) {
|
|
390
|
+
return '';
|
|
391
|
+
}
|
|
392
|
+
if (cmd === 'router' && args[1] === 'eigrp') {
|
|
393
|
+
this.mode = 'EIGRP_CONFIG';
|
|
394
|
+
this.eigrpAsn = args[2] || null;
|
|
395
|
+
this.eigrpEnabled = true;
|
|
396
|
+
return '';
|
|
397
|
+
}
|
|
398
|
+
if (cmd === 'no' && args[1] === 'router' && args[2] === 'eigrp') {
|
|
399
|
+
this.eigrpEnabled = false;
|
|
400
|
+
this.eigrpAsn = null;
|
|
401
|
+
return '';
|
|
402
|
+
}
|
|
403
|
+
if (cmd === 'vtp' && args[1]) {
|
|
404
|
+
if (args[1] === 'mode' && args[2]) {
|
|
405
|
+
this.vtpMode = args[2].toLowerCase();
|
|
406
|
+
}
|
|
407
|
+
else if (args[1] === 'domain' && args[2]) {
|
|
408
|
+
this.vtpDomain = args[2];
|
|
409
|
+
}
|
|
410
|
+
else if (args[1] === 'password' && args[2]) {
|
|
411
|
+
this.vtpPassword = args[2];
|
|
412
|
+
}
|
|
413
|
+
return '';
|
|
414
|
+
}
|
|
415
|
+
if (cmd === 'ntp' && args[1] === 'server' && args[2]) {
|
|
416
|
+
if (!this.ntpServers.includes(args[2])) {
|
|
417
|
+
this.ntpServers.push(args[2]);
|
|
418
|
+
}
|
|
419
|
+
return '';
|
|
420
|
+
}
|
|
421
|
+
if (cmd === 'snmp-server' && args[1] === 'community' && args[2]) {
|
|
422
|
+
if (!this.snmpCommunities.includes(args[2])) {
|
|
423
|
+
this.snmpCommunities.push(args[2]);
|
|
424
|
+
}
|
|
425
|
+
return '';
|
|
426
|
+
}
|
|
427
|
+
if (cmd === 'ip' && args[1] === 'nat' && args[2] === 'inside' && args[3] === 'source') {
|
|
428
|
+
this.natRules.push(args.slice(2).join(' '));
|
|
429
|
+
return '';
|
|
430
|
+
}
|
|
431
|
+
if (cmd === 'access-list' && args[1] && args[2]) {
|
|
432
|
+
const aclId = args[1];
|
|
433
|
+
const rule = args.slice(2).join(' ');
|
|
434
|
+
if (!this.acls.has(aclId)) {
|
|
435
|
+
this.acls.set(aclId, []);
|
|
436
|
+
}
|
|
437
|
+
this.acls.get(aclId).push(rule);
|
|
438
|
+
return '';
|
|
439
|
+
}
|
|
440
|
+
if (cmd === 'ip' && args[1] === 'access-list' && (args[2] === 'standard' || args[2] === 'extended') && args[3]) {
|
|
441
|
+
this.mode = 'ACL_CONFIG';
|
|
442
|
+
return '';
|
|
443
|
+
}
|
|
346
444
|
if (cmd === 'ip' && args[1] === 'dhcp' && args[2] === 'pool' && args[3]) {
|
|
347
445
|
this.mode = 'DHCP_CONFIG';
|
|
348
446
|
return '';
|
|
@@ -447,6 +545,58 @@ show the available options.`;
|
|
|
447
545
|
if (cmd === 'ip' && args[1] === 'ospf') {
|
|
448
546
|
return '';
|
|
449
547
|
}
|
|
548
|
+
if (cmd === 'switchport' && args[1] === 'mode' && args[2] === 'trunk') {
|
|
549
|
+
iface.switchportMode = 'trunk';
|
|
550
|
+
iface.isSwitchport = true;
|
|
551
|
+
return '';
|
|
552
|
+
}
|
|
553
|
+
if (cmd === 'switchport' && args[1] === 'trunk' && args[2] === 'allowed' && args[3] === 'vlan') {
|
|
554
|
+
return '';
|
|
555
|
+
}
|
|
556
|
+
if (cmd === 'channel-group' && args[1] && args[2] === 'mode' && args[3]) {
|
|
557
|
+
return '';
|
|
558
|
+
}
|
|
559
|
+
if (cmd === 'standby' && args[1]) {
|
|
560
|
+
const group = args[1];
|
|
561
|
+
if (!this.hsrpGroups.has(group)) {
|
|
562
|
+
this.hsrpGroups.set(group, { virtualIp: '', priority: 100, preempt: false });
|
|
563
|
+
}
|
|
564
|
+
const hsrp = this.hsrpGroups.get(group);
|
|
565
|
+
if (args[2] === 'ip' && args[3]) {
|
|
566
|
+
hsrp.virtualIp = args[3];
|
|
567
|
+
}
|
|
568
|
+
else if (args[2] === 'priority' && args[3]) {
|
|
569
|
+
hsrp.priority = parseInt(args[3], 10);
|
|
570
|
+
}
|
|
571
|
+
else if (args[2] === 'preempt') {
|
|
572
|
+
hsrp.preempt = true;
|
|
573
|
+
}
|
|
574
|
+
return '';
|
|
575
|
+
}
|
|
576
|
+
if (cmd === 'vrrp' && args[1]) {
|
|
577
|
+
const group = args[1];
|
|
578
|
+
if (!this.vrrpGroups.has(group)) {
|
|
579
|
+
this.vrrpGroups.set(group, { virtualIp: '', priority: 100 });
|
|
580
|
+
}
|
|
581
|
+
const vrrp = this.vrrpGroups.get(group);
|
|
582
|
+
if (args[2] === 'ip' && args[3]) {
|
|
583
|
+
vrrp.virtualIp = args[3];
|
|
584
|
+
}
|
|
585
|
+
else if (args[2] === 'priority' && args[3]) {
|
|
586
|
+
vrrp.priority = parseInt(args[3], 10);
|
|
587
|
+
}
|
|
588
|
+
return '';
|
|
589
|
+
}
|
|
590
|
+
if (cmd === 'ip' && args[1] === 'nat' && (args[2] === 'inside' || args[2] === 'outside')) {
|
|
591
|
+
iface.natType = args[2];
|
|
592
|
+
if (args[2] === 'inside') {
|
|
593
|
+
this.natInsideInterfaces.add(this.activeInterface);
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
this.natOutsideInterfaces.add(this.activeInterface);
|
|
597
|
+
}
|
|
598
|
+
return '';
|
|
599
|
+
}
|
|
450
600
|
return `% Invalid input detected at '^' marker.`;
|
|
451
601
|
}
|
|
452
602
|
if (this.mode === 'OSPF_CONFIG') {
|
|
@@ -458,6 +608,60 @@ show the available options.`;
|
|
|
458
608
|
}
|
|
459
609
|
return `% Invalid input detected at '^' marker.`;
|
|
460
610
|
}
|
|
611
|
+
if (this.mode === 'RIP_CONFIG') {
|
|
612
|
+
if (cmd === 'version' && (args[1] === '1' || args[1] === '2')) {
|
|
613
|
+
this.ripVersion = parseInt(args[1], 10);
|
|
614
|
+
return '';
|
|
615
|
+
}
|
|
616
|
+
if (cmd === 'no' && args[1] === 'auto-summary') {
|
|
617
|
+
this.ripAutoSummary = false;
|
|
618
|
+
return '';
|
|
619
|
+
}
|
|
620
|
+
if (cmd === 'auto-summary') {
|
|
621
|
+
this.ripAutoSummary = true;
|
|
622
|
+
return '';
|
|
623
|
+
}
|
|
624
|
+
if (cmd === 'network' && args[1]) {
|
|
625
|
+
return '';
|
|
626
|
+
}
|
|
627
|
+
if (cmd === 'passive-interface' || (cmd === 'no' && args[1] === 'passive-interface')) {
|
|
628
|
+
return '';
|
|
629
|
+
}
|
|
630
|
+
return `% Invalid input detected at '^' marker.`;
|
|
631
|
+
}
|
|
632
|
+
if (this.mode === 'BGP_CONFIG') {
|
|
633
|
+
if (cmd === 'neighbor' && args[1]) {
|
|
634
|
+
return '';
|
|
635
|
+
}
|
|
636
|
+
if (cmd === 'no' && args[1] === 'neighbor' && args[2]) {
|
|
637
|
+
return '';
|
|
638
|
+
}
|
|
639
|
+
if (cmd === 'network' && args[1]) {
|
|
640
|
+
return '';
|
|
641
|
+
}
|
|
642
|
+
if (cmd === 'no' && args[1] === 'auto-summary') {
|
|
643
|
+
return '';
|
|
644
|
+
}
|
|
645
|
+
if (cmd === 'auto-summary') {
|
|
646
|
+
return '';
|
|
647
|
+
}
|
|
648
|
+
return `% Invalid input detected at '^' marker.`;
|
|
649
|
+
}
|
|
650
|
+
if (this.mode === 'EIGRP_CONFIG') {
|
|
651
|
+
if (cmd === 'network' && args[1]) {
|
|
652
|
+
return '';
|
|
653
|
+
}
|
|
654
|
+
if (cmd === 'no' && args[1] === 'auto-summary') {
|
|
655
|
+
return '';
|
|
656
|
+
}
|
|
657
|
+
if (cmd === 'auto-summary') {
|
|
658
|
+
return '';
|
|
659
|
+
}
|
|
660
|
+
if (cmd === 'passive-interface' || (cmd === 'no' && args[1] === 'passive-interface')) {
|
|
661
|
+
return '';
|
|
662
|
+
}
|
|
663
|
+
return `% Invalid input detected at '^' marker.`;
|
|
664
|
+
}
|
|
461
665
|
if (this.mode === 'DHCP_CONFIG') {
|
|
462
666
|
if (cmd === 'network' || cmd === 'default-router' || cmd === 'dns-server') {
|
|
463
667
|
return '';
|
|
@@ -475,19 +679,19 @@ show the available options.`;
|
|
|
475
679
|
const showArgs = cmd === 'do' ? args.slice(2) : args.slice(1);
|
|
476
680
|
const showCmd = showArgs[0]?.toLowerCase();
|
|
477
681
|
if (showCmd === 'version' || showCmd === 'ver') {
|
|
478
|
-
return `Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 15.0(2)SE4, RELEASE SOFTWARE (fc1)
|
|
479
|
-
Technical Support: http://www.cisco.com/techsupport
|
|
480
|
-
Copyright (c) 1986-2013 by Cisco Systems, Inc.
|
|
481
|
-
Compiled Wed 26-Jun-13 02:49 by prod_rel_team
|
|
482
|
-
|
|
483
|
-
ROM: Bootstrap program is 12.2(44)SE Version
|
|
484
|
-
BOOTLDR: C2960 Boot Loader (C2960-HBOOT-M) Version 12.2(44)SE, RELEASE SOFTWARE (fc1)
|
|
485
|
-
|
|
486
|
-
Switch1 uptime is 2 hours, 15 minutes
|
|
487
|
-
System returned to ROM by power-on
|
|
488
|
-
System image file is "flash:/c2960-lanbasek9-mz.150-2.SE4.bin"
|
|
489
|
-
|
|
490
|
-
This product contains cryptographic features and is subject to Y...
|
|
682
|
+
return `Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 15.0(2)SE4, RELEASE SOFTWARE (fc1)
|
|
683
|
+
Technical Support: http://www.cisco.com/techsupport
|
|
684
|
+
Copyright (c) 1986-2013 by Cisco Systems, Inc.
|
|
685
|
+
Compiled Wed 26-Jun-13 02:49 by prod_rel_team
|
|
686
|
+
|
|
687
|
+
ROM: Bootstrap program is 12.2(44)SE Version
|
|
688
|
+
BOOTLDR: C2960 Boot Loader (C2960-HBOOT-M) Version 12.2(44)SE, RELEASE SOFTWARE (fc1)
|
|
689
|
+
|
|
690
|
+
Switch1 uptime is 2 hours, 15 minutes
|
|
691
|
+
System returned to ROM by power-on
|
|
692
|
+
System image file is "flash:/c2960-lanbasek9-mz.150-2.SE4.bin"
|
|
693
|
+
|
|
694
|
+
This product contains cryptographic features and is subject to Y...
|
|
491
695
|
`;
|
|
492
696
|
}
|
|
493
697
|
if (showCmd === 'ip' && showArgs[1]?.startsWith('int') && showArgs[2]?.startsWith('br')) {
|
|
@@ -524,6 +728,70 @@ This product contains cryptographic features and is subject to Y...
|
|
|
524
728
|
out += `!\nend\n`;
|
|
525
729
|
return out;
|
|
526
730
|
}
|
|
731
|
+
if (showCmd === 'ip' && showArgs[1] === 'protocols') {
|
|
732
|
+
let out = '';
|
|
733
|
+
if (this.ospfEnabled) {
|
|
734
|
+
out += `Routing Protocol is "ospf ${this.ospfProcessId || '10'}"\n` +
|
|
735
|
+
` Outgoing update filter list for all interfaces is not set\n` +
|
|
736
|
+
` Incoming update filter list for all interfaces is not set\n` +
|
|
737
|
+
` Router ID 192.168.1.254\n` +
|
|
738
|
+
` Number of areas in this router is 1. 1 normal 0 stub 0 nssa\n` +
|
|
739
|
+
` Routing for Networks:\n` +
|
|
740
|
+
` 192.168.1.0/24 area 0\n` +
|
|
741
|
+
` Routing Information Sources:\n` +
|
|
742
|
+
` Gateway Distance Last Update\n` +
|
|
743
|
+
` Distance: (default is 110)\n\n`;
|
|
744
|
+
}
|
|
745
|
+
if (this.ripEnabled) {
|
|
746
|
+
out += `Routing Protocol is "rip"\n` +
|
|
747
|
+
` Sending updates every 30 seconds, next due in 15 seconds\n` +
|
|
748
|
+
` Invalid 180 seconds, hold down 180, flushed 240\n` +
|
|
749
|
+
` Outgoing update filter list for all interfaces is not set\n` +
|
|
750
|
+
` Incoming update filter list for all interfaces is not set\n` +
|
|
751
|
+
` Redistributing: rip\n` +
|
|
752
|
+
` Default version control: send version ${this.ripVersion}, receive version ${this.ripVersion}\n` +
|
|
753
|
+
` Interface Send Recv Triggered RIP Key-chain\n`;
|
|
754
|
+
for (const name of this.interfaces.keys()) {
|
|
755
|
+
out += ` ${name.padEnd(21)} ${this.ripVersion} ${this.ripVersion}\n`;
|
|
756
|
+
}
|
|
757
|
+
out += ` Automatic network summarization is ${this.ripAutoSummary ? 'in effect' : 'not in effect'}\n` +
|
|
758
|
+
` Maximum path: 4\n` +
|
|
759
|
+
` Routing for Networks:\n` +
|
|
760
|
+
` 192.168.1.0\n` +
|
|
761
|
+
` Routing Information Sources:\n` +
|
|
762
|
+
` Gateway Distance Last Update\n` +
|
|
763
|
+
` Distance: (default is 120)\n\n`;
|
|
764
|
+
}
|
|
765
|
+
if (this.bgpEnabled) {
|
|
766
|
+
out += `Routing Protocol is "bgp ${this.bgpAsn || '65000'}"\n` +
|
|
767
|
+
` Outgoing update filter list for all interfaces is not set\n` +
|
|
768
|
+
` Incoming update filter list for all interfaces is not set\n` +
|
|
769
|
+
` IGP synchronization is disabled\n` +
|
|
770
|
+
` Automatic route summarization is disabled\n` +
|
|
771
|
+
` Routing Information Sources:\n` +
|
|
772
|
+
` Gateway Distance Last Update\n` +
|
|
773
|
+
` Distance: external 20 internal 200 local 200\n\n`;
|
|
774
|
+
}
|
|
775
|
+
if (this.eigrpEnabled) {
|
|
776
|
+
out += `Routing Protocol is "eigrp ${this.eigrpAsn || '100'}"\n` +
|
|
777
|
+
` Outgoing update filter list for all interfaces is not set\n` +
|
|
778
|
+
` Incoming update filter list for all interfaces is not set\n` +
|
|
779
|
+
` Default networks being advertised:\n` +
|
|
780
|
+
` 192.168.1.0\n` +
|
|
781
|
+
` EIGRP-IPv4 Protocol for AS(${this.eigrpAsn || '100'})\n` +
|
|
782
|
+
` Metric weight K1=1, K2=0, K3=1, K4=0, K5=0\n` +
|
|
783
|
+
` NSF-aware route hold timer is 240s\n` +
|
|
784
|
+
` Router-ID: 192.168.1.254\n` +
|
|
785
|
+
` Topology Kisspoint limit: 100\n` +
|
|
786
|
+
` Routing Information Sources:\n` +
|
|
787
|
+
` Gateway Distance Last Update\n` +
|
|
788
|
+
` Distance: internal 90 external 170\n\n`;
|
|
789
|
+
}
|
|
790
|
+
if (!out) {
|
|
791
|
+
out = '*** No routing protocols configured ***\n';
|
|
792
|
+
}
|
|
793
|
+
return out;
|
|
794
|
+
}
|
|
527
795
|
if (showCmd === 'ip' && showArgs[1]?.startsWith('ro')) {
|
|
528
796
|
if (!this.ipRoutingEnabled) {
|
|
529
797
|
return '% IP routing table is not enabled';
|
|
@@ -574,17 +842,79 @@ This product contains cryptographic features and is subject to Y...
|
|
|
574
842
|
return out;
|
|
575
843
|
}
|
|
576
844
|
if (showCmd === 'cdp' && showArgs[1]?.startsWith('ne')) {
|
|
577
|
-
return `Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
|
|
578
|
-
S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone
|
|
579
|
-
|
|
580
|
-
Device ID Local Intrfce Holdtme Capability Platform Port ID
|
|
581
|
-
Switch2 Gig 0/1 125 S I WS-C2960- Gig 0/1
|
|
845
|
+
return `Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
|
|
846
|
+
S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone
|
|
847
|
+
|
|
848
|
+
Device ID Local Intrfce Holdtme Capability Platform Port ID
|
|
849
|
+
Switch2 Gig 0/1 125 S I WS-C2960- Gig 0/1
|
|
582
850
|
`;
|
|
583
851
|
}
|
|
852
|
+
if (showCmd === 'vtp' && showArgs[1] === 'status') {
|
|
853
|
+
return `VTP Version capability : 1 to 3\n` +
|
|
854
|
+
`VTP version running : 1\n` +
|
|
855
|
+
`VTP Operating Mode : ${this.vtpMode}\n` +
|
|
856
|
+
`VTP Domain Name : ${this.vtpDomain || ''}\n` +
|
|
857
|
+
`VTP Pruning Mode : Disabled\n` +
|
|
858
|
+
`VTP V2 Mode : Disabled\n` +
|
|
859
|
+
`VTP Traps Generation : Disabled\n` +
|
|
860
|
+
`MD5 digest : 0x94 0xC2 0x6E 0x93 0xA3 0xE2 0xD4 0xFA \n` +
|
|
861
|
+
`Configuration last modified by 0.0.0.0 at 0-0-00 00:00:00\n`;
|
|
862
|
+
}
|
|
863
|
+
if (showCmd === 'standby' && (showArgs[1] === 'brief' || !showArgs[1])) {
|
|
864
|
+
let out = ' Preempt State Active Standby Virtual IP\n';
|
|
865
|
+
for (const [group, hsrp] of this.hsrpGroups.entries()) {
|
|
866
|
+
out += `Gi0/1 ${group.padEnd(6)} ${hsrp.priority.toString().padEnd(4)} ${hsrp.preempt ? 'P' : ' '} Active local unknown ${hsrp.virtualIp}\n`;
|
|
867
|
+
}
|
|
868
|
+
if (this.hsrpGroups.size === 0) {
|
|
869
|
+
out = '*** No HSRP standby groups configured ***\n';
|
|
870
|
+
}
|
|
871
|
+
return out;
|
|
872
|
+
}
|
|
873
|
+
if (showCmd === 'vrrp' && (showArgs[1] === 'brief' || !showArgs[1])) {
|
|
874
|
+
let out = 'Interface Grp Fip Pri Time Own Pre State Master addr Group addr\n';
|
|
875
|
+
for (const [group, vrrp] of this.vrrpGroups.entries()) {
|
|
876
|
+
out += `Gi0/1 ${group.padEnd(4)} 1 ${vrrp.priority.toString().padEnd(3)} 3.609 N Y Master local ${vrrp.virtualIp}\n`;
|
|
877
|
+
}
|
|
878
|
+
if (this.vrrpGroups.size === 0) {
|
|
879
|
+
out = '*** No VRRP groups configured ***\n';
|
|
880
|
+
}
|
|
881
|
+
return out;
|
|
882
|
+
}
|
|
883
|
+
if (showCmd === 'ip' && showArgs[1] === 'nat' && showArgs[2] === 'translations') {
|
|
884
|
+
let out = 'Pro Inside global Inside local Outside local Outside global\n';
|
|
885
|
+
for (const rule of this.natRules) {
|
|
886
|
+
out += `tcp 192.0.2.1:80 192.168.1.10:80 --- ---\n`;
|
|
887
|
+
}
|
|
888
|
+
if (this.natRules.length === 0) {
|
|
889
|
+
out = '*** No NAT translations active ***\n';
|
|
890
|
+
}
|
|
891
|
+
return out;
|
|
892
|
+
}
|
|
893
|
+
if (showCmd === 'access-lists') {
|
|
894
|
+
let out = '';
|
|
895
|
+
for (const [aclId, rules] of this.acls.entries()) {
|
|
896
|
+
out += `Standard IP access list ${aclId}\n`;
|
|
897
|
+
rules.forEach((rule, idx) => {
|
|
898
|
+
out += ` ${(idx + 1) * 10} ${rule}\n`;
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
if (this.acls.size === 0) {
|
|
902
|
+
out = '*** No access lists configured ***\n';
|
|
903
|
+
}
|
|
904
|
+
return out;
|
|
905
|
+
}
|
|
906
|
+
if (showCmd === 'ntp' && (showArgs[1] === 'status' || showArgs[1] === 'associations')) {
|
|
907
|
+
if (this.ntpServers.length === 0) {
|
|
908
|
+
return 'NTP is not enabled.\n';
|
|
909
|
+
}
|
|
910
|
+
let out = 'Clock is synchronized, stratum 2, reference is ' + this.ntpServers[0] + '\n';
|
|
911
|
+
out += 'nominal freq is 250.0000 Hz, actual freq is 250.0000 Hz, precision is 2**24\n';
|
|
912
|
+
return out;
|
|
913
|
+
}
|
|
584
914
|
if (showCmd === 'lldp' && showArgs[1]?.startsWith('ne')) {
|
|
585
|
-
return `Device ID Local Intf Hold-time Capability Port ID
|
|
586
|
-
Switch2 Gi0/1 120 S Gi0/1
|
|
587
|
-
Total entries displayed: 1
|
|
915
|
+
return `Device ID Local Intf Hold-time Capability Port ID
|
|
916
|
+
Switch2 Gi0/1 120 S Gi0/1
|
|
917
|
+
Total entries displayed: 1
|
|
588
918
|
`;
|
|
589
919
|
}
|
|
590
920
|
return `% Unrecognized show command: show ${showArgs.join(' ')}`;
|
|
@@ -625,11 +955,16 @@ Total entries displayed: 1
|
|
|
625
955
|
}
|
|
626
956
|
if (cmd === 'ping' && args[1]) {
|
|
627
957
|
const ip = args[1];
|
|
628
|
-
return `Sending 5, 100-byte ICMP Echos to ${ip}, timeout is 2 seconds:
|
|
629
|
-
!!!!!
|
|
630
|
-
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms
|
|
958
|
+
return `Sending 5, 100-byte ICMP Echos to ${ip}, timeout is 2 seconds:
|
|
959
|
+
!!!!!
|
|
960
|
+
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms
|
|
631
961
|
`;
|
|
632
962
|
}
|
|
963
|
+
if (cmd === 'test' && args[1] === 'trigger-syslog') {
|
|
964
|
+
const msgText = args.slice(2).join(' ');
|
|
965
|
+
exports.simulatorEvents.emit('syslog', msgText);
|
|
966
|
+
return `[Simulator Test] Triggered syslog: ${msgText}`;
|
|
967
|
+
}
|
|
633
968
|
return `% Unrecognized command: ${trimmed}`;
|
|
634
969
|
}
|
|
635
970
|
normalizeInterfaceName(name) {
|