diff --git a/app/constants.js b/app/constants.js index 7a2c40b..fbc10e8 100644 --- a/app/constants.js +++ b/app/constants.js @@ -36,7 +36,8 @@ const DEFAULTS = { "client", "public" ), - CLIENT_FILE: "client.htm" + CLIENT_FILE: "client.htm", + MAX_AUTH_ATTEMPTS: 2 } /** diff --git a/app/ssh.js b/app/ssh.js index c1fced5..5ffe9c2 100644 --- a/app/ssh.js +++ b/app/ssh.js @@ -6,6 +6,7 @@ const EventEmitter = require("events") const { createNamespacedDebug } = require("./logger") const { SSHConnectionError, handleError } = require("./errors") const { maskSensitiveData } = require("./utils") +const { DEFAULTS } = require("./constants") const debug = createNamespacedDebug("ssh") @@ -21,7 +22,6 @@ class SSHConnection extends EventEmitter { this.stream = null this.creds = null this.authAttempts = 0 - this.maxAuthAttempts = 2 } /** @@ -92,7 +92,7 @@ class SSHConnection extends EventEmitter { debug(`connect: error: ${err.message}`) // Check if this is an authentication error and we haven't exceeded max attempts - if (this.authAttempts < this.maxAuthAttempts) { + if (this.authAttempts < DEFAULTS.MAX_AUTH_ATTEMPTS) { this.authAttempts++ debug( `Authentication attempt ${this.authAttempts} failed, trying password authentication`