Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@applitools/execution-grid-tunnel

Package Overview
Dependencies
Maintainers
0
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@applitools/execution-grid-tunnel - npm Package Compare versions

Comparing version 3.0.6 to 3.0.7

2

package.json
{
"name": "@applitools/execution-grid-tunnel",
"version": "3.0.6",
"version": "3.0.7",
"description": "",

@@ -5,0 +5,0 @@ "main": "scripts/run-execution-grid-tunnel.js",

@@ -1,5 +0,4 @@

const tls = require('tls')
const net = require('net')
const { KeepaliveMessageFilter } = require('./keepalive-filter-message');
const {KeepaliveMessageFilter} = require('./keepalive-filter-message')

@@ -10,47 +9,61 @@ const ATTACHING_REQUEST = 'attaching-request'

class TunnelConnection {
constructor({keepAliveMessage, connectedMessage, logger, connectionId}){
constructor({keepAliveMessage, connectedMessage, logger, connectionId}) {
this._logger = logger
this._filter = new KeepaliveMessageFilter({ keepAliveMessage })
this._filter = new KeepaliveMessageFilter({keepAliveMessage})
this._connectedMessage = connectedMessage
this._filter.on('error', (error) => logger.warn({action: 'filter-error', error: error.stack || error.message}))
this._filter.on('error', (error) =>
logger.warn({action: 'filter-error', error: error.stack || error.message}),
)
this._connectionId = connectionId
}
connect({tunnelId, host, port, token, protocol = 'tcp', localProxyOptions}){
connect({tunnelId, host, port, token, protocol = 'tcp', localProxyOptions}) {
return new Promise((resolve, reject) => {
let isResolved = false
this._logger.debug({action: 'connection-info', connectionId: this._connectionId, port, host, token, protocol})
const remoteConnection = protocol == 'tcp' ? net.connect(port,host): tls.connect(port, host)
this._logger.debug({
action: 'connection-info',
connectionId: this._connectionId,
port,
host,
token,
protocol,
})
const remoteConnection = protocol == 'tcp' ? net.connect(port, host) : tls.connect(port, host)
this._remoteConnection = remoteConnection
remoteConnection.once('connect', () => {
remoteConnection.write(JSON.stringify({tunnelId, token}))
remoteConnection.once('data', (chunk) => {
const result = chunk.toString()
if (result !== this._connectedMessage){
this._logger.warn({action: 'connection-refused', connectionId: this._connectionId, error: result})
const error = new Error(`Server Error: ${result}`)
return reject(error)
}
this._localConnection = net.connect(localProxyOptions)
this._localConnection = net.connect(localProxyOptions)
this._localConnection.on('error',
e => {
this._logger.warn({
action: 'local-connection-error',
connectionId: this._connectionId,
error: e.stack || e.message
})
})
this._localConnection.on('error', (e) => {
this._logger.warn({
action: 'local-connection-error',
connectionId: this._connectionId,
error: e.stack || e.message,
})
})
this._localConnection.once('connect', () => {
this._localConnection.on('end', () => {
this._logger.debug({
action: 'local-connection-end',
this._localConnection.once('connect', () => {
this._localConnection.on('end', () => {
this._logger.debug({
action: 'local-connection-end',
connectionId: this._connectionId,
tunnelId,
})
remoteConnection.end()
})
remoteConnection.write(JSON.stringify({tunnelId, token}))
remoteConnection.once('data', (chunk) => {
const result = chunk.toString()
if (result !== this._connectedMessage) {
this._logger.warn({
action: 'connection-refused',
connectionId: this._connectionId,
tunnelId
error: result,
})
remoteConnection.end()
})
const error = new Error(`Server Error: ${result}`)
this._localConnection.end()
return reject(error)
}
remoteConnection.pipe(this._filter).pipe(this._localConnection).pipe(remoteConnection)

@@ -63,7 +76,7 @@ isResolved = true

remoteConnection.on('error', e => {
remoteConnection.on('error', (e) => {
this._logger.warn({
action: 'remote-connection-error',
connectionId: this._connectionId,
error: e.stack || e.message
error: e.stack || e.message,
})

@@ -80,10 +93,10 @@

waitForAttachingRequest(){
waitForAttachingRequest() {
return this._filter.waitForChunk().then(() => ATTACHING_REQUEST)
}
waitForRemoteConnectionClosing(){
return new Promise(resolve => {
waitForRemoteConnectionClosing() {
return new Promise((resolve) => {
this._remoteConnection.once('end', () => {
resolve(CLOSING_CONNECTION)
resolve(CLOSING_CONNECTION)
})

@@ -93,22 +106,22 @@ })

end(){
if(!this._localConnection?.closed){
end() {
if (!this._localConnection?.closed) {
this._localConnection.end()
}
if(!this._remoteConnection.closed){
}
if (!this._remoteConnection.closed) {
this._remoteConnection.end()
}
}
}
destroy(){
if(!this._localConnection?.destroyed){
this._localConnection.destroy()
destroy() {
if (!this._localConnection?.destroyed) {
this._localConnection.destroy()
}
if(!this._remoteConnection.destroyed){
this._remoteConnection.destroy()
if (!this._remoteConnection.destroyed) {
this._remoteConnection.destroy()
}
}
}
}
module.exports = { TunnelConnection, ATTACHING_REQUEST, CLOSING_CONNECTION}
module.exports = {TunnelConnection, ATTACHING_REQUEST, CLOSING_CONNECTION}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc