Giter Site home page Giter Site logo

Comments (14)

jancurn avatar jancurn commented on August 11, 2024 3

Oh right, now I understand. Let us look into it. CC @szmarczak

from proxy-chain.

jancurn avatar jancurn commented on August 11, 2024

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.

anton-lsports avatar anton-lsports commented on August 11, 2024

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.

anton-lsports avatar anton-lsports commented on August 11, 2024

Hi Jan, do you have any updates?

from proxy-chain.

jancurn avatar jancurn commented on August 11, 2024

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.

avihaizanaa avatar avihaizanaa commented on August 11, 2024

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.

jancurn avatar jancurn commented on August 11, 2024

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.

avihaizanaa avatar avihaizanaa commented on August 11, 2024

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.

szmarczak avatar szmarczak commented on August 11, 2024

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.

anton-lsports avatar anton-lsports commented on August 11, 2024

#296

from proxy-chain.

szmarczak avatar szmarczak commented on August 11, 2024

@anton-lsports Can you explain your comment a bit more please? I'm confused.

from proxy-chain.

avihaizanaa avatar avihaizanaa commented on August 11, 2024

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.

jirimoravcik avatar jirimoravcik commented on August 11, 2024

Hello, can you further comment on the Pull Request? And also comment what forceTunnel means in the code. Thanks

from proxy-chain.

fnesveda avatar fnesveda commented on August 11, 2024

Closing as @szmarczak's suggestion in #288 (comment) should be enough for this usecase.

from proxy-chain.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.