Comments (14)
Oh right, now I understand. Let us look into it. CC @szmarczak
from proxy-chain.
So you'd like the anonymizeProxy
function to return a URL like http://localhost:8453
instead of the password-less http://myproxy.example.com
? Please can you explain why, what difference does it make to you?
from proxy-chain.
I using external free proxies without authorization - on tunnel, for example the browser loaded with proxy 127.0.0.1:8080 always and the tunnel changed on the fly...
from proxy-chain.
Hi Jan, do you have any updates?
from proxy-chain.
But why do you need the "anonymized" URL like http://127.0.0.1:8080
, why don't you use the target free proxy URL? It just works too, no?
from proxy-chain.
My need is to open a browser with http://127.0.0.1:8080 as a tunnel for switching proxies on the fly. When I want to use some proxy I use the proxy-chain that way I can switch between proxies as shown below:
import * as Puppeteer from 'puppeteer';
import * as proxyChain from 'proxy-chain';
let newProxyUrl = null;
let page = null;
(async () => {
const browser = await Puppeteer.launch({
headless: false,
args: [`--proxy-server=http://127.0.0.1:8080`], //the proxy is static, NOT CHANGED ANY MORE
});
page = await browser.newPage();
//first time set proxy
await switchProxy(
'http://username:passwored@proxyExample:port'
);
await page.goto('https://ifconfig.me/');
})();
async function switchProxy(proxy) {
console.log('switch IP to new one: ' + proxy);
if (newProxyUrl !== null)
await proxyChain.closeAnonymizedProxy(newProxyUrl, true);
newProxyUrl = await proxyChain.anonymizeProxy({ url: proxy, port: 8080 });
await page.goto('https://ifconfig.me/');
console.log(newProxyUrl);
}
function randomProxy() {
const proxyList = [
// example for proxy WITH username and password (works good)
'http://username:passwored@proxyExample:port',
// example for proxy WITHOUT username and password (throw exception)
'http://proxyExample:port',
];
switchProxy(proxyList[Math.floor(Math.random() * proxyList.length)]);
}
//this will change the proxy every minute
setInterval(randomProxy, 15000);
In the code example as shown above you can see that the tunnel is loaded only if I use proxy with username and password.
and that because the tunnel is not longer open and you return the proxy string as is (as it was provided, without processing the proxy tunnel).
from proxy-chain.
Perhaps we could add an option that would also anonymize password-less proxy URLs, but not sure whether it's not overkill, as the caller might decide this for themselves. "anonymization" might refer to also hiding proxy hostname and password, so logically this would be correct.
from proxy-chain.
Thanks you very much for the fast reply :)
We are looking for the solution for the detailed scenario.
Would love if you can update us for an estimation :)
from proxy-chain.
Hi @avihaizanaa! I believe that the best solution would be to use ProxyChain.Server
like so:
let upstreamProxyUrl = 'http://proxy.example.com:2222';
const switchProxy = proxy => {
upstreamProxyUrl = proxy;
// Force browsers to update the connections in order not to use the old proxy anymore
server.closeConnections();
};
const server = new ProxyChain.Server({
port: 8000,
prepareRequestFunction: () => {
return {
upstreamProxyUrl,
};
},
});
await server.listen();
This way you don't need to close & start the server over and over again.
from proxy-chain.
from proxy-chain.
@anton-lsports Can you explain your comment a bit more please? I'm confused.
from proxy-chain.
Hi @szmarczak,
We will test the solution you gave us, but in the mean time we would like if you can check the PR we send as a solution suggestion.
#296
thanks!
from proxy-chain.
Hello, can you further comment on the Pull Request? And also comment what forceTunnel
means in the code. Thanks
from proxy-chain.
Closing as @szmarczak's suggestion in #288 (comment) should be enough for this usecase.
from proxy-chain.
Related Issues (20)
- A lot of TCP connections HOT 5
- SOCKS5 support HOT 11
- Passing custom http agent on every prepareRequestFunction HOT 1
- Introduce command line interface to start a local proxy server connect to upstream HOT 2
- Issue with latest stable version 2.2.1 and README about customTag HOT 2
- Linux Mint: Invalid upstream proxy credentials HOT 1
- how can i get origin headers of http request HOT 1
- intercept local requests HOT 2
- Add suport for Bun runtime - Issue with `net.Socket.write` HOT 8
- proxy-chain and puppeteer in same process do not send username and password proxy-authorization HOT 1
- Consider binding HTTP server to a specific hostname HOT 1
- TimeoutError: Navigation timeout of 30000 ms exceeded HOT 9
- Proxy Authentication 407 HOT 3
- Proxy-chain never reconnect when get this error: "Failed to connect to upstream proxy: Error: socket hang up" HOT 5
- getting code 400 for upstream proxy HOT 1
- How do I self sign a request using my certs HOT 1
- Convert "GET" requests to "CONNECT"
- Proxy only certain requests HOT 1
- How to use dynamic upstream proxy pool?
- How to proxy HTTPS? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proxy-chain.