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.2.0-debug-5 to 0.2.0-debug-6

2

package.json
{
"name": "@applitools/eg-socks5-proxy-server",
"version": "0.2.0-debug-5",
"version": "0.2.0-debug-6",
"description": "",

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

@@ -5,73 +5,73 @@ const binary = require('binary')

const {
RFC_1928_ATYP,
RFC_1928_COMMANDS,
RFC_1928_METHODS,
RFC_1928_REPLIES,
RFC_1928_VERSION,
RFC_1929_REPLIES,
RFC_1929_VERSION,
RFC_1928_ATYP,
RFC_1928_COMMANDS,
RFC_1928_METHODS,
RFC_1928_REPLIES,
RFC_1928_VERSION,
RFC_1929_REPLIES,
RFC_1929_VERSION,
} = require('./constants')
module.exports = {authenticate}
/**
* +----+------+----------+------+----------+
* |VER | ULEN | UNAME | PLEN | PASSWD |
* +----+------+----------+------+----------+
* | 1 | 1 | 1 to 255 | 1 | 1 to 255 |
* +----+------+----------+------+----------+
*
*
* @param {Buffer} buffer - a buffer
* @returns {undefined}
**/
function authenticate({socket, buffer, options, connect, end, onAuthenticated, onFailed}) {
let authDomain = domain.create()
* +----+------+----------+------+----------+
* |VER | ULEN | UNAME | PLEN | PASSWD |
* +----+------+----------+------+----------+
* | 1 | 1 | 1 to 255 | 1 | 1 to 255 |
* +----+------+----------+------+----------+
*
*
* @param {Buffer} buffer - a buffer
* @returns {undefined}
**/
function authenticate({socket, buffer, options, connect, end, onAuthenticated, onFailed}) {
let authDomain = domain.create()
binary
.stream(buffer)
.word8('ver')
.word8('ulen')
.buffer('uname', 'ulen')
.word8('plen')
.buffer('passwd', 'plen')
.tap((args) => {
// capture the raw buffer
args.requestBuffer = buffer
binary
.stream(buffer)
.word8('ver')
.word8('ulen')
.buffer('uname', 'ulen')
.word8('plen')
.buffer('passwd', 'plen')
.tap((args) => {
// capture the raw buffer
args.requestBuffer = buffer
// verify version is appropriate
if (args.ver !== RFC_1929_VERSION) {
return end(RFC_1929_REPLIES.GENERAL_FAILURE, args)
}
// verify version is appropriate
if (args.ver !== RFC_1929_VERSION) {
return end(RFC_1929_REPLIES.GENERAL_FAILURE, args)
}
authDomain.on('error', (err) => {
// emit failed authentication event
onFailed(args, err)
authDomain.on('error', (err) => {
// emit failed authentication event
onFailed(args, err)
// respond with auth failure
return end(RFC_1929_REPLIES.GENERAL_FAILURE, args)
})
// respond with auth failure
return end(RFC_1929_REPLIES.GENERAL_FAILURE, args)
})
// perform authentication
options.authenticate(
args.uname.toString(),
args.passwd.toString(),
socket,
authDomain.intercept(() => {
// emit successful authentication event
onAuthenticated(args)
// perform authentication
options.authenticate(
args.uname.toString(),
args.passwd.toString(),
socket,
authDomain.intercept(() => {
// emit successful authentication event
onAuthenticated(args)
// respond with success...
let responseBuffer = Buffer.allocUnsafe(2)
responseBuffer[0] = RFC_1929_VERSION
responseBuffer[1] = RFC_1929_REPLIES.SUCCEEDED
// respond with success...
let responseBuffer = Buffer.allocUnsafe(2)
responseBuffer[0] = RFC_1929_VERSION
responseBuffer[1] = RFC_1929_REPLIES.SUCCEEDED
// respond then listen for cmd and dst info
socket.write(responseBuffer, () => {
// now listen for more details
socket.once('data', connect)
})
}),
)
})
}
// respond then listen for cmd and dst info
socket.write(responseBuffer, () => {
// now listen for more details
socket.once('data', connect)
})
}),
)
})
}

@@ -45,3 +45,3 @@ const net = require('net')

const dataTimeoutId2 = setTimeout(() => {
destination.destroy()
//destination.destroy()
end(originalSocket, RFC_1928_REPLIES.NETWORK_UNREACHABLE, args)

@@ -54,5 +54,9 @@ proxyServer.onOriginDataTimeout()

destination.pipe(originalSocket)
destination.write(args.requestBuffer, () => {
originalSocket.pipe(destination)
destination.once('data', (data) => {
originalSocket.write(data, () => {
originalSocket.pipe(destination)
destination.pipe(originalSocket)
})
})
})

@@ -59,0 +63,0 @@

const binary = require('binary')
const {
RFC_1928_METHODS,
RFC_1928_REPLIES,
RFC_1928_VERSION,
} = require('./constants')
const {RFC_1928_METHODS, RFC_1928_REPLIES, RFC_1928_VERSION} = require('./constants')
module.exports = {handshake}
module.exports = {handshake}

@@ -20,62 +16,61 @@ /**

* @param {Buffer} buffer - a buffer
* @param {any} options
* @param {Function} connet
* @param {any} options
* @param {Function} connet
* @param {Function} authenticate
* @param {Function} end
* @param {Function} end
* @param {Function} onHandShakeCompleted
*
*
* @returns {undefined}
**/
**/
function handshake({socket, buffer, options, connect, authenticate, end, onHandshakeCompleted}) {
clientHandshakeBuffer = buffer
binary
.stream(buffer)
.word8('ver')
.word8('nmethods')
.buffer('methods', 'nmethods')
.tap((args) => {
// verify version is appropriate
if (args.ver !== RFC_1928_VERSION) {
return end(RFC_1928_REPLIES.GENERAL_FAILURE, args)
}
const clientHandshakeBuffer = buffer
binary
.stream(buffer)
.word8('ver')
.word8('nmethods')
.buffer('methods', 'nmethods')
.tap((args) => {
// verify version is appropriate
if (args.ver !== RFC_1928_VERSION) {
return end(RFC_1928_REPLIES.GENERAL_FAILURE, args)
}
// convert methods buffer to an array
let acceptedMethods = [].slice.call(args.methods).reduce((methods, method) => {
methods[method] = true
return methods
}, {}),
basicAuth = typeof options.authenticate === 'function',
next = connect,
noAuth =
!basicAuth && typeof acceptedMethods[0] !== 'undefined' && acceptedMethods[0],
responseBuffer = Buffer.allocUnsafe(2)
// convert methods buffer to an array
let acceptedMethods = [].slice.call(args.methods).reduce((methods, method) => {
methods[method] = true
return methods
}, {}),
basicAuth = typeof options.authenticate === 'function',
next = connect,
noAuth = !basicAuth && typeof acceptedMethods[0] !== 'undefined' && acceptedMethods[0],
responseBuffer = Buffer.allocUnsafe(2)
// form response Buffer
responseBuffer[0] = RFC_1928_VERSION
responseBuffer[1] = RFC_1928_METHODS.NO_AUTHENTICATION_REQUIRED
// form response Buffer
responseBuffer[0] = RFC_1928_VERSION
responseBuffer[1] = RFC_1928_METHODS.NO_AUTHENTICATION_REQUIRED
// check for basic auth configuration
if (basicAuth) {
responseBuffer[1] = RFC_1928_METHODS.BASIC_AUTHENTICATION
next = authenticate
// check for basic auth configuration
if (basicAuth) {
responseBuffer[1] = RFC_1928_METHODS.BASIC_AUTHENTICATION
next = authenticate
// if NO AUTHENTICATION REQUIRED and
} else if (!basicAuth && noAuth) {
responseBuffer[1] = RFC_1928_METHODS.NO_AUTHENTICATION_REQUIRED
next = connect
// if NO AUTHENTICATION REQUIRED and
} else if (!basicAuth && noAuth) {
responseBuffer[1] = RFC_1928_METHODS.NO_AUTHENTICATION_REQUIRED
next = connect
// basic auth callback not provided and no auth is not supported
} else {
return end(RFC_1928_METHODS.NO_ACCEPTABLE_METHODS, args)
}
// basic auth callback not provided and no auth is not supported
} else {
return end(RFC_1928_METHODS.NO_ACCEPTABLE_METHODS, args)
}
// respond then listen for cmd and dst info
socket.write(responseBuffer, () => {
// emit handshake event
socket.once('data', next)
onHandshakeCompleted && onHandshakeCompleted(clientHandshakeBuffer)
// now listen for more details
})
// respond then listen for cmd and dst info
socket.write(responseBuffer, () => {
// emit handshake event
socket.once('data', next)
onHandshakeCompleted && onHandshakeCompleted(clientHandshakeBuffer)
// now listen for more details
})
}
})
}
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