From 1d813f6e6c6915b8f75330dbb5bfe01f3b6c2fc9 Mon Sep 17 00:00:00 2001 From: Bill Church Date: Fri, 29 Nov 2024 16:31:58 +0000 Subject: [PATCH] chore: refactor maxauthattempts to const --- app/constants.js | 3 ++- app/ssh.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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`