Comments (9)
I think I was right. If I explicitly set the hinternet
to c_void_p
it works for us, too:
diff --git a/px.py b/px.py
index 25a4e56..62587af 100644
--- a/px.py
+++ b/px.py
@@ -922,6 +922,7 @@ WINHTTP_ACCESS_TYPE_NAMED_PROXY = 3
WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY = 4
def winhttp_find_proxy_for_url(url, autodetect=False, pac_url=None, autologon=True):
+ ctypes.windll.winhttp.WinHttpOpen.restype = ctypes.c_void_p
hInternet = ctypes.windll.winhttp.WinHttpOpen(
ctypes.wintypes.LPCWSTR("Px"),
WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY, WINHTTP_NO_PROXY_NAME,
@@ -945,6 +946,7 @@ def winhttp_find_proxy_for_url(url, autodetect=False, pac_url=None, autologon=Tr
proxy_info = WINHTTP_PROXY_INFO()
+ ctypes.windll.winhttp.WinHttpGetProxyForUrl.argtypes = [ctypes.c_void_p, ctypes.wintypes.LPCWSTR, ctypes.POINTER(WINHTTP_AUTOPROXY_OPTIONS), ctypes.POINTER(WINHTTP_PROXY_INFO)]
ok = ctypes.windll.winhttp.WinHttpGetProxyForUrl(hInternet, ctypes.wintypes.LPCWSTR(url),
ctypes.byref(autoproxy_options), ctypes.byref(proxy_info))
if not ok:
I testet it on 64 Bit Windows 7 and Windows 10 with Python 3.6.3 and 3.6.5. Anyone with a 32 Bit machine and/or an older Python version around to test this?
from px.
What does the actual PAC file look like? Does it actually return a proxy string for that host?
It might be worth trying with pypac and seeing what it thinks the proxy string is.
from px.
So just to clarify, WPAD = discovery using DNS/DHCP. It looks like you have set AutoConfigURL = PAC mode and not WPAD.
That being said, can you also verify that IE is able to use this PAC file and resolve correctly?
from px.
I have the same error on Windows 7. Pinned it to the usage of WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY which is only supported on Windows 8.1 and newer.
from px.
Too be honest, I'm not sure where PAC starts and WPAD ends (cp. https://en.wikipedia.org/wiki/Web_Proxy_Auto-Discovery_Protocol), so maybe my wording was a little bit inaccurate.
But IE works without problems and the PAC file is valid. It should return "PROXY proxy.rwe.com:8080"
.
As we are using Win10, WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY should work for us. I changed to the deprecated version WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, but WinHttpGetProxyForUrl() still gives me the same ERROR_INVALID_HANDLE (6).
I've still no idea, what handle this error code is referring to. :-(
from px.
I tried an older version of px (2018-03-03) and pypac seems to work correctly:
MainProcess: Thread_0: 1525689668: do_CONNECT: Entering
MainProcess: Thread_0: 1525689668: do_transaction: Entering
MainProcess: Thread_0: 1525689668: get_destination: chocolatey.org:443
MainProcess: Thread_0: 1525689668: load_proxy: Skip proxy refresh
MainProcess: Thread_0: 1525689668: find_proxy_for_url: pypac = [('proxy.rwe.com', 8080)] -1
MainProcess: Thread_0: 1525689668: get_destination: Proxy from PAC = [('proxy.rwe.com', 8080)]
MainProcess: Thread_0: 1525689668: do_socket_connect: New connection: ('proxy.rwe.com', 8080)
MainProcess: Thread_0: 1525689668: do_proxy_type: Searching proxy type
MainProcess: Thread_0: 1525689668: do_socket: Entering
from px.
Maybe I found something related:
https://stackoverflow.com/questions/45783063/obtaining-windows-service-handle-in-python
Summary: Python 3.6 has some problems with 32/64 Bit Pointers which might lead to problems with ctypes and Win32-APIs on 64 Bit machines.
No idea if this can be fixed, maybe this is not related at all!?
from px.
I've implemented your fix in the latest release, please verify and close. Thank you!
from px.
The new version works for us. Tested on W7 and W10. Thanks!!
from px.
Related Issues (20)
- PAC file encoding HOT 11
- IPv6 connect support HOT 2
- have an option to launch in the background HOT 1
- px status command HOT 3
- Px related issues when other applocations make localhost request HOT 2
- hostonly and WSL2 HOT 7
- `curl: (56) Proxy CONNECT aborted` error with px 0.8 when using curl.exe HOT 7
- 'Requires libcurl' when using 'tools.py --libcurl' HOT 1
- Installing fails with: Invalid numerical argument /Werror=incompatible-pointer-types. HOT 1
- px.exe 18 security vendors and no sandboxes flagged this file as malicious HOT 25
- Support for macOS Ventura 13.4? HOT 4
- Spaces in PAC proxy list cause blank proxies to be added HOT 2
- Is there a way to restart the proxy (Windows)? HOT 7
- Windows Defender "Threat Found" display HOT 4
- keyring_jeepney broken HOT 2
- Support for keyrings.cryptfile HOT 4
- Logging Directory <> Working Directory HOT 4
- Win11 - The publisher could not be verified HOT 1
- Does this tool support Kerberos authentication to a corporate Web proxy ? HOT 1
- Timeout and connection reset HOT 2
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 px.