n8n-nodes-netdevices
Version:
n8n node to interact with network devices (Cisco, Juniper, Palo Alto PAN-OS, Ciena SAOS, Linux, etc.)
110 lines (109 loc) • 3.74 kB
TypeScript
import { Client } from 'ssh2';
import { EventEmitter } from 'events';
export declare function formatSSHPrivateKey(privateKey: string): string;
export declare function validateSSHPrivateKey(privateKey: string): boolean;
export interface JumpHostConfig {
host: string;
port: number;
username: string;
password?: string;
privateKey?: string;
passphrase?: string;
authMethod: 'password' | 'privateKey';
timeout?: number;
}
export interface DeviceCredentials {
host: string;
port: number;
username: string;
password?: string;
authMethod: 'password' | 'privateKey';
privateKey?: string;
passphrase?: string;
deviceType: string;
timeout?: number;
keepAlive?: boolean;
fastMode?: boolean;
commandTimeout?: number;
reuseConnection?: boolean;
connectionPooling?: boolean;
useJumpHost?: boolean;
jumpHostHost?: string;
jumpHostPort?: number;
jumpHostUsername?: string;
jumpHostAuthMethod?: 'password' | 'privateKey';
jumpHostPassword?: string;
jumpHostPrivateKey?: string;
jumpHostPassphrase?: string;
}
export interface CommandResult {
command: string;
output: string;
success: boolean;
error?: string;
}
export declare class BaseConnection extends EventEmitter {
client: Client;
credentials: DeviceCredentials;
isConnected: boolean;
currentChannel: any;
protected basePrompt: string;
protected enabledPrompt: string;
protected configPrompt: string;
protected timeout: number;
protected encoding: string;
protected newline: string;
protected returnChar: string;
protected fastMode: boolean;
protected commandTimeout: number;
protected reuseConnection: boolean;
protected connectionPooling: boolean;
protected lastActivity: number;
protected lastSuccessfulAlgorithmIndex: number;
private static connectionPool;
private static poolCleanupInterval;
constructor(credentials: DeviceCredentials, fastMode?: boolean, connectionPooling?: boolean, reuseConnection?: boolean);
private setupEventHandlers;
connect(): Promise<void>;
private validateCredentials;
private validateJumpHostConfig;
private tryConnect;
private tryConnectWithConfig;
disconnect(): Promise<void>;
sessionPreparation(): Promise<void>;
private createShellChannel;
protected setBasePrompt(): Promise<void>;
protected disablePaging(): Promise<void>;
protected setTerminalWidth(): Promise<void>;
protected writeChannel(data: string): Promise<void>;
protected readChannel(timeout?: number): Promise<string>;
protected readUntilPrompt(expectedPrompt?: string, timeout?: number): Promise<string>;
sendCommand(command: string): Promise<CommandResult>;
sendConfig(configCommands: string[]): Promise<CommandResult>;
protected enterConfigMode(): Promise<void>;
protected exitConfigMode(): Promise<void>;
protected sanitizeOutput(output: string, command: string): string;
getCurrentConfig(): Promise<CommandResult>;
saveConfig(): Promise<CommandResult>;
rebootDevice(): Promise<CommandResult>;
isAlive(): boolean;
healthCheck(): Promise<boolean>;
getDeviceType(): string;
getHost(): string;
getConnectionInfo(): {
host: string;
port: number;
deviceType: string;
connected: boolean;
};
private setupConnectionPooling;
private cleanupConnectionPool;
private getConnectionKey;
protected getOptimizedAlgorithms(): any[];
static forceCleanupConnectionPool(): void;
static getConnectionPoolStatus(): {
totalConnections: number;
connections: string[];
};
private sessionPreparationWithTimeout;
}