From 32e674f26c7a6245c123dbf9d7988b13eda750fa Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 18 Dec 2018 17:28:25 +0100 Subject: [PATCH] Added protocol validation --- lib/Connection.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Connection.js b/lib/Connection.js index 678e7f1e5..b0327ab44 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -6,7 +6,7 @@ const https = require('https') const debug = require('debug')('elasticsearch') const decompressResponse = require('decompress-response') const pump = require('pump') -const { TimeoutError } = require('./errors') +const { TimeoutError, ConfigurationError } = require('./errors') class Connection { constructor (opts = {}) { @@ -21,6 +21,10 @@ class Connection { this._status = opts.status || Connection.statuses.ALIVE this.roles = opts.roles || defaultRoles + if (!['http:', 'https:'].includes(this.url.protocol)) { + throw new ConfigurationError(`Invalid protocol: '${this.url.protocol}'`) + } + const agentOptions = Object.assign({}, { keepAlive: true, keepAliveMsecs: 1000,