emarock/proxy-pac-proxy

Does it support changing network connections

erenoglu opened this issue · 5 comments

Hi, I was wondering if proxy-pac-proxy supports changing environments.

For example, I will start proxy-pac-proxy with a PAC url, which will work while I'm at work.
But when I go home, how will it behave? In such case, does proxy-pac-proxy simply act as a forwarding proxy directly to the destination host without forwarding any traffic to an upstream proxy? (as none would be defined, since no PAC would be reachable when I'm at home).

I just checked it, it does not support. So I started the proxy-pac-proxy with the PAC url, it worked when I was in my corporate network. Once I changed network to one that does not need a proxy, proxy-pac-proxy stopped serving connections, my browser showed "ERR_TUNNEL_CONNECTION_FAILED" error.

Could this feature be added to dynamically adapt if the PAC file can't be reached anymore?

The URL of the .pac file is passed at start time via a CLI option or through an environment variable. Once the file is retrieved and parsed, it is not checked again, nor I think it should be. Detection of network and/or configuration changes is better handled at a different level; for example, on Mac platforms an Automator script could take care of restarting proxy-pac-proxy with the proper parameters whenever a network change occurs.

Thanks @emarock , I was hoping that once I start prox-pac-proxy, it would then run seamless regardless of network changes. Just like browsers who work with a PAC even if you change networks.
I am roaming between office & home, using proxy-pac-proxy with some linux apps which dont support PAC but have hard coded proxy address to proxy-pac-proxy. They stop working when I reach home.
So unless such feature could be added, it means I will need to restart the service somehow with different configuration file.
Hope it would support starting w/o pointing to any PAC.

Unfortunately PAC discovery could be quite intricate and is very platform-dependent, so it is kept out of scope for proxy-pac-proxy, but could be implemented quite easily on top of it for a scenario like yours (i.e. in a if-up.d script).

On a side note, is there any specific reason why you hardcoded the URL to the PAC file rather than setting it as a env variable (or a cli option in an alias, or something like that..)?

Actually I dont need PAC discovery. It's much more simpler:
A) If proxy-pac-proxy can't anymore reach destination proxy, it would try direct connection to requested host.
B) If the requested host is not reachable, then proxy-pac-proxy would try to read a PAC file.

In my scenairo, one of A or B would certainly work, and if both wont work, then it means I have another problem which I can configure proxy-pac-proxy to tackle with (ie a different network with a different PAC).

To answer your question, its simple to start the service from upstart deamon with a PAC url parameter than fiddling with Environment variables in service context (for me), but I guess I could also do that, it to set and unset a variable. In any case, I need to restart the service, and that is what I'm trying to avoid as it's difficult.

PS1. I alreayd have a semi-working model with stopping/starting with new config using tinyproxy.
PS2. I'm trying this on a Chromebook to help my linux apps connect to internet, no ifplugd here in sandard setup (but I did compile one for myself)