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

@applitools/eg-socks5-proxy-server

Package Overview
Dependencies
Maintainers
30
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@applitools/eg-socks5-proxy-server - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

2

package.json
{
"name": "@applitools/eg-socks5-proxy-server",
"version": "0.1.4",
"version": "0.1.5",
"description": "",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -26,8 +26,21 @@ const net = require('net')

destination.write(clientHandshakeBuffer, () => {
let isTimeoutCalled = false
const handshakeTimeout = setTimeout(()=> {
proxyServer.onHandshakeTimeout()
isTimeoutCalled = true
}, 10000)
destination.once('data', () => {
destination.write(args.requestBuffer, () => {
destination.pipe(originalSocket)
originalSocket.pipe(destination)
})
proxyServer.onHandShakeCompleted && proxyServer.onHandShakeCompleted()
clearTimeout(handshakeTimeout)
if (!isTimeoutCalled){
destination.write(args.requestBuffer, () => {
destination.pipe(originalSocket)
originalSocket.pipe(destination)
})
proxyServer.onHandShakeCompleted && proxyServer.onHandShakeCompleted()
}
else{
destination.destroy()
}
})

@@ -34,0 +47,0 @@ })

@@ -33,3 +33,5 @@ const {

REMOTE_PROXY_HANDSHAKE_COMPLETED: 'remote-proxy-handshake-completed',
REMOTE_PROXY_HANDSHAKE_TIMEOUT: 'remote-proxy-handshake-timeout',
ORIGIN_SOCKET_ERROR: 'orgin-socket-error',

@@ -264,2 +266,4 @@ REMOTE_SOCKET_ERROR: 'remote-socket-error',

let createExecuterAndRegisterToEvents
if (proxyServer){

@@ -269,2 +273,7 @@ proxyServer.onHandShakeCompleted = () => {

}
proxyServer.onHandshakeTimeout = () => {
self.server.emit(EVENTS.REMOTE_PROXY_HANDSHAKE_TIMEOUT, {originInfo, destinationInfo, proxyServer})
createExecuterAndRegisterToEvents()
}
}

@@ -277,72 +286,76 @@

})
let connectionTimeout = setTimeout(
() =>
self.server.emit(EVENTS.REMOTE_CONNECTION_TIMEOUT_ERROR, {
createExecuterAndRegisterToEvents = () => {
let connectionTimeout = setTimeout(
() =>
self.server.emit(EVENTS.REMOTE_CONNECTION_TIMEOUT_ERROR, {
originInfo,
destinationInfo,
proxyServer,
}),
120000,
)
const clearConnectionTimeout = () => {
connectionTimeout && clearTimeout(connectionTimeout)
connectionTimeout = null
}
let destination = createRequestExecuter({
originalSocket: socket,
clientHandshakeBuffer,
proxyServer,
args,
})
self.destinationSockets.push(socket)
destination.on('connect', () => {
connectionFilterDomain.exit()
clearConnectionTimeout()
// close destination socket when after original socket was closed
socket.on('close', () => {
destination.destroy()
self.destinationSockets.splice(self.destinationSockets.indexOf(socket), 1)
})
const event = proxyServer
? EVENTS.CONNECTED_TO_REMOTE_PROXY
: EVENTS.CONNECTED_TO_REMOTE_ADDRESS
self.server.emit(event, {destinationInfo, originInfo, proxyServer})
})
destination.on('error', (err) => {
// exit the connection filter domain
connectionFilterDomain.exit()
clearConnectionTimeout()
// notify of connection error
err.addr = args.dst.addr
err.atyp = args.atyp
err.port = args.dst.port
self.server.emit(EVENTS.REMOTE_SOCKET_ERROR, {
err,
destination,
args,
originInfo,
destinationInfo,
proxyServer,
}),
120000,
)
const clearConnectionTimeout = () => {
connectionTimeout && clearTimeout(connectionTimeout)
connectionTimeout = null
})
if (err.code && err.code === 'EADDRNOTAVAIL') {
return end(RFC_1928_REPLIES.HOST_UNREACHABLE, args)
}
if (err.code && err.code === 'ECONNREFUSED') {
return end(RFC_1928_REPLIES.CONNECTION_REFUSED, args)
}
return end(RFC_1928_REPLIES.NETWORK_UNREACHABLE, args)
})
}
let destination = createRequestExecuter({
originalSocket: socket,
clientHandshakeBuffer,
proxyServer,
args,
})
self.destinationSockets.push(socket)
destination.on('connect', () => {
connectionFilterDomain.exit()
clearConnectionTimeout()
// close destination socket when after original socket was closed
socket.on('close', () => {
destination.destroy()
self.destinationSockets.splice(self.destinationSockets.indexOf(socket), 1)
})
const event = proxyServer
? EVENTS.CONNECTED_TO_REMOTE_PROXY
: EVENTS.CONNECTED_TO_REMOTE_ADDRESS
self.server.emit(event, {destinationInfo, originInfo, proxyServer})
})
destination.on('error', (err) => {
// exit the connection filter domain
connectionFilterDomain.exit()
clearConnectionTimeout()
// notify of connection error
err.addr = args.dst.addr
err.atyp = args.atyp
err.port = args.dst.port
self.server.emit(EVENTS.REMOTE_SOCKET_ERROR, {
err,
destination,
args,
originInfo,
destinationInfo,
proxyServer,
})
if (err.code && err.code === 'EADDRNOTAVAIL') {
return end(RFC_1928_REPLIES.HOST_UNREACHABLE, args)
}
if (err.code && err.code === 'ECONNREFUSED') {
return end(RFC_1928_REPLIES.CONNECTION_REFUSED, args)
}
return end(RFC_1928_REPLIES.NETWORK_UNREACHABLE, args)
})
createExecuterAndRegisterToEvents()
}),

@@ -349,0 +362,0 @@ )

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