UNPKG

n8n-nodes-netdevices

Version:

n8n node to interact with network devices (Cisco, MikroTik, Arista, Extreme Networks, Dell, Juniper, HP, Aruba, Ubiquiti, Palo Alto, Fortinet - ISP, data center, campus, and edge)

77 lines 2.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UbiquitiUnifiSwitchConnection = void 0; const ubiquiti_edgeswitch_connection_1 = require("./ubiquiti-edgeswitch-connection"); class UbiquitiUnifiSwitchConnection extends ubiquiti_edgeswitch_connection_1.UbiquitiEdgeSwitchConnection { constructor(credentials) { super(credentials); this.inTelnetSession = false; } async sessionPreparation() { await this.createCiscoShellChannel(); await this.setBasePrompt(); await this.enterSwitchCli(); if (this.fastMode) { await this.setBasePrompt(); } else { await this.setBasePrompt(); await this.checkAndEnterEnableMode(); await this.disablePaging(); await new Promise(resolve => setTimeout(resolve, 300)); } } async enterSwitchCli() { try { await this.writeChannel('telnet localhost' + this.newline); const output = await this.readChannel(5000); if (output.includes('(UBNT)') || output.includes('>')) { this.inTelnetSession = true; } else { throw new Error('Failed to enter switch CLI. Expected (UBNT) prompt not found.'); } } catch (error) { throw new Error(`Failed to telnet to switch CLI: ${error}`); } } async exitSwitchCli() { if (!this.inTelnetSession) { return; } try { if (this.inConfigMode) { await this.exitConfigMode(); } await this.writeChannel('exit' + this.newline); await this.readChannel(2000); this.inTelnetSession = false; } catch (error) { } } async disconnect() { if (!this.isConnected) { return; } try { await this.exitSwitchCli(); } catch (error) { } await super.disconnect(); } async cleanup() { try { if (this.inConfigMode) { await this.exitConfigMode(); } await this.exitSwitchCli(); } catch (error) { } } } exports.UbiquitiUnifiSwitchConnection = UbiquitiUnifiSwitchConnection; //# sourceMappingURL=ubiquiti-unifi-connection.js.map