Socket
Socket
Sign inDemoInstall

elasticsearch-aws-tunneling

Package Overview
Dependencies
35
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0-alpha.27 to 1.0.0-alpha.28

19

clients/elasticsearch.local.client.js

@@ -5,2 +5,3 @@ 'use strict'

const JOI = require('joi')
const HTTPError = require('node-http-error')
const DEBUG = require('debug')('elasticsearch-aws-tunneling.local')

@@ -15,2 +16,4 @@

DEBUG('Connecting to local Elasticsearch.')
const optionsValidation = JOI

@@ -25,3 +28,3 @@ .object()

.validate(options, { allowUnknown: true })
if (optionsValidation.error) return Promise.reject(optionsValidation.error)
if (optionsValidation.error) throw optionsValidation.error

@@ -37,3 +40,15 @@ /**

return new Client(options)
try {
const client = new Client(elasticsearchOptions)
return Promise.resolve({
message: 'Connected to local Elasticsearch.',
client: client,
})
} catch (error) {
return Promise.reject(
new HTTPError(500, 'Error. Could not connect to local Elasticsearch.', { error, elasticsearchOptions })
)
}
}

@@ -40,0 +55,0 @@

48

clients/elasticsearch.remote.client.js

@@ -7,2 +7,3 @@ 'use strict'

const JOI = require('joi')
const HTTPError = require('node-http-error')
const DEBUG = require('debug')('elasticsearch-aws-tunneling.remote')

@@ -18,2 +19,4 @@

DEBUG('Connecting to remote Elasticsearch.')
const optionsValidation = JOI

@@ -35,9 +38,7 @@ .object()

.validate(options)
if (optionsValidation.error) return Promise.reject(optionsValidation.error)
if (optionsValidation.error) throw optionsValidation.error
const client = options.makeTunnel
return options.makeTunnel
? await _connectThroughSSHTunnel(options)
: _connect(options)
return Promise.resolve(client)
}

@@ -52,2 +53,4 @@

DEBUG('Client is outside VPC, connecting to cluster through SSH tunnel.')
/**

@@ -67,3 +70,5 @@ * @type {import 'tunnel-ssh'.Config}

.catch(err => err)
if (tunnel instanceof Error) return Promise.reject(tunnel)
if (tunnel instanceof Error) return Promise.reject(
new HTTPError(500, 'Error. Could not create SSH tunnel.', { error: tunnel, options })
)

@@ -81,5 +86,14 @@ DEBUG(`Tunnel listening on port ${options.elasticsearchNodePort}.`)

return Promise.resolve(
new Client(elasticsearchOptions)
)
try {
const client = new Client(elasticsearchOptions)
return Promise.resolve({
message: 'Connected to remote Elasticsearch through our EC2 ssh tunnel.',
client: client,
})
} catch (error) {
return Promise.reject(
new HTTPError(500, 'Error. Could not connect to remote Elasticsearch through our EC2 ssh tunnel..', { error, elasticsearchOptions })
)
}
}

@@ -97,2 +111,4 @@

DEBUG('Client is inside VPC, connecting directly to cluster.')
/**

@@ -107,5 +123,15 @@ * @type {import '@elastic/elasticsearch'.ClientOptions} Elasticsearch client options.

return Promise.resolve(
new Client(elasticsearchOptions)
)
try {
const client = new Client(elasticsearchOptions)
return Promise.resolve({
message: 'Connected to remote Elasticsearch.',
client: client,
})
} catch (error) {
return Promise.reject(
new HTTPError(500, 'Error. Could not connect to remote Elasticsearch.', { error, elasticsearchOptions })
)
}
}

@@ -112,0 +138,0 @@

{
"name": "elasticsearch-aws-tunneling",
"version": "1.0.0-alpha.27",
"version": "1.0.0-alpha.28",
"description": "Elasticsearch wich allow SSH tunneling into a AWS Elasticsearch VPC by going through a EC2 instance hosted in the same VPC.",

@@ -23,5 +23,6 @@ "main": "index.js",

"joi": "^14.3.1",
"node-http-error": "^2.0.0",
"tunnel-ssh": "^4.1.4"
},
"gitHead": "f7c6f435eff298d7c36e5846d7a3c4a58e649c0d"
"gitHead": "51f3c764dd07106c332ddf3084d0ad9dafd0c3a8"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc