chore: refactor maxauthattempts to const
This commit is contained in:
parent
402b678b37
commit
1d813f6e6c
2 changed files with 4 additions and 3 deletions
|
@ -36,7 +36,8 @@ const DEFAULTS = {
|
||||||
"client",
|
"client",
|
||||||
"public"
|
"public"
|
||||||
),
|
),
|
||||||
CLIENT_FILE: "client.htm"
|
CLIENT_FILE: "client.htm",
|
||||||
|
MAX_AUTH_ATTEMPTS: 2
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,6 +6,7 @@ const EventEmitter = require("events")
|
||||||
const { createNamespacedDebug } = require("./logger")
|
const { createNamespacedDebug } = require("./logger")
|
||||||
const { SSHConnectionError, handleError } = require("./errors")
|
const { SSHConnectionError, handleError } = require("./errors")
|
||||||
const { maskSensitiveData } = require("./utils")
|
const { maskSensitiveData } = require("./utils")
|
||||||
|
const { DEFAULTS } = require("./constants")
|
||||||
|
|
||||||
const debug = createNamespacedDebug("ssh")
|
const debug = createNamespacedDebug("ssh")
|
||||||
|
|
||||||
|
@ -21,7 +22,6 @@ class SSHConnection extends EventEmitter {
|
||||||
this.stream = null
|
this.stream = null
|
||||||
this.creds = null
|
this.creds = null
|
||||||
this.authAttempts = 0
|
this.authAttempts = 0
|
||||||
this.maxAuthAttempts = 2
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,7 +92,7 @@ class SSHConnection extends EventEmitter {
|
||||||
debug(`connect: error: ${err.message}`)
|
debug(`connect: error: ${err.message}`)
|
||||||
|
|
||||||
// Check if this is an authentication error and we haven't exceeded max attempts
|
// 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++
|
this.authAttempts++
|
||||||
debug(
|
debug(
|
||||||
`Authentication attempt ${this.authAttempts} failed, trying password authentication`
|
`Authentication attempt ${this.authAttempts} failed, trying password authentication`
|
||||||
|
|
Loading…
Reference in a new issue