UNPKG

n8n-nodes-netdevices

Version:
86 lines (85 loc) 2.9 kB
import { Client } from 'ssh2'; import { EventEmitter } from 'events'; 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; } export interface CommandResult { command: string; output: string; success: boolean; error?: string; } export declare class BaseConnection extends EventEmitter { protected client: Client; protected credentials: DeviceCredentials; protected isConnected: boolean; protected 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; private static connectionPool; private static poolCleanupInterval; constructor(credentials: DeviceCredentials); private setupEventHandlers; connect(): Promise<void>; private validateCredentials; private tryConnect; disconnect(): Promise<void>; protected 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; private getOptimizedAlgorithms; static forceCleanupConnectionPool(): void; static getConnectionPoolStatus(): { totalConnections: number; connections: string[]; }; }