Skip to content

Commit

Permalink
fix: decode username and password for socks tunnel (#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
jirimoravcik authored Aug 21, 2024
1 parent c46eafd commit b326f95
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
4 changes: 2 additions & 2 deletions src/chain_socks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions test/socks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
};
},
});
Expand All @@ -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) => {
Expand Down

0 comments on commit b326f95

Please sign in to comment.