diff --git a/src/driver/freenas/http/api.js b/src/driver/freenas/http/api.js index b9f0057..7bfcda9 100644 --- a/src/driver/freenas/http/api.js +++ b/src/driver/freenas/http/api.js @@ -110,54 +110,15 @@ class Api { } async getApiVersion() { - const systemVersion = await this.getSystemVersion(); - - if (systemVersion.v2) { - if ((await this.getSystemVersionMajorMinor()) == 11.2) { - return 1; - } - return 2; - } - - if (systemVersion.v1) { - return 1; - } - return 2; } async getIsFreeNAS() { - const systemVersion = await this.getSystemVersion(); - let version; - - if (systemVersion.v2) { - version = systemVersion.v2; - } else { - version = systemVersion.v1.fullversion; - } - - if (version.toLowerCase().includes("freenas")) { - return true; - } - return false; } async getIsTrueNAS() { - const systemVersion = await this.getSystemVersion(); - let version; - - if (systemVersion.v2) { - version = systemVersion.v2; - } else { - version = systemVersion.v1.fullversion; - } - - if (version.toLowerCase().includes("truenas")) { - return true; - } - - return false; + return true; } async getIsScale() { @@ -261,28 +222,6 @@ class Api { versionErrors.v2 = e.toString(); } - httpClient.setApiVersion(1); - /** - * {"fullversion": "FreeNAS-9.3-STABLE-201503200528", "name": "FreeNAS", "version": "9.3"} - * {"fullversion": "FreeNAS-11.2-U5 (c129415c52)", "name": "FreeNAS", "version": ""} - */ - try { - response = await httpClient.get(endpoint, null, { timeout: 5 * 1000 }); - versionResponses.v1 = response; - if (response.statusCode == 200 && IsJsonString(response.body)) { - versionInfo.v1 = response.body; - await this.setVersionInfoCache(versionInfo); - - // reset apiVersion - httpClient.setApiVersion(startApiVersion); - - return versionInfo; - } - } catch (e) { - // if more info is needed use e.stack - versionErrors.v1 = e.toString(); - } - // throw error if cannot get v1 or v2 data // likely bad creds/url throw new Error( diff --git a/src/driver/freenas/http/index.js b/src/driver/freenas/http/index.js index 54f4a34..cafd6ff 100644 --- a/src/driver/freenas/http/index.js +++ b/src/driver/freenas/http/index.js @@ -9,11 +9,7 @@ class Client { constructor(options = {}) { this.options = JSON.parse(JSON.stringify(options)); this.logger = console; - - // default to v1.0 for now - if (!this.options.apiVersion) { - this.options.apiVersion = 2; - } + this.options.apiVersion = 2; } getHttpAgent() { diff --git a/src/utils/mount.js b/src/utils/mount.js index 0448557..e1884f0 100644 --- a/src/utils/mount.js +++ b/src/utils/mount.js @@ -10,7 +10,17 @@ const FINDMNT_COMMON_OPTIONS = [ "--nofsroot", // prevents unwanted behavior with cifs volumes ]; -const DEFAULT_TIMEOUT = process.env.MOUNT_DEFAULT_TIMEOUT || 30000; +let DEFAULT_TIMEOUT = 30 * 1000; + +if (process.env.MOUNT_DEFAULT_TIMEOUT) { + if (/^\d+$/.test(process.env.MOUNT_DEFAULT_TIMEOUT)) { + DEFAULT_TIMEOUT = parseInt(process.env.MOUNT_DEFAULT_TIMEOUT); + } else { + console.log( + "invalid MOUNT_DEFAULT_TIMEOUT set: " + process.env.MOUNT_DEFAULT_TIMEOUT + ); + } +} class Mount { constructor(options = {}) {