First of all I'll explain why I have a problem with proxies. When I'm working at home I could use the ISP's proxyserver but I don't need to. When I'm working at the office I MUST use a proxyserver, but which one depends on the location. Fortunatley my company provides an autoproxy configuration script. When I'm working on a customer's LAN it all depends. Some do not allow Internet access, other don't need proxy servers, some have a fixed proxyserver and only a few use autoconfig scripts.
The problem I'm facing now is that I don't have a solution for all situations.
I've been looking at how urllib.py determines which proxy server it should use for which protocol, and I can't say I'm happy about it. The getproxies function first looks if there are environment variables of the form protocol_proxy (e.g. http_proxy) and uses those if found.
If not, it looks in the Windows registry (HKCUSoftwareMicrosoftWindowsCurrentVersionInternet Settings) for ProxyEnable and ProxyServer.
Because I'm running PyDS as a service (as LocalSystem) (thanks to Georg) now, I not even sure which user is used in the registry (certainly not myself). I could run the service under my own accoutn and have that problem solved, but then I shouldn't forget to go and change the password for the service each time I renew mine.
The environment variables are problematic too because Localsystem only sees changes at the next reboot. Changing to my useraccount would mean that I would need to restart the service every time the proxy settings change.
So, suppose I change the sevice account for PyDS into mine, I would still have a problem because in some of the situations I'd have to use a autoproxy configscript in which case I'd have to clear the ProxyEnable registry setting. I'll have to think about this one.
I change networks at least 3 times a day when working and I almost never reboot my laptop. This brings me to the next challenge: changing the proxy settings automagically.
Now, that shouldn't be too hard. I can create a configuration table containing the correct proxy settings for each network I'm on ( combination of IP-range and domainname). I could write a PyDS-tool that checks the network every minute (shoudn't be that hard) and then changes the proxy settings according to the network I'm on at that moment.
|