From 38833321a5579a88af701153ef6b1af6683ea84f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Morav=C4=8D=C3=ADk?= Date: Wed, 21 Aug 2024 15:27:54 +0200 Subject: [PATCH 1/3] fix: decode username and password for socks tunnel --- src/chain_socks.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chain_socks.ts b/src/chain_socks.ts index 0bd0c436..2fe8a528 100644 --- a/src/chain_socks.ts +++ b/src/chain_socks.ts @@ -50,8 +50,8 @@ export const chainSocks = async ({ host: hostname, port: Number(port), type: socksProtocolToVersionNumber(handlerOpts.upstreamProxyUrlParsed.protocol), - userId: username, - password, + userId: decodeURIComponent(username), + password: decodeURIComponent(password), }; if (head && head.length > 0) { From 6b93e67c229f7c83e89c08609df460bbafd3da03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Morav=C4=8D=C3=ADk?= Date: Wed, 21 Aug 2024 15:31:35 +0200 Subject: [PATCH 2/3] add @ to test username to validate it works properly --- test/socks.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/socks.js b/test/socks.js index 26ed1049..831cfb0c 100644 --- a/test/socks.js +++ b/test/socks.js @@ -51,14 +51,14 @@ describe('SOCKS protocol', () => { }); socksServer.listen(socksPort, 'localhost'); socksServer.useAuth(socksv5.auth.UserPassword((user, password, cb) => { - cb(user === 'proxy-chain' && password === 'rules!'); + cb(user === 'proxy-ch@in' && password === 'rules!'); })); proxyServer = new ProxyChain.Server({ port: proxyPort, prepareRequestFunction() { return { - upstreamProxyUrl: `socks://proxy-chain:rules!@localhost:${socksPort}`, + upstreamProxyUrl: `socks://proxy-ch@in:rules!@localhost:${socksPort}`, }; }, }); @@ -81,10 +81,10 @@ describe('SOCKS protocol', () => { }); socksServer.listen(socksPort, 'localhost'); socksServer.useAuth(socksv5.auth.UserPassword((user, password, cb) => { - cb(user === 'proxy-chain' && password === 'rules!'); + cb(user === 'proxy-ch@in' && password === 'rules!'); })); - ProxyChain.anonymizeProxy({ port: proxyPort, url: `socks://proxy-chain:rules!@localhost:${socksPort}` }).then((anonymizedProxyUrl) => { + ProxyChain.anonymizeProxy({ port: proxyPort, url: `socks://proxy-ch@in:rules!@localhost:${socksPort}` }).then((anonymizedProxyUrl) => { anonymizeProxyUrl = anonymizedProxyUrl; gotScraping.get({ url: 'https://example.com', proxyUrl: anonymizedProxyUrl }) .then((response) => { From 822f7a16458b390cd06470be6312d76e8e91815a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Morav=C4=8D=C3=ADk?= Date: Wed, 21 Aug 2024 15:38:23 +0200 Subject: [PATCH 3/3] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1dbf15a7..ee47f92c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "proxy-chain", - "version": "2.5.2", + "version": "2.5.3", "description": "Node.js implementation of a proxy server (think Squid) with support for SSL, authentication, upstream proxy chaining, and protocol tunneling.", "main": "dist/index.js", "keywords": [