ciscollm-cli 1.3.3 → 1.3.5
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/README.md +19 -25
- package/dist/cli/commands/daemonCommand.d.ts +4 -0
- package/dist/cli/commands/daemonCommand.js +68 -0
- package/dist/cli/commands/daemonCommand.js.map +1 -0
- package/dist/cli/commands/monitorCommand.js +17 -1
- package/dist/cli/commands/monitorCommand.js.map +1 -1
- package/dist/cli/commands/runCommand.d.ts +1 -3
- package/dist/cli/commands/runCommand.js +177 -470
- package/dist/cli/commands/runCommand.js.map +1 -1
- package/dist/cli/ui/interactiveWizard.d.ts +1 -0
- package/dist/cli/ui/interactiveWizard.js +429 -0
- package/dist/cli/ui/interactiveWizard.js.map +1 -0
- package/dist/cli/ui/ui.js +0 -5
- package/dist/cli/ui/ui.js.map +1 -1
- package/dist/core/agent/AgentLoop.d.ts +15 -3
- package/dist/core/agent/AgentLoop.js +196 -67
- package/dist/core/agent/AgentLoop.js.map +1 -1
- package/dist/core/agent/AutoRemediationEngine.d.ts +14 -0
- package/dist/core/agent/AutoRemediationEngine.js +75 -0
- package/dist/core/agent/AutoRemediationEngine.js.map +1 -0
- package/dist/core/agent/DigitalTwin.d.ts +10 -0
- package/dist/core/agent/DigitalTwin.js +41 -0
- package/dist/core/agent/DigitalTwin.js.map +1 -0
- package/dist/core/agent/IntentTranslator.d.ts +8 -0
- package/dist/core/agent/IntentTranslator.js +63 -0
- package/dist/core/agent/IntentTranslator.js.map +1 -0
- package/dist/core/agent/MemoryManager.d.ts +14 -0
- package/dist/core/agent/MemoryManager.js +89 -0
- package/dist/core/agent/MemoryManager.js.map +1 -0
- package/dist/core/agent/MultiAgentCoordinator.js +0 -2
- package/dist/core/agent/MultiAgentCoordinator.js.map +1 -1
- package/dist/core/agent/NetworkPlanner.d.ts +9 -0
- package/dist/core/agent/NetworkPlanner.js +111 -0
- package/dist/core/agent/NetworkPlanner.js.map +1 -0
- package/dist/core/agent/PromptEngine.d.ts +1 -1
- package/dist/core/agent/PromptEngine.js +23 -13
- package/dist/core/agent/PromptEngine.js.map +1 -1
- package/dist/core/guardrails/NetworkAudit.js +1 -1
- package/dist/core/guardrails/NetworkAudit.js.map +1 -1
- package/dist/core/plugins/PluginManager.d.ts +17 -0
- package/dist/core/plugins/PluginManager.js +108 -0
- package/dist/core/plugins/PluginManager.js.map +1 -0
- package/dist/core/rollback/TransactionManager.js +0 -5
- package/dist/core/rollback/TransactionManager.js.map +1 -1
- package/dist/index.js +36 -61
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/llm/LLMClient.d.ts +1 -0
- package/dist/infrastructure/llm/LLMClient.js +33 -9
- package/dist/infrastructure/llm/LLMClient.js.map +1 -1
- package/dist/infrastructure/protocols/SshSession.d.ts +1 -0
- package/dist/infrastructure/protocols/SshSession.js +5 -4
- package/dist/infrastructure/protocols/SshSession.js.map +1 -1
- package/dist/infrastructure/protocols/TelnetSession.d.ts +1 -0
- package/dist/infrastructure/protocols/TelnetSession.js +5 -1
- package/dist/infrastructure/protocols/TelnetSession.js.map +1 -1
- package/dist/server/devices/ASADevice.d.ts +17 -0
- package/dist/server/devices/ASADevice.js +160 -0
- package/dist/server/devices/ASADevice.js.map +1 -0
- package/dist/server/devices/BaseDevice.d.ts +11 -0
- package/dist/server/devices/BaseDevice.js +19 -0
- package/dist/server/devices/BaseDevice.js.map +1 -0
- package/dist/server/devices/IOSDevice.d.ts +100 -0
- package/dist/server/devices/IOSDevice.js +1561 -0
- package/dist/server/devices/IOSDevice.js.map +1 -0
- package/dist/server/devices/LinuxServerDevice.d.ts +8 -0
- package/dist/server/devices/LinuxServerDevice.js +71 -0
- package/dist/server/devices/LinuxServerDevice.js.map +1 -0
- package/dist/server/devices/PCDevice.d.ts +20 -0
- package/dist/server/devices/PCDevice.js +86 -0
- package/dist/server/devices/PCDevice.js.map +1 -0
- package/dist/server/devices/RouterDevice.d.ts +4 -0
- package/dist/server/devices/RouterDevice.js +11 -0
- package/dist/server/devices/RouterDevice.js.map +1 -0
- package/dist/server/devices/SwitchDevice.d.ts +4 -0
- package/dist/server/devices/SwitchDevice.js +11 -0
- package/dist/server/devices/SwitchDevice.js.map +1 -0
- package/dist/server/devices/WLCDevice.d.ts +15 -0
- package/dist/server/devices/WLCDevice.js +88 -0
- package/dist/server/devices/WLCDevice.js.map +1 -0
- package/dist/server/index.js +47 -22
- package/dist/server/index.js.map +1 -1
- package/dist/server/shell-simulator.js +1 -2
- package/dist/server/shell-simulator.js.map +1 -1
- package/dist/server/ssh.d.ts +2 -1
- package/dist/server/ssh.js +22 -9
- package/dist/server/ssh.js.map +1 -1
- package/dist/server/telnet.d.ts +3 -2
- package/dist/server/telnet.js +10 -42
- package/dist/server/telnet.js.map +1 -1
- package/dist/shared/bootBanner.d.ts +1 -0
- package/dist/shared/bootBanner.js +93 -0
- package/dist/shared/bootBanner.js.map +1 -0
- package/dist/shared/constants.js +1 -1
- package/dist/shared/constants.js.map +1 -1
- package/package.json +1 -1
- package/dist/cli/commands/dashboardCommand.d.ts +0 -1
- package/dist/cli/commands/dashboardCommand.js +0 -16
- package/dist/cli/commands/dashboardCommand.js.map +0 -1
- package/dist/cli/commands/shellCommand.d.ts +0 -1
- package/dist/cli/commands/shellCommand.js +0 -44
- package/dist/cli/commands/shellCommand.js.map +0 -1
- package/dist/infrastructure/protocols/CmlSession.d.ts +0 -26
- package/dist/infrastructure/protocols/CmlSession.js +0 -448
- package/dist/infrastructure/protocols/CmlSession.js.map +0 -1
- package/dist/infrastructure/protocols/NetconfSession.d.ts +0 -74
- package/dist/infrastructure/protocols/NetconfSession.js +0 -553
- package/dist/infrastructure/protocols/NetconfSession.js.map +0 -1
- package/dist/server/dashboard.d.ts +0 -3
- package/dist/server/dashboard.js +0 -1149
- package/dist/server/dashboard.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CmlSession.js","sourceRoot":"","sources":["../../../src/infrastructure/protocols/CmlSession.ts"],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IAAI,CAAC,eAAK,CAAC,MAAM,CAAC,6BAA6B,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACzE,CAAC;QACL,CAAC;aAAM,IAAI,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC5C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CACjB,0BAA0B,IAAI,CAAC,WAAW,sCAAsC,CACnF,CAAC,CAAC;QACP,CAAC;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAExB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,IAAI,CAAC;gBACD,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;gBACxC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC,CAAC;YACtE,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;YACV,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QACtB,CAAC;IACL,CAAC;CACJ;AApcD,gCAocC"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { BaseSession } from './BaseSession';
|
|
2
|
-
export type NetconfFramingVersion = '1.0' | '1.1';
|
|
3
|
-
export interface NetconfCredentials {
|
|
4
|
-
username?: string;
|
|
5
|
-
password?: string;
|
|
6
|
-
privateKey?: string | Buffer;
|
|
7
|
-
passphrase?: string;
|
|
8
|
-
helloTimeoutMs?: number;
|
|
9
|
-
rpcTimeoutMs?: number;
|
|
10
|
-
readyTimeoutMs?: number;
|
|
11
|
-
keepaliveInterval?: number;
|
|
12
|
-
}
|
|
13
|
-
export interface NetconfEditConfigObject {
|
|
14
|
-
target?: 'candidate' | 'running' | 'startup';
|
|
15
|
-
config: Record<string, any>;
|
|
16
|
-
defaultOperation?: 'merge' | 'replace' | 'none' | 'remove';
|
|
17
|
-
testOption?: 'test-then-set' | 'set' | 'test-only';
|
|
18
|
-
errorOption?: 'stop-on-error' | 'continue-on-error' | 'rollback-on-error';
|
|
19
|
-
messageId?: number | string;
|
|
20
|
-
}
|
|
21
|
-
export interface NetconfGetConfigObject {
|
|
22
|
-
source?: 'candidate' | 'running' | 'startup';
|
|
23
|
-
filter?: Record<string, any>;
|
|
24
|
-
messageId?: number | string;
|
|
25
|
-
}
|
|
26
|
-
export interface NetconfRpcEnvelope {
|
|
27
|
-
xml: string;
|
|
28
|
-
parsed: Record<string, any>;
|
|
29
|
-
}
|
|
30
|
-
export declare class NetconfSession extends BaseSession {
|
|
31
|
-
private host;
|
|
32
|
-
private port;
|
|
33
|
-
private credentials;
|
|
34
|
-
private sshClient;
|
|
35
|
-
private netconfStream;
|
|
36
|
-
private connected;
|
|
37
|
-
private connectionPromise;
|
|
38
|
-
private negotiatedFraming;
|
|
39
|
-
private negotiatedCapabilities;
|
|
40
|
-
private incomingBuffer;
|
|
41
|
-
private bufferedMessages;
|
|
42
|
-
private pendingMessageWaiters;
|
|
43
|
-
private helloMessageWaiter;
|
|
44
|
-
private nextMessageId;
|
|
45
|
-
private readonly parser;
|
|
46
|
-
private readonly builder;
|
|
47
|
-
constructor(host: string, port?: number, credentials?: NetconfCredentials);
|
|
48
|
-
connect(): Promise<void>;
|
|
49
|
-
execute(xmlPayload: string, timeoutMs?: number): Promise<string>;
|
|
50
|
-
executeParsed(xmlPayload: string, timeoutMs?: number): Promise<NetconfRpcEnvelope>;
|
|
51
|
-
buildRpcRequest(request: NetconfEditConfigObject | NetconfGetConfigObject): string;
|
|
52
|
-
buildEditConfigRpc(request: NetconfEditConfigObject): string;
|
|
53
|
-
buildGetConfigRpc(request?: NetconfGetConfigObject): string;
|
|
54
|
-
parseRpcReply(xml: string): Promise<Record<string, any>>;
|
|
55
|
-
frameMessage(xmlPayload: string, framing?: NetconfFramingVersion): string;
|
|
56
|
-
disconnect(): Promise<void>;
|
|
57
|
-
private buildConnectOptions;
|
|
58
|
-
private performHelloExchange;
|
|
59
|
-
private buildHelloMessage;
|
|
60
|
-
private buildErrorMessage;
|
|
61
|
-
private throwIfRpcError;
|
|
62
|
-
private extractCapabilities;
|
|
63
|
-
private wrapTargetNode;
|
|
64
|
-
private toXmlNode;
|
|
65
|
-
private findFirstText;
|
|
66
|
-
private writeFrame;
|
|
67
|
-
private bindStream;
|
|
68
|
-
private handleIncomingData;
|
|
69
|
-
private extractNextMessage;
|
|
70
|
-
private waitForHelloMessage;
|
|
71
|
-
private waitForMessageForId;
|
|
72
|
-
private rejectPending;
|
|
73
|
-
private cleanupConnection;
|
|
74
|
-
}
|
|
@@ -1,553 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.NetconfSession = void 0;
|
|
7
|
-
const BaseSession_1 = require("./BaseSession");
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const ssh2_1 = require("ssh2");
|
|
10
|
-
const xml2js_1 = require("xml2js");
|
|
11
|
-
const NETCONF_BASE_1_0 = 'urn:ietf:params:xml:ns:netconf:base:1.0';
|
|
12
|
-
const NETCONF_BASE_1_1 = 'urn:ietf:params:netconf:base:1.1';
|
|
13
|
-
class NetconfSession extends BaseSession_1.BaseSession {
|
|
14
|
-
host;
|
|
15
|
-
port;
|
|
16
|
-
credentials;
|
|
17
|
-
sshClient = null;
|
|
18
|
-
netconfStream = null;
|
|
19
|
-
connected = false;
|
|
20
|
-
connectionPromise = null;
|
|
21
|
-
negotiatedFraming = '1.0';
|
|
22
|
-
negotiatedCapabilities = [];
|
|
23
|
-
incomingBuffer = '';
|
|
24
|
-
bufferedMessages = [];
|
|
25
|
-
pendingMessageWaiters = new Map();
|
|
26
|
-
helloMessageWaiter = null;
|
|
27
|
-
nextMessageId = 1;
|
|
28
|
-
parser = new xml2js_1.Parser({
|
|
29
|
-
explicitArray: false,
|
|
30
|
-
ignoreAttrs: false,
|
|
31
|
-
trim: true,
|
|
32
|
-
attrkey: '$',
|
|
33
|
-
charkey: '_'
|
|
34
|
-
});
|
|
35
|
-
builder = new xml2js_1.Builder({
|
|
36
|
-
headless: false,
|
|
37
|
-
renderOpts: {
|
|
38
|
-
pretty: true,
|
|
39
|
-
indent: ' ',
|
|
40
|
-
newline: '\n'
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
constructor(host, port = 830, credentials = {}) {
|
|
44
|
-
super();
|
|
45
|
-
this.host = host;
|
|
46
|
-
this.port = port;
|
|
47
|
-
this.credentials = credentials;
|
|
48
|
-
this.state = {
|
|
49
|
-
currentMode: 'PRIVILEGED_EXEC',
|
|
50
|
-
hostname: `netconf-${host}`,
|
|
51
|
-
prompt: `NETCONF@${host}:${port}`
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
async connect() {
|
|
55
|
-
if (this.connected) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (this.connectionPromise) {
|
|
59
|
-
return this.connectionPromise;
|
|
60
|
-
}
|
|
61
|
-
console.log(chalk_1.default.cyan(`❯ Establishing SSH NETCONF subsystem connection to ${this.host}:${this.port}...`));
|
|
62
|
-
const client = new ssh2_1.Client();
|
|
63
|
-
this.sshClient = client;
|
|
64
|
-
let resolveConnection;
|
|
65
|
-
let rejectConnection;
|
|
66
|
-
const promise = new Promise((resolve, reject) => {
|
|
67
|
-
resolveConnection = resolve;
|
|
68
|
-
rejectConnection = reject;
|
|
69
|
-
});
|
|
70
|
-
this.connectionPromise = promise.finally(() => {
|
|
71
|
-
this.connectionPromise = null;
|
|
72
|
-
});
|
|
73
|
-
let settled = false;
|
|
74
|
-
const succeed = () => {
|
|
75
|
-
if (settled) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
settled = true;
|
|
79
|
-
this.connected = true;
|
|
80
|
-
console.log(chalk_1.default.green(`[+] Exchanging capabilities (<hello> message) completed successfully.`));
|
|
81
|
-
resolveConnection();
|
|
82
|
-
};
|
|
83
|
-
const fail = (error) => {
|
|
84
|
-
if (settled) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
settled = true;
|
|
88
|
-
this.cleanupConnection();
|
|
89
|
-
rejectConnection(error);
|
|
90
|
-
};
|
|
91
|
-
client.on('error', fail);
|
|
92
|
-
client.on('close', () => {
|
|
93
|
-
this.connected = false;
|
|
94
|
-
this.netconfStream = null;
|
|
95
|
-
if (!settled) {
|
|
96
|
-
fail(new Error(`NETCONF SSH connection to ${this.host}:${this.port} closed before the subsystem became ready.`));
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
this.rejectPending(new Error('NETCONF session closed.'));
|
|
100
|
-
});
|
|
101
|
-
client.on('ready', () => {
|
|
102
|
-
client.subsys('netconf', (error, stream) => {
|
|
103
|
-
if (error) {
|
|
104
|
-
fail(error);
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
this.netconfStream = stream;
|
|
108
|
-
this.bindStream(stream);
|
|
109
|
-
this.performHelloExchange()
|
|
110
|
-
.then(succeed)
|
|
111
|
-
.catch(fail);
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
try {
|
|
115
|
-
client.connect(this.buildConnectOptions());
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
fail(error);
|
|
119
|
-
}
|
|
120
|
-
return this.connectionPromise;
|
|
121
|
-
}
|
|
122
|
-
async execute(xmlPayload, timeoutMs = this.credentials.rpcTimeoutMs ?? 15000) {
|
|
123
|
-
const response = await this.executeParsed(xmlPayload, timeoutMs);
|
|
124
|
-
return response.xml;
|
|
125
|
-
}
|
|
126
|
-
async executeParsed(xmlPayload, timeoutMs = this.credentials.rpcTimeoutMs ?? 15000) {
|
|
127
|
-
await this.connect();
|
|
128
|
-
if (!this.netconfStream) {
|
|
129
|
-
throw new Error('NETCONF session is not connected.');
|
|
130
|
-
}
|
|
131
|
-
const framedPayload = this.frameMessage(xmlPayload, this.negotiatedFraming);
|
|
132
|
-
console.log(chalk_1.default.cyan(`❯ Sending NETCONF RPC request to ${this.host}...`));
|
|
133
|
-
const msgIdMatch = /message-id=["']([^"']+)["']/i.exec(xmlPayload);
|
|
134
|
-
const messageId = msgIdMatch ? msgIdMatch[1] : null;
|
|
135
|
-
if (!messageId) {
|
|
136
|
-
throw new Error('Unable to extract message-id from NETCONF RPC payload.');
|
|
137
|
-
}
|
|
138
|
-
await this.writeFrame(framedPayload);
|
|
139
|
-
const xml = await this.waitForMessageForId(messageId, timeoutMs);
|
|
140
|
-
const parsed = await this.parseRpcReply(xml);
|
|
141
|
-
this.throwIfRpcError(parsed);
|
|
142
|
-
return { xml, parsed };
|
|
143
|
-
}
|
|
144
|
-
buildRpcRequest(request) {
|
|
145
|
-
if ('config' in request) {
|
|
146
|
-
return this.buildEditConfigRpc(request);
|
|
147
|
-
}
|
|
148
|
-
return this.buildGetConfigRpc(request);
|
|
149
|
-
}
|
|
150
|
-
buildEditConfigRpc(request) {
|
|
151
|
-
const messageId = String(request.messageId ?? this.nextMessageId++);
|
|
152
|
-
const rpcBody = {
|
|
153
|
-
rpc: {
|
|
154
|
-
$: {
|
|
155
|
-
xmlns: NETCONF_BASE_1_0,
|
|
156
|
-
'message-id': messageId
|
|
157
|
-
},
|
|
158
|
-
'edit-config': [{
|
|
159
|
-
target: [this.wrapTargetNode(request.target ?? 'running')],
|
|
160
|
-
config: [this.toXmlNode(request.config)]
|
|
161
|
-
}]
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
const editConfig = rpcBody.rpc['edit-config'][0];
|
|
165
|
-
if (request.defaultOperation) {
|
|
166
|
-
editConfig['default-operation'] = [request.defaultOperation];
|
|
167
|
-
}
|
|
168
|
-
if (request.testOption) {
|
|
169
|
-
editConfig['test-option'] = [request.testOption];
|
|
170
|
-
}
|
|
171
|
-
if (request.errorOption) {
|
|
172
|
-
editConfig['error-option'] = [request.errorOption];
|
|
173
|
-
}
|
|
174
|
-
return this.builder.buildObject(rpcBody);
|
|
175
|
-
}
|
|
176
|
-
buildGetConfigRpc(request = {}) {
|
|
177
|
-
const messageId = String(request.messageId ?? this.nextMessageId++);
|
|
178
|
-
const rpcBody = {
|
|
179
|
-
rpc: {
|
|
180
|
-
$: {
|
|
181
|
-
xmlns: NETCONF_BASE_1_0,
|
|
182
|
-
'message-id': messageId
|
|
183
|
-
},
|
|
184
|
-
'get-config': [{
|
|
185
|
-
source: [this.wrapTargetNode(request.source ?? 'running')]
|
|
186
|
-
}]
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
if (request.filter) {
|
|
190
|
-
rpcBody.rpc['get-config'][0].filter = [this.toXmlNode(request.filter)];
|
|
191
|
-
}
|
|
192
|
-
return this.builder.buildObject(rpcBody);
|
|
193
|
-
}
|
|
194
|
-
async parseRpcReply(xml) {
|
|
195
|
-
const parsed = await this.parser.parseStringPromise(xml);
|
|
196
|
-
return parsed;
|
|
197
|
-
}
|
|
198
|
-
frameMessage(xmlPayload, framing = this.negotiatedFraming) {
|
|
199
|
-
if (framing === '1.1') {
|
|
200
|
-
const length = Buffer.byteLength(xmlPayload, 'utf8');
|
|
201
|
-
return `\n#${length}\n${xmlPayload}\n##\n`;
|
|
202
|
-
}
|
|
203
|
-
return `${xmlPayload}]]>]]>`;
|
|
204
|
-
}
|
|
205
|
-
async disconnect() {
|
|
206
|
-
this.connected = false;
|
|
207
|
-
this.negotiatedFraming = '1.0';
|
|
208
|
-
this.negotiatedCapabilities = [];
|
|
209
|
-
this.incomingBuffer = '';
|
|
210
|
-
this.bufferedMessages = [];
|
|
211
|
-
this.rejectPending(new Error('NETCONF session closed.'));
|
|
212
|
-
if (this.netconfStream) {
|
|
213
|
-
this.netconfStream.end?.();
|
|
214
|
-
this.netconfStream = null;
|
|
215
|
-
}
|
|
216
|
-
if (this.sshClient) {
|
|
217
|
-
this.sshClient.end();
|
|
218
|
-
this.sshClient = null;
|
|
219
|
-
}
|
|
220
|
-
console.log(chalk_1.default.green(`[+] NETCONF Session to ${this.host} cleanly closed.`));
|
|
221
|
-
}
|
|
222
|
-
buildConnectOptions() {
|
|
223
|
-
const username = this.credentials.username ?? process.env.NETCONF_USERNAME;
|
|
224
|
-
const password = this.credentials.password ?? process.env.NETCONF_PASSWORD;
|
|
225
|
-
if (!username) {
|
|
226
|
-
throw new Error('NETCONF username is required. Pass it in the constructor or set NETCONF_USERNAME.');
|
|
227
|
-
}
|
|
228
|
-
return {
|
|
229
|
-
host: this.host,
|
|
230
|
-
port: this.port,
|
|
231
|
-
username,
|
|
232
|
-
password,
|
|
233
|
-
privateKey: this.credentials.privateKey,
|
|
234
|
-
passphrase: this.credentials.passphrase,
|
|
235
|
-
readyTimeout: this.credentials.readyTimeoutMs ?? 20000,
|
|
236
|
-
keepaliveInterval: this.credentials.keepaliveInterval ?? 10000,
|
|
237
|
-
tryKeyboard: false
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
async performHelloExchange() {
|
|
241
|
-
const hello = this.buildHelloMessage();
|
|
242
|
-
await this.writeFrame(this.frameMessage(hello, '1.0'));
|
|
243
|
-
const helloTimeout = this.credentials.helloTimeoutMs ?? 15000;
|
|
244
|
-
const peerHelloXml = await this.waitForHelloMessage(helloTimeout);
|
|
245
|
-
const peerHello = await this.parseRpcReply(peerHelloXml);
|
|
246
|
-
this.negotiatedCapabilities = this.extractCapabilities(peerHello);
|
|
247
|
-
this.negotiatedFraming = this.negotiatedCapabilities.includes(NETCONF_BASE_1_1) ? '1.1' : '1.0';
|
|
248
|
-
}
|
|
249
|
-
buildHelloMessage() {
|
|
250
|
-
return this.builder.buildObject({
|
|
251
|
-
hello: {
|
|
252
|
-
$: {
|
|
253
|
-
xmlns: NETCONF_BASE_1_0
|
|
254
|
-
},
|
|
255
|
-
capabilities: {
|
|
256
|
-
capability: [NETCONF_BASE_1_0, NETCONF_BASE_1_1]
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
buildErrorMessage(errorPayload) {
|
|
262
|
-
const errors = Array.isArray(errorPayload) ? errorPayload : [errorPayload];
|
|
263
|
-
const descriptions = [];
|
|
264
|
-
for (const err of errors) {
|
|
265
|
-
const errorTag = this.findFirstText(err?.['error-tag'] ?? err?.errorTag ?? err?.['error-type'] ?? err?.errorType);
|
|
266
|
-
const errorMessage = this.findFirstText(err?.['error-message'] ?? err?.errorMessage ?? err?._);
|
|
267
|
-
const errorPath = this.findFirstText(err?.['error-path'] ?? err?.errorPath);
|
|
268
|
-
const errorInfo = err?.['error-info'] ? JSON.stringify(err['error-info']) : '';
|
|
269
|
-
let desc = '';
|
|
270
|
-
if (errorTag && errorMessage) {
|
|
271
|
-
desc = `${errorTag}: ${errorMessage}`;
|
|
272
|
-
}
|
|
273
|
-
else if (errorTag) {
|
|
274
|
-
desc = errorTag;
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
desc = errorMessage || 'Unknown NETCONF rpc-error';
|
|
278
|
-
}
|
|
279
|
-
if (errorPath) {
|
|
280
|
-
desc += ` (path: ${errorPath})`;
|
|
281
|
-
}
|
|
282
|
-
if (errorInfo) {
|
|
283
|
-
desc += ` (info: ${errorInfo})`;
|
|
284
|
-
}
|
|
285
|
-
descriptions.push(desc);
|
|
286
|
-
}
|
|
287
|
-
return descriptions.join('; ');
|
|
288
|
-
}
|
|
289
|
-
throwIfRpcError(parsed) {
|
|
290
|
-
const reply = parsed['rpc-reply'] ?? parsed.rpcReply ?? parsed.rpc;
|
|
291
|
-
const rpcError = reply?.['rpc-error'];
|
|
292
|
-
if (!rpcError) {
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
const error = new Error(`NETCONF rpc-error: ${this.buildErrorMessage(rpcError)}`);
|
|
296
|
-
error.details = parsed;
|
|
297
|
-
throw error;
|
|
298
|
-
}
|
|
299
|
-
extractCapabilities(parsedHello) {
|
|
300
|
-
const hello = parsedHello.hello ?? parsedHello['hello'];
|
|
301
|
-
const capabilityValue = hello?.capabilities?.capability ?? [];
|
|
302
|
-
if (Array.isArray(capabilityValue)) {
|
|
303
|
-
return capabilityValue.map(item => this.findFirstText(item)).filter(Boolean);
|
|
304
|
-
}
|
|
305
|
-
const single = this.findFirstText(capabilityValue);
|
|
306
|
-
return single ? [single] : [];
|
|
307
|
-
}
|
|
308
|
-
wrapTargetNode(target) {
|
|
309
|
-
return { [target]: [''] };
|
|
310
|
-
}
|
|
311
|
-
toXmlNode(value) {
|
|
312
|
-
if (Array.isArray(value)) {
|
|
313
|
-
return value.map(item => this.toXmlNode(item));
|
|
314
|
-
}
|
|
315
|
-
if (value === null || value === undefined) {
|
|
316
|
-
return '';
|
|
317
|
-
}
|
|
318
|
-
if (typeof value === 'object') {
|
|
319
|
-
const node = {};
|
|
320
|
-
for (const [key, child] of Object.entries(value)) {
|
|
321
|
-
if (key === '$' || key === '_') {
|
|
322
|
-
node[key] = child;
|
|
323
|
-
continue;
|
|
324
|
-
}
|
|
325
|
-
node[key] = [this.toXmlNode(child)];
|
|
326
|
-
}
|
|
327
|
-
return node;
|
|
328
|
-
}
|
|
329
|
-
return String(value);
|
|
330
|
-
}
|
|
331
|
-
findFirstText(value) {
|
|
332
|
-
if (value === null || value === undefined) {
|
|
333
|
-
return '';
|
|
334
|
-
}
|
|
335
|
-
if (typeof value === 'string') {
|
|
336
|
-
return value.trim();
|
|
337
|
-
}
|
|
338
|
-
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
339
|
-
return String(value);
|
|
340
|
-
}
|
|
341
|
-
if (Array.isArray(value)) {
|
|
342
|
-
for (const item of value) {
|
|
343
|
-
const text = this.findFirstText(item);
|
|
344
|
-
if (text) {
|
|
345
|
-
return text;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
return '';
|
|
349
|
-
}
|
|
350
|
-
if (typeof value === 'object') {
|
|
351
|
-
if (typeof value._ === 'string') {
|
|
352
|
-
return value._.trim();
|
|
353
|
-
}
|
|
354
|
-
for (const child of Object.values(value)) {
|
|
355
|
-
const text = this.findFirstText(child);
|
|
356
|
-
if (text) {
|
|
357
|
-
return text;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
return '';
|
|
362
|
-
}
|
|
363
|
-
async writeFrame(payload) {
|
|
364
|
-
if (!this.netconfStream) {
|
|
365
|
-
throw new Error('NETCONF stream is not available.');
|
|
366
|
-
}
|
|
367
|
-
await new Promise((resolve, reject) => {
|
|
368
|
-
const accepted = this.netconfStream.write(payload, (error) => {
|
|
369
|
-
if (error) {
|
|
370
|
-
reject(error);
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
if (accepted) {
|
|
374
|
-
resolve();
|
|
375
|
-
return;
|
|
376
|
-
}
|
|
377
|
-
this.netconfStream.once('drain', () => resolve());
|
|
378
|
-
this.netconfStream.once('error', (error) => reject(error));
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
bindStream(stream) {
|
|
382
|
-
stream.on('data', (chunk) => {
|
|
383
|
-
this.handleIncomingData(chunk.toString());
|
|
384
|
-
});
|
|
385
|
-
stream.on('error', (error) => {
|
|
386
|
-
this.rejectPending(error);
|
|
387
|
-
});
|
|
388
|
-
stream.on('close', () => {
|
|
389
|
-
this.connected = false;
|
|
390
|
-
this.netconfStream = null;
|
|
391
|
-
this.rejectPending(new Error('NETCONF stream closed.'));
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
handleIncomingData(chunk) {
|
|
395
|
-
this.incomingBuffer += chunk;
|
|
396
|
-
while (true) {
|
|
397
|
-
const extracted = this.extractNextMessage(this.incomingBuffer, this.negotiatedFraming);
|
|
398
|
-
if (!extracted) {
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
this.incomingBuffer = extracted.remainder;
|
|
402
|
-
const payload = extracted.payload.trim();
|
|
403
|
-
const msgIdMatch = /message-id=["']([^"']+)["']/i.exec(payload);
|
|
404
|
-
const messageId = msgIdMatch ? msgIdMatch[1] : null;
|
|
405
|
-
if (messageId) {
|
|
406
|
-
const waiter = this.pendingMessageWaiters.get(messageId);
|
|
407
|
-
if (waiter) {
|
|
408
|
-
this.pendingMessageWaiters.delete(messageId);
|
|
409
|
-
clearTimeout(waiter.timer);
|
|
410
|
-
waiter.resolve(payload);
|
|
411
|
-
continue;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
else if (this.helloMessageWaiter && payload.includes('<hello')) {
|
|
415
|
-
const waiter = this.helloMessageWaiter;
|
|
416
|
-
this.helloMessageWaiter = null;
|
|
417
|
-
clearTimeout(waiter.timer);
|
|
418
|
-
waiter.resolve(payload);
|
|
419
|
-
continue;
|
|
420
|
-
}
|
|
421
|
-
this.bufferedMessages.push(payload);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
extractNextMessage(buffer, framing) {
|
|
425
|
-
if (framing === '1.0') {
|
|
426
|
-
const delimiter = ']]>]]>';
|
|
427
|
-
const delimiterIndex = buffer.indexOf(delimiter);
|
|
428
|
-
if (delimiterIndex === -1) {
|
|
429
|
-
return null;
|
|
430
|
-
}
|
|
431
|
-
return {
|
|
432
|
-
payload: buffer.slice(0, delimiterIndex),
|
|
433
|
-
remainder: buffer.slice(delimiterIndex + delimiter.length)
|
|
434
|
-
};
|
|
435
|
-
}
|
|
436
|
-
let cursor = 0;
|
|
437
|
-
let payload = '';
|
|
438
|
-
while (cursor < buffer.length) {
|
|
439
|
-
while (cursor < buffer.length && (buffer[cursor] === '\n' || buffer[cursor] === '\r')) {
|
|
440
|
-
cursor++;
|
|
441
|
-
}
|
|
442
|
-
if (cursor >= buffer.length) {
|
|
443
|
-
return null;
|
|
444
|
-
}
|
|
445
|
-
if (buffer.startsWith('##', cursor)) {
|
|
446
|
-
cursor += 2;
|
|
447
|
-
if (buffer[cursor] === '\r') {
|
|
448
|
-
cursor++;
|
|
449
|
-
}
|
|
450
|
-
if (buffer[cursor] === '\n') {
|
|
451
|
-
cursor++;
|
|
452
|
-
}
|
|
453
|
-
return {
|
|
454
|
-
payload,
|
|
455
|
-
remainder: buffer.slice(cursor)
|
|
456
|
-
};
|
|
457
|
-
}
|
|
458
|
-
if (buffer[cursor] !== '#') {
|
|
459
|
-
return null;
|
|
460
|
-
}
|
|
461
|
-
cursor++;
|
|
462
|
-
const lengthEnd = buffer.indexOf('\n', cursor);
|
|
463
|
-
if (lengthEnd === -1) {
|
|
464
|
-
return null;
|
|
465
|
-
}
|
|
466
|
-
const chunkLength = Number(buffer.slice(cursor, lengthEnd).trim());
|
|
467
|
-
if (!Number.isFinite(chunkLength) || chunkLength < 0) {
|
|
468
|
-
throw new Error(`Invalid NETCONF chunk length: ${buffer.slice(cursor, lengthEnd)}`);
|
|
469
|
-
}
|
|
470
|
-
cursor = lengthEnd + 1;
|
|
471
|
-
if (buffer.length < cursor + chunkLength) {
|
|
472
|
-
return null;
|
|
473
|
-
}
|
|
474
|
-
payload += buffer.slice(cursor, cursor + chunkLength);
|
|
475
|
-
cursor += chunkLength;
|
|
476
|
-
}
|
|
477
|
-
return null;
|
|
478
|
-
}
|
|
479
|
-
waitForHelloMessage(timeoutMs) {
|
|
480
|
-
const bufferedIndex = this.bufferedMessages.findIndex(m => m.includes('<hello'));
|
|
481
|
-
if (bufferedIndex !== -1) {
|
|
482
|
-
const msg = this.bufferedMessages[bufferedIndex];
|
|
483
|
-
this.bufferedMessages.splice(bufferedIndex, 1);
|
|
484
|
-
return Promise.resolve(msg);
|
|
485
|
-
}
|
|
486
|
-
return new Promise((resolve, reject) => {
|
|
487
|
-
const timer = setTimeout(() => {
|
|
488
|
-
if (this.helloMessageWaiter && this.helloMessageWaiter.timer === timer) {
|
|
489
|
-
this.helloMessageWaiter = null;
|
|
490
|
-
}
|
|
491
|
-
reject(new Error(`NETCONF hello handshake timeout after ${timeoutMs}ms.`));
|
|
492
|
-
}, timeoutMs);
|
|
493
|
-
this.helloMessageWaiter = {
|
|
494
|
-
resolve,
|
|
495
|
-
reject,
|
|
496
|
-
timer
|
|
497
|
-
};
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
waitForMessageForId(messageId, timeoutMs) {
|
|
501
|
-
const bufferedIndex = this.bufferedMessages.findIndex(m => {
|
|
502
|
-
const match = /message-id=["']([^"']+)["']/i.exec(m);
|
|
503
|
-
return match ? match[1] === messageId : false;
|
|
504
|
-
});
|
|
505
|
-
if (bufferedIndex !== -1) {
|
|
506
|
-
const msg = this.bufferedMessages[bufferedIndex];
|
|
507
|
-
this.bufferedMessages.splice(bufferedIndex, 1);
|
|
508
|
-
return Promise.resolve(msg);
|
|
509
|
-
}
|
|
510
|
-
return new Promise((resolve, reject) => {
|
|
511
|
-
const timer = setTimeout(() => {
|
|
512
|
-
if (this.pendingMessageWaiters.has(messageId)) {
|
|
513
|
-
this.pendingMessageWaiters.delete(messageId);
|
|
514
|
-
}
|
|
515
|
-
reject(new Error(`NETCONF response timeout for message-id ${messageId} after ${timeoutMs}ms.`));
|
|
516
|
-
}, timeoutMs);
|
|
517
|
-
this.pendingMessageWaiters.set(messageId, {
|
|
518
|
-
resolve,
|
|
519
|
-
reject,
|
|
520
|
-
timer
|
|
521
|
-
});
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
rejectPending(error) {
|
|
525
|
-
if (this.helloMessageWaiter) {
|
|
526
|
-
const waiter = this.helloMessageWaiter;
|
|
527
|
-
this.helloMessageWaiter = null;
|
|
528
|
-
clearTimeout(waiter.timer);
|
|
529
|
-
waiter.reject(error);
|
|
530
|
-
}
|
|
531
|
-
for (const waiter of this.pendingMessageWaiters.values()) {
|
|
532
|
-
clearTimeout(waiter.timer);
|
|
533
|
-
waiter.reject(error);
|
|
534
|
-
}
|
|
535
|
-
this.pendingMessageWaiters.clear();
|
|
536
|
-
}
|
|
537
|
-
cleanupConnection() {
|
|
538
|
-
this.connected = false;
|
|
539
|
-
this.negotiatedFraming = '1.0';
|
|
540
|
-
this.negotiatedCapabilities = [];
|
|
541
|
-
this.incomingBuffer = '';
|
|
542
|
-
this.bufferedMessages = [];
|
|
543
|
-
if (this.netconfStream) {
|
|
544
|
-
this.netconfStream = null;
|
|
545
|
-
}
|
|
546
|
-
if (this.sshClient) {
|
|
547
|
-
this.sshClient = null;
|
|
548
|
-
}
|
|
549
|
-
this.rejectPending(new Error('NETCONF connection reset.'));
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
exports.NetconfSession = NetconfSession;
|
|
553
|
-
//# sourceMappingURL=NetconfSession.js.map
|