MarkusBernhardt / proxy-vole

Proxy Vole is a Java library to auto detect the platform network proxy settings.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Native ProxySelector for Windows platform

phansson opened this issue · comments

More options exist these days in Windows API than when proxy-vole was first conceived.

I'm wondering whether the time has come to have an additional ProxySelector which outsource everything to Windows. Currently proxy config auto detection is outsourced on Windows, but proxy resolution is not, but it could be, because WinHTTP API now has functions for this. So, you can imagine a ProxySelector in proxy-vole which does just that. Such a ProxySelector would constantly call Windows to figure out which proxy to call for a given http/https request.

I would name it something like WindowsNativeProxySelector. Unlike the other ProxySelectors in the proxy-vole lib this new ProxySelector wouldn't actually need to know anything about settings, nor would it need to download PAC or even to evaluate it for each URL. In the crucial select() method it would simply ask Windows for the answer. It would essentially be a black box.

The (small) downside of such a ProxySelector is that it would need to cross the java<-->native barrier for every call to the ProxySelector. Since we're basing ourselves on JNA (not JNI) then this may not be as quick as we would like. Dunno. Perhaps a non-issue?

The upside is that it would get rid of the nightmare of figuring out what the current settings in registry are, how to locate PAC file, how to download it (including if downloading requires silent auth) and how to evaluate it in a Javascript parser. Use of this ProxySelector would pretty much guarantee the same user experience as those applications developed by Microsoft, e.g. later version of Microsoft IE and Microsoft Edge in particular.

I'm logging my thoughts here to collect input on the idea ... before I move to hacking it up and creating a pull request.

I like this idea. I don't know how fast the JNA will be, but with as complicated as the Windows proxy settings are, this search strategy sounds worth it to me.

Did you ever do this? It'd be great.