From e70ee5b59306ea37dd0c72603c61b33b1555def9 Mon Sep 17 00:00:00 2001 From: Björn Hagemeister Date: Tue, 11 Nov 2014 14:40:18 +0100 Subject: Added proxy java classes. --- doc/PacIPv6.txt | 6 + doc/changelog.txt | 56 + doc/internet_explorer_info.txt | 4 + doc/mac_osx.txt | 7 + doc/misc_links.txt | 5 + doc/pac_files_docu.html | 1182 ++++++++++++++++++++ misc/logo.png | Bin 0 -> 11923 bytes misc/logo.xcf | Bin 0 -> 26871 bytes misc/splash.xcf | Bin 0 -> 350958 bytes misc/stylesheet.css | 50 + pom.xml | 214 ++++ .../java/com/btr/proxy/search/ProxySearch.java | 258 +++++ .../com/btr/proxy/search/ProxySearchStrategy.java | 22 + .../browser/firefox/FirefoxProfileSource.java | 23 + .../firefox/FirefoxProxySearchStrategy.java | 267 +++++ .../browser/firefox/FirefoxSettingParser.java | 79 ++ .../browser/firefox/LinuxFirefoxProfileSource.java | 46 + .../browser/firefox/WinFirefoxProfileSource.java | 71 ++ .../search/browser/ie/IELocalByPassFilter.java | 28 + .../search/browser/ie/IEProxySearchStrategy.java | 213 ++++ .../search/desktop/DesktopProxySearchStrategy.java | 69 ++ .../desktop/gnome/GnomeProxySearchStrategy.java | 353 ++++++ .../desktop/gnome/ProxySchemasGSettingsAccess.java | 60 + .../search/desktop/kde/KdeProxySearchStrategy.java | 198 ++++ .../search/desktop/kde/KdeSettingsParser.java | 132 +++ .../search/desktop/osx/OsxProxySearchStrategy.java | 325 ++++++ .../btr/proxy/search/desktop/win/DLLManager.java | 171 +++ .../proxy/search/desktop/win/Win32IESettings.java | 68 ++ .../proxy/search/desktop/win/Win32ProxyUtils.java | 88 ++ .../search/desktop/win/WinProxySearchStrategy.java | 52 + .../proxy/search/env/EnvProxySearchStrategy.java | 130 +++ .../proxy/search/java/JavaProxySearchStrategy.java | 133 +++ .../proxy/search/wpad/WpadProxySearchStrategy.java | 234 ++++ .../wpad/WpadProxySearchStrategyWithDHPC.java | 315 ++++++ .../btr/proxy/search/wpad/dhcp/DHCPMessage.java | 880 +++++++++++++++ .../btr/proxy/search/wpad/dhcp/DHCPOptions.java | 235 ++++ .../com/btr/proxy/search/wpad/dhcp/DHCPSocket.java | 107 ++ .../btr/proxy/selector/direct/NoProxySelector.java | 70 ++ .../proxy/selector/fixed/FixedProxySelector.java | 69 ++ .../proxy/selector/fixed/FixedSocksSelector.java | 27 + .../proxy/selector/misc/BufferedProxySelector.java | 126 +++ .../selector/misc/ProtocolDispatchSelector.java | 115 ++ .../selector/misc/ProxyListFallbackSelector.java | 150 +++ .../proxy/selector/pac/JavaxPacScriptParser.java | 147 +++ .../btr/proxy/selector/pac/PacProxySelector.java | 184 +++ .../btr/proxy/selector/pac/PacScriptMethods.java | 656 +++++++++++ .../btr/proxy/selector/pac/PacScriptParser.java | 29 + .../btr/proxy/selector/pac/PacScriptSource.java | 31 + .../selector/pac/ProxyEvaluationException.java | 51 + .../proxy/selector/pac/RhinoPacScriptParser.java | 318 ++++++ .../btr/proxy/selector/pac/ScriptAvailability.java | 46 + .../com/btr/proxy/selector/pac/ScriptMethods.java | 256 +++++ .../btr/proxy/selector/pac/UrlPacScriptSource.java | 270 +++++ .../selector/whitelist/DefaultWhiteListParser.java | 78 ++ .../proxy/selector/whitelist/HostnameFilter.java | 93 ++ .../selector/whitelist/IPv4WithSubnetChecker.java | 29 + .../proxy/selector/whitelist/IpRangeFilter.java | 83 ++ .../whitelist/ProxyBypassListSelector.java | 84 ++ .../whitelist/UseProxyWhiteListSelector.java | 74 ++ .../proxy/selector/whitelist/WhiteListParser.java | 24 + src/main/java/com/btr/proxy/test/ProxyTester.java | 176 +++ .../java/com/btr/proxy/util/EmptyXMLResolver.java | 26 + src/main/java/com/btr/proxy/util/Logger.java | 87 ++ src/main/java/com/btr/proxy/util/PListParser.java | 544 +++++++++ src/main/java/com/btr/proxy/util/PlatformUtil.java | 114 ++ .../java/com/btr/proxy/util/ProxyException.java | 50 + src/main/java/com/btr/proxy/util/ProxyUtil.java | 84 ++ src/main/java/com/btr/proxy/util/UriFilter.java | 21 + src/main/resources/lib/gsettings-amd64.so | Bin 0 -> 11979 bytes src/main/resources/lib/gsettings-x86.so | Bin 0 -> 11822 bytes src/main/resources/lib/proxy_util_amd64.dll | Bin 0 -> 40448 bytes src/main/resources/lib/proxy_util_ia64.dll | Bin 0 -> 91136 bytes src/main/resources/lib/proxy_util_w32.dll | Bin 0 -> 43520 bytes src/test/java/com/btr/proxy/Examples.java | 47 + src/test/java/com/btr/proxy/TestUtil.java | 61 + .../com/btr/proxy/search/browser/FirefoxTest.java | 144 +++ .../java/com/btr/proxy/search/browser/IeTest.java | 59 + .../search/desktop/DesktopProxySearchTest.java | 45 + .../proxy/search/desktop/win/DLLManagerTest.java | 78 ++ .../proxy/search/gnome/GnomeProxySearchTest.java | 117 ++ .../btr/proxy/search/java/JavaProxySearchTest.java | 137 +++ .../btr/proxy/search/kde/KdeProxySearchTest.java | 177 +++ .../btr/proxy/selector/fixed/FixedProxyTest.java | 56 + .../proxy/selector/java/JavaProxySelectorTest.java | 28 + .../proxy/selector/misc/ProtocolDispatchTest.java | 87 ++ .../misc/ProxyListFallbackSelectorTest.java | 94 ++ .../selector/pac/JavaxPacScriptParserTest.java | 119 ++ .../btr/proxy/selector/pac/PacPerProtocolTest.java | 47 + .../btr/proxy/selector/pac/PacProxyDebugging.java | 103 ++ .../proxy/selector/pac/PacProxySelectorTest.java | 133 +++ .../proxy/selector/pac/PacScriptMethodsTest.java | 165 +++ .../selector/pac/RhinoPacScriptParserTest.java | 114 ++ .../proxy/selector/pac/UrlPacScriptSourceTest.java | 34 + .../btr/proxy/selector/whitelist/NoProxyTest.java | 108 ++ .../java/com/btr/proxy/util/PListParserTest.java | 101 ++ .../java/com/btr/proxy/util/ProxyUtilTest.java | 78 ++ .../java/com/btr/proxy/util/UriFilterTest.java | 122 ++ .../.mozilla/firefox/9f1uyzzu.default/prefs.js | 76 ++ .../.mozilla/firefox/9f1uyzzu.default/prefs.js | 77 ++ .../.mozilla/firefox/9f1uyzzu.default/prefs.js | 76 ++ .../.mozilla/firefox/9f1uyzzu.default/prefs.js | 77 ++ .../.gconf/system/http_proxy/%gconf.xml | 23 + .../gnome_manual/.gconf/system/proxy/%gconf.xml | 36 + .../gnome_none/.gconf/system/http_proxy/%gconf.xml | 21 + .../.gconf/system/http_proxy/%gconf.xml | 26 + .../.gconf/system/proxy/%gconf.xml | 39 + .../.gconf/system/http_proxy/%gconf.xml | 26 + .../.gconf/system/proxy/%gconf.xml | 36 + .../data/kde_env/.kde/share/config/kioslaverc | 17 + .../data/kde_manual/.kde/share/config/kioslaverc | 17 + .../data/kde_none/.kde/share/config/kioslaverc | 17 + .../kde_pac_script/.kde/share/config/kioslaverc | 17 + .../kde_white_list/.kde/share/config/kioslaverc | 17 + src/test/resources/data/osx/osx_all.plist | 144 +++ src/test/resources/data/osx/osx_manual.plist | 144 +++ src/test/resources/data/osx/osx_pac.plist | 144 +++ src/test/resources/data/pac/test1.pac | 4 + src/test/resources/data/pac/test2.pac | 10 + src/test/resources/data/pac/testDateRange.pac | 11 + src/test/resources/data/pac/testLocalIP.pac | 4 + src/test/resources/data/pac/testMultiProxy.pac | 4 + src/test/resources/data/pac/testTimeRange.pac | 11 + src/test/resources/data/pac/testWeekDay.pac | 10 + src/test/resources/data/win/proxy_util_amd64.dll | 0 src/test/resources/data/win/proxy_util_ia64.dll | 0 src/test/resources/data/win/proxy_util_w32.dll | 0 src/test/resources/data/wpad/wpad.pac | 4 + src_native/gnome/ProxySchemasGSettingsAccess.c | 117 ++ src_native/gnome/ProxySchemasGSettingsAccess.h | 21 + src_native/gnome/make | 2 + src_native/win/proxy_util_w23/compile.bat | 1 + src_native/win/proxy_util_w23/dllmain.cpp | 19 + .../win/proxy_util_w23/proxy_util_w23.vcproj | 255 +++++ src_native/win/proxy_util_w23/proxy_util_w32.cpp | 205 ++++ src_native/win/proxy_util_w23/proxy_util_w32.h | 50 + src_native/win/proxy_util_w23/stdafx.cpp | 2 + src_native/win/proxy_util_w23/stdafx.h | 11 + src_native/win/proxy_util_w23/targetver.h | 28 + src_native/win/proxy_util_w32.sln | 20 + src_native/win/proxy_util_w32.suo | Bin 0 -> 41984 bytes 140 files changed, 14266 insertions(+) create mode 100644 doc/PacIPv6.txt create mode 100644 doc/changelog.txt create mode 100644 doc/internet_explorer_info.txt create mode 100644 doc/mac_osx.txt create mode 100644 doc/misc_links.txt create mode 100644 doc/pac_files_docu.html create mode 100644 misc/logo.png create mode 100644 misc/logo.xcf create mode 100644 misc/splash.xcf create mode 100644 misc/stylesheet.css create mode 100644 pom.xml create mode 100644 src/main/java/com/btr/proxy/search/ProxySearch.java create mode 100644 src/main/java/com/btr/proxy/search/ProxySearchStrategy.java create mode 100644 src/main/java/com/btr/proxy/search/browser/firefox/FirefoxProfileSource.java create mode 100644 src/main/java/com/btr/proxy/search/browser/firefox/FirefoxProxySearchStrategy.java create mode 100644 src/main/java/com/btr/proxy/search/browser/firefox/FirefoxSettingParser.java create mode 100644 src/main/java/com/btr/proxy/search/browser/firefox/LinuxFirefoxProfileSource.java create mode 100644 src/main/java/com/btr/proxy/search/browser/firefox/WinFirefoxProfileSource.java create mode 100644 src/main/java/com/btr/proxy/search/browser/ie/IELocalByPassFilter.java create mode 100644 src/main/java/com/btr/proxy/search/browser/ie/IEProxySearchStrategy.java create mode 100644 src/main/java/com/btr/proxy/search/desktop/DesktopProxySearchStrategy.java create mode 100644 src/main/java/com/btr/proxy/search/desktop/gnome/GnomeProxySearchStrategy.java create mode 100644 src/main/java/com/btr/proxy/search/desktop/gnome/ProxySchemasGSettingsAccess.java create mode 100644 src/main/java/com/btr/proxy/search/desktop/kde/KdeProxySearchStrategy.java create mode 100644 src/main/java/com/btr/proxy/search/desktop/kde/KdeSettingsParser.java create mode 100644 src/main/java/com/btr/proxy/search/desktop/osx/OsxProxySearchStrategy.java create mode 100644 src/main/java/com/btr/proxy/search/desktop/win/DLLManager.java create mode 100644 src/main/java/com/btr/proxy/search/desktop/win/Win32IESettings.java create mode 100644 src/main/java/com/btr/proxy/search/desktop/win/Win32ProxyUtils.java create mode 100644 src/main/java/com/btr/proxy/search/desktop/win/WinProxySearchStrategy.java create mode 100644 src/main/java/com/btr/proxy/search/env/EnvProxySearchStrategy.java create mode 100644 src/main/java/com/btr/proxy/search/java/JavaProxySearchStrategy.java create mode 100644 src/main/java/com/btr/proxy/search/wpad/WpadProxySearchStrategy.java create mode 100644 src/main/java/com/btr/proxy/search/wpad/WpadProxySearchStrategyWithDHPC.java create mode 100644 src/main/java/com/btr/proxy/search/wpad/dhcp/DHCPMessage.java create mode 100644 src/main/java/com/btr/proxy/search/wpad/dhcp/DHCPOptions.java create mode 100644 src/main/java/com/btr/proxy/search/wpad/dhcp/DHCPSocket.java create mode 100644 src/main/java/com/btr/proxy/selector/direct/NoProxySelector.java create mode 100644 src/main/java/com/btr/proxy/selector/fixed/FixedProxySelector.java create mode 100644 src/main/java/com/btr/proxy/selector/fixed/FixedSocksSelector.java create mode 100644 src/main/java/com/btr/proxy/selector/misc/BufferedProxySelector.java create mode 100644 src/main/java/com/btr/proxy/selector/misc/ProtocolDispatchSelector.java create mode 100644 src/main/java/com/btr/proxy/selector/misc/ProxyListFallbackSelector.java create mode 100644 src/main/java/com/btr/proxy/selector/pac/JavaxPacScriptParser.java create mode 100644 src/main/java/com/btr/proxy/selector/pac/PacProxySelector.java create mode 100644 src/main/java/com/btr/proxy/selector/pac/PacScriptMethods.java create mode 100644 src/main/java/com/btr/proxy/selector/pac/PacScriptParser.java create mode 100644 src/main/java/com/btr/proxy/selector/pac/PacScriptSource.java create mode 100644 src/main/java/com/btr/proxy/selector/pac/ProxyEvaluationException.java create mode 100644 src/main/java/com/btr/proxy/selector/pac/RhinoPacScriptParser.java create mode 100644 src/main/java/com/btr/proxy/selector/pac/ScriptAvailability.java create mode 100644 src/main/java/com/btr/proxy/selector/pac/ScriptMethods.java create mode 100644 src/main/java/com/btr/proxy/selector/pac/UrlPacScriptSource.java create mode 100644 src/main/java/com/btr/proxy/selector/whitelist/DefaultWhiteListParser.java create mode 100644 src/main/java/com/btr/proxy/selector/whitelist/HostnameFilter.java create mode 100644 src/main/java/com/btr/proxy/selector/whitelist/IPv4WithSubnetChecker.java create mode 100644 src/main/java/com/btr/proxy/selector/whitelist/IpRangeFilter.java create mode 100644 src/main/java/com/btr/proxy/selector/whitelist/ProxyBypassListSelector.java create mode 100644 src/main/java/com/btr/proxy/selector/whitelist/UseProxyWhiteListSelector.java create mode 100644 src/main/java/com/btr/proxy/selector/whitelist/WhiteListParser.java create mode 100644 src/main/java/com/btr/proxy/test/ProxyTester.java create mode 100644 src/main/java/com/btr/proxy/util/EmptyXMLResolver.java create mode 100644 src/main/java/com/btr/proxy/util/Logger.java create mode 100644 src/main/java/com/btr/proxy/util/PListParser.java create mode 100644 src/main/java/com/btr/proxy/util/PlatformUtil.java create mode 100644 src/main/java/com/btr/proxy/util/ProxyException.java create mode 100644 src/main/java/com/btr/proxy/util/ProxyUtil.java create mode 100644 src/main/java/com/btr/proxy/util/UriFilter.java create mode 100644 src/main/resources/lib/gsettings-amd64.so create mode 100644 src/main/resources/lib/gsettings-x86.so create mode 100644 src/main/resources/lib/proxy_util_amd64.dll create mode 100644 src/main/resources/lib/proxy_util_ia64.dll create mode 100644 src/main/resources/lib/proxy_util_w32.dll create mode 100644 src/test/java/com/btr/proxy/Examples.java create mode 100644 src/test/java/com/btr/proxy/TestUtil.java create mode 100644 src/test/java/com/btr/proxy/search/browser/FirefoxTest.java create mode 100644 src/test/java/com/btr/proxy/search/browser/IeTest.java create mode 100644 src/test/java/com/btr/proxy/search/desktop/DesktopProxySearchTest.java create mode 100644 src/test/java/com/btr/proxy/search/desktop/win/DLLManagerTest.java create mode 100644 src/test/java/com/btr/proxy/search/gnome/GnomeProxySearchTest.java create mode 100644 src/test/java/com/btr/proxy/search/java/JavaProxySearchTest.java create mode 100644 src/test/java/com/btr/proxy/search/kde/KdeProxySearchTest.java create mode 100644 src/test/java/com/btr/proxy/selector/fixed/FixedProxyTest.java create mode 100644 src/test/java/com/btr/proxy/selector/java/JavaProxySelectorTest.java create mode 100644 src/test/java/com/btr/proxy/selector/misc/ProtocolDispatchTest.java create mode 100644 src/test/java/com/btr/proxy/selector/misc/ProxyListFallbackSelectorTest.java create mode 100644 src/test/java/com/btr/proxy/selector/pac/JavaxPacScriptParserTest.java create mode 100644 src/test/java/com/btr/proxy/selector/pac/PacPerProtocolTest.java create mode 100644 src/test/java/com/btr/proxy/selector/pac/PacProxyDebugging.java create mode 100644 src/test/java/com/btr/proxy/selector/pac/PacProxySelectorTest.java create mode 100644 src/test/java/com/btr/proxy/selector/pac/PacScriptMethodsTest.java create mode 100644 src/test/java/com/btr/proxy/selector/pac/RhinoPacScriptParserTest.java create mode 100644 src/test/java/com/btr/proxy/selector/pac/UrlPacScriptSourceTest.java create mode 100644 src/test/java/com/btr/proxy/selector/whitelist/NoProxyTest.java create mode 100644 src/test/java/com/btr/proxy/util/PListParserTest.java create mode 100644 src/test/java/com/btr/proxy/util/ProxyUtilTest.java create mode 100644 src/test/java/com/btr/proxy/util/UriFilterTest.java create mode 100644 src/test/resources/data/ff3_manual/.mozilla/firefox/9f1uyzzu.default/prefs.js create mode 100644 src/test/resources/data/ff3_none/.mozilla/firefox/9f1uyzzu.default/prefs.js create mode 100644 src/test/resources/data/ff3_pac_script/.mozilla/firefox/9f1uyzzu.default/prefs.js create mode 100644 src/test/resources/data/ff3_white_list/.mozilla/firefox/9f1uyzzu.default/prefs.js create mode 100755 src/test/resources/data/gnome_manual/.gconf/system/http_proxy/%gconf.xml create mode 100755 src/test/resources/data/gnome_manual/.gconf/system/proxy/%gconf.xml create mode 100755 src/test/resources/data/gnome_none/.gconf/system/http_proxy/%gconf.xml create mode 100755 src/test/resources/data/gnome_pac_script/.gconf/system/http_proxy/%gconf.xml create mode 100755 src/test/resources/data/gnome_pac_script/.gconf/system/proxy/%gconf.xml create mode 100755 src/test/resources/data/gnome_white_list/.gconf/system/http_proxy/%gconf.xml create mode 100755 src/test/resources/data/gnome_white_list/.gconf/system/proxy/%gconf.xml create mode 100644 src/test/resources/data/kde_env/.kde/share/config/kioslaverc create mode 100644 src/test/resources/data/kde_manual/.kde/share/config/kioslaverc create mode 100644 src/test/resources/data/kde_none/.kde/share/config/kioslaverc create mode 100644 src/test/resources/data/kde_pac_script/.kde/share/config/kioslaverc create mode 100644 src/test/resources/data/kde_white_list/.kde/share/config/kioslaverc create mode 100644 src/test/resources/data/osx/osx_all.plist create mode 100644 src/test/resources/data/osx/osx_manual.plist create mode 100644 src/test/resources/data/osx/osx_pac.plist create mode 100644 src/test/resources/data/pac/test1.pac create mode 100644 src/test/resources/data/pac/test2.pac create mode 100644 src/test/resources/data/pac/testDateRange.pac create mode 100644 src/test/resources/data/pac/testLocalIP.pac create mode 100644 src/test/resources/data/pac/testMultiProxy.pac create mode 100644 src/test/resources/data/pac/testTimeRange.pac create mode 100644 src/test/resources/data/pac/testWeekDay.pac create mode 100644 src/test/resources/data/win/proxy_util_amd64.dll create mode 100644 src/test/resources/data/win/proxy_util_ia64.dll create mode 100644 src/test/resources/data/win/proxy_util_w32.dll create mode 100644 src/test/resources/data/wpad/wpad.pac create mode 100644 src_native/gnome/ProxySchemasGSettingsAccess.c create mode 100644 src_native/gnome/ProxySchemasGSettingsAccess.h create mode 100644 src_native/gnome/make create mode 100755 src_native/win/proxy_util_w23/compile.bat create mode 100644 src_native/win/proxy_util_w23/dllmain.cpp create mode 100644 src_native/win/proxy_util_w23/proxy_util_w23.vcproj create mode 100644 src_native/win/proxy_util_w23/proxy_util_w32.cpp create mode 100644 src_native/win/proxy_util_w23/proxy_util_w32.h create mode 100644 src_native/win/proxy_util_w23/stdafx.cpp create mode 100644 src_native/win/proxy_util_w23/stdafx.h create mode 100644 src_native/win/proxy_util_w23/targetver.h create mode 100644 src_native/win/proxy_util_w32.sln create mode 100644 src_native/win/proxy_util_w32.suo diff --git a/doc/PacIPv6.txt b/doc/PacIPv6.txt new file mode 100644 index 0000000..3b3587e --- /dev/null +++ b/doc/PacIPv6.txt @@ -0,0 +1,6 @@ + +PAC IPV6 in Windows Vista and newer +http://blogs.msdn.com/b/wndp/archive/2006/07/18/ipv6-wpad-for-winhttp-and-wininet.aspx + +And the extension specs at: +http://blogs.msdn.com/b/wndp/archive/2006/07/13/ipv6-pac-extensions-v0-9.aspx \ No newline at end of file diff --git a/doc/changelog.txt b/doc/changelog.txt new file mode 100644 index 0000000..4bcff46 --- /dev/null +++ b/doc/changelog.txt @@ -0,0 +1,56 @@ +Change Log: +This file contains the change log. The changes are marked with the following symbology. + ++ for a new feature +- for a removed feature +* for a modified feature or a bugfix + +----------------- +Current version +* Fixed issue 29 : KDE settings file was not found on KDE4. This is solved now. +* Fixed issue 25 : Disabled DTD and schema validation in settings parsers. + +20120920 +* Improved the fix for issue 26 PAC download recursion bug + +20120905 +* Fixed issue 26 : Implemented (hopefully) better fix for PAC download recursion bug +* Fixed issue 27 + 22 : JavaProxySearch was used always even if no http.proxyHost property was set. + +20120727 +* Fixed issue 19 : Added check to return null if no KDE settings are available. +* Fixed issue 20 : Fix in isInNet method. Resolve host names to IP addresses. +* Fixed issue 21 : Improved handling of empty/invalid URIs + +20111102 +* Fixed issue 14 : Added code to cleanup temporary dll files that were not deleted on VM exit. +* Fixed issue 18 : Added code to support the https.proxy system properties too. +* Fixed issue 9 : IE PAC file urls are now patched to be in line with Firefox URLs. ++ Added support for automatic retry if PAC returns a list of fallback proxies. ++ Started to implement IPv6 support + +20110515 ++ Added (experiemental) support for Max OSX. This is not very well tested yet but should work. ++ Fixed issue 15 : The Firefox proxy search lacked support for socks proxy. This is now available. +* Fixed issue 12 : The PAC JavaScript method isInNet did not work for all patterns. This is fixed now. + +20110210 +* Fixed issue 11: Parsing was unreliable when a PAC script returned more than one proxy +* Some code cleanup to fix some minor problems (platform detection issues and others) ++ Added a debug system property "com.btr.proxy.pac.overrideLocalIP" for the PAC parser ++ Added Support for the IE "Bypass Proxy Server for local addresses" feature + +20100914 ++ PAC support on Java 1.6 will now use the javax.script framework and the internal javascript engine that is shipped with JRE6. This will allow you to support PAC without bundling the Rhino engine which will dramatically reduce the footprint of the library. Java 1.5 will still be supported but then you need to bundle it with the Rhino engine. ++ Added contributed dlls to support 64 windows version for the IE proxy detection. +* Some fixes for the http client that is used to download PAC scripts from a webserver. We accept now all content-type send by the server and we support now different charsets for the scripts. +* Fixed some unit tests that did not pass and did some other small fixes. + +20100724 +* Fixed Issue 5: PAC Parser was not working correctly in multithreaded environments. + +20100411 +* Fixed Issue 4: Improved parser used to parse proxy urls from environment varibales and other places + +Older +Did not track changes for older releases \ No newline at end of file diff --git a/doc/internet_explorer_info.txt b/doc/internet_explorer_info.txt new file mode 100644 index 0000000..6b49928 --- /dev/null +++ b/doc/internet_explorer_info.txt @@ -0,0 +1,4 @@ + +The following article gives a good description of IEs "Bypass Proxy Server for local addresses" feature and how it works. + +http://www.windowsreference.com/internet-explorer/bypass-proxy-server-for-local-addresses-in-internet-explorer-explained/ \ No newline at end of file diff --git a/doc/mac_osx.txt b/doc/mac_osx.txt new file mode 100644 index 0000000..df9c18e --- /dev/null +++ b/doc/mac_osx.txt @@ -0,0 +1,7 @@ +Settings are stored in a XML file that can be found at + +/Library/Preferences/SystemConfiguration/preferences.plist + +The plist file format is specified under + +http://www.apple.com/DTDs/PropertyList-1.0.dtd diff --git a/doc/misc_links.txt b/doc/misc_links.txt new file mode 100644 index 0000000..b16885f --- /dev/null +++ b/doc/misc_links.txt @@ -0,0 +1,5 @@ + +Oracle iPlanet Web Proxy Server +-------------------------------- +http://download.oracle.com/docs/cd/E21692_01/821-1882/adyrr/index.html + diff --git a/doc/pac_files_docu.html b/doc/pac_files_docu.html new file mode 100644 index 0000000..9e08bf8 --- /dev/null +++ b/doc/pac_files_docu.html @@ -0,0 +1,1182 @@ + + + + + + + + + Proxy Client Autoconfig File Format + + +
Documentation
+ +
+

+Navigator Proxy Auto-Config File Format

+ +
March 1996 +

(There are several examples and tips in the end of this document) +


+ +
  +


+
+
+
+
+

The proxy autoconfig file is written in JavaScript. The file must define +the function: +

        function FindProxyForURL(url, host)
+        {
+            ...
+        }
+which will be called by the Navigator in the following way for every URL +that is retrieved by it: +
        ret = FindProxyForURL(url, host);
+where: +
+
+url
+ +
+the full URL being accessed.
+ +
+host
+ +
+the hostname extracted from the URL. This is only for convenience, it is +the exact same string as between :// and the first : +or / after that. The port number is not included in this parameter. +It can be extracted from the URL when necessary.
+ +
+ret
+ +
+(the return value) a string describing the configuration. The format of +this string is defined below.
+
+ +
+

+Saving the Auto-Config File
+Setting the MIME Type

+ +
    +
  1. +You should save the JavaScript function to file with a +.pac filename +extension; for example:
  2. + +
            proxy.pac
    +Note 1: You should save the JavaScript function by itself, +not embed it in HTML. +

    Note 2: The examples in the end of this document are +complete, +there is no additional syntax needed to save it into a file and use it +(of course, the JavaScripts have to be edited to reflect your site's domain +name and/or subnets). +

  3. +Next, you should configure your server to map the +.pac filename +extension to the MIME type:
  4. + +
            application/x-ns-proxy-autoconfig
    +If using a Netscape server, edit the mime.types file in the config +directory. If using Apache, CERN or NCSA servers, use the AddType +directive. +
     
+ +
+

+Return Value Format

+The JavaScript function returns a single string. +

If the string is null, no proxies should be used. +

The string can contain any number of the following building blocks, +separated by a semicolon: +

+
+DIRECT
+ +
+Connections should be made directly, without any proxies.
+ +
+PROXY host:port
+ +
+The specified proxy should be used.
+ +
+SOCKS host:port
+ +
+The specified SOCKS server should be used.
+ +
  +

  +
  +
 

+If there are multiple semicolon-separated settings, the left-most setting +will be used, until the Navigator fails to establish the connection to +the proxy. In that case the next value will be used, etc. +

The Navigator will automatically retry a previously unresponsive proxy +after 30 minutes, then after 1 hour from the previous try (always adding +an extra 30 minutes). +

If all proxies are down, and there was no DIRECT option specified, +the Navigator will ask if proxies should be temporarily ignored, and direct +connections attempted. The Navigator will ask if proxies should be retried +after 20 minutes has passed (then the next time 40 minutes from the previous +question, always adding 20 minutes). +

+Examples:

+ +
+
+PROXY w3proxy.netscape.com:8080; PROXY mozilla.netscape.com:8081
+ +
+Primary proxy is w3proxy:8080; if that goes down start using mozilla:8081 +until the primary proxy comes up again.
+ +
+PROXY w3proxy.netscape.com:8080; PROXY mozilla.netscape.com:8081; DIRECT
+ +
+Same as above, but if both proxies go down, automatically start making +direct connections. (In the first example above, Netscape will ask user +confirmation about making direct connections; in this third case, there +is no user intervention.)
+ +
+PROXY w3proxy.netscape.com:8080; SOCKS socks:1080
+ +
+Use SOCKS if the primary proxy goes down.
+ +
  +

  +
  +
 

+ +
+

+Predefined Functions and Environment for the JavaScript Function

+ + + +
+

+isPlainHostName(host)

+ +
+
+host
+ +
+the hostname from the URL (excluding port number).
+
+True iff there is no domain name in the hostname (no dots). +

+Examples:

+ +
+
+isPlainHostName("www")
+ +
+is true.
+ +
+isPlainHostName("www.netscape.com")
+ +
+is false.
+ +
  +

  +
  +
 

+ +
+

+dnsDomainIs(host, domain)

+ +
+
+host
+ +
+is the hostname from the URL.
+ +
+domain
+ +
+is the domain name to test the hostname against.
+
+Returns true iff the domain of hostname matches. +

+Examples:

+ +
+
+dnsDomainIs("www.netscape.com", ".netscape.com")
+ +
+is true.
+ +
+dnsDomainIs("www", ".netscape.com")
+ +
+is false.
+ +
+dnsDomainIs("www.mcom.com", ".netscape.com")
+ +
+is false.
+ +
  +

  +
  +
 

+ +
+

+localHostOrDomainIs(host, hostdom)

+ +
+
+host
+ +
+the hostname from the URL.
+ +
+hostdom
+ +
+fully qualified hostname to match against.
+
+Is true if the hostname matches exactly the specified hostname, or if there +is no domain name part in the hostname, but the unqualified hostname matches. +

+Examples:

+ +
+
+localHostOrDomainIs("www.netscape.com", "www.netscape.com")
+ +
+is true (exact match).
+ +
+localHostOrDomainIs("www", "www.netscape.com")
+ +
+is true (hostname match, domain not specified).
+ +
+localHostOrDomainIs("www.mcom.com", "www.netscape.com")
+ +
+is false (domain name mismatch).
+ +
+localHostOrDomainIs("home.netscape.com", "www.netscape.com")
+ +
+is false (hostname mismatch).
+ +
  +

  +
  +
 

+ +
+

+isResolvable(host)

+ +
+
+host
+ +
+is the hostname from the URL.
+
+Tries to resolve the hostname. Returns true if succeeds. +

+Examples:

+ +
+
+isResolvable("www.netscape.com")
+ +
+is true (unless DNS fails to resolve it due to a firewall or some other +reason).
+ +
+isResolvable("bogus.domain.foobar")
+ +
+is false.
+ +
  +

  +
  +
 

+ +
+

+isInNet(host, pattern, mask)

+ +
+
+host
+ +
+a DNS hostname, or IP address. If a hostname is passed, it will be resoved +into an IP address by this function.
+ +
+pattern
+ +
+an IP address pattern in the dot-separated format
+ +
+mask
+ +
+mask for the IP address pattern informing which parts of the IP address +should be matched against. 0 means ignore, 255 means match.
+
+True iff the IP address of the host matches the specified IP address pattern. +

Pattern and mask specification is done the same way as for SOCKS configuration. +

+Examples:

+ +
+
+isInNet(host, "198.95.249.79", "255.255.255.255")
+ +
+is true iff the IP address of host matches exactly 198.95.249.79.
+ +
+isInNet(host, "198.95.0.0", "255.255.0.0")
+ +
+is true iff the IP address of the host matches 198.95.*.*.
+ +
  +

  +
  +
 

+ +
+

+dnsResolve(host)

+ +
+
+host
+ +
+hostname to resolve
+
+Resolves the given DNS hostname into an IP address, and returns it in the +dot separated format as a string. +

+Example:

+ +
+
+dnsResolve("home.netscape.com")
+ +
+returns the string "198.95.249.79".
+
+ +
+

+myIpAddress()

+Returns the IP address of the host that the Navigator is running on, as +a string in the dot-separated integer format. +

+Example:

+ +
+
+myIpAddress()
+ +
+would return the string "198.95.249.79" if you were running the +Navigator on that host.
+
+ +
+

+dnsDomainLevels(host)

+ +
+
+host
+ +
+is the hostname from the URL.
+
+Returns the number (integer) of DNS domain levels (number of dots) in the +hostname. +

+Examples:

+ +
+
+dnsDomainLevels("www")
+ +
+returns 0.
+ +
+dnsDomainLevels("www.netscape.com")
+ +
+returns 2.
+ +
  +

  +
  +
 

+ +
+

+shExpMatch(str, shexp)

+ +
+
+str
+ +
+is any string to compare (e.g. the URL, or the hostname).
+ +
+shexp
+ +
+is a shell expression to compare against.
+
+Returns true if the string matches the specified shell expression. +

Actually, currently the patterns are shell expressions, not +regular expressions. +

+Examples:

+ +
+
+shExpMatch("http://home.netscape.com/people/ari/index.html", "*/ari/*")
+ +
+is true.
+ +
+shExpMatch("http://home.netscape.com/people/montulli/index.html", "*/ari/*")
+ +
+is false.
+ +
  +

  +
  +
 

+ +
+

+weekdayRange(wd1, wd2, gmt)

+ +
+
+wd1
+ +
+and
+ +
+wd2
+ +
+are one of the weekday strings:
+ +
    SUN MON TUE WED THU FRI SAT
+ +
+gmt
+ +
+is either the string: GMT or is left out.
+ +
  +

  +
  +
 

+Only the first parameter is mandatory. Either the second, the third, or +both may be left out. +

If only one parameter is present, the function yeilds a true value on +the weekday that the parameter represents. If the string +"GMT" +is specified as a second parameter, times are taken to be in GMT, otherwise +in local timezone. +

If both wd1 and wd1 are defined, the condition is +true if the current weekday is in between those two weekdays. Bounds are +inclusive. If the "GMT" parameter is specified, times are taken +to be in GMT, otherwise the local timezone is used. +

+Examples:

+ +
+
+weekdayRange("MON", "FRI")
+ +
+true Monday trhough Friday (local timezone).
+ +
+weekdayRange("MON", "FRI", "GMT")
+ +
+same as above, but GMT timezone.
+ +
+weekdayRange("SAT")
+ +
+true on Saturdays local time.
+ +
+weekdayRange("SAT", "GMT")
+ +
+true on Saturdays GMT time.
+ +
+weekdayRange("FRI", "MON")
+ +
+true Friday through Monday (note, order does matter!).
+ +
  +

  +
  +
 

+ +
+

+dateRange(day)
+dateRange(day1, day2)
+dateRange(mon)
+dateRange(month1, month2)
+dateRange(year)
+dateRange(year1, year2)
+dateRange(day1, month1, day2, month2)
+dateRange(month1, year1, month2, year2)
+dateRange(day1, month1, year1, day2, month2, year2)
+dateRange(day1, month1, year1, day2, month2, year2, gmt)

+ +
+
+day
+ +
+is the day of month between 1 and 31 (as an integer).
+ +
+month
+ +
+is one of the month strings:
+ +
    JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
+ +
+year
+ +
+is the full year number, for example 1995 (but not 95). Integer.
+ +
+gmt
+ +
+is either the string "GMT", which makes time comparison occur +in GMT timezone; if left unspecified, times are taken to be in the local +timezone.
+ +
  +

  +

Even though the above examples don't show, the "GMT" parameter +can be specified in any of the 9 different call profiles, always as the +last parameter. +
  +
 

+If only a single value is specified (from each category: day, month, year), +the function returns a true value only on days that match that specification. +If both values are specified, the result is true between those times, including +bounds. +

+Examples:

+ +
+
+dateRange(1)
+ +
+true on the first day of each month, local timezone.
+ +
+dateRange(1, "GMT")
+ +
+true on the first day of each month, GMT timezone.
+ +
+dateRange(1, 15)
+ +
+true on the first half of each month.
+ +
+dateRange(24, "DEC")
+ +
+true on 24th of December each year.
+ +
+dateRange(24, "DEC", 1995)
+ +
+true on 24th of December, 1995.
+ +
+dateRange("JAN", "MAR")
+ +
+true on the first quarter of the year.
+ +
+dateRange(1, "JUN", 15, "AUG")
+ +
+true from June 1st until August 15th, each year (including June 1st and +August 15th).
+ +
+dateRange(1, "JUN", 15, 1995, "AUG", 1995)
+ +
+true from June 1st, 1995, until August 15th, same year.
+ +
+dateRange("OCT", 1995, "MAR", 1996)
+ +
+true from October 1995 until March 1996 (including the entire month of +October 1995 and March 1996).
+ +
+dateRange(1995)
+ +
+true during the entire year 1995.
+ +
+dateRange(1995, 1997)
+ +
+true from beginning of year 1995 until the end of year 1997.
+ +
  +

  +
  +
 

+ +
+

+timeRange(hour)
+timeRange(hour1, hour2)
+timeRange(hour1, min1, hour2, min2)
+timeRange(hour1, min1, sec1, hour2, min2, sec2)
+timeRange(hour1, min1, sec1, hour2, min2, sec2, gmt)

+ +
+
+hour
+ +
+is the hour from 0 to 23. (0 is midnight, 23 is 11 pm.)
+ +
+min
+ +
+minutes from 0 to 59.
+ +
+sec
+ +
+seconds from 0 to 59.
+ +
+gmt
+ +
+either the string "GMT" for GMT timezone, or not specified, for +local timezone. Again, even though the above list doesn't show it, this +parameter may be present in each of the different parameter profiles, always +as the last parameter.
+ +
  +

  +
  +
 

+True during (or between) the specified time(s). +

+Examples:

+ +
+
+timerange(12)
+ +
+true from noon to 1pm.
+ +
+timerange(12, 13)
+ +
+same as above.
+ +
+timerange(12, "GMT")
+ +
+true from noon to 1pm, in GMT timezone.
+ +
+timerange(9, 17)
+ +
+true from 9am to 5pm.
+ +
+timerange(8, 30, 17, 00)
+ +
+true from 8:30am to 5:00pm.
+ +
+timerange(0, 0, 0, 0, 0, 30)
+ +
+true between midnight and 30 seconds past midnight.
+ +
  +

  +
  +
 

+ +
+

+Example #1: +Use proxy for everything except local hosts

+This would work in Netscape's environment. All hosts which aren't fully +qualified, or the ones that are in local domain, will be connected to directly. +Everything else will go through +w3proxy:8080. If the proxy goes +down, connections become automatically direct. +
    function FindProxyForURL(url, host)
+    {
+        if (isPlainHostName(host) ||
+            dnsDomainIs(host, ".netscape.com"))
+            return "DIRECT";
+        else
+            return "PROXY w3proxy.netscape.com:8080; DIRECT";
+    }
+Note: This is the simplest and most efficient autoconfig file for +cases where there's only one proxy. +

+


+

+Example #1b: +As above, but use proxy for local servers which +are outside the firewall

+If there are hosts (such as the main Web server) that belong to the local +domain but are outside the firewall, and are only reachable through the +proxy server, those exceptions can be handled using the +localHostOrDomainIs() +function: +
    function FindProxyForURL(url, host)
+    {
+        if ((isPlainHostName(host) ||
+             dnsDomainIs(host, ".netscape.com")) &&
+            !localHostOrDomainIs(host, "www.netscape.com") &&
+            !localHostOrDoaminIs(host, "merchant.netscape.com"))
+
+            return "DIRECT";
+        else
+            return "PROXY w3proxy.netscape.com:8080; DIRECT";
+    }
+The above will use the proxy for everything else except local hosts in +the netscape.com domain, with the further exception that hosts +www.netscape.com +and +merchant.netscape.com will go through the proxy. +

Note the order of the above exceptions for efficiency: localHostOrDomainIs() +functions only get executed for URLs that are in local domain, not for +every URL. Be careful to note the parentheses around the or expression +before the and expression to achieve the abovementioned efficient +behaviour. +

+


+

+Example #2: +Use proxy only if cannot resolve host

+This example would work in an environment where internal DNS is set up +so that it can only resolve internal host names, and the goal is to use +a proxy only for hosts which aren't resolvable: +
    function FindProxyForURL(url, host)
+    {
+        if (isResolvable(host))
+            return "DIRECT";
+        else
+            return "PROXY proxy.mydomain.com:8080";
+    }
+The above requires consulting the DNS every time; it can be grouped smartly +with other rules so that DNS is consulted only if other rules do not yield +a result: +
    function FindProxyForURL(url, host)
+    {
+        if (isPlainHostName(host) ||
+            dnsDomainIs(host, ".mydomain.com") ||
+            isResolvable(host))
+            return "DIRECT";
+        else
+            return "PROXY proxy.mydomain.com:8080";
+    }
+ +
+

+Example #3: +Subnet based decisions

+In this example all the hosts in a given subnet are connected to directly, +others through the proxy. +
    function FindProxyForURL(url, host)
+    {
+        if (isInNet(host, "198.95.0.0", "255.255.0.0"))
+            return "DIRECT";
+        else
+            return "PROXY proxy.mydomain.com:8080";
+    }
+Again, use of DNS in the above can be minimized by adding redundant rules +in the beginning: +
    function FindProxyForURL(url, host)
+    {
+        if (isPlainHostName(host) ||
+            dnsDomainIs(host, ".mydomain.com") ||
+            isInNet(host, "198.95.0.0", "255.255.0.0"))
+            return "DIRECT";
+        else
+            return "PROXY proxy.mydomain.com:8080";
+    }
+ +
+

+Example #4: +Load balancing/routing based on URL patterns

+This example is more sophisticated. There are four (4) proxy servers; one +of them is a hot stand-by for all of the other ones, so if any of the remaining +three goes down, the fourth one will take over. +

Furthermore, the three remaining proxy servers share the load based +on URL patterns, which makes their caching more effective (there is only +one copy of any document on the three servers -- as opposed to one copy +on each of them). The load is distributed like this: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ProxyPurpose
#1.com domain
#2.edu domain
#3all other domains
#4hot stand-by
+ +

All local accesses are desired to be direct. All proxy servers run on +the port 8080 (they wouldn't need to). Note how strings can be concatenated +by the + operator in JavaScript. +

    function FindProxyForURL(url, host)
+    {
+        if (isPlainHostName(host) || dnsDomainIs(host, ".mydomain.com"))
+            return "DIRECT";
+        else if (shExpMatch(host, "*.com"))
+            return "PROXY proxy1.mydomain.com:8080; " +
+                   "PROXY proxy4.mydomain.com:8080";
+        else if (shExpMatch(host, "*.edu"))
+            return "PROXY proxy2.mydomain.com:8080; " +
+                   "PROXY proxy4.mydomain.com:8080";
+        else
+            return "PROXY proxy3.mydomain.com:8080; " +
+                   "PROXY proxy4.mydomain.com:8080";
+    }
+ +
+

+Example #5: +Setting a proxy for a specific protocol

+Most of the standard JavaScript functionality is available for use in the +FindProxyForURL() +function. As an example, to set different proxies based on the protocol, +the substring() function can be used: +
        function FindProxyForURL(url, host)
+        {
+            if (url.substring(0, 5) == "http:") {
+
+                return "PROXY http-proxy.mydomain.com:8080";
+            }
+            else if (url.substring(0, 4) == "ftp:") {
+
+                return "PROXY ftp-proxy.mydomain.com:8080";
+            }
+            else if (url.substring(0, 7) == "gopher:") {
+
+                return "PROXY gopher-proxy.mydomain.com:8080";
+            }
+            else if (url.substring(0, 6) == "https:" ||
+                     url.substring(0, 6) == "snews:") {
+
+                return "PROXY security-proxy.mydomain.com:8080";
+            }
+            else {
+
+                return "DIRECT";
+            }
+        }
+Note: The same can be accomplished using the +shExpMatch() +function described earlier; for example: +
        ...
+        if (shExpMatch(url, "http:*")) {
+            return "PROXY http-proxy.mydomain.com:8080;
+        }
+        ...
+ +
+

+Tips

+ + + +
March 1996 +
+

+ + + + + + + + + + +

Help   |   Site Map   |   How to Get Netscape Products   |   Advertise With Us   |   Add Site   |   Custom Browser Program
+ +Autos   |   Business   |   Computing & Internet   |   Entertainment   |   Family   |   Games   |   Health   |   Lifestyles   |   Local   |   Netscape   |   Netscape Open Directory   |   News   |   Personal Finance   |   Real Estate   |   Research & Learn   |  Shopping   |   Small Business   |   Sports   |   Travel
+ + + + + + +
+ +© 1999 Netscape, All Rights Reserved. Legal & Privacy Notices
This site powered by Netscape SuiteSpot servers.
+ +

+ +
  +


+
+ + +

\ No newline at end of file diff --git a/misc/logo.png b/misc/logo.png new file mode 100644 index 0000000..2578a28 Binary files /dev/null and b/misc/logo.png differ diff --git a/misc/logo.xcf b/misc/logo.xcf new file mode 100644 index 0000000..341b9ec Binary files /dev/null and b/misc/logo.xcf differ diff --git a/misc/splash.xcf b/misc/splash.xcf new file mode 100644 index 0000000..be7f243 Binary files /dev/null and b/misc/splash.xcf differ diff --git a/misc/stylesheet.css b/misc/stylesheet.css new file mode 100644 index 0000000..51dd0b8 --- /dev/null +++ b/misc/stylesheet.css @@ -0,0 +1,50 @@ +/* Javadoc style sheet */ + +/* Define colors, fonts and other style attributes here to override the defaults */ + +/* Page background color */ +body { background-color: #FFFFFF; color:#000000 } + +/* + #B0DAFF Light blue text + #1279C6 Blue background + #04469D Darker blue background + #E86F00 Orange Text + #F1F1F1 Ligher gray +*/ + +/* Headings */ +h1 { font-size: 145%; color:#E86F00; } +h2 { font-size: 145%; color:#E86F00; } + + +/* Links */ +a:link{color:#1279C6; text-decoration:none; } +a:visited {color:#1279C6; text-decoration:none; } +/*a:focus {font-weight:bold; color:#04469D; text-decoration:underline; }*/ +a:hover {font-weight:bold; color:#1279C6; text-decoration:underline; } + +/* HR and table borders*/ +hr{border-style: solid; } +table{border-style: solid; } +th{border-style: none; } + +/* Table colors */ +.TableHeadingColor { background: #1279C6; color:#FFFFFF; } +.TableSubHeadingColor { background: #1279C6; color:#FFFFFF; } +.TableRowColor { background: #FFFFFF; color:#000000; } + +/* Font used in left-hand frame lists */ +.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#E86F00 } +.FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#E86F00 } +.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#E86F00 } + +/* Navigation bar fonts and colors */ +.NavBarCell1 { background-color:#1279C6; color:#000000} +.NavBarCell1Rev { background-color:#04469D; color:#FFFFFF} +.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} +.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} + +.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} +.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..051368e --- /dev/null +++ b/pom.xml @@ -0,0 +1,214 @@ + + 4.0.0 + com.googlecode.vestige + proxy_vole + 0.0.3-SNAPSHOT + jar + Proxy Vole + + install + + + + maven-antrun-plugin + 1.6 + + + maven-assembly-plugin + 2.2-beta-5 + + + maven-clean-plugin + 2.4.1 + + + maven-compiler-plugin + 2.3.1 + + + maven-dependency-plugin + 2.1 + + + maven-deploy-plugin + 2.5 + + + maven-ear-plugin + 2.4.2 + + + maven-ejb-plugin + 2.2.1 + + + maven-help-plugin + 2.1.1 + + + maven-install-plugin + 2.3.1 + + + maven-jar-plugin + 2.3.1 + + + maven-javadoc-plugin + 2.7 + + + maven-plugin-plugin + 2.6 + + + maven-rar-plugin + 2.2 + + + maven-release-plugin + 2.0 + + + maven-repository-plugin + 2.3 + + + maven-resources-plugin + 2.4.3 + + + maven-scm-plugin + 1.3 + + + maven-site-plugin + 2.2 + + + maven-source-plugin + 2.1.2 + + + maven-surefire-plugin + 2.8 + + + maven-war-plugin + 2.1-beta-1 + + + maven-checkstyle-plugin + 2.6 + + + org.riedelcastro + gcupload-maven-plugin + 0.9 + + + org.codehaus.mojo + jaxb2-maven-plugin + 1.3 + + + + + + maven-compiler-plugin + + 1.5 + 1.5 + + + + + + org.jvnet.wagon-svn + wagon-svn + 1.9 + + + + + UTF-8 + + + + googlecode + http://vestige.googlecode.com/svn/repo + + true + + + false + + + + + + googlecode + http://vestige.googlecode.com/svn/repo + + true + + + false + + + + + + googlecode + svn:https://vestige.googlecode.com/svn/repo + + + googlecode + svn:https://vestige.googlecode.com/svn/repo + + + + + + + + + scm:svn:http://vestige.googlecode.com/svn/proxy_vole/trunk + scm:svn:https://vestige.googlecode.com/svn/proxy_vole/trunk + + + + + org.apache.maven.plugins + maven-surefire-report-plugin + 2.5 + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.2 + + + + index + + + + + + + + + org.mozilla + rhino + 1.7R4 + true + + + junit + junit + 4.8.2 + test + + + diff --git a/src/main/java/com/btr/proxy/search/ProxySearch.java b/src/main/java/com/btr/proxy/search/ProxySearch.java new file mode 100644 index 0000000..19db95f --- /dev/null +++ b/src/main/java/com/btr/proxy/search/ProxySearch.java @@ -0,0 +1,258 @@ +package com.btr.proxy.search; + +import java.awt.GraphicsEnvironment; +import java.net.ProxySelector; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; + +import com.btr.proxy.search.browser.firefox.FirefoxProxySearchStrategy; +import com.btr.proxy.search.browser.ie.IEProxySearchStrategy; +import com.btr.proxy.search.desktop.DesktopProxySearchStrategy; +import com.btr.proxy.search.desktop.gnome.GnomeProxySearchStrategy; +import com.btr.proxy.search.desktop.kde.KdeProxySearchStrategy; +import com.btr.proxy.search.desktop.win.WinProxySearchStrategy; +import com.btr.proxy.search.env.EnvProxySearchStrategy; +import com.btr.proxy.search.java.JavaProxySearchStrategy; +import com.btr.proxy.selector.misc.BufferedProxySelector; +import com.btr.proxy.selector.misc.ProxyListFallbackSelector; +import com.btr.proxy.selector.pac.PacProxySelector; +import com.btr.proxy.util.Logger; +import com.btr.proxy.util.PlatformUtil; +import com.btr.proxy.util.ProxyException; +import com.btr.proxy.util.Logger.LogBackEnd; +import com.btr.proxy.util.Logger.LogLevel; + +/***************************************************************************** + * Main class to setup and initialize the proxy detection system.
+ * This class can be used to select a proxy discovery strategy.
+ * Implements the "Builder" pattern.
+ * Use addStrategy to add one or more search strategies.
+ * If you are done call the getProxySelector method.
+ * Then the strategies are asked one after the other for a ProxySelector until + * an valid selector is found.
+ *

+ * Invoke the static getDefaultProxySearch method to use a default search strategy. + *

+ * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public class ProxySearch implements ProxySearchStrategy { + + private static final int DEFAULT_PAC_CACHE_SIZE = 20; + + private static final long DEFAULT_PAC_CACHE_TTL = 1000*60*10; // 10 Minutes + + private List strategies; + private int pacCacheSize; + private long pacCacheTTL; + + /***************************************************************************** + * Types of proxy detection supported by the builder. + ****************************************************************************/ + + public enum Strategy { + /// Use the platform settings. + OS_DEFAULT, + /// Use the settings of the platforms default browser. + BROWSER, + /// Use Firefox settings + FIREFOX, + /// Use InternetExplorer settings + IE, + /// Use environment variables for proxy settings. + ENV_VAR, + /// Use windows default proxy settings. + WIN, + /// Use KDE desktop default proxy settings. + KDE, + /// Use KDE desktop default proxy settings. + GNOME, + /// Use Java Networking system properties + JAVA + } + + /************************************************************************* + * Constructor + ************************************************************************/ + + public ProxySearch() { + super(); + this.strategies = new ArrayList(); + this.pacCacheSize = DEFAULT_PAC_CACHE_SIZE; + this.pacCacheTTL = DEFAULT_PAC_CACHE_TTL; + } + + /************************************************************************* + * Sets up a ProxySearch that uses a default search strategy suitable for + * every platform. + * @return a ProxySearch initialized with default settings. + ************************************************************************/ + + public static ProxySearch getDefaultProxySearch() { + ProxySearch s = new ProxySearch(); + + // Test if we are a server or a client. + boolean headless = GraphicsEnvironment.isHeadless(); + + if (headless) { + s.addStrategy(Strategy.JAVA); + s.addStrategy(Strategy.OS_DEFAULT); + s.addStrategy(Strategy.ENV_VAR); + } else { + s.addStrategy(Strategy.JAVA); + s.addStrategy(Strategy.BROWSER); + s.addStrategy(Strategy.OS_DEFAULT); + s.addStrategy(Strategy.ENV_VAR); + } + Logger.log(ProxySearch.class, LogLevel.TRACE, "Using default search priority: {0}", s); + + return s; + } + + /************************************************************************* + * Adds an search strategy to the list of proxy searches strategies. + * @param strategy the search strategy to add. + ************************************************************************/ + + public void addStrategy(Strategy strategy) { + switch (strategy) { + case OS_DEFAULT: + this.strategies.add(new DesktopProxySearchStrategy()); + break; + case BROWSER: + this.strategies.add(getDefaultBrowserStrategy()); + break; + case FIREFOX: + this.strategies.add(new FirefoxProxySearchStrategy()); + break; + case IE: + this.strategies.add(new IEProxySearchStrategy()); + break; + case ENV_VAR: + this.strategies.add(new EnvProxySearchStrategy()); + break; + case WIN: + this.strategies.add(new WinProxySearchStrategy()); + break; + case KDE: + this.strategies.add(new KdeProxySearchStrategy()); + break; + case GNOME: + this.strategies.add(new GnomeProxySearchStrategy()); + break; + case JAVA: + this.strategies.add(new JavaProxySearchStrategy()); + break; + default: + throw new IllegalArgumentException("Unknown strategy code!"); + } + } + + /************************************************************************* + * Sets the cache size of the PAC proxy selector cache. + * This defines the number of URLs that are cached together with the PAC + * script result. This improves performance because for URLs that are + * in the cache the script is not executed again. + * You have to set this before you add any strategies that may create a + * PAC script proxy selector. + * @param size of the cache. Set it to 0 to disable caching. + * @param ttl is the time to live of the cache entries as amount of milliseconds. + ************************************************************************/ + + public void setPacCacheSettings(int size, long ttl) { + this.pacCacheSize = size; + this.pacCacheTTL = ttl; + } + + /************************************************************************* + * Gets the search strategy for the platforms default browser. + * @return a ProxySearchStrategy, null if no supported browser was found. + ************************************************************************/ + + private ProxySearchStrategy getDefaultBrowserStrategy() { + switch (PlatformUtil.getDefaultBrowser()) { + case IE: + return new IEProxySearchStrategy(); + case FIREFOX: + return new FirefoxProxySearchStrategy(); + } + return null; + } + + /************************************************************************* + * Gets the proxy selector that will use the configured search order. + * @return a ProxySelector, null if none was found for the current + * builder configuration. + ************************************************************************/ + + public ProxySelector getProxySelector() { + Logger.log(getClass(), LogLevel.TRACE, "Executing search strategies to find proxy selector"); + for (ProxySearchStrategy strat : this.strategies) { + try { + ProxySelector selector = strat.getProxySelector(); + if (selector != null) { + selector = installBufferingAndFallbackBehaviour(selector); + return selector; + } + } catch (ProxyException e) { + Logger.log(getClass(), LogLevel.DEBUG, "Strategy {0} failed trying next one.", e); + // Ignore and try next strategy. + } + } + + return null; + } + + /************************************************************************* + * If it is PAC and we have caching enabled set it here. + * @param selector + * @return + ************************************************************************/ + + private ProxySelector installBufferingAndFallbackBehaviour(ProxySelector selector) { + if (selector instanceof PacProxySelector) { + if (this.pacCacheSize > 0) { + selector = new BufferedProxySelector(this.pacCacheSize, this.pacCacheTTL, selector); + } + selector = new ProxyListFallbackSelector(selector); + } + return selector; + } + + /************************************************************************* + * toString + * @see java.lang.Object#toString() + ************************************************************************/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder("Proxy search: "); + for (ProxySearchStrategy strat : this.strategies) { + sb.append(strat); + sb.append(" "); + } + return sb.toString(); + } + + /************************************************************************* + * For testing only. Will print the logging & proxy information to the console. + * @param args the command line arguments. + ************************************************************************/ + + public static void main(String[] args) { + ProxySearch ps = ProxySearch.getDefaultProxySearch(); + Logger.setBackend(new LogBackEnd() { + + public void log(Class clazz, LogLevel loglevel, String msg, + Object... params) { + System.out.println(MessageFormat.format(msg, params)); + } + + public boolean isLogginEnabled(LogLevel logLevel) { + return true; + } + }); + ps.getProxySelector(); + } + +} diff --git a/src/main/java/com/btr/proxy/search/ProxySearchStrategy.java b/src/main/java/com/btr/proxy/search/ProxySearchStrategy.java new file mode 100644 index 0000000..6f14c28 --- /dev/null +++ b/src/main/java/com/btr/proxy/search/ProxySearchStrategy.java @@ -0,0 +1,22 @@ +package com.btr.proxy.search; + +import java.net.ProxySelector; + +import com.btr.proxy.util.ProxyException; + +/***************************************************************************** + * Interface for a proxy search strategy. + * + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +public interface ProxySearchStrategy { + + /************************************************************************* + * Gets the a ProxySelector found by applying the search strategy. + * @return a ProxySelector, null if none is found. + ************************************************************************/ + + public ProxySelector getProxySelector() throws ProxyException; + +} diff --git a/src/main/java/com/btr/proxy/search/browser/firefox/FirefoxProfileSource.java b/src/main/java/com/btr/proxy/search/browser/firefox/FirefoxProfileSource.java new file mode 100644 index 0000000..8517074 --- /dev/null +++ b/src/main/java/com/btr/proxy/search/browser/firefox/FirefoxProfileSource.java @@ -0,0 +1,23 @@ +package com.btr.proxy.search.browser.firefox; + +import java.io.File; +import java.io.IOException; + +/***************************************************************************** + * A profile source for Firefox profiles. + * + * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 + ****************************************************************************/ + +interface FirefoxProfileSource { + + /************************************************************************* + * Gets a profile folder found on the current system. + * If multiple profile folders are available the "default" profile is chosen. + * @return a profile folder. + * @throws IOException on error. + ************************************************************************/ + + public File getProfileFolder() throws IOException; + +} diff --git a/src/main/java/com/btr/proxy/search/browser/firefox/FirefoxProxySearchStrategy.java b/src/main/java/com/btr/proxy/search/browser/firefox/FirefoxProxySearchStrategy.java new file mode 100644 index 0000000..30c3be1 --- /dev/null +++ b/src/main/java/com/btr/proxy/search/browser/firefox/FirefoxProxySearchStrategy.java @@ -0,0 +1,267 @@ +package com.btr.proxy.search.browser.firefox; + +import java.io.IOException; +import java.net.ProxySelector; +import java.util.Properties; + +import com.btr.proxy.search.ProxySearchStrategy; +import com.btr.proxy.search.desktop.DesktopProxySearchStrategy; +import com.btr.proxy.search.wpad.WpadProxySearchStrategy; +import com.btr.proxy.selector.direct.NoProxySelector; +import com.btr.proxy.selector.fixed.FixedProxySelector; +import com.btr.proxy.selector.fixed.FixedSocksSelector; +import com.btr.proxy.selector.misc.ProtocolDispatchSelector; +import com.btr.proxy.selector.whitelist.ProxyBypassListSelector; +import com.btr.proxy.util.Logger; +import com.btr.proxy.util.Logger.LogLevel; +import com.btr.proxy.util.PlatformUtil; +import com.btr.proxy.util.PlatformUtil.Platform; +import com.btr.proxy.util.ProxyException; +import com.btr.proxy.util.ProxyUtil; + +/***************************************************************************** + * Loads the Firefox3 proxy settings from the users Firefox3 settings. + * This will load the file prefs.js that is located in the + *

+ * .mozilla/firefox/(profile)/ folder. + *

+ * + * See Mozilla_Networking_Preferences + * for an explanation of the proxy settings. + *

+ * The following settings are extracted from + * this file: + *

+ * Some generic settings:
+ * + * Host names and ports per protocol are stored in the following settings: + *