-
-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Provide manual PAC file in config #65
Comments
From what I've seen in the code, doesn't Px already support this? From lines 1329-1333 in px.py: if "file://" in State.pac:
host = State.config.get("proxy", "listen") or "localhost"
port = State.config.getint("proxy", "port")
pac = "http://%s:%d/PACFile.pac" % (host, port)
dprint("PAC URL is local: " + pac) |
That code is for handling local file paths entered into Internet Settings. My VPN would download the PAC and put that format in there. This works for browsers but not with WinHttp which Px uses to handle PAC files on Windows. The file:// format wasn't working so I had to host it within Px itself. It could be reused for this feature - put in a local path into Internet Settings. However, I think what @s-kocher wants is to bypass Internet Settings altogether although I am now wondering what the benefit would be. Regardless, once Px is ported to Linux, it might need something like this unless Linux has a standard way to define proxies with PAC files. |
May be my exact problem can help to understand the feature I requested : |
so yes @genotrance : bypass internet settings to load PAC file is a good summary of my need |
I'm also needing this on windows because for some reason winhttp doesn't read the URL of the PAC file in my windows internet settings. |
Thanks a lot 👍 , I will test it at my company soon |
def set_pac(pac):
if pac == "":
return
pacproxy = False
if pac.startswith("http"):
pacproxy = True
elif pac.startswith("file"):
pac = file_url_to_local_path(pac)
if os.path.exists(pac):
pacproxy = True
if pacproxy:
State.pac = pac
else:
pprint("Unsupported PAC location or file not found: %s" % pac)
sys.exit()
def file_url_to_local_path(file_url):
parts = urlparse.urlparse(file_url)
path = urlparse.unquote(parts.path)
if path.startswith('/') and not path.startswith('//'):
if len(parts.netloc) == 2 and parts.netloc[1] == ':':
return parts.netloc + path
return 'C:' + path
if len(path) > 2 and path[1] == ':':
return path
[proxy]
server =
pac = 'file://C:/Users/test/Network/pac.js'
listen = 127.0.0.1
port = 3128
gateway = 0
hostonly = 1
allow = *.*.*.*
useragent =
username =
auth =
[settings]
workers = 3
threads = 6
idle = 30
socktimeout = 20.0
proxyreload = 60
foreground = 0
log = 0
|
@lioux: you need to set |
From what I understand, actually PAC are only handled if used in the system Internet Settings and there is no way to use another PAC file.
It will be useful to be able to load a PAC from a local file or specific URL defined in configuration px.ini (and / or CLI parameter).
The text was updated successfully, but these errors were encountered: