Skip to content

Commit

Permalink
Merge branch 'master' into chore/update-workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
jirimoravcik committed Sep 12, 2024
2 parents 9f4023d + 1bf7809 commit 2ce7f2c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
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
7 changes: 6 additions & 1 deletion test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ To run the tests, you need to add the following line to your `/etc/hosts`:

```
# Used by proxy-chain NPM package tests
127.0.0.1 localhost
127.0.0.1 localhost-test
```

This is a workaround to PhantomJS' behavior where it skips proxy servers for localhost addresses.
The `localhost` entry is for avoiding dual-stack issues, e.g. when the test server listens at ::1
(results of getaddrinfo have specifed order) and the client attempts to connect to 127.0.0.1 .

The `localhost-test` entry is a workaround to PhantomJS' behavior where it skips proxy servers for
localhost addresses.
7 changes: 6 additions & 1 deletion test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,12 @@ const createTestSuite = ({
// For SSL, we need to return curl's stderr to check what kind of error was there
const output = await curlGet(curlUrl, `http://bad:[email protected]:${mainProxyServerPort}`, !useSsl);
if (useSsl) {
expect(output).to.contain('Received HTTP code 407 from proxy after CONNECT');
expect(output).to.contain.oneOf([
// Old error message before dafdb20a26d0c890e83dea61a104b75408481ebd
'Received HTTP code 407 from proxy after CONNECT',
// and that after
'CONNECT tunnel failed, response 407',
]);
} else {
expect(output).to.contain('Proxy credentials required');
}
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 2ce7f2c

Please sign in to comment.