Now onto the real purpose of this post...
On a Window's platform it's pretty easy to get the system's proxy settings (which are also the IE proxy settings). You can use either WinHttpGetIEProxyForCurrentUser() or InternetOpen() from C/C++ - which is a good language choice for a Plugin.
An example of WinHttpGetIEProxyForCurrentUser() is located here: http://stackoverflow.com/questions/202547
An example of InternetOpen() is located here: http://support.microsoft.com/kb/226473
These are not good options for most browsers, such as those based on Mozilla. Instead other APIs are required such as NPAPI or XPCOM.
The current preference is NPAPI, with updates to this API as recently as early '09. It includes new options to remove dependency on browser specific XPCOM APIs (more on that in a second). To cut to the chase, the new API is NPN_GetValueForURL() (in npapi.h). Use this with the NPNURLVariable parameter set to NPNURLVProxy. An example of using this API for Cookies is here: http://forums.mozillazine.org/viewtopic.php?f=27&t=1233835
According to this post (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6796470), the NPAPI enhancements are available as far back as Firefox 3.1.
As for the XPCOM API, it was provided by Firefox to provide more access than available through the initial versions of NPAPI (https://developer.mozilla.org/En/XPCOM_API_Reference). However, it was browser specific, and only available in Firefox. According to this post, it is deprecated following Firefox 3.6: https://lists.ximiam.com/pipermail/moonlight-list/2009-October/000628.html
The XPCOM API provides a set of nsIProtocolProxyService APIs (https://developer.mozilla.org/en/NsIProtocolProxyService). These provide access to a number of browser proxy settings. Here's an example of using the XPCOM API from both C++ and a script: https://developer.mozilla.org/en/Creating_XPCOM_Components/Using_XPCOM_Components#Finding_Mozilla_Components
Note that both the NPAPI and XPCOM APIs provide info about the resolved proxy settings. This means that if Automatic proxy settings are used, the values returned via these APIs are the actual proxy server, rather than a link to a PAC file.
No comments:
Post a Comment