@applitools/eg-socks5-proxy-server
Advanced tools
Comparing version 0.4.6 to 0.5.0
@@ -5,7 +5,3 @@ export declare const AUTHENTICATION = "authenticate"; | ||
export declare const HANDSHAKE = "handshake"; | ||
export declare const PROXY_CONNECT = "proxyConnect"; | ||
export declare const PROXY_DATA = "proxyData"; | ||
export declare const PROXY_DISCONNECT = "proxyDisconnect"; | ||
export declare const PROXY_END = "proxyEnd"; | ||
export declare const PROXY_ERROR = "proxyError"; | ||
export declare const ACCEPT_NEW_REQUEST = "accept-new-request"; | ||
@@ -21,2 +17,3 @@ export declare const CONNECTED_TO_REMOTE_ADDRESS = "connected-to-remote-address"; | ||
export declare const REMOTE_CONNECTION_TIMEOUT_ERROR = "remote-connection-timeout-error"; | ||
export declare const PRIVATE_ADDRESS_WAS_BLOCKED = "private-address-was-blocked"; | ||
//# sourceMappingURL=events.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.REMOTE_CONNECTION_TIMEOUT_ERROR = exports.REMOTE_SOCKET_ERROR = exports.ORIGIN_SOCKET_ERROR = exports.REMOTE_PROXY_RFC_1928_REPLY = exports.REMOTE_PROXY_RFC_1928_REPLY_TIMEOUT = exports.REMOTE_PROXY_HANDSHAKE_TIMEOUT = exports.REMOTE_PROXY_HANDSHAKE_COMPLETED = exports.CONNECTED_TO_REMOTE_PROXY = exports.CONNECTED_TO_REMOTE_ADDRESS = exports.ACCEPT_NEW_REQUEST = exports.PROXY_ERROR = exports.PROXY_END = exports.PROXY_DISCONNECT = exports.PROXY_DATA = exports.PROXY_CONNECT = exports.HANDSHAKE = exports.CONNECTION_FILTER = exports.AUTHENTICATION_ERROR = exports.AUTHENTICATION = void 0; | ||
exports.PRIVATE_ADDRESS_WAS_BLOCKED = exports.REMOTE_CONNECTION_TIMEOUT_ERROR = exports.REMOTE_SOCKET_ERROR = exports.ORIGIN_SOCKET_ERROR = exports.REMOTE_PROXY_RFC_1928_REPLY = exports.REMOTE_PROXY_RFC_1928_REPLY_TIMEOUT = exports.REMOTE_PROXY_HANDSHAKE_TIMEOUT = exports.REMOTE_PROXY_HANDSHAKE_COMPLETED = exports.CONNECTED_TO_REMOTE_PROXY = exports.CONNECTED_TO_REMOTE_ADDRESS = exports.ACCEPT_NEW_REQUEST = exports.PROXY_END = exports.HANDSHAKE = exports.CONNECTION_FILTER = exports.AUTHENTICATION_ERROR = exports.AUTHENTICATION = void 0; | ||
exports.AUTHENTICATION = 'authenticate'; | ||
@@ -8,7 +8,3 @@ exports.AUTHENTICATION_ERROR = 'authenticateError'; | ||
exports.HANDSHAKE = 'handshake'; | ||
exports.PROXY_CONNECT = 'proxyConnect'; | ||
exports.PROXY_DATA = 'proxyData'; | ||
exports.PROXY_DISCONNECT = 'proxyDisconnect'; | ||
exports.PROXY_END = 'proxyEnd'; | ||
exports.PROXY_ERROR = 'proxyError'; | ||
exports.ACCEPT_NEW_REQUEST = 'accept-new-request'; | ||
@@ -24,2 +20,3 @@ exports.CONNECTED_TO_REMOTE_ADDRESS = 'connected-to-remote-address'; | ||
exports.REMOTE_CONNECTION_TIMEOUT_ERROR = 'remote-connection-timeout-error'; | ||
exports.PRIVATE_ADDRESS_WAS_BLOCKED = 'private-address-was-blocked'; | ||
//# sourceMappingURL=events.js.map |
@@ -25,2 +25,4 @@ /// <reference types="node" /> | ||
getProxyServers: () => import("../types/utils").ProxyPoolOptions | undefined; | ||
set shouldBlockPrivateAddresses(value: boolean); | ||
get shouldBlockPrivateAddresses(): boolean; | ||
} | ||
@@ -27,0 +29,0 @@ export declare function createSocks5ProxyServer(options?: Socks5ProxyOptions): SocksServer; |
@@ -40,2 +40,3 @@ "use strict"; | ||
const net_1 = __importDefault(require("net")); | ||
const private_ip_1 = __importDefault(require("private-ip")); | ||
const _alwaysTrue = (data) => true; | ||
@@ -151,2 +152,10 @@ /** | ||
}; | ||
if (self.options.shouldBlockPrivateAddresses && | ||
(0, private_ip_1.default)(destinationInfo.address)) { | ||
self.server.emit(EVENTS.PRIVATE_ADDRESS_WAS_BLOCKED, { | ||
destinationInfo, | ||
originInfo, | ||
}); | ||
return end(constants_1.RFC_1928_REPLIES.CONNECTION_NOT_ALLOWED, args); | ||
} | ||
let createExecuterAndRegisterToEvents = null; | ||
@@ -334,2 +343,8 @@ let proxyServer = undefined; | ||
} | ||
set shouldBlockPrivateAddresses(value) { | ||
this.options.shouldBlockPrivateAddresses = value; | ||
} | ||
get shouldBlockPrivateAddresses() { | ||
return !!this.options.shouldBlockPrivateAddresses; | ||
} | ||
} | ||
@@ -336,0 +351,0 @@ exports.SocksServer = SocksServer; |
{ | ||
"name": "@applitools/eg-socks5-proxy-server", | ||
"version": "0.4.6", | ||
"version": "0.5.0", | ||
"description": "", | ||
@@ -34,3 +34,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"binary": "^0.3.0" | ||
"binary": "^0.3.0", | ||
"private-ip": "^2.3.4" | ||
}, | ||
@@ -37,0 +38,0 @@ "devDependencies": { |
@@ -5,7 +5,3 @@ export const AUTHENTICATION = 'authenticate' | ||
export const HANDSHAKE = 'handshake' | ||
export const PROXY_CONNECT = 'proxyConnect' | ||
export const PROXY_DATA = 'proxyData' | ||
export const PROXY_DISCONNECT = 'proxyDisconnect' | ||
export const PROXY_END = 'proxyEnd' | ||
export const PROXY_ERROR = 'proxyError' | ||
@@ -22,1 +18,2 @@ export const ACCEPT_NEW_REQUEST = 'accept-new-request' | ||
export const REMOTE_CONNECTION_TIMEOUT_ERROR = 'remote-connection-timeout-error' | ||
export const PRIVATE_ADDRESS_WAS_BLOCKED = 'private-address-was-blocked' |
@@ -22,2 +22,3 @@ import { | ||
import net, {Socket} from 'net' | ||
import isIpPrivate from 'private-ip' | ||
@@ -144,3 +145,3 @@ import {ISocksServer, ProxyServers, SetProxyServerOptions, Socks5ProxyOptions} from '../types' | ||
const originInfo = { | ||
const originInfo: AddressInfo = { | ||
address: socket.remoteAddress, | ||
@@ -150,2 +151,13 @@ port: socket.remotePort, | ||
if ( | ||
self.options.shouldBlockPrivateAddresses && | ||
isIpPrivate(destinationInfo.address!) | ||
) { | ||
self.server.emit(EVENTS.PRIVATE_ADDRESS_WAS_BLOCKED, { | ||
destinationInfo, | ||
originInfo, | ||
}) | ||
return end(RFC_1928_REPLIES.CONNECTION_NOT_ALLOWED, args) | ||
} | ||
let createExecuterAndRegisterToEvents: any = null | ||
@@ -393,2 +405,10 @@ | ||
public getProxyServers = () => this.options.proxyServers | ||
public set shouldBlockPrivateAddresses(value: boolean) { | ||
this.options.shouldBlockPrivateAddresses = value | ||
} | ||
public get shouldBlockPrivateAddresses() { | ||
return !!this.options.shouldBlockPrivateAddresses | ||
} | ||
} | ||
@@ -395,0 +415,0 @@ |
@@ -26,2 +26,3 @@ import {Socket} from 'net' | ||
export interface FullSocks5ProxyOptions { | ||
shouldBlockPrivateAddresses: boolean | ||
proxyServer: SingleProxyOptions | ||
@@ -28,0 +29,0 @@ proxyServers: ProxyPoolOptions |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102225
1886
2
+ Addedprivate-ip@^2.3.4
+ Addedip-regex@4.3.0(transitive)
+ Addedipaddr.js@2.2.0(transitive)
+ Addedis-ip@3.1.0(transitive)
+ Addednetmask@2.0.2(transitive)
+ Addedprivate-ip@2.3.4(transitive)