Skip to content

Commit b326f95

Browse files
authored
fix: decode username and password for socks tunnel (#550)
1 parent c46eafd commit b326f95

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "proxy-chain",
3-
"version": "2.5.2",
3+
"version": "2.5.3",
44
"description": "Node.js implementation of a proxy server (think Squid) with support for SSL, authentication, upstream proxy chaining, and protocol tunneling.",
55
"main": "dist/index.js",
66
"keywords": [

src/chain_socks.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ export const chainSocks = async ({
5050
host: hostname,
5151
port: Number(port),
5252
type: socksProtocolToVersionNumber(handlerOpts.upstreamProxyUrlParsed.protocol),
53-
userId: username,
54-
password,
53+
userId: decodeURIComponent(username),
54+
password: decodeURIComponent(password),
5555
};
5656

5757
if (head && head.length > 0) {

test/socks.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ describe('SOCKS protocol', () => {
5151
});
5252
socksServer.listen(socksPort, 'localhost');
5353
socksServer.useAuth(socksv5.auth.UserPassword((user, password, cb) => {
54-
cb(user === 'proxy-chain' && password === 'rules!');
54+
cb(user === 'proxy-ch@in' && password === 'rules!');
5555
}));
5656

5757
proxyServer = new ProxyChain.Server({
5858
port: proxyPort,
5959
prepareRequestFunction() {
6060
return {
61-
upstreamProxyUrl: `socks://proxy-chain:rules!@localhost:${socksPort}`,
61+
upstreamProxyUrl: `socks://proxy-ch@in:rules!@localhost:${socksPort}`,
6262
};
6363
},
6464
});
@@ -81,10 +81,10 @@ describe('SOCKS protocol', () => {
8181
});
8282
socksServer.listen(socksPort, 'localhost');
8383
socksServer.useAuth(socksv5.auth.UserPassword((user, password, cb) => {
84-
cb(user === 'proxy-chain' && password === 'rules!');
84+
cb(user === 'proxy-ch@in' && password === 'rules!');
8585
}));
8686

87-
ProxyChain.anonymizeProxy({ port: proxyPort, url: `socks://proxy-chain:rules!@localhost:${socksPort}` }).then((anonymizedProxyUrl) => {
87+
ProxyChain.anonymizeProxy({ port: proxyPort, url: `socks://proxy-ch@in:rules!@localhost:${socksPort}` }).then((anonymizedProxyUrl) => {
8888
anonymizeProxyUrl = anonymizedProxyUrl;
8989
gotScraping.get({ url: 'https://example.com', proxyUrl: anonymizedProxyUrl })
9090
.then((response) => {

0 commit comments

Comments
 (0)