GithubHelp home page GithubHelp logo

WPAD not working for us!? about px HOT 9 CLOSED

genotrance avatar genotrance commented on August 16, 2024
WPAD not working for us!?

from px.

Comments (9)

ccbur avatar ccbur commented on August 16, 2024 1

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.

genotrance avatar genotrance commented on August 16, 2024

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.

genotrance avatar genotrance commented on August 16, 2024

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.

awbrackm avatar awbrackm commented on August 16, 2024

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.

ccbur avatar ccbur commented on August 16, 2024

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.

ccbur avatar ccbur commented on August 16, 2024

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.

ccbur avatar ccbur commented on August 16, 2024

Maybe I found something related:

https://stackoverflow.com/questions/45783063/obtaining-windows-service-handle-in-python

asweigart/pyperclip#25

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.

genotrance avatar genotrance commented on August 16, 2024

I've implemented your fix in the latest release, please verify and close. Thank you!

from px.

ccbur avatar ccbur commented on August 16, 2024

The new version works for us. Tested on W7 and W10. Thanks!!

from px.

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.