pax_global_header00006660000000000000000000000064130266225200014510gustar00rootroot0000000000000052 comment=76263133aa603f7a995e5e3bd3ff6d57f0c76a47 proxy-vole-proxy-vole-1.0.3/000077500000000000000000000000001302662252000157575ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/.gitignore000066400000000000000000000000761302662252000177520ustar00rootroot00000000000000# Eclipse .project .settings .classpath bin/ # Maven target/ proxy-vole-proxy-vole-1.0.3/CHANGELOG.md000066400000000000000000000105651302662252000175770ustar00rootroot00000000000000#Change Log This file contains the change log. ##Unreleased ##1.0.3 * Fixed issue #5: Failed to find SOCKS proxy with Java search strategy. Thanks to sake! * Added proxy selection to README.md. Thanks to Guido Schnepp! ##1.0.2 * Fixed issue #2: NullPointerException if PAC method returns null * Fixed issue #1: Caching with individual URLs might not be ideal * Changes after receiving some mails from different people about ASL2 licensing ##1.0.1 * Fix NullPointerException in IEProxySearchStrategy. ##1.0.0 * Fork on github. * Made it deployable to Maven Central for me (Maven coordinates, package names). * Added OsxFirefoxProfileSource. * Removed the Rhino Javascript parser needed for Java 5. * Removed the Windows DLL and its sources. * Port from JNI to JNA ##Last version of proxy-vole at Google Code repository * Preparing migration to Maven * We now support on Linux Gnome the dconf settings format * Fixed issue 55 : Improved shExpMatch method * Fixed issue 51 : UnsatisfiedLinkError if dll was cleaned up by another instance that is closed. * Fixed issue 50 : Mixed white list with "local bypass" enabled * Fixed issue 48 : Expiry date for redownload of pac script content was broken. * Fixed issue 47 : If no PAC selector is available ignore the whitelist settings (OSX only). ##20131209 * Fixed issue with myIPAddress() returning 127.0.0.1 instead of the real address on linux * Fixed issue 46 : Handle cleanup of temp files more robust * Fixed issue 44 : Selecting bluetooth interface in OS/X 10.8 * Fixed issue 39 : Default timeout is used when fetching PAC script, causes 5 minute delay * Fixed issue 38 : Detect invalid PAC scripts early and abort * Fixed issue 36 : methods returned java.lang.String objects instead of JS strings ##20121203 * Fixed issue 31 : Improved the support for "no proxy" definitions. * 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 * Added support for automatic retry if PAC returns a list of fallback proxies. * Started to implement IPv6 support * 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. ##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 * 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 * 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) ##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 proxy-vole-proxy-vole-1.0.3/LICENSE.md000066400000000000000000000243761302662252000173770ustar00rootroot00000000000000Apache License ============== _Version 2.0, January 2004_ _<>_ ### Terms and Conditions for use, reproduction, and distribution #### 1. Definitions “License” shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. “Licensor” shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. “Legal Entity” shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, “control” means **(i)** the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the outstanding shares, or **(iii)** beneficial ownership of such entity. “You” (or “Your”) shall mean an individual or Legal Entity exercising permissions granted by this License. “Source” form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. “Object” form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. “Work” shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). “Derivative Works” shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. “Contribution” shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, “submitted” means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as “Not a Contribution.” “Contributor” shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. #### 2. Grant of Copyright License Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. #### 3. Grant of Patent License Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. #### 4. Redistribution You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: * **(a)** You must give any other recipients of the Work or Derivative Works a copy of this License; and * **(b)** You must cause any modified files to carry prominent notices stating that You changed the files; and * **(c)** You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and * **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. #### 5. Submission of Contributions Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. #### 6. Trademarks This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. #### 7. Disclaimer of Warranty Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. #### 8. Limitation of Liability In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. #### 9. Accepting Warranty or Additional Liability While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. _END OF TERMS AND CONDITIONS_ ### APPENDIX: How to apply the Apache License to your work To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets `[]` replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same “printed page” as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. proxy-vole-proxy-vole-1.0.3/NOTICE.md000066400000000000000000000040731302662252000172660ustar00rootroot00000000000000##Copyright 2016 Markus Bernhardt Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ##Copyright 2009 Bernd Rosstauscher All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY BERND ROSSTAUSCHER ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BERND ROSSTAUSCHER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. proxy-vole-proxy-vole-1.0.3/README.md000066400000000000000000000171761302662252000172520ustar00rootroot00000000000000#proxy-vole Proxy Vole is a Java library to auto detect the platform network proxy settings. Note: This library is a fork of the now dead [proxy-vole](https://code.google.com/p/proxy-vole/) project by Bernd Rosstauscher hosted at Google Code. ##Introduction The library provides some proxy setting search strategies to read the proxy settings from the system config (Windows, KDE, Gnome, OSX), browser config (Firefox, IE) or environment variables and provides you an ready to use proxy selector. ##Why a fork? * Can't contact Bernd Rosstauscher. * Google Code is dead by now. * proxy-vole seems to be dead even longer. Last commit mid 2015. Last release end 2013. * proxy-vole is not available on any public Maven repository. Needed to change the Maven coordinates and Java package names to be able to push it to Maven Central on my own. * I don't like the Windows DLL and usage of JNI. Replaced both by JNA. ##Usage ###Using the default strategy to find the settings ```Java // Use the static factory method getDefaultProxySearch to create a proxy search instance // configured with the default proxy search strategies for the current environment. ProxySearch proxySearch = ProxySearch.getDefaultProxySearch(); // Invoke the proxy search. This will create a ProxySelector with the detected proxy settings. ProxySelector proxySelector = proxySearch.getProxySelector(); // Install this ProxySelector as default ProxySelector for all connections. ProxySelector.setDefault(proxySelector); ``` ###Modifying the search strategy ```Java // Create a not configured proxy search instance and configure customized proxy search strategies. ProxySearch proxySearch = new ProxySearch(); if (PlatformUtil.getCurrentPlattform() == Platform.WIN) { proxySearch.addStrategy(Strategy.IE); proxySearch.addStrategy(Strategy.FIREFOX); proxySearch.addStrategy(Strategy.JAVA); } else if (PlatformUtil.getCurrentPlattform() == Platform.LINUX) { proxySearch.addStrategy(Strategy.GNOME); proxySearch.addStrategy(Strategy.KDE); proxySearch.addStrategy(Strategy.FIREFOX); } else { proxySearch.addStrategy(Strategy.OS_DEFAULT); } ``` ###Improving PAC performance When your system uses a proxy automation script (PAC) Javascript is used to determine the actual proxy. If your program needs to access a lot of HTTP URLs, then this might become a performance bottleneck. To speed things up a little bit, you can activate a cache that will store already processed URLs. When a cached URL is accessed the Javascript execution will be skipped and the cached proxy is used. ```Java // Use the static factory method getDefaultProxySearch to create a proxy search instance // configured with the default proxy search strategies for the current environment. ProxySearch proxySearch = ProxySearch.getDefaultProxySearch(); // Cache 20 hosts for up to 10 minutes. This is the default. proxySearch.setPacCacheSettings(20, 1000*60*5, CacheScope.CACHE_SCOPE_HOST); ``` ###How to handle proxy authentication Some proxy servers request a login from the user before they will allow any connections. Proxy Vole has no support to handle this automatically. This needs to be done manually, because there is no way to read the login and password. These settings are stored encrypted. You need to install an authenticator in your Java program manually and e.g. ask the user in a dialog to enter the username and password. ```Java Authenticator.setDefault(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { if (getRequestorType() == RequestorType.PROXY) { return new PasswordAuthentication("proxy-user", "proxy-password".toCharArray()); } else { return super.getPasswordAuthentication(); } } }); ``` ###Choose the right proxy Please be aware a Java ProxySelector returns a list of valid proxies for a given URL and sometimes simply choosing the first one is not good enough. Very often a check of the supported protocol is neccessary. The following code chooses the first HTTP/S proxy. ```Java Proxy proxy = Proxy.NO_PROXY; // Get list of proxies from default ProxySelector available for given URL List proxies = null; if (ProxySelector.getDefault() != null) { proxies = ProxySelector.getDefault().select(uri); } // Find first proxy for HTTP/S. Any DIRECT proxy in the list returned is only second choice if (proxies != null) { loop: for (Proxy p : proxies) { switch (p.type()) { case HTTP: proxy = p; break loop; case DIRECT: proxy = p; break; } } } ``` ###Logging Proxy Vole does not use Log4J, LogBack or SLF4J to make the library as light weight as possible with no external dependencies. If you need to know what is going on inside of the library you may want to install a logger. ```Java // Register MyLogger instance Logger.setBackend(new MyLogger()); ``` ###Testing PAC Testing the PAC parser can be problematic, because the myIPAddress() method returns different results on different machines. Therefore the system property com.github.markusbernhardt.proxy.pac.overrideLocalIP can be set for unit tests. It's value will always be used as myIPAddress in all PAC scripts. ```Java System.setProperty(PacScriptMethods.OVERRIDE_LOCAL_IP, "123.123.123.123"); ``` ###Proxy Vole Tester There is also a small GUI to test the different search strategies. Simply start the [jar-with-dependencies](http://search.maven.org/remotecontent?filepath=com/github/markusbernhardt/proxy-vole/1.0.1/proxy-vole-1.0.1-jar-with-dependencies.jar) or directly the class `com.github.markusbernhardt.proxy.ui.ProxyTester`. ![Screenshot](https://raw.githubusercontent.com/MarkusBernhardt/proxy-vole/master/src/site/screenshots/proxy-vole-tester.png "Proxy Vole Tester") ##Motivation Today more and more applications try to take direct advantage of Internet connectivity and web services to bring web content to your desktop. Java has very good network and Internet connectivity with build in APIs for HTTP, HTTPS, FTP and a web services stack. But the first thing that you need, to use all this fantastic technology, is a working Internet connection. And this is where Java lacks a lot in my opinion. When you develop an applet or an Java Webstart application the situation is quite good. The Java Plugin will use the proxy settings and connections as used by the browser, but for standalone applications the situation is quite unsatisfactory. You have to ask your users to twiddle with system properties and every Java application has it's own way of setting proxy configurations. In business environments where you often can find proxy configuration scripts you are stuck. ##Current Situation To set the proxy settings in Java you can use some (documented, but hard to find) system properties on application startup. At runtime you can use the `ProxySelector` API to configure the proxy settings. Java even comes with a system property to detect the system proxy settings automatically, but this one is poorly documented and unreliable in its behaviour. ##The Solution Use the Proxy Vole library to provide network connectivity out of the box for your Java application. It provides strategies for auto detecting the current proxy settings. There are many configurable strategies to choose from. At the moment Proxy Vole supports the following proxy detection strategies. * Read platform settings (Supports: Windows, KDE, Gnome, OSX) * Read browser setting (Supports: Firefox 3.x+, Internet Explorer; Chrome and Webkit use the platform settings) * Read environment variables (often used variables on Linux / Unix server systems) * Auto detection script by using WPAD/PAC (Not all variations supported) proxy-vole-proxy-vole-1.0.3/pom.xml000066400000000000000000000210201302662252000172670ustar00rootroot00000000000000 4.0.0 org.sonatype.oss oss-parent 9 com.github.markusbernhardt proxy-vole 1.0.3 Proxy Vole Proxy Vole is a Java library to auto detect the platform network proxy settings. https://github.com/MarkusBernhardt/proxy-vole UTF-8 true true 1.6 https://github.com/MarkusBernhardt/proxy-vole scm:git://github.com/MarkusBernhardt/proxy-vole.git scm:git:ssh://git@github.com/MarkusBernhardt/proxy-vole.git The Apache Software License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt repo Markus Bernhardt markus.bernhardt@me.com org.ini4j ini4j net.java.dev.jna jna net.java.dev.jna jna-platform junit junit test org.ini4j ini4j 0.5.4 net.java.dev.jna jna 4.2.2 net.java.dev.jna jna-platform 4.2.2 junit junit 4.12 org.apache.maven.plugins maven-deploy-plugin 2.8.2 org.apache.maven.plugins maven-compiler-plugin 3.5.1 ${java.version} ${java.version} ${project.build.sourceEncoding} true true javac org.apache.maven.plugins maven-eclipse-plugin 2.10 ${downloadSources} ${downloadJavadocs} org.apache.maven.plugins maven-jar-plugin 2.6 true true org.apache.maven.plugins maven-source-plugin 3.0.0 jar verify jar org.apache.maven.plugins maven-javadoc-plugin 2.10.3 jar verify jar org.apache.maven.plugins maven-assembly-plugin 2.6 jar-with-dependencies com.github.markusbernhardt.proxy.ui.ProxyTester make-assembly package single org.eclipse.m2e lifecycle-mapping 1.0.0 org.apache.maven.plugins maven-enforcer-plugin [1.0.0,) enforce proxy-vole-proxy-vole-1.0.3/src/000077500000000000000000000000001302662252000165465ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/doc/000077500000000000000000000000001302662252000173135ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/doc/PacIPv6.txt000066400000000000000000000003461302662252000212670ustar00rootroot00000000000000 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.aspxproxy-vole-proxy-vole-1.0.3/src/doc/internet_explorer_info.txt000066400000000000000000000003651302662252000246430ustar00rootroot00000000000000 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/proxy-vole-proxy-vole-1.0.3/src/doc/mac_osx.txt000066400000000000000000000003171302662252000215060ustar00rootroot00000000000000Settings 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 proxy-vole-proxy-vole-1.0.3/src/doc/misc_links.txt000066400000000000000000000002121302662252000222020ustar00rootroot00000000000000 Oracle iPlanet Web Proxy Server -------------------------------- http://download.oracle.com/docs/cd/E21692_01/821-1882/adyrr/index.html proxy-vole-proxy-vole-1.0.3/src/doc/pac_files_docu.html000066400000000000000000001154571302662252000231550ustar00rootroot00000000000000 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:
Proxy Purpose
#1 .com domain
#2 .edu domain
#3 all other domains
#4 hot 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

  • The autoconfig file can be output by a CGI script. This is useful e.g. when making the autoconfig file act differently based on the client IP address (the REMOTE_ADDR environment variable in CGI).
  • Use of isInNet(), isResolvable() and dnsResolve() functions should be carefully considered, as they require DNS server to be consulted (whereas all other autoconfig related functions are mere string matching functions). If a proxy is used, the proxy will perform its own DNS lookup which would double the impact on the DNS server. Most of the time these functions are not necessary to achieve the desired result.

  •  

     
     
     


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.


 



proxy-vole-proxy-vole-1.0.3/src/main/000077500000000000000000000000001302662252000174725ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/000077500000000000000000000000001302662252000204135ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/000077500000000000000000000000001302662252000211715ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/000077500000000000000000000000001302662252000224535ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/000077500000000000000000000000001302662252000256475ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/000077500000000000000000000000001302662252000270305ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/ProxySearch.java000066400000000000000000000252001302662252000321410ustar00rootroot00000000000000package com.github.markusbernhardt.proxy; import java.awt.GraphicsEnvironment; import java.net.ProxySelector; import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; import com.github.markusbernhardt.proxy.search.browser.firefox.FirefoxProxySearchStrategy; import com.github.markusbernhardt.proxy.search.browser.ie.IEProxySearchStrategy; import com.github.markusbernhardt.proxy.search.desktop.DesktopProxySearchStrategy; import com.github.markusbernhardt.proxy.search.desktop.gnome.GnomeDConfProxySearchStrategy; import com.github.markusbernhardt.proxy.search.desktop.gnome.GnomeProxySearchStrategy; import com.github.markusbernhardt.proxy.search.desktop.kde.KdeProxySearchStrategy; import com.github.markusbernhardt.proxy.search.desktop.win.WinProxySearchStrategy; import com.github.markusbernhardt.proxy.search.env.EnvProxySearchStrategy; import com.github.markusbernhardt.proxy.search.java.JavaProxySearchStrategy; import com.github.markusbernhardt.proxy.selector.misc.BufferedProxySelector; import com.github.markusbernhardt.proxy.selector.misc.BufferedProxySelector.CacheScope; import com.github.markusbernhardt.proxy.selector.misc.ProxyListFallbackSelector; import com.github.markusbernhardt.proxy.selector.pac.PacProxySelector; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.Logger.LogBackEnd; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; import com.github.markusbernhardt.proxy.util.PlatformUtil; import com.github.markusbernhardt.proxy.util.ProxyException; /***************************************************************************** * 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 Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, 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 static final CacheScope DEFAULT_PAC_CACHE_SCOPE = CacheScope.CACHE_SCOPE_HOST; private List strategies; private int pacCacheSize; private long pacCacheTTL; private CacheScope pacCacheScope; /***************************************************************************** * 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; this.pacCacheScope = DEFAULT_PAC_CACHE_SCOPE; } /************************************************************************* * 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 GnomeDConfProxySearchStrategy()); 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. * @param cacheScope * the desired cache scope. ************************************************************************/ public void setPacCacheSettings(int size, long ttl, CacheScope cacheScope) { this.pacCacheSize = size; this.pacCacheTTL = ttl; this.pacCacheScope = cacheScope; } /************************************************************************* * 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. ************************************************************************/ @Override 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); Logger.log(getClass(), LogLevel.INFO, "Proxy found for " + strat.getName()); return selector; } else { Logger.log(getClass(), LogLevel.INFO, "No proxy found for " + strat.getName() + ". Trying next one."); } } catch (ProxyException e) { Logger.log(getClass(), LogLevel.DEBUG, "Strategy {0} failed trying next one.", e); // Ignore and try next strategy. } } return null; } /************************************************************************* * Gets the printable name of the search strategy. * * @return the printable name of the search strategy ************************************************************************/ @Override public String getName() { return "default"; } /************************************************************************* * If it is PAC and we have caching enabled set it here. * * @param selector * the proxy selector to wrap * @return the wrapped proxy selector or the passed in selector if nothing * is done. ************************************************************************/ private ProxySelector installBufferingAndFallbackBehaviour(ProxySelector selector) { if (selector instanceof PacProxySelector) { if (this.pacCacheSize > 0) { selector = new BufferedProxySelector(this.pacCacheSize, this.pacCacheTTL, selector, pacCacheScope); } 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(); } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/ProxySearchStrategy.java000066400000000000000000000022061302662252000336650ustar00rootroot00000000000000package com.github.markusbernhardt.proxy; import java.net.ProxySelector; import com.github.markusbernhardt.proxy.util.ProxyException; /***************************************************************************** * Interface for a proxy search strategy. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public interface ProxySearchStrategy { /************************************************************************* * Gets the a ProxySelector found by applying the search strategy. * * @return a ProxySelector, null if none is found. * @throws ProxyException * on error ************************************************************************/ public ProxySelector getProxySelector() throws ProxyException; /************************************************************************* * Gets the printable name of the search strategy. * * @return the printable name of the search strategy ************************************************************************/ public String getName(); } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/jna/000077500000000000000000000000001302662252000276005ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/jna/win/000077500000000000000000000000001302662252000303755ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/jna/win/WinHttp.java000066400000000000000000000075461302662252000326510ustar00rootroot00000000000000package com.github.markusbernhardt.proxy.jna.win; import com.sun.jna.Native; import com.sun.jna.platform.win32.WTypes; import com.sun.jna.platform.win32.WinDef; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; /** * WinHttp.dll Interface. * * @author Markus Bernhardt, Copyright 2016 */ public interface WinHttp extends StdCallLibrary { WinHttp INSTANCE = (WinHttp) Native.loadLibrary("winhttp", WinHttp.class, W32APIOptions.UNICODE_OPTIONS); /** * Use DHCP to locate the proxy auto-configuration file. */ int WINHTTP_AUTO_DETECT_TYPE_DHCP = 0x00000001; /** * Use DNS to attempt to locate the proxy auto-configuration file at a * well-known location on the domain of the local computer. */ int WINHTTP_AUTO_DETECT_TYPE_DNS_A = 0x00000002; /** * Resolves all host names directly without a proxy. */ int WINHTTP_ACCESS_TYPE_DEFAULT_PROXY = 0; /** * Retrieves the static proxy or direct configuration from the registry. * WINHTTP_ACCESS_TYPE_DEFAULT_PROXY does not inherit browser proxy * settings. WinHTTP does not share any proxy settings with Internet * Explorer. *

* The WinHTTP proxy configuration is set by one of these mechanisms. *

    *
  • The proxycfg.exe utility on Windows XP and Windows Server 2003 or * earlier.
  • *
  • The netsh.exe utility on Windows Vista and Windows Server 2008 or * later.
  • *
  • WinHttpSetDefaultProxyConfiguration on all platforms.
  • *
*/ int WINHTTP_ACCESS_TYPE_NO_PROXY = 1; /** * Passes requests to the proxy unless a proxy bypass list is supplied and * the name to be resolved bypasses the proxy. In this case, this function * uses WINHTTP_ACCESS_TYPE_NAMED_PROXY. */ int WINHTTP_ACCESS_TYPE_NAMED_PROXY = 3; /** * The WinHttpDetectAutoProxyConfigUrl function finds the URL for the Proxy * Auto-Configuration (PAC) file. This function reports the URL of the PAC * file, but it does not download the file. * * @param dwAutoDetectFlags * A data type that specifies what protocols to use to locate the * PAC file. If both the DHCP and DNS auto detect flags are set, * DHCP is used first; if no PAC URL is discovered using DHCP, * then DNS is used. Set {@code WINHTTP_AUTO_DETECT_TYPE_DHCP}, * {@code WINHTTP_AUTO_DETECT_TYPE_DNS_A} or both. * @param ppwszAutoConfigUrl * A data type that returns a pointer to a null-terminated * Unicode string that contains the configuration URL that * receives the proxy data. You must free the string pointed to * by ppwszAutoConfigUrl using the GlobalFree function. * @return {@code true} if successful; otherwise, {@code false}. */ boolean WinHttpDetectAutoProxyConfigUrl(WinDef.DWORD dwAutoDetectFlags, WTypes.LPWSTR ppwszAutoConfigUrl); /** * The WinHttpGetDefaultProxyConfiguration function retrieves the default * WinHTTP proxy configuration from the registry. * * @param pProxyInfo * A pointer to a variable of type WINHTTP_PROXY_INFO that * receives the default proxy configuration. * @return {@code true} if successful; otherwise, {@code false}. */ boolean WinHttpGetDefaultProxyConfiguration(WinHttpProxyInfo pProxyInfo); /** * The WinHttpGetIEProxyConfigForCurrentUser function retrieves the Internet * Explorer proxy configuration for the current user. * * @param pProxyConfig * A pointer, on input, to a WINHTTP_CURRENT_USER_IE_PROXY_CONFIG * structure. On output, the structure contains the Internet * Explorer proxy settings for the current active network * connection (for example, LAN, dial-up, or VPN connection). * @return {@code true} if successful; otherwise, {@code false}. */ boolean WinHttpGetIEProxyConfigForCurrentUser(WinHttpCurrentUserIEProxyConfig pProxyConfig); } WinHttpCurrentUserIEProxyConfig.java000066400000000000000000000065501302662252000373740ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/jna/winpackage com.github.markusbernhardt.proxy.jna.win; import java.util.Arrays; import java.util.List; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.platform.win32.WTypes; /** * The WINHTTP_CURRENT_USER_IE_PROXY_CONFIG structure contains the Internet * Explorer proxy configuration information. * * @author Markus Bernhardt, Copyright 2016 */ public class WinHttpCurrentUserIEProxyConfig extends Structure { /** * If TRUE, indicates that the Internet Explorer proxy configuration for the * current user specifies "automatically detect settings". */ public boolean fAutoDetect; /** * Pointer to a null-terminated Unicode string that contains the * auto-configuration URL if the Internet Explorer proxy configuration for * the current user specifies "Use automatic proxy configuration". */ public WTypes.LPWSTR lpszAutoConfigUrl; /** * Pointer to a null-terminated Unicode string that contains the proxy URL * if the Internet Explorer proxy configuration for the current user * specifies "use a proxy server". */ public WTypes.LPWSTR lpszProxy; /** * Pointer to a null-terminated Unicode string that contains the optional * proxy by-pass server list. */ public WTypes.LPWSTR lpszProxyBypass; /** * Create WinHttpCurrentUserIeProxyConfig structure. */ public WinHttpCurrentUserIEProxyConfig() { super(); } /** * Create WinHttpCurrentUserIeProxyConfig structure cast onto pre-allocated * memory. * * @param pointer * pointer to pre-allocated memory */ public WinHttpCurrentUserIEProxyConfig(Pointer pointer) { super(pointer); read(); } /** * Return this Structure's field names in their proper order. For example, * *
	 * 
	 * protected List getFieldOrder() {
	 *     return Arrays.asList(new String[] { ... });
	 * }
	 * 
	 * 
* * IMPORTANT When deriving from an existing Structure * subclass, ensure that you augment the list provided by the superclass, * e.g. * *
	 * 
	 * protected List getFieldOrder() {
	 *     List fields = new ArrayList(super.getFieldOrder());
	 *     fields.addAll(Arrays.asList(new String[] { ... }));
	 *     return fields;
	 * }
	 * 
	 * 
* * Field order must be explicitly indicated, since the field order as * returned by {@link Class#getFields()} is not guaranteed to be * predictable. * * @return ordered list of field names */ @Override protected List getFieldOrder() { return Arrays.asList("fAutoDetect", "lpszAutoConfigUrl", "lpszProxy", "lpszProxyBypass"); } /** * Tagging interface to indicate the address of an instance of the Structure * type is to be used within a Structure definition rather than * nesting the full Structure contents. The default behavior is to inline * Structure fields. */ public static class ByReference extends WinHttpProxyInfo implements Structure.ByReference { } /** * Tagging interface to indicate the value of an instance of the * Structure type is to be used in function invocations rather * than its address. The default behavior is to treat Structure * function parameters and return values as by reference, meaning the * address of the structure is used. */ public static class ByValue extends WinHttpProxyInfo implements Structure.ByValue { } } WinHttpProxyInfo.java000066400000000000000000000057631302662252000344470ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/jna/winpackage com.github.markusbernhardt.proxy.jna.win; import java.util.Arrays; import java.util.List; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.platform.win32.WTypes; import com.sun.jna.platform.win32.WinDef; /** * The WINHTTP_PROXY_INFO structure contains the session or default proxy * configuration. * * @author Markus Bernhardt, Copyright 2016 */ public class WinHttpProxyInfo extends Structure { /** * Unsigned long integer value that contains the access type. This can be * one of the following values: *
    *
  • WINHTTP_ACCESS_TYPE_NO_PROXY
  • *
  • WINHTTP_ACCESS_TYPE_DEFAULT_PROXY
  • *
  • WINHTTP_ACCESS_TYPE_NAMED_PROXY
  • *
*/ public WinDef.DWORD dwAccessType; /** * Pointer to a string value that contains the proxy server list. */ public WTypes.LPWSTR lpszProxy; /** * Pointer to a string value that contains the proxy bypass list. */ public WTypes.LPWSTR lpszProxyBypass; /** * Create WinHttpProxyInfo structure. */ public WinHttpProxyInfo() { super(); } /** * Create WinHttpProxyInfo structure cast onto pre-allocated memory. * * @param pointer * pointer to pre-allocated memory */ public WinHttpProxyInfo(Pointer pointer) { super(pointer); read(); } /** * Return this Structure's field names in their proper order. For example, * *
	 * 
	 * protected List getFieldOrder() {
	 *     return Arrays.asList(new String[] { ... });
	 * }
	 * 
	 * 
* * IMPORTANT When deriving from an existing Structure * subclass, ensure that you augment the list provided by the superclass, * e.g. * *
	 * 
	 * protected List getFieldOrder() {
	 *     List fields = new ArrayList(super.getFieldOrder());
	 *     fields.addAll(Arrays.asList(new String[] { ... }));
	 *     return fields;
	 * }
	 * 
	 * 
* * Field order must be explicitly indicated, since the field order as * returned by {@link Class#getFields()} is not guaranteed to be * predictable. * * @return ordered list of field names */ @Override protected List getFieldOrder() { return Arrays.asList("dwAccessType", "lpszProxy", "lpszProxyBypass"); } /** * Tagging interface to indicate the address of an instance of the Structure * type is to be used within a Structure definition rather than * nesting the full Structure contents. The default behavior is to inline * Structure fields. */ public static class ByReference extends WinHttpProxyInfo implements Structure.ByReference { } /** * Tagging interface to indicate the value of an instance of the * Structure type is to be used in function invocations rather * than its address. The default behavior is to treat Structure * function parameters and return values as by reference, meaning the * address of the structure is used. */ public static class ByValue extends WinHttpProxyInfo implements Structure.ByValue { } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/000077500000000000000000000000001302662252000302755ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/browser/000077500000000000000000000000001302662252000317605ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/browser/firefox/000077500000000000000000000000001302662252000334225ustar00rootroot00000000000000FirefoxProfileSource.java000066400000000000000000000014351302662252000403150ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/browser/firefoxpackage com.github.markusbernhardt.proxy.search.browser.firefox; import java.io.File; import java.io.IOException; /***************************************************************************** * A profile source for Firefox profiles. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ interface FirefoxProfileSource { /************************************************************************* * Gets the profiles.ini file found on the current system. * * @return the config folder. * @throws IOException * on error. ************************************************************************/ public File getProfilesIni() throws IOException; } FirefoxProxySearchStrategy.java000066400000000000000000000270601302662252000415300ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/browser/firefoxpackage com.github.markusbernhardt.proxy.search.browser.firefox; import java.io.IOException; import java.net.ProxySelector; import java.util.Properties; import com.github.markusbernhardt.proxy.ProxySearchStrategy; import com.github.markusbernhardt.proxy.search.desktop.DesktopProxySearchStrategy; import com.github.markusbernhardt.proxy.search.wpad.WpadProxySearchStrategy; import com.github.markusbernhardt.proxy.selector.direct.NoProxySelector; import com.github.markusbernhardt.proxy.selector.fixed.FixedProxySelector; import com.github.markusbernhardt.proxy.selector.fixed.FixedSocksSelector; import com.github.markusbernhardt.proxy.selector.misc.ProtocolDispatchSelector; import com.github.markusbernhardt.proxy.selector.whitelist.ProxyBypassListSelector; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; import com.github.markusbernhardt.proxy.util.PlatformUtil; import com.github.markusbernhardt.proxy.util.PlatformUtil.Platform; import com.github.markusbernhardt.proxy.util.ProxyException; import com.github.markusbernhardt.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:
*
    *
  • network.proxy.type -> n/a = use system settings, 0 = direct, 1 * = Fixed proxy settings, 2 = proxy script (PAC), 3 = also direct , 4 = auto * detect (WPAD)
  • *
  • network.proxy.share_proxy_settings -> true = use same proxy for * all protocols
  • *
  • network.proxy.no_proxies_on -> a comma separated ignore list. *
  • *
  • network.proxy.autoconfig_url -> a URL to an proxy configuration * script
  • *
* Host names and ports per protocol are stored in the following settings: *
    *
  • network.proxy.http
  • *
  • network.proxy.http_port
  • *
  • network.proxy.ssl
  • *
  • network.proxy.ssl_port
  • *
  • network.proxy.ftp
  • *
  • network.proxy.ftp_port
  • *
  • network.proxy.gopher
  • *
  • network.proxy.gopher_port
  • *
  • network.proxy.socks
  • *
  • network.proxy.socks_port
  • *
  • network.proxy.socks_version -> 4 or 5
  • *
*

* Note that if there are more than one profile the first profile found will be * used. *

* * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class FirefoxProxySearchStrategy implements ProxySearchStrategy { private FirefoxProfileSource profileScanner; private FirefoxSettingParser settingsParser; /************************************************************************* * ProxySelector * * @see java.net.ProxySelector#ProxySelector() ************************************************************************/ public FirefoxProxySearchStrategy() { super(); if (PlatformUtil.getCurrentPlattform() == Platform.WIN) { this.profileScanner = new WinFirefoxProfileSource(); } else if (PlatformUtil.getCurrentPlattform() == Platform.MAC_OS) { this.profileScanner = new OsxFirefoxProfileSource(); } else { this.profileScanner = new LinuxFirefoxProfileSource(); } this.settingsParser = new FirefoxSettingParser(); } /************************************************************************* * Loads the proxy settings and initializes a proxy selector for the firefox * proxy settings. * * @return a configured ProxySelector, null if none is found. * @throws ProxyException * on file reading error. ************************************************************************/ @Override public ProxySelector getProxySelector() throws ProxyException { Logger.log(getClass(), LogLevel.TRACE, "Detecting Firefox settings."); Properties settings = readSettings(); ProxySelector result = null; int type = Integer.parseInt(settings.getProperty("network.proxy.type", "-1")); switch (type) { case -1: // Use system settings Logger.log(getClass(), LogLevel.TRACE, "Firefox uses system settings"); result = new DesktopProxySearchStrategy().getProxySelector(); break; case 0: // Use no proxy Logger.log(getClass(), LogLevel.TRACE, "Firefox uses no proxy"); result = NoProxySelector.getInstance(); break; case 1: // Fixed settings Logger.log(getClass(), LogLevel.TRACE, "Firefox uses manual settings"); result = setupFixedProxySelector(settings); break; case 2: // PAC Script String pacScriptUrl = settings.getProperty("network.proxy.autoconfig_url", ""); Logger.log(getClass(), LogLevel.TRACE, "Firefox uses script (PAC) {0}", pacScriptUrl); result = ProxyUtil.buildPacSelectorForUrl(pacScriptUrl); break; case 3: // Backward compatibility to netscape. Logger.log(getClass(), LogLevel.TRACE, "Netscape compability mode -> uses no proxy"); result = NoProxySelector.getInstance(); break; case 4: // WPAD auto config Logger.log(getClass(), LogLevel.TRACE, "Firefox uses automatic detection (WPAD)"); result = new WpadProxySearchStrategy().getProxySelector(); break; default: break; } // Wrap in white list filter. String noProxyList = settings.getProperty("network.proxy.no_proxies_on", null); if (result != null && noProxyList != null && noProxyList.trim().length() > 0) { Logger.log(getClass(), LogLevel.TRACE, "Firefox uses proxy bypass list for: {0}", noProxyList); result = new ProxyBypassListSelector(noProxyList, result); } return result; } /************************************************************************* * Gets the printable name of the search strategy. * * @return the printable name of the search strategy ************************************************************************/ @Override public String getName() { return "firefox"; } /************************************************************************* * Reads the settings file and stores all settings in a Properties map. * * @return the parsed settings. * @throws ProxyException * on read error. ************************************************************************/ public Properties readSettings() throws ProxyException { try { Properties settings = settingsParser.parseSettings(profileScanner); return settings; } catch (IOException e) { throw new ProxyException("No Firefox installation found"); } } /************************************************************************* * Parse the fixed proxy settings and build an ProxySelector for this a * chained configuration. * * @param settings * the proxy settings to evaluate. ************************************************************************/ private ProxySelector setupFixedProxySelector(Properties settings) { ProtocolDispatchSelector ps = new ProtocolDispatchSelector(); installHttpProxy(ps, settings); if (isProxyShared(settings)) { installSharedProxy(ps); } else { installFtpProxy(ps, settings); installSecureProxy(ps, settings); installSocksProxy(ps, settings); } return ps; } /************************************************************************* * @param ps * @param settings * @throws NumberFormatException ************************************************************************/ private void installFtpProxy(ProtocolDispatchSelector ps, Properties settings) throws NumberFormatException { installSelectorForProtocol(ps, settings, "ftp"); } /************************************************************************* * @param ps * @param settings * @throws NumberFormatException ************************************************************************/ private void installHttpProxy(ProtocolDispatchSelector ps, Properties settings) throws NumberFormatException { installSelectorForProtocol(ps, settings, "http"); } /************************************************************************* * Checks if the "share proxy settings" option is set * * @param settings * to parse * @return true if the option is set else false ************************************************************************/ private boolean isProxyShared(Properties settings) { return Boolean.TRUE.toString() .equals(settings.getProperty("network.proxy.share_proxy_settings", "false").toLowerCase()); } /************************************************************************* * @param ps ************************************************************************/ private void installSharedProxy(ProtocolDispatchSelector ps) { ProxySelector httpProxy = ps.getSelector("http"); if (httpProxy != null) { ps.setFallbackSelector(httpProxy); } } /************************************************************************* * @param ps * @param settings * @throws NumberFormatException ************************************************************************/ private void installSocksProxy(ProtocolDispatchSelector ps, Properties settings) throws NumberFormatException { String proxyHost = settings.getProperty("network.proxy.socks", null); int proxyPort = Integer.parseInt(settings.getProperty("network.proxy.socks_port", "0")); if (proxyHost != null && proxyPort != 0) { Logger.log(getClass(), LogLevel.TRACE, "Firefox socks proxy is {0}:{1}", proxyHost, proxyPort); ps.setSelector("socks", new FixedSocksSelector(proxyHost, proxyPort)); } } /************************************************************************* * @param ps * @param settings * @throws NumberFormatException ************************************************************************/ private void installSecureProxy(ProtocolDispatchSelector ps, Properties settings) throws NumberFormatException { String proxyHost = settings.getProperty("network.proxy.ssl", null); int proxyPort = Integer.parseInt(settings.getProperty("network.proxy.ssl_port", "0")); if (proxyHost != null && proxyPort != 0) { Logger.log(getClass(), LogLevel.TRACE, "Firefox secure proxy is {0}:{1}", proxyHost, proxyPort); ps.setSelector("https", new FixedProxySelector(proxyHost, proxyPort)); ps.setSelector("sftp", new FixedProxySelector(proxyHost, proxyPort)); } } /************************************************************************* * Installs a proxy selector for the given protocol when settings are * available. * * @param ps * a ProtocolDispatchSelector to configure. * @param settings * to read the config from. * @param protocol * to configure. * @throws NumberFormatException ************************************************************************/ private void installSelectorForProtocol(ProtocolDispatchSelector ps, Properties settings, String protocol) throws NumberFormatException { String proxyHost = settings.getProperty("network.proxy." + protocol, null); int proxyPort = Integer.parseInt(settings.getProperty("network.proxy." + protocol + "_port", "0")); if (proxyHost != null && proxyPort != 0) { Logger.log(getClass(), LogLevel.TRACE, "Firefox " + protocol + " proxy is {0}:{1}", proxyHost, proxyPort); ps.setSelector(protocol, new FixedProxySelector(proxyHost, proxyPort)); } } } FirefoxSettingParser.java000066400000000000000000000063531302662252000403320ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/browser/firefoxpackage com.github.markusbernhardt.proxy.search.browser.firefox; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Map.Entry; import java.util.Properties; import org.ini4j.Ini; import org.ini4j.Profile.Section; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; /***************************************************************************** * Parser for the Firefox settings file. Will extract all relevant proxy * settings form the configuration file. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ class FirefoxSettingParser { /************************************************************************* * Constructor ************************************************************************/ public FirefoxSettingParser() { super(); } /************************************************************************* * Parse the settings file and extract all network.proxy.* settings from it. * * @param source * of the Firefox profiles. * @return the parsed properties. * @throws IOException * on read error. ************************************************************************/ public Properties parseSettings(FirefoxProfileSource source) throws IOException { // Search settings folder File profileFolder = null; // Read profiles.ini File profilesIniFile = source.getProfilesIni(); if (profilesIniFile.exists()) { Ini profilesIni = new Ini(profilesIniFile); for (Entry entry : profilesIni.entrySet()) { if ("default".equals(entry.getValue().get("Name"))) { if ("1".equals(entry.getValue().get("IsRelative"))) { profileFolder = new File(profilesIniFile.getParentFile().getAbsolutePath(), entry.getValue().get("Path")); } } } } if (profileFolder != null) { Logger.log(getClass(), LogLevel.DEBUG, "Firefox settings folder is {0}", profileFolder); } else { Logger.log(getClass(), LogLevel.DEBUG, "Firefox settings folder not found!"); } // Read settings from file File settingsFile = new File(profileFolder, "prefs.js"); BufferedReader fin = new BufferedReader(new InputStreamReader(new FileInputStream(settingsFile))); Properties result = new Properties(); try { String line = fin.readLine(); while (line != null) { line = line.trim(); if (line.startsWith("user_pref(\"network.proxy")) { line = line.substring(10, line.length() - 2); int index = line.indexOf(","); String key = line.substring(0, index).trim(); if (key.startsWith("\"")) { key = key.substring(1); } if (key.endsWith("\"")) { key = key.substring(0, key.length() - 1); } String value = line.substring(index + 1).trim(); if (value.startsWith("\"")) { value = value.substring(1); } if (value.endsWith("\"")) { value = value.substring(0, value.length() - 1); } result.put(key, value); } line = fin.readLine(); } } finally { fin.close(); } return result; } } LinuxFirefoxProfileSource.java000066400000000000000000000021321302662252000413300ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/browser/firefoxpackage com.github.markusbernhardt.proxy.search.browser.firefox; import java.io.File; import com.github.markusbernhardt.proxy.util.PlatformUtil; /***************************************************************************** * Searches for Firefox profile on an Linux / Unix base system. This will scan * the .mozilla folder in the users home directory to find the profiles. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ // TODO 02.06.2015 bros Format has changed in newer versions of firefox. class LinuxFirefoxProfileSource implements FirefoxProfileSource { /************************************************************************* * Get profiles.ini for the Linux Firefox profile ************************************************************************/ @Override public File getProfilesIni() { File userDir = new File(PlatformUtil.getUserHomeDir()); return new File(userDir, ".mozilla" + File.separator + "firefox" + File.separator + "profiles.ini"); } } OsxFirefoxProfileSource.java000066400000000000000000000022321302662252000410030ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/browser/firefoxpackage com.github.markusbernhardt.proxy.search.browser.firefox; import java.io.File; import com.github.markusbernhardt.proxy.util.PlatformUtil; /***************************************************************************** * Searches for Firefox profile on an OSX system. This will scan the * Library/Application Support/Firefox folder in the users home directory * to find the profiles. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ // TODO 02.06.2015 bros Format has changed in newer versions of firefox. class OsxFirefoxProfileSource implements FirefoxProfileSource { /************************************************************************* * Get profiles.ini for the Linux Firefox profile ************************************************************************/ @Override public File getProfilesIni() { File userDir = new File(PlatformUtil.getUserHomeDir()); return new File(userDir, "Library" + File.separator + "Application Support" + File.separator + "Firefox" + File.separator + "profiles.ini"); } } WinFirefoxProfileSource.java000066400000000000000000000035651302662252000410010ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/browser/firefoxpackage com.github.markusbernhardt.proxy.search.browser.firefox; import java.io.File; import java.io.IOException; import com.sun.jna.platform.win32.Shell32Util; import com.sun.jna.platform.win32.ShlObj; /***************************************************************************** * Finds the Firefox profile on Windows platforms. On Windows the profiles are * located in the users appdata directory under: *

* Mozilla\Firefox\Profiles\ *

* The location of the appdata folder is read from the windows registry. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ // TODO 02.06.2015 bros Format has changed in newer versions of firefox. class WinFirefoxProfileSource implements FirefoxProfileSource { /************************************************************************* * Constructor ************************************************************************/ public WinFirefoxProfileSource() { super(); } /************************************************************************* * Reads the current location of the app data folder from the registry. * * @return a path to the folder. ************************************************************************/ private String getAppFolder() { return Shell32Util.getFolderPath(ShlObj.CSIDL_APPDATA); } /************************************************************************* * Get profiles.ini for the Windows Firefox profile * * @throws IOException * on error. ************************************************************************/ @Override public File getProfilesIni() throws IOException { File appDataDir = new File(getAppFolder()); return new File(appDataDir, "Mozilla" + File.separator + "Firefox" + File.separator + "profiles.ini"); } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/browser/ie/000077500000000000000000000000001302662252000323555ustar00rootroot00000000000000IELocalByPassFilter.java000066400000000000000000000015351302662252000367050ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/browser/iepackage com.github.markusbernhardt.proxy.search.browser.ie; import java.net.URI; import com.github.markusbernhardt.proxy.util.UriFilter; /***************************************************************************** * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class IELocalByPassFilter implements UriFilter { /************************************************************************* * accept * * @see com.github.markusbernhardt.proxy.util.UriFilter#accept(java.net.URI) ************************************************************************/ public boolean accept(URI uri) { if (uri == null) { return false; } String host = uri.getAuthority(); return host != null && !host.contains("."); } } IEProxyConfig.java000066400000000000000000000044721302662252000356350ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/browser/iepackage com.github.markusbernhardt.proxy.search.browser.ie; /***************************************************************************** * Proxy settings container used for the native methods. Will contain the * Internet Explorer proxy settings as reported by windows WinHTTP API. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class IEProxyConfig { private boolean autoDetect; private String autoConfigUrl; private String proxy; private String proxyBypass; /************************************************************************* * Constructor * * @param autoDetect * flag is autodetect is active or not. * @param autoConfigUrl * the URL for a PAC script * @param proxy * the proxy server selected * @param proxyBypass * the proxy bypass address list. ************************************************************************/ public IEProxyConfig(boolean autoDetect, String autoConfigUrl, String proxy, String proxyBypass) { super(); this.autoDetect = autoDetect; this.autoConfigUrl = autoConfigUrl; this.proxy = proxy; this.proxyBypass = proxyBypass; } /************************************************************************* * @return Returns the autoDetect. ************************************************************************/ public boolean isAutoDetect() { return this.autoDetect; } /************************************************************************* * @return Returns the autoConfigUrl. ************************************************************************/ public String getAutoConfigUrl() { return this.autoConfigUrl; } /************************************************************************* * @return Returns the proxy. ************************************************************************/ public String getProxy() { return this.proxy; } /************************************************************************* * @return Returns the proxyBypass. ************************************************************************/ public String getProxyBypass() { return this.proxyBypass; } } IEProxySearchStrategy.java000066400000000000000000000237041302662252000373570ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/browser/iepackage com.github.markusbernhardt.proxy.search.browser.ie; import java.io.ByteArrayInputStream; import java.io.IOException; import java.net.ProxySelector; import java.util.ArrayList; import java.util.List; import java.util.Properties; import com.github.markusbernhardt.proxy.ProxySearchStrategy; import com.github.markusbernhardt.proxy.jna.win.WinHttp; import com.github.markusbernhardt.proxy.jna.win.WinHttpCurrentUserIEProxyConfig; import com.github.markusbernhardt.proxy.selector.fixed.FixedProxySelector; import com.github.markusbernhardt.proxy.selector.misc.ProtocolDispatchSelector; import com.github.markusbernhardt.proxy.selector.pac.PacProxySelector; import com.github.markusbernhardt.proxy.selector.whitelist.ProxyBypassListSelector; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; import com.github.markusbernhardt.proxy.util.ProxyException; import com.github.markusbernhardt.proxy.util.ProxyUtil; import com.github.markusbernhardt.proxy.util.UriFilter; import com.sun.jna.platform.win32.WTypes.LPWSTR; import com.sun.jna.platform.win32.WinDef.DWORD; /***************************************************************************** * Extracts the proxy settings for Microsoft Internet Explorer. The settings are * read by invoking native Windows API methods. * * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 ****************************************************************************/ public class IEProxySearchStrategy implements ProxySearchStrategy { /************************************************************************* * getProxySelector * * @see com.github.markusbernhardt.proxy.ProxySearchStrategy#getProxySelector() ************************************************************************/ @Override public ProxySelector getProxySelector() throws ProxyException { Logger.log(getClass(), LogLevel.TRACE, "Detecting IE proxy settings"); IEProxyConfig ieProxyConfig = readIEProxyConfig(); ProxySelector result = createPacSelector(ieProxyConfig); if (result == null) { result = createFixedProxySelector(ieProxyConfig); } return result; } /************************************************************************* * Gets the printable name of the search strategy. * * @return the printable name of the search strategy ************************************************************************/ @Override public String getName() { return "IE"; } /************************************************************************* * Loads the settings from the windows registry. * * @return WinIESettings containing all proxy settings. ************************************************************************/ public IEProxyConfig readIEProxyConfig() { // Retrieve the IE proxy configuration. WinHttpCurrentUserIEProxyConfig winHttpCurrentUserIeProxyConfig = new WinHttpCurrentUserIEProxyConfig(); boolean result = WinHttp.INSTANCE.WinHttpGetIEProxyConfigForCurrentUser(winHttpCurrentUserIeProxyConfig); if (!result) { return null; } // Create IEProxyConfig instance return new IEProxyConfig(winHttpCurrentUserIeProxyConfig.fAutoDetect, winHttpCurrentUserIeProxyConfig.lpszAutoConfigUrl != null ? winHttpCurrentUserIeProxyConfig.lpszAutoConfigUrl.getValue() : null, winHttpCurrentUserIeProxyConfig.lpszProxy != null ? winHttpCurrentUserIeProxyConfig.lpszProxy.getValue() : null, winHttpCurrentUserIeProxyConfig.lpszProxyBypass != null ? winHttpCurrentUserIeProxyConfig.lpszProxyBypass.getValue() : null); } /************************************************************************* * Parses the settings and creates an PAC ProxySelector for it. * * @param ieSettings * the IE settings to use. * @return a PacProxySelector the selector or null. ************************************************************************/ private PacProxySelector createPacSelector(IEProxyConfig ieProxyConfig) { String pacUrl = null; if (ieProxyConfig.isAutoDetect()) { Logger.log(getClass(), LogLevel.TRACE, "Autodetecting script URL."); // This will take some time. DWORD dwAutoDetectFlags = new DWORD( WinHttp.WINHTTP_AUTO_DETECT_TYPE_DHCP | WinHttp.WINHTTP_AUTO_DETECT_TYPE_DNS_A); LPWSTR ppwszAutoConfigUrl = new LPWSTR(); boolean result = WinHttp.INSTANCE.WinHttpDetectAutoProxyConfigUrl(dwAutoDetectFlags, ppwszAutoConfigUrl); if (result) { pacUrl = ppwszAutoConfigUrl.getValue(); } } if (pacUrl == null) { pacUrl = ieProxyConfig.getAutoConfigUrl(); } if (pacUrl != null && pacUrl.trim().length() > 0) { Logger.log(getClass(), LogLevel.TRACE, "IE uses script: " + pacUrl); // Fix for issue 9 // If the IE has a file URL and it only starts has 2 slashes, // add a third so it can be properly converted to the URL class if (pacUrl.startsWith("file://") && !pacUrl.startsWith("file:///")) { pacUrl = "file:///" + pacUrl.substring(7); } return ProxyUtil.buildPacSelectorForUrl(pacUrl); } return null; } /************************************************************************* * Parses the proxy settings into an ProxySelector. * * @param ieSettings * the settings to use. * @return a ProxySelector, null if no settings are set. * @throws ProxyException * on error. ************************************************************************/ private ProxySelector createFixedProxySelector(IEProxyConfig ieProxyConfig) throws ProxyException { String proxyString = ieProxyConfig.getProxy(); String bypassList = ieProxyConfig.getProxyBypass(); if (proxyString == null) { return null; } Logger.log(getClass(), LogLevel.TRACE, "IE uses manual settings: {0} with bypass list: {1}", proxyString, bypassList); Properties p = parseProxyList(proxyString); ProtocolDispatchSelector ps = new ProtocolDispatchSelector(); addSelectorForProtocol(p, "http", ps); addSelectorForProtocol(p, "https", ps); addSelectorForProtocol(p, "ftp", ps); addSelectorForProtocol(p, "gopher", ps); addSelectorForProtocol(p, "socks", ps); addFallbackSelector(p, ps); ProxySelector result = setByPassListOnSelector(bypassList, ps); return result; } /************************************************************************* * Installs the proxy exclude list on the given selector. * * @param bypassList * the list of urls / hostnames to ignore. * @param ps * the proxy selector to wrap. * @return a wrapped proxy selector that will handle the bypass list. ************************************************************************/ private ProxySelector setByPassListOnSelector(String bypassList, ProtocolDispatchSelector ps) { if (bypassList != null && bypassList.trim().length() > 0) { ProxyBypassListSelector result; if ("".equals(bypassList.trim())) { result = buildLocalBypassSelector(ps); } else { bypassList = bypassList.replace(';', ','); result = new ProxyBypassListSelector(bypassList, ps); } return result; } return ps; } /************************************************************************* * Wraps the given selector to handle "local" addresses * * @param ps * the proxy selector to wrap. * @return a wrapped proxy selector that will handle the local addresses. ************************************************************************/ private ProxyBypassListSelector buildLocalBypassSelector(ProtocolDispatchSelector ps) { List localBypassFilter = new ArrayList(); localBypassFilter.add(new IELocalByPassFilter()); return new ProxyBypassListSelector(localBypassFilter, ps); } /************************************************************************* * Installs a fallback selector that is used whenever no protocol specific * selector is defined. * * @param settings * to take the proxy settings from. * @param ps * to install the created selector on. ************************************************************************/ private void addFallbackSelector(Properties settings, ProtocolDispatchSelector ps) { String proxy = settings.getProperty("default"); if (proxy != null) { ps.setFallbackSelector(ProxyUtil.parseProxySettings(proxy)); } } /************************************************************************* * Creates a selector for a given protocol. The proxy will be taken from the * settings and installed on the dispatch selector. * * @param settings * to take the proxy settings from. * @param protocol * to create a selector for. * @param ps * to install the created selector on. ************************************************************************/ private void addSelectorForProtocol(Properties settings, String protocol, ProtocolDispatchSelector ps) { String proxy = settings.getProperty(protocol); if (proxy != null) { FixedProxySelector protocolSelector = ProxyUtil.parseProxySettings(proxy); ps.setSelector(protocol, protocolSelector); } } /************************************************************************* * Parses the proxy list and splits it by protocol. * * @param proxyString * the proxy list string * @return Properties with separated settings. * @throws ProxyException * on parse error. ************************************************************************/ private Properties parseProxyList(String proxyString) throws ProxyException { Properties p = new Properties(); if (proxyString.indexOf('=') == -1) { p.setProperty("default", proxyString); } else { try { proxyString = proxyString.replace(';', '\n'); p.load(new ByteArrayInputStream(proxyString.getBytes("ISO-8859-1"))); } catch (IOException e) { Logger.log(getClass(), LogLevel.ERROR, "Error reading IE settings as properties: {0}", e); throw new ProxyException(e); } } return p; } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/desktop/000077500000000000000000000000001302662252000317465ustar00rootroot00000000000000DesktopProxySearchStrategy.java000066400000000000000000000064451302662252000400670ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/desktoppackage com.github.markusbernhardt.proxy.search.desktop; import java.net.ProxySelector; import com.github.markusbernhardt.proxy.ProxySearchStrategy; import com.github.markusbernhardt.proxy.search.desktop.gnome.GnomeProxySearchStrategy; import com.github.markusbernhardt.proxy.search.desktop.kde.KdeProxySearchStrategy; import com.github.markusbernhardt.proxy.search.desktop.osx.OsxProxySearchStrategy; import com.github.markusbernhardt.proxy.search.desktop.win.WinProxySearchStrategy; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.PlatformUtil; import com.github.markusbernhardt.proxy.util.ProxyException; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; import com.github.markusbernhardt.proxy.util.PlatformUtil.Desktop; import com.github.markusbernhardt.proxy.util.PlatformUtil.Platform; /***************************************************************************** * This search provider will try to find out on which desktop platform we are * running and then will initialize the default proxy search. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class DesktopProxySearchStrategy implements ProxySearchStrategy { /************************************************************************* * Gets the default ProxySelector for the current platform. * * @return a ProxySelector, null if none is found. * @throws ProxyException * on error. ************************************************************************/ @Override public ProxySelector getProxySelector() throws ProxyException { ProxySearchStrategy strategy = findDesktopSpecificStrategy(); return strategy == null ? null : strategy.getProxySelector(); } /************************************************************************* * Gets the printable name of the search strategy. * * @return the printable name of the search strategy ************************************************************************/ @Override public String getName() { return "desktop"; } /************************************************************************* * Determine the desktop and create a strategy for it. * * @return a desktop specific strategy, null if none was found. ************************************************************************/ private ProxySearchStrategy findDesktopSpecificStrategy() { Platform pf = PlatformUtil.getCurrentPlattform(); Desktop dt = PlatformUtil.getCurrentDesktop(); Logger.log(getClass(), LogLevel.TRACE, "Detecting system settings."); ProxySearchStrategy strategy = null; if (pf == Platform.WIN) { Logger.log(getClass(), LogLevel.TRACE, "We are running on Windows."); strategy = new WinProxySearchStrategy(); } else if (dt == Desktop.KDE) { Logger.log(getClass(), LogLevel.TRACE, "We are running on KDE."); strategy = new KdeProxySearchStrategy(); } else if (dt == Desktop.GNOME) { Logger.log(getClass(), LogLevel.TRACE, "We are running on Gnome."); strategy = new GnomeProxySearchStrategy(); } else if (dt == Desktop.MAC_OS) { Logger.log(getClass(), LogLevel.TRACE, "We are running on Mac OSX."); strategy = new OsxProxySearchStrategy(); } return strategy; } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/desktop/gnome/000077500000000000000000000000001302662252000330535ustar00rootroot00000000000000GnomeDConfProxySearchStrategy.java000066400000000000000000000317011302662252000415330ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/desktop/gnomepackage com.github.markusbernhardt.proxy.search.desktop.gnome; import java.io.IOException; import java.net.ProxySelector; import java.util.Properties; import com.github.markusbernhardt.proxy.ProxySearchStrategy; import com.github.markusbernhardt.proxy.selector.direct.NoProxySelector; import com.github.markusbernhardt.proxy.selector.fixed.FixedProxySelector; import com.github.markusbernhardt.proxy.selector.misc.ProtocolDispatchSelector; import com.github.markusbernhardt.proxy.selector.whitelist.ProxyBypassListSelector; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.ProxyException; import com.github.markusbernhardt.proxy.util.ProxyUtil; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; import java.io.BufferedReader; import java.io.InputStreamReader; /***************************************************************************** * Loads the Gnome proxy settings from the Gnome GConf settings. *

* The following settings are extracted from the configuration that is stored in * .gconf folder found in the user's home directory: *

*
    *
  • org.gnome.system.proxy.http enabled -> bool used only by * gnome-vfs
  • *
  • org.gnome.system.proxy.http host -> string * "my-proxy.example.com" without "http://"
  • *
  • org.gnome.system.proxy.http port -> int
  • *
  • org.gnome.system.proxy.http use-authentication -> bool
  • *
  • org.gnome.system.proxy.http authentication-user -> string
  • *
  • org.gnome.system.proxy.http authentication-password -> string *
  • *
  • org.gnome.system.proxy ignore-hosts -> list-of-string
  • *
  • org.gnome.system.proxy mode -> string THIS IS THE CANONICAL * KEY; SEE BELOW
  • *
  • org.gnome.system.proxy use-same-proxy -> bool
  • *
  • org.gnome.system.proxy.https host -> string * "proxy-for-https.example.com"
  • *
  • org.gnome.system.proxy.https port -> int
  • *
  • org.gnome.system.proxy.ftp host -> string * "proxy-for-ftp.example.com"
  • *
  • org.gnome.system.proxy.ftp port -> int
  • *
  • org.gnome.system.proxy.socks host -> string * "proxy-for-socks.example.com"
  • *
  • org.gnome.system.proxy.socks port -> int
  • *
  • org.gnome.system.proxy autoconfig-url -> string * "http://proxy-autoconfig.example.com"
  • *
* org.gnome.system.proxy mode can be either:
* "none" -> No proxy is used
* "manual" -> The user's configuration values are used * (org.gnome.system.http_proxy/{host,port,etc.})
* "auto" -> The "org.gnome.system.proxy/autoconfig_url" key is used
*

* GNOME Proxy_configuration settings are explained * here in detail *

* * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ // TODO Work in progress: Needs unit tests and testing and code review public class GnomeDConfProxySearchStrategy implements ProxySearchStrategy { /************************************************************************* * ProxySelector * * @see java.net.ProxySelector#ProxySelector() ************************************************************************/ public GnomeDConfProxySearchStrategy() { super(); } /************************************************************************* * Loads the proxy settings and initializes a proxy selector for the Gnome * proxy settings. * * @return a configured ProxySelector, null if none is found. * @throws ProxyException * on file reading error. ************************************************************************/ @Override public ProxySelector getProxySelector() throws ProxyException { Logger.log(getClass(), LogLevel.TRACE, "Detecting Gnome proxy settings"); Properties settings = readSettings(); String type = settings.getProperty("org.gnome.system.proxy mode"); Logger.log(getClass(), LogLevel.TRACE, "Mode is :{0}", type); ProxySelector result = null; if (type == null) { String useProxy = settings.getProperty("org.gnome.system.proxy.http enabled"); if (useProxy == null) { return null; } type = Boolean.parseBoolean(useProxy) ? "manual" : "none"; } if ("none".equals(type)) { Logger.log(getClass(), LogLevel.TRACE, "Gnome uses no proxy"); result = NoProxySelector.getInstance(); } if ("manual".equals(type)) { Logger.log(getClass(), LogLevel.TRACE, "Gnome uses manual proxy settings"); result = setupFixedProxySelector(settings); } if ("auto".equals(type)) { String pacScriptUrl = settings.getProperty("org.gnome.system.proxy autoconfig-url", ""); Logger.log(getClass(), LogLevel.TRACE, "Gnome uses autodetect script {0}", pacScriptUrl); result = ProxyUtil.buildPacSelectorForUrl(pacScriptUrl); } // Wrap into white-list filter? String noProxyList = settings.getProperty("org.gnome.system.proxy ignore-hosts", null); if (result != null && noProxyList != null && noProxyList.trim().length() > 0) { Logger.log(getClass(), LogLevel.TRACE, "Gnome uses proxy bypass list: {0}", noProxyList); result = new ProxyBypassListSelector(noProxyList, result); } return result; } /************************************************************************* * Gets the printable name of the search strategy. * * @return the printable name of the search strategy ************************************************************************/ @Override public String getName() { return "gnome"; } /************************************************************************* * Load the proxy settings from the gconf settings XML file. * * @return the loaded settings stored in a properties object. * @throws ProxyException * on processing error. ************************************************************************/ public Properties readSettings() throws ProxyException { Properties settings = new Properties(); try { parseSettings(settings); } catch (IOException e) { Logger.log(getClass(), LogLevel.ERROR, "Gnome settings read error.", e); throw new ProxyException(e); } return settings; } /************************************************************************* * Parse the fixed proxy settings and build an ProxySelector for this a * chained configuration. * * @param settings * the proxy settings to evaluate. ************************************************************************/ private ProxySelector setupFixedProxySelector(Properties settings) { if (!hasProxySettings(settings)) { return null; } ProtocolDispatchSelector ps = new ProtocolDispatchSelector(); installHttpSelector(settings, ps); if (useForAllProtocols(settings)) { ps.setFallbackSelector(ps.getSelector("http")); } else { installSecureSelector(settings, ps); installFtpSelector(settings, ps); installSocksSelector(settings, ps); } return ps; } /************************************************************************* * Check if the http proxy should also be used for all other protocols. * * @param settings * to inspect. * @return true if only one proxy is configured else false. ************************************************************************/ private boolean useForAllProtocols(Properties settings) { return Boolean.parseBoolean(settings.getProperty("org.gnome.system.proxy use-same-proxy", "false")); } /************************************************************************* * Checks if we have Proxy configuration settings in the properties. * * @param settings * to inspect. * @return true if we have found Proxy settings. ************************************************************************/ private boolean hasProxySettings(Properties settings) { String proxyHost = settings.getProperty("org.gnome.system.proxy.http host", null); return proxyHost != null && proxyHost.length() > 0; } /************************************************************************* * Install a http proxy from the given settings. * * @param settings * to inspect * @param ps * the dispatch selector to configure. * @throws NumberFormatException ************************************************************************/ private void installHttpSelector(Properties settings, ProtocolDispatchSelector ps) throws NumberFormatException { String proxyHost = settings.getProperty("org.gnome.system.proxy.http host", null); int proxyPort = Integer.parseInt(settings.getProperty("org.gnome.system.proxy.http port", "0").trim()); if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) { Logger.log(getClass(), LogLevel.TRACE, "Gnome http proxy is {0}:{1}", proxyHost, proxyPort); ps.setSelector("http", new FixedProxySelector(proxyHost.trim(), proxyPort)); } } /************************************************************************* * Install a socks proxy from the given settings. * * @param settings * to inspect * @param ps * the dispatch selector to configure. * @throws NumberFormatException ************************************************************************/ private void installSocksSelector(Properties settings, ProtocolDispatchSelector ps) throws NumberFormatException { String proxyHost = settings.getProperty("org.gnome.system.proxy.socks host", null); int proxyPort = Integer.parseInt(settings.getProperty("org.gnome.system.proxy.socks port", "0").trim()); if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) { Logger.log(getClass(), LogLevel.TRACE, "Gnome socks proxy is {0}:{1}", proxyHost, proxyPort); ps.setSelector("socks", new FixedProxySelector(proxyHost.trim(), proxyPort)); } } /************************************************************************* * @param settings * @param ps * @throws NumberFormatException ************************************************************************/ private void installFtpSelector(Properties settings, ProtocolDispatchSelector ps) throws NumberFormatException { String proxyHost = settings.getProperty("org.gnome.system.proxy.ftp host", null); int proxyPort = Integer.parseInt(settings.getProperty("org.gnome.system.proxy.ftp port", "0").trim()); if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) { Logger.log(getClass(), LogLevel.TRACE, "Gnome ftp proxy is {0}:{1}", proxyHost, proxyPort); ps.setSelector("ftp", new FixedProxySelector(proxyHost.trim(), proxyPort)); } } /************************************************************************* * @param settings * @param ps * @throws NumberFormatException ************************************************************************/ private void installSecureSelector(Properties settings, ProtocolDispatchSelector ps) throws NumberFormatException { String proxyHost = settings.getProperty("org.gnome.system.proxy.https host", null); int proxyPort = Integer.parseInt(settings.getProperty("org.gnome.system.proxy.https port", "0").trim()); if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) { Logger.log(getClass(), LogLevel.TRACE, "Gnome secure proxy is {0}:{1}", proxyHost, proxyPort); ps.setSelector("https", new FixedProxySelector(proxyHost.trim(), proxyPort)); ps.setSelector("sftp", new FixedProxySelector(proxyHost.trim(), proxyPort)); } } /************************************************************************* * Parse the settings file and extract all network.proxy.* settings from it. * * @param context * the gconf context to parse. * @param settings * the settings object to fill. * @return the parsed properties. * @throws IOException * on read error. ************************************************************************/ private Properties parseSettings(Properties settings) throws IOException { String line; Logger.log(getClass(), LogLevel.TRACE, "exec gsettings list-recursively org.gnome.system.proxy"); Process p = Runtime.getRuntime().exec("gsettings list-recursively org.gnome.system.proxy"); BufferedReader bri = new BufferedReader(new InputStreamReader(p.getInputStream())); while ((line = bri.readLine()) != null) { Logger.log(getClass(), LogLevel.TRACE, line); int schemaSep = line.indexOf(" "); int keySep = line.indexOf(" ", schemaSep + 1); String entry = line.substring(0, keySep); String value = line.substring(keySep + 1).replaceAll("'", ""); // TODO 30.03.2015 bros Test for IP6 compatibility if (value.matches("\\[.*\\]")) { value = value.replaceAll("\\[|\\]| ", ""); } Logger.log(getClass(), LogLevel.TRACE, "prop is: {0}|{1}", entry, value); settings.setProperty(entry, value); } try { p.waitFor(); } catch (InterruptedException ex) { Logger.log(getClass(), LogLevel.ERROR, ex.getMessage()); } return settings; } } GnomeProxySearchStrategy.java000066400000000000000000000361571302662252000406330ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/desktop/gnomepackage com.github.markusbernhardt.proxy.search.desktop.gnome; import java.io.File; import java.io.IOException; import java.net.ProxySelector; import java.util.Properties; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import com.github.markusbernhardt.proxy.ProxySearchStrategy; import com.github.markusbernhardt.proxy.selector.direct.NoProxySelector; import com.github.markusbernhardt.proxy.selector.fixed.FixedProxySelector; import com.github.markusbernhardt.proxy.selector.misc.ProtocolDispatchSelector; import com.github.markusbernhardt.proxy.selector.whitelist.ProxyBypassListSelector; import com.github.markusbernhardt.proxy.util.EmptyXMLResolver; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.PlatformUtil; import com.github.markusbernhardt.proxy.util.ProxyException; import com.github.markusbernhardt.proxy.util.ProxyUtil; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; /***************************************************************************** * Loads the Gnome proxy settings from the Gnome GConf settings. *

* The following settings are extracted from the configuration that is stored in * .gconf folder found in the user's home directory: *

*
    *
  • /system/http_proxy/use_http_proxy -> bool used only by * gnome-vfs
  • *
  • /system/http_proxy/host -> string "my-proxy.example.com" * without "http://"
  • *
  • /system/http_proxy/port -> int
  • *
  • /system/http_proxy/use_authentication -> bool
  • *
  • /system/http_proxy/authentication_user -> string
  • *
  • /system/http_proxy/authentication_password -> string
  • *
  • /system/http_proxy/ignore_hosts -> list-of-string
  • *
  • /system/proxy/mode -> string THIS IS THE CANONICAL KEY; SEE * BELOW
  • *
  • /system/proxy/secure_host -> string * "proxy-for-https.example.com"
  • *
  • /system/proxy/secure_port -> int
  • *
  • /system/proxy/ftp_host -> string "proxy-for-ftp.example.com" *
  • *
  • /system/proxy/ftp_port -> int
  • *
  • /system/proxy/socks_host -> string * "proxy-for-socks.example.com"
  • *
  • /system/proxy/socks_port -> int
  • *
  • /system/proxy/autoconfig_url -> string * "http://proxy-autoconfig.example.com"
  • *
* /system/proxy/mode can be either:
* "none" -> No proxy is used
* "manual" -> The user's configuration values are used * (/system/http_proxy/{host,port,etc.})
* "auto" -> The "/system/proxy/autoconfig_url" key is used
*

* GNOME Proxy_configuration settings are explained * here in detail *

* * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class GnomeProxySearchStrategy implements ProxySearchStrategy { /************************************************************************* * ProxySelector * * @see java.net.ProxySelector#ProxySelector() ************************************************************************/ public GnomeProxySearchStrategy() { super(); } /************************************************************************* * Loads the proxy settings and initializes a proxy selector for the Gnome * proxy settings. * * @return a configured ProxySelector, null if none is found. * @throws ProxyException * on file reading error. ************************************************************************/ @Override public ProxySelector getProxySelector() throws ProxyException { Logger.log(getClass(), LogLevel.TRACE, "Detecting Gnome proxy settings"); Properties settings = readSettings(); String type = settings.getProperty("/system/proxy/mode"); ProxySelector result = null; if (type == null) { String useProxy = settings.getProperty("/system/http_proxy/use_http_proxy"); if (useProxy == null) { return null; } type = Boolean.parseBoolean(useProxy) ? "manual" : "none"; } if ("none".equals(type)) { Logger.log(getClass(), LogLevel.TRACE, "Gnome uses no proxy"); result = NoProxySelector.getInstance(); } if ("manual".equals(type)) { Logger.log(getClass(), LogLevel.TRACE, "Gnome uses manual proxy settings"); result = setupFixedProxySelector(settings); } if ("auto".equals(type)) { String pacScriptUrl = settings.getProperty("/system/proxy/autoconfig_url", ""); Logger.log(getClass(), LogLevel.TRACE, "Gnome uses autodetect script {0}", pacScriptUrl); result = ProxyUtil.buildPacSelectorForUrl(pacScriptUrl); } // Wrap into white-list filter? String noProxyList = settings.getProperty("/system/http_proxy/ignore_hosts", null); if (result != null && noProxyList != null && noProxyList.trim().length() > 0) { Logger.log(getClass(), LogLevel.TRACE, "Gnome uses proxy bypass list: {0}", noProxyList); result = new ProxyBypassListSelector(noProxyList, result); } return result; } /************************************************************************* * Gets the printable name of the search strategy. * * @return the printable name of the search strategy ************************************************************************/ @Override public String getName() { return "gnome"; } /************************************************************************* * Load the proxy settings from the gconf settings XML file. * * @return the loaded settings stored in a properties object. * @throws ProxyException * on processing error. ************************************************************************/ public Properties readSettings() throws ProxyException { Properties settings = new Properties(); try { parseSettings("/system/proxy/", settings); parseSettings("/system/http_proxy/", settings); } catch (IOException e) { Logger.log(getClass(), LogLevel.ERROR, "Gnome settings file error.", e); throw new ProxyException(e); } return settings; } /************************************************************************* * Finds the Gnome GConf settings file. * * @param context * the gconf context to parse. * @return a file or null if does not exist. ************************************************************************/ private File findSettingsFile(String context) { // Normally we should inspect /etc/gconf//path to find out // where the actual file is. // But for normal systems this is always stored in .gconf folder in the // user's home directory. File userDir = new File(PlatformUtil.getUserHomeDir()); // Build directory path for context StringBuilder path = new StringBuilder(); String[] parts = context.split("/"); for (String part : parts) { path.append(part); path.append(File.separator); } File settingsFile = new File(userDir, ".gconf" + File.separator + path.toString() + "%gconf.xml"); if (!settingsFile.exists()) { Logger.log(getClass(), LogLevel.WARNING, "Gnome settings: {0} not found.", settingsFile); return null; } return settingsFile; } /************************************************************************* * Parse the fixed proxy settings and build an ProxySelector for this a * chained configuration. * * @param settings * the proxy settings to evaluate. ************************************************************************/ private ProxySelector setupFixedProxySelector(Properties settings) { if (!hasProxySettings(settings)) { return null; } ProtocolDispatchSelector ps = new ProtocolDispatchSelector(); installHttpSelector(settings, ps); if (useForAllProtocols(settings)) { ps.setFallbackSelector(ps.getSelector("http")); } else { installSecureSelector(settings, ps); installFtpSelector(settings, ps); installSocksSelector(settings, ps); } return ps; } /************************************************************************* * Check if the http proxy should also be used for all other protocols. * * @param settings * to inspect. * @return true if only one proxy is configured else false. ************************************************************************/ private boolean useForAllProtocols(Properties settings) { return Boolean.parseBoolean(settings.getProperty("/system/http_proxy/use_same_proxy", "false")); } /************************************************************************* * Checks if we have Proxy configuration settings in the properties. * * @param settings * to inspect. * @return true if we have found Proxy settings. ************************************************************************/ private boolean hasProxySettings(Properties settings) { String proxyHost = settings.getProperty("/system/http_proxy/host", null); return proxyHost != null && proxyHost.length() > 0; } /************************************************************************* * Install a http proxy from the given settings. * * @param settings * to inspect * @param ps * the dispatch selector to configure. * @throws NumberFormatException ************************************************************************/ private void installHttpSelector(Properties settings, ProtocolDispatchSelector ps) throws NumberFormatException { String proxyHost = settings.getProperty("/system/http_proxy/host", null); int proxyPort = Integer.parseInt(settings.getProperty("/system/http_proxy/port", "0").trim()); if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) { Logger.log(getClass(), LogLevel.TRACE, "Gnome http proxy is {0}:{1}", proxyHost, proxyPort); ps.setSelector("http", new FixedProxySelector(proxyHost.trim(), proxyPort)); } } /************************************************************************* * Install a socks proxy from the given settings. * * @param settings * to inspect * @param ps * the dispatch selector to configure. * @throws NumberFormatException ************************************************************************/ private void installSocksSelector(Properties settings, ProtocolDispatchSelector ps) throws NumberFormatException { String proxyHost = settings.getProperty("/system/proxy/socks_host", null); int proxyPort = Integer.parseInt(settings.getProperty("/system/proxy/socks_port", "0").trim()); if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) { Logger.log(getClass(), LogLevel.TRACE, "Gnome socks proxy is {0}:{1}", proxyHost, proxyPort); ps.setSelector("socks", new FixedProxySelector(proxyHost.trim(), proxyPort)); } } /************************************************************************* * @param settings * @param ps * @throws NumberFormatException ************************************************************************/ private void installFtpSelector(Properties settings, ProtocolDispatchSelector ps) throws NumberFormatException { String proxyHost = settings.getProperty("/system/proxy/ftp_host", null); int proxyPort = Integer.parseInt(settings.getProperty("/system/proxy/ftp_port", "0").trim()); if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) { Logger.log(getClass(), LogLevel.TRACE, "Gnome ftp proxy is {0}:{1}", proxyHost, proxyPort); ps.setSelector("ftp", new FixedProxySelector(proxyHost.trim(), proxyPort)); } } /************************************************************************* * @param settings * @param ps * @throws NumberFormatException ************************************************************************/ private void installSecureSelector(Properties settings, ProtocolDispatchSelector ps) throws NumberFormatException { String proxyHost = settings.getProperty("/system/proxy/secure_host", null); int proxyPort = Integer.parseInt(settings.getProperty("/system/proxy/secure_port", "0").trim()); if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) { Logger.log(getClass(), LogLevel.TRACE, "Gnome secure proxy is {0}:{1}", proxyHost, proxyPort); ps.setSelector("https", new FixedProxySelector(proxyHost.trim(), proxyPort)); ps.setSelector("sftp", new FixedProxySelector(proxyHost.trim(), proxyPort)); } } /************************************************************************* * Parse the settings file and extract all network.proxy.* settings from it. * * @param context * the gconf context to parse. * @param settings * the settings object to fill. * @return the parsed properties. * @throws IOException * on read error. ************************************************************************/ private Properties parseSettings(String context, Properties settings) throws IOException { // Read settings from file File settingsFile = findSettingsFile(context); if (settingsFile == null) { return settings; } try { DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); documentBuilder.setEntityResolver(new EmptyXMLResolver()); Document doc = documentBuilder.parse(settingsFile); Element root = doc.getDocumentElement(); Node entry = root.getFirstChild(); while (entry != null) { if ("entry".equals(entry.getNodeName()) && entry instanceof Element) { String entryName = ((Element) entry).getAttribute("name"); settings.setProperty(context + entryName, getEntryValue((Element) entry)); } entry = entry.getNextSibling(); } } catch (SAXException e) { Logger.log(getClass(), LogLevel.ERROR, "Gnome settings parse error", e); throw new IOException(e.getMessage()); } catch (ParserConfigurationException e) { Logger.log(getClass(), LogLevel.ERROR, "Gnome settings parse error", e); throw new IOException(e.getMessage()); } return settings; } /************************************************************************* * Parse an entry value from a given entry node. * * @param entry * the XML node to inspect. * @return the value, null if it has no value. ************************************************************************/ private String getEntryValue(Element entry) { String type = entry.getAttribute("type"); if ("int".equals(type) || "bool".equals(type)) { return entry.getAttribute("value"); } if ("string".equals(type)) { NodeList list = entry.getElementsByTagName("stringvalue"); if (list.getLength() > 0) { return list.item(0).getTextContent(); } } if ("list".equals(type)) { StringBuilder result = new StringBuilder(); NodeList list = entry.getElementsByTagName("li"); // Build comma separated list of items for (int i = 0; i < list.getLength(); i++) { if (result.length() > 0) { result.append(","); } result.append(getEntryValue((Element) list.item(i))); } return result.toString(); } return null; } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/desktop/kde/000077500000000000000000000000001302662252000325115ustar00rootroot00000000000000KdeProxySearchStrategy.java000066400000000000000000000200311302662252000377070ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/desktop/kdepackage com.github.markusbernhardt.proxy.search.desktop.kde; import java.io.IOException; import java.net.ProxySelector; import java.util.Properties; import com.github.markusbernhardt.proxy.ProxySearchStrategy; import com.github.markusbernhardt.proxy.search.env.EnvProxySearchStrategy; import com.github.markusbernhardt.proxy.search.wpad.WpadProxySearchStrategy; import com.github.markusbernhardt.proxy.selector.direct.NoProxySelector; import com.github.markusbernhardt.proxy.selector.fixed.FixedProxySelector; import com.github.markusbernhardt.proxy.selector.misc.ProtocolDispatchSelector; import com.github.markusbernhardt.proxy.selector.whitelist.ProxyBypassListSelector; import com.github.markusbernhardt.proxy.selector.whitelist.UseProxyWhiteListSelector; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; import com.github.markusbernhardt.proxy.util.ProxyException; import com.github.markusbernhardt.proxy.util.ProxyUtil; /***************************************************************************** * Loads the KDE4 proxy settings from the KDE kioslaverc file. This will * load properties from the file *

* .kde/share/config/kioslaverc *

* starting from the current users home directory. *

* The following settings are extracted from the section "[Proxy Settings]": *

*
    *
  • AuthMode -> 0 = no auth., 1 = use login.
  • *
  • ProxyType -> 0 = direct 1 = use fixed settings, 2 = use PAC, 3 * = automatic (WPAD) , 4 = Use environment variables?
  • *
  • Proxy Config Script -> URL to PAC file
  • *
  • ftpProxy -> Fixed ftp proxy address e.g. * http://www.ftp-proxy.com:8080
  • *
  • httpProxy -> Fixed http proxy e.g * http://www.http-proxy.com:8080
  • *
  • httpsProxy -> Fixed https proxy e.g * http://www.https-proxy.com:8080
  • *
  • NoProxyFor -> Proxy white list
  • *
  • ReversedException -> false = use NoProxyFor, true = revert * meaning of the NoProxyFor list
  • *
* * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class KdeProxySearchStrategy implements ProxySearchStrategy { private KdeSettingsParser settingsParser; /************************************************************************* * ProxySelector using the given parser. * * @see java.net.ProxySelector#ProxySelector() ************************************************************************/ public KdeProxySearchStrategy() { this(new KdeSettingsParser()); } /************************************************************************* * ProxySelector * * @param settingsParser * the KdeSettingsParser instance to use. * @see java.net.ProxySelector#ProxySelector() ************************************************************************/ public KdeProxySearchStrategy(KdeSettingsParser settingsParser) { super(); this.settingsParser = settingsParser; } /************************************************************************* * Loads the proxy settings and initializes a proxy selector for the firefox * proxy settings. * * @return a configured ProxySelector, null if none is found. * @throws ProxyException * on file reading error. ************************************************************************/ @Override public ProxySelector getProxySelector() throws ProxyException { Logger.log(getClass(), LogLevel.TRACE, "Detecting Kde proxy settings"); Properties settings = readSettings(); if (settings == null) { return null; } ProxySelector result = null; int type = Integer.parseInt(settings.getProperty("ProxyType", "-1")); switch (type) { case 0: // Use no proxy Logger.log(getClass(), LogLevel.TRACE, "Kde uses no proxy"); result = NoProxySelector.getInstance(); break; case 1: // Fixed settings Logger.log(getClass(), LogLevel.TRACE, "Kde uses manual proxy settings"); result = setupFixedProxySelector(settings); break; case 2: // PAC Script String pacScriptUrl = settings.getProperty("Proxy Config Script", ""); Logger.log(getClass(), LogLevel.TRACE, "Kde uses autodetect script {0}", pacScriptUrl); result = ProxyUtil.buildPacSelectorForUrl(pacScriptUrl); break; case 3: // WPAD Logger.log(getClass(), LogLevel.TRACE, "Kde uses WPAD to detect the proxy"); result = new WpadProxySearchStrategy().getProxySelector(); break; case 4: // Use environment variables Logger.log(getClass(), LogLevel.TRACE, "Kde reads proxy from environment"); result = setupEnvVarSelector(settings); break; default: break; } return result; } /************************************************************************* * Gets the printable name of the search strategy. * * @return the printable name of the search strategy ************************************************************************/ @Override public String getName() { return "kde"; } /************************************************************************* * Reads the settings and stores them in a properties map. * * @return the parsed settings. * @throws ProxyException ************************************************************************/ private Properties readSettings() throws ProxyException { try { return this.settingsParser.parseSettings(); } catch (IOException e) { Logger.log(getClass(), LogLevel.ERROR, "Can't parse settings.", e); throw new ProxyException(e); } } /************************************************************************* * Builds an environment variable selector. * * @param settings * the settings to read from. * @return the ProxySelector using environment variables. ************************************************************************/ private ProxySelector setupEnvVarSelector(Properties settings) { ProxySelector result; result = new EnvProxySearchStrategy(settings.getProperty("httpProxy"), settings.getProperty("httpsProxy"), settings.getProperty("ftpProxy"), settings.getProperty("NoProxyFor")).getProxySelector(); return result; } /************************************************************************* * Parse the fixed proxy settings and build an ProxySelector for this a * chained configuration. * * @param settings * the proxy settings to evaluate. ************************************************************************/ private ProxySelector setupFixedProxySelector(Properties settings) { String proxyVar = settings.getProperty("httpProxy", null); FixedProxySelector httpPS = ProxyUtil.parseProxySettings(proxyVar); if (httpPS == null) { Logger.log(getClass(), LogLevel.TRACE, "Kde http proxy is {0}", proxyVar); return null; } ProtocolDispatchSelector ps = new ProtocolDispatchSelector(); ps.setSelector("http", httpPS); proxyVar = settings.getProperty("httpsProxy", null); FixedProxySelector httpsPS = ProxyUtil.parseProxySettings(proxyVar); if (httpsPS != null) { Logger.log(getClass(), LogLevel.TRACE, "Kde https proxy is {0}", proxyVar); ps.setSelector("https", httpsPS); } proxyVar = settings.getProperty("ftpProxy", null); FixedProxySelector ftpPS = ProxyUtil.parseProxySettings(proxyVar); if (ftpPS != null) { Logger.log(getClass(), LogLevel.TRACE, "Kde ftp proxy is {0}", proxyVar); ps.setSelector("ftp", ftpPS); } // Wrap in white list filter. String noProxyList = settings.getProperty("NoProxyFor", null); if (noProxyList != null && noProxyList.trim().length() > 0) { boolean reverse = "true".equals(settings.getProperty("ReversedException", "false")); if (reverse) { Logger.log(getClass(), LogLevel.TRACE, "Kde proxy blacklist is {0}", noProxyList); return new UseProxyWhiteListSelector(noProxyList, ps); } else { Logger.log(getClass(), LogLevel.TRACE, "Kde proxy whitelist is {0}", noProxyList); return new ProxyBypassListSelector(noProxyList, ps); } } return ps; } } KdeSettingsParser.java000066400000000000000000000103251302662252000366770ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/desktop/kdepackage com.github.markusbernhardt.proxy.search.desktop.kde; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Properties; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; import com.github.markusbernhardt.proxy.util.PlatformUtil; /***************************************************************************** * Parser for the KDE settings file. The KDE proxy settings are stored in the * file: *

* .kde/share/config/kioslaverc *

* in the users home directory. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class KdeSettingsParser { private File settingsFile; /************************************************************************* * Constructor ************************************************************************/ public KdeSettingsParser() { this(null); } /************************************************************************* * Constructor * * @param settingsFile * the settings file to use. ************************************************************************/ public KdeSettingsParser(File settingsFile) { super(); this.settingsFile = settingsFile; } /************************************************************************* * Parse the settings file and extract all network.proxy.* settings from it. * * @return the parsed properties. * @throws IOException * on read error. ************************************************************************/ public Properties parseSettings() throws IOException { // Search for existing settings. if (this.settingsFile == null) { this.settingsFile = findSettingsFile(); } if (this.settingsFile == null) { return null; } // Read settings from file. BufferedReader fin = new BufferedReader(new InputStreamReader(new FileInputStream(this.settingsFile))); Properties result = new Properties(); try { String line = fin.readLine(); // Find section start. while (line != null && !"[Proxy Settings]".equals(line.trim())) { line = fin.readLine(); } if (line == null) { return result; } // Read full section line = ""; while (line != null && !line.trim().startsWith("[")) { line = line.trim(); int index = line.indexOf('='); if (index > 0) { String key = line.substring(0, index).trim(); String value = line.substring(index + 1).trim(); result.setProperty(key, value); } line = fin.readLine(); } } finally { fin.close(); } return result; } /************************************************************************* * Finds all the KDE network settings file. * * @return a file or null if does not exist. ************************************************************************/ private File findSettingsFile() { File userDir = new File(PlatformUtil.getUserHomeDir()); if ("4".equals(System.getenv("KDE_SESSION_VERSION"))) { this.settingsFile = findSettingsFile(new File(userDir, ".kde4" + File.separator + "share" + File.separator + "config" + File.separator + "kioslaverc")); } if (this.settingsFile == null) { return findSettingsFile(new File(userDir, ".kde" + File.separator + "share" + File.separator + "config" + File.separator + "kioslaverc")); } else { return this.settingsFile; } } /************************************************************************* * Internal method to test if the settings file is at the given place. * * @param settingsFile * the path to test. * @return the file or null if it does not exist. ************************************************************************/ private File findSettingsFile(File settingsFile) { Logger.log(getClass(), LogLevel.TRACE, "Searching Kde settings in {0}", settingsFile); if (!settingsFile.exists()) { Logger.log(getClass(), LogLevel.DEBUG, "Settings not found"); return null; } Logger.log(getClass(), LogLevel.TRACE, "Settings found"); return settingsFile; } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/desktop/osx/000077500000000000000000000000001302662252000325575ustar00rootroot00000000000000OsxProxySearchStrategy.java000066400000000000000000000352021302662252000400310ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/desktop/osxpackage com.github.markusbernhardt.proxy.search.desktop.osx; import java.io.File; import java.io.IOException; import java.net.NetworkInterface; import java.net.ProxySelector; import java.net.SocketException; import java.util.ArrayList; import java.util.Arrays; import java.util.Enumeration; import java.util.List; import com.github.markusbernhardt.proxy.ProxySearchStrategy; import com.github.markusbernhardt.proxy.search.browser.ie.IELocalByPassFilter; import com.github.markusbernhardt.proxy.search.wpad.WpadProxySearchStrategy; import com.github.markusbernhardt.proxy.selector.direct.NoProxySelector; import com.github.markusbernhardt.proxy.selector.fixed.FixedProxySelector; import com.github.markusbernhardt.proxy.selector.fixed.FixedSocksSelector; import com.github.markusbernhardt.proxy.selector.misc.ProtocolDispatchSelector; import com.github.markusbernhardt.proxy.selector.whitelist.ProxyBypassListSelector; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; import com.github.markusbernhardt.proxy.util.PListParser; import com.github.markusbernhardt.proxy.util.PListParser.Dict; import com.github.markusbernhardt.proxy.util.PListParser.XmlParseException; import com.github.markusbernhardt.proxy.util.ProxyException; import com.github.markusbernhardt.proxy.util.ProxyUtil; import com.github.markusbernhardt.proxy.util.UriFilter; /***************************************************************************** * Loads the OSX system proxy settings from the settings file. *

* All settings are stored in OSX in a special XML file format. These settings * file are named plist files and contain nested dictionaries, arrays and * values. *

*

* To parse this file we use a parser that is derived from a plist parser that * comes with the xmlwise XML parser package: *

*

* http://code.google.com/p/xmlwise/ *

*

* I modified that parser to work with the default Java XML parsing library. *

*

* The plist file is located on OSX at: *

*

* /Library/Preferences/SystemConfiguration/preferences.plist *

* * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class OsxProxySearchStrategy implements ProxySearchStrategy { public static final String OVERRIDE_SETTINGS_FILE = "com.github.markusbernhardt.proxy.osx.settingsFile"; public static final String OVERRIDE_ACCEPTED_DEVICES = "com.github.markusbernhardt.proxy.osx.acceptedDevices"; private static final String SETTINGS_FILE = "/Library/Preferences/SystemConfiguration/preferences.plist"; /************************************************************************* * ProxySelector * * @see java.net.ProxySelector#ProxySelector() ************************************************************************/ public OsxProxySearchStrategy() { super(); } /************************************************************************* * Loads the proxy settings and initializes a proxy selector for the OSX * proxy settings. * * @return a configured ProxySelector, null if none is found. * @throws ProxyException * on file reading error. ************************************************************************/ @Override public ProxySelector getProxySelector() throws ProxyException { Logger.log(getClass(), LogLevel.TRACE, "Detecting OSX proxy settings"); try { List acceptedInterfaces = getNetworkInterfaces(); Dict settings = PListParser.load(getSettingsFile()); Object currentSet = settings.getAtPath("/CurrentSet"); if (currentSet == null) { throw new ProxyException("CurrentSet not defined"); } Dict networkSet = (Dict) settings.getAtPath(String.valueOf(currentSet)); // TODO 30.03.2015 bros Test for IP6 compatibility List serviceOrder = (List) networkSet.getAtPath("/Network/Global/IPv4/ServiceOrder"); if (serviceOrder == null || serviceOrder.size() == 0) { throw new ProxyException("ServiceOrder not defined"); } // Look at the Services in priority order and pick the first one // that was // also accepted above Dict proxySettings = null; for (int i = 0; i < serviceOrder.size() && proxySettings == null; i++) { Object candidateService = serviceOrder.get(i); Object networkService = networkSet.getAtPath("/Network/Service/" + candidateService + "/__LINK__"); if (networkService == null) { throw new ProxyException("NetworkService not defined."); } Dict selectedServiceSettings = (Dict) settings.getAtPath("" + networkService); String interfaceName = (String) selectedServiceSettings.getAtPath("/Interface/DeviceName"); if (acceptedInterfaces.contains(interfaceName)) { Logger.log(getClass(), LogLevel.TRACE, "Looking up proxies for device " + interfaceName); proxySettings = (Dict) selectedServiceSettings.getAtPath("/Proxies"); } } if (proxySettings == null) { return NoProxySelector.getInstance(); } return buildSelector(proxySettings); } catch (XmlParseException e) { throw new ProxyException(e); } catch (IOException e) { throw new ProxyException(e); } } /************************************************************************* * Gets the printable name of the search strategy. * * @return the printable name of the search strategy ************************************************************************/ @Override public String getName() { return "osx"; } /************************************************************************* * Build a selector from the given settings. * * @param proxySettings * to parse * @return the configured selector * @throws ProxyException * on error ************************************************************************/ private ProxySelector buildSelector(Dict proxySettings) throws ProxyException { ProtocolDispatchSelector ps = new ProtocolDispatchSelector(); installSelectorForProtocol(proxySettings, ps, "HTTP"); installSelectorForProtocol(proxySettings, ps, "HTTPS"); installSelectorForProtocol(proxySettings, ps, "FTP"); installSelectorForProtocol(proxySettings, ps, "Gopher"); installSelectorForProtocol(proxySettings, ps, "RTSP"); installSocksProxy(proxySettings, ps); ProxySelector result = ps; result = installPacProxyIfAvailable(proxySettings, result); result = autodetectProxyIfAvailable(proxySettings, result); if (result != null) { result = installExceptionList(proxySettings, result); result = installSimpleHostFilter(proxySettings, result); } return result; } /************************************************************************* * Create a list of Ethernet interfaces that are connected * * @return a list of available interface names * @throws SocketException ************************************************************************/ private List getNetworkInterfaces() throws SocketException { String override = System.getProperty(OVERRIDE_ACCEPTED_DEVICES); if (override != null && override.length() > 0) { return Arrays.asList(override.split(";")); } List acceptedInterfaces = new ArrayList(); Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements()) { NetworkInterface ni = interfaces.nextElement(); if (isInterfaceAllowed(ni)) { acceptedInterfaces.add(ni.getName()); } } return acceptedInterfaces; } /************************************************************************* * Check if a given network interface is interesting for us. * * @param ni * the interface to check * @return true if accepted else false. * @throws SocketException * on error. ************************************************************************/ private boolean isInterfaceAllowed(NetworkInterface ni) throws SocketException { return !ni.isLoopback() && !ni.isPointToPoint() && // Not sure if we // should filter the // point to point // interfaces? !ni.isVirtual() && ni.isUp(); } /************************************************************************* * Gets the settings file to parse the settings from. * * @return the settings file. ************************************************************************/ private File getSettingsFile() { File result = new File(SETTINGS_FILE); String overrideFile = System.getProperty(OVERRIDE_SETTINGS_FILE); if (overrideFile != null) { return new File(overrideFile); } return result; } /************************************************************************* * Install a filter to ignore simple host names without domain name. * * @param proxySettings * the dictionary containing all settings * @param result * the proxy selector that needs to be adapted. * @return a wrapped proxy selector that will ignore simple names. ************************************************************************/ private ProxySelector installSimpleHostFilter(Dict proxySettings, ProxySelector result) { if (isActive(proxySettings.get("ExcludeSimpleHostnames"))) { List localBypassFilter = new ArrayList(); localBypassFilter.add(new IELocalByPassFilter()); result = new ProxyBypassListSelector(localBypassFilter, result); } return result; } /************************************************************************* * Install a host name base filter to handle the proxy exclude list. * * @param proxySettings * the dictionary containing all settings * @param result * the proxy selector that needs to be adapted. * @return a wrapped proxy selector that will handle the exclude list. ************************************************************************/ private ProxySelector installExceptionList(Dict proxySettings, ProxySelector result) { List proxyExceptions = (List) proxySettings.get("ExceptionsList"); if (proxyExceptions != null && proxyExceptions.size() > 0) { Logger.log(getClass(), LogLevel.TRACE, "OSX uses proxy bypass list: {0}", proxyExceptions); String noProxyList = toCommaSeparatedString(proxyExceptions); result = new ProxyBypassListSelector(noProxyList, result); } return result; } /************************************************************************* * Convert a list to a comma separated list. * * @param proxyExceptions * list of elements. * @return a comma separated string of the list's content. ************************************************************************/ private String toCommaSeparatedString(List proxyExceptions) { StringBuilder result = new StringBuilder(); for (Object object : proxyExceptions) { if (result.length() > 0) { result.append(","); } result.append(object); } return result.toString(); } /************************************************************************* * Invoke WPAD proxy detection if configured. * * @param proxySettings * the settings to analyse. * @param result * the current proxy selector. * @return a WPAD proxy selector or the passed in proxy selector. * @throws ProxyException * on automatic detection errors. ************************************************************************/ private ProxySelector autodetectProxyIfAvailable(Dict proxySettings, ProxySelector result) throws ProxyException { if (isActive(proxySettings.get("ProxyAutoDiscoveryEnable"))) { ProxySelector wp = new WpadProxySearchStrategy().getProxySelector(); if (wp != null) { result = wp; } } return result; } /************************************************************************* * Use a PAC based proxy selector if configured. * * @param proxySettings * the settings to analyse. * @param result * the current proxy selector. * @return a PAC proxy selector or the passed in proxy selector. ************************************************************************/ private ProxySelector installPacProxyIfAvailable(Dict proxySettings, ProxySelector result) { if (isActive(proxySettings.get("ProxyAutoConfigEnable"))) { String url = (String) proxySettings.get("ProxyAutoConfigURLString"); result = ProxyUtil.buildPacSelectorForUrl(url); } return result; } /************************************************************************* * Build a socks proxy and set it for the socks protocol. * * @param proxySettings * to read the config values from. * @param ps * the ProtocolDispatchSelector to install the new proxy on. ************************************************************************/ private void installSocksProxy(Dict proxySettings, ProtocolDispatchSelector ps) { if (isActive(proxySettings.get("SOCKSEnable"))) { String proxyHost = (String) proxySettings.get("SOCKSProxy"); int proxyPort = (Integer) proxySettings.get("SOCKSPort"); ps.setSelector("socks", new FixedSocksSelector(proxyHost, proxyPort)); Logger.log(getClass(), LogLevel.TRACE, "OSX socks proxy is {0}:{1}", proxyHost, proxyPort); } } /************************************************************************* * Installs a proxy selector for the given protocoll on the * ProtocolDispatchSelector * * @param proxySettings * to read the config for the procotol from. * @param ps * the ProtocolDispatchSelector to install the new selector on. * @param protocol * to use. ************************************************************************/ private void installSelectorForProtocol(Dict proxySettings, ProtocolDispatchSelector ps, String protocol) { String prefix = protocol.trim(); if (isActive(proxySettings.get(prefix + "Enable"))) { String proxyHost = (String) proxySettings.get(prefix + "Proxy"); int proxyPort = (Integer) proxySettings.get(prefix + "Port"); FixedProxySelector fp = new FixedProxySelector(proxyHost, proxyPort); ps.setSelector(protocol.toLowerCase(), fp); Logger.log(getClass(), LogLevel.TRACE, "OSX uses for {0} the proxy {1}:{2}", protocol, proxyHost, proxyPort); } } /************************************************************************* * Checks if the given value is set to "on". * * @param value * the value to test. * @return true if it is set else false. ************************************************************************/ private boolean isActive(Object value) { return Integer.valueOf(1).equals(value); } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/desktop/win/000077500000000000000000000000001302662252000325435ustar00rootroot00000000000000WinProxySearchStrategy.java000066400000000000000000000037111302662252000400010ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/desktop/winpackage com.github.markusbernhardt.proxy.search.desktop.win; import java.net.ProxySelector; import com.github.markusbernhardt.proxy.ProxySearchStrategy; import com.github.markusbernhardt.proxy.search.browser.ie.IEProxySearchStrategy; import com.github.markusbernhardt.proxy.util.ProxyException; /***************************************************************************** * Extracts the proxy settings from the windows registry. This will read the * windows system proxy settings. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class WinProxySearchStrategy implements ProxySearchStrategy { /************************************************************************* * Constructor ************************************************************************/ public WinProxySearchStrategy() { super(); } /************************************************************************* * getProxySelector * * @see com.github.markusbernhardt.proxy.ProxySearchStrategy#getProxySelector() ************************************************************************/ @Override public ProxySelector getProxySelector() throws ProxyException { // TODO Rossi 08.05.2009 Implement this by using Win API calls. // new Win32ProxyUtils().winHttpGetDefaultProxyConfiguration() // Current fallback is to use the IE settings. This is better // because the registry settings are most of the time not set. // Some Windows server installations may use it though. return new IEProxySearchStrategy().getProxySelector(); } /************************************************************************* * Gets the printable name of the search strategy. * * @return the printable name of the search strategy ************************************************************************/ @Override public String getName() { return "windows"; } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/env/000077500000000000000000000000001302662252000310655ustar00rootroot00000000000000EnvProxySearchStrategy.java000066400000000000000000000123611302662252000363170ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/envpackage com.github.markusbernhardt.proxy.search.env; import java.net.ProxySelector; import java.util.Properties; import com.github.markusbernhardt.proxy.ProxySearchStrategy; import com.github.markusbernhardt.proxy.selector.misc.ProtocolDispatchSelector; import com.github.markusbernhardt.proxy.selector.whitelist.ProxyBypassListSelector; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.ProxyUtil; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; /***************************************************************************** * Reads some environment variables and extracts the proxy settings from them. * These variables are mainly set on linux / unix environments. The following * variables are read per default: *
    *
  • http_proxy -> This will be used for http / https
  • *
  • https_proxy -> Will be used for https, if not set then * http_proxy is used instead.
  • *
  • ftp_proxy -> Used for FTP.
  • *
  • no_proxy -> a no proxy white list.
  • *
* * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class EnvProxySearchStrategy implements ProxySearchStrategy { private String httpEnv; private String httpsEnv; private String ftpEnv; private String noProxyEnv; private String httpProxy; private String httpsProxy; private String ftpProxy; private String noProxy; /************************************************************************* * Constructor Will use the default environment variables. ************************************************************************/ public EnvProxySearchStrategy() { this("http_proxy", "https_proxy", "ftp_proxy", "no_proxy"); } /************************************************************************* * Constructor * * @param httpEnv * name of environment variable * @param httpsEnv * name of environment variable * @param ftpEnv * name of environment variable * @param noProxyEnv * name of environment variable ************************************************************************/ public EnvProxySearchStrategy(String httpEnv, String httpsEnv, String ftpEnv, String noProxyEnv) { super(); this.httpEnv = httpEnv; this.httpsEnv = httpsEnv; this.ftpEnv = ftpEnv; this.noProxyEnv = noProxyEnv; loadProxySettings(); } /************************************************************************* * Loads the proxy settings from the system environment variables. ************************************************************************/ private void loadProxySettings() { this.httpProxy = System.getenv(this.httpEnv); this.httpsProxy = System.getenv(this.httpsEnv); this.ftpProxy = System.getenv(this.ftpEnv); this.noProxy = System.getenv(this.noProxyEnv); } /************************************************************************* * Loads the settings and stores them in a properties map. * * @return the settings. ************************************************************************/ public Properties readSettings() { Properties result = new Properties(); result.setProperty(this.httpEnv, this.httpProxy); result.setProperty(this.httpsEnv, this.httpsProxy); result.setProperty(this.ftpEnv, this.ftpProxy); result.setProperty(this.noProxyEnv, this.noProxy); return result; } /************************************************************************* * Loads the proxy settings from environment variables. * * @return a configured ProxySelector, null if none is found. ************************************************************************/ @Override public ProxySelector getProxySelector() { Logger.log(getClass(), LogLevel.TRACE, "Inspecting environment variables."); // Check if http_proxy var is set. ProxySelector httpPS = ProxyUtil.parseProxySettings(this.httpProxy); if (httpPS == null) { return null; } Logger.log(getClass(), LogLevel.TRACE, "Http Proxy is {0}", this.httpProxy); ProtocolDispatchSelector ps = new ProtocolDispatchSelector(); ps.setSelector("http", httpPS); ProxySelector httpsPS = ProxyUtil.parseProxySettings(this.httpsProxy); Logger.log(getClass(), LogLevel.TRACE, "Https Proxy is {0}", httpsPS == null ? this.httpsProxy : httpsPS); ps.setSelector("https", httpsPS != null ? httpsPS : httpPS); ProxySelector ftpPS = ProxyUtil.parseProxySettings(this.ftpProxy); if (ftpPS != null) { Logger.log(getClass(), LogLevel.TRACE, "Ftp Proxy is {0}", this.ftpProxy); ps.setSelector("ftp", ftpPS); } // Wrap with white list support ProxySelector result = ps; if (this.noProxy != null && this.noProxy.trim().length() > 0) { Logger.log(getClass(), LogLevel.TRACE, "Using proxy bypass list: {0}", this.noProxy); result = new ProxyBypassListSelector(this.noProxy, ps); } return result; } /************************************************************************* * Gets the printable name of the search strategy. * * @return the printable name of the search strategy ************************************************************************/ @Override public String getName() { return "env"; } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/java/000077500000000000000000000000001302662252000312165ustar00rootroot00000000000000JavaProxySearchStrategy.java000066400000000000000000000125061302662252000366020ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/javapackage com.github.markusbernhardt.proxy.search.java; import java.net.ProxySelector; import com.github.markusbernhardt.proxy.ProxySearchStrategy; import com.github.markusbernhardt.proxy.selector.fixed.FixedProxySelector; import com.github.markusbernhardt.proxy.selector.fixed.FixedSocksSelector; import com.github.markusbernhardt.proxy.selector.misc.ProtocolDispatchSelector; import com.github.markusbernhardt.proxy.selector.whitelist.ProxyBypassListSelector; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; /***************************************************************************** * Reads some java system properties and extracts the proxy settings from them. * The following variables are read: *
    *
  • http.proxyHost (default: none)
  • *
  • http.proxyPort (default: 80 if http.proxyHost specified)
  • *
  • http.nonProxyHosts (default: none)
  • *
*
    *
  • https.proxyHost (default: none)
  • *
  • https.proxyPort (default: 443 if https.proxyHost specified)
  • *
*
    *
  • ftp.proxyHost (default: none)
  • *
  • ftp.proxyPort (default: 80 if ftp.proxyHost specified)
  • *
  • ftp.nonProxyHosts (default: none)
  • *
*
    *
  • socksProxyHost
  • *
  • socksProxyPort (default: 1080)
  • *
*

* This is based on information found here:
* http://download.oracle.com/javase/6/docs/technotes/guides/net/proxies.html *

* If the "http.proxyHost" property is not set then the no proxy selector is * setup This property is used as marker to signal that the System settings * should be used. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class JavaProxySearchStrategy implements ProxySearchStrategy { /************************************************************************* * Constructor Will use the default environment variables. ************************************************************************/ public JavaProxySearchStrategy() { super(); } /************************************************************************* * Loads the proxy settings from environment variables. * * @return a configured ProxySelector, null if none is found. ************************************************************************/ @Override public ProxySelector getProxySelector() { ProtocolDispatchSelector ps = new ProtocolDispatchSelector(); Logger.log(getClass(), LogLevel.TRACE, "Using settings from Java System Properties"); setupProxyForProtocol(ps, "http", 80); setupProxyForProtocol(ps, "https", 443); setupProxyForProtocol(ps, "ftp", 80); setupProxyForProtocol(ps, "ftps", 80); boolean socksAvailable = setupSocktProxy(ps); if (ps.size() == 0 && !socksAvailable) { return null; } return ps; } /************************************************************************* * Gets the printable name of the search strategy. * * @return the printable name of the search strategy ************************************************************************/ @Override public String getName() { return "java"; } /************************************************************************* * Parse SOCKS settings * * @param ps * @throws NumberFormatException ************************************************************************/ private boolean setupSocktProxy(ProtocolDispatchSelector ps) { String host = System.getProperty("socksProxyHost"); if (host == null || host.trim().length() == 0) { return false; } String port = System.getProperty("socksProxyPort", "1080"); Logger.log(getClass(), LogLevel.TRACE, "Socks proxy {0}:{1} found", host, port); ps.setFallbackSelector(new FixedSocksSelector(host, Integer.parseInt(port))); return true; } /************************************************************************* * Parse properties for the given protocol. * * @param ps * @param protocol * @throws NumberFormatException ************************************************************************/ private void setupProxyForProtocol(ProtocolDispatchSelector ps, String protocol, int defaultPort) { String host = System.getProperty(protocol + ".proxyHost"); if (host == null || host.trim().length() == 0) { return; } String port = System.getProperty(protocol + ".proxyPort", Integer.toString(defaultPort)); String whiteList = System.getProperty(protocol + ".nonProxyHosts", "").replace('|', ','); if ("https".equalsIgnoreCase(protocol)) { // This is dirty but https has // no own property for it. whiteList = System.getProperty("http.nonProxyHosts", "").replace('|', ','); } Logger.log(getClass(), LogLevel.TRACE, protocol.toUpperCase() + " proxy {0}:{1} found using whitelist: {2}", host, port, whiteList); ProxySelector protocolSelector = new FixedProxySelector(host, Integer.parseInt(port)); if (whiteList.trim().length() > 0) { protocolSelector = new ProxyBypassListSelector(whiteList, protocolSelector); } ps.setSelector(protocol, protocolSelector); } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/wpad/000077500000000000000000000000001302662252000312305ustar00rootroot00000000000000WpadProxySearchStrategy.java000066400000000000000000000130571302662252000366300ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/wpadpackage com.github.markusbernhardt.proxy.search.wpad; import java.io.IOException; import java.net.HttpURLConnection; import java.net.InetAddress; import java.net.Proxy; import java.net.ProxySelector; import java.net.URL; import java.net.UnknownHostException; import java.util.Properties; import com.github.markusbernhardt.proxy.ProxySearchStrategy; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.ProxyException; import com.github.markusbernhardt.proxy.util.ProxyUtil; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; /***************************************************************************** * Uses automatic proxy script search (WPAD) to find an PAC file automatically. *

* Note: at the moment only the DNS name guessing schema is implemented. All * others are missing. *

*

* For more information about WPAD: * * Web_Proxy_Autodiscovery_Protocol *

*

* Outdated RFC draft: * draft-ietf-wrec-wpad-01.txt *

* * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class WpadProxySearchStrategy implements ProxySearchStrategy { /************************************************************************* * Constructor ************************************************************************/ public WpadProxySearchStrategy() { super(); } /************************************************************************* * Loads the proxy settings from a PAC file. The location of the PAC file is * determined automatically. * * @return a configured ProxySelector, null if none is found. * @throws ProxyException * on error. ************************************************************************/ @Override public ProxySelector getProxySelector() throws ProxyException { try { Logger.log(getClass(), LogLevel.TRACE, "Using WPAD to find a proxy"); String pacScriptUrl = detectScriptUrlPerDHCP(); if (pacScriptUrl == null) { pacScriptUrl = detectScriptUrlPerDNS(); } if (pacScriptUrl == null) { return null; } Logger.log(getClass(), LogLevel.TRACE, "PAC script url found: {0}", pacScriptUrl); return ProxyUtil.buildPacSelectorForUrl(pacScriptUrl); } catch (IOException e) { Logger.log(getClass(), LogLevel.ERROR, "Error during WPAD search.", e); throw new ProxyException(e); } } /************************************************************************* * Gets the printable name of the search strategy. * * @return the printable name of the search strategy ************************************************************************/ @Override public String getName() { return "wpad"; } /************************************************************************* * Loads the settings and stores them in a properties map. * * @return the settings. ************************************************************************/ public Properties readSettings() { try { String pacScriptUrl = detectScriptUrlPerDHCP(); if (pacScriptUrl == null) { pacScriptUrl = detectScriptUrlPerDNS(); } if (pacScriptUrl == null) { return null; } Properties result = new Properties(); result.setProperty("url", pacScriptUrl); return result; } catch (IOException e) { // Ignore and return empty properties. return new Properties(); } } /************************************************************************* * Uses DNS to find the script URL. Attention: this detection method is * known to have some severe security issues. * * @return the URL, null if not found. ************************************************************************/ private String detectScriptUrlPerDNS() throws IOException { String result = null; String fqdn = InetAddress.getLocalHost().getCanonicalHostName(); if (fqdn.equalsIgnoreCase("localhost") || fqdn.length() == 0 || Character.isDigit(fqdn.charAt(0))) { return result; } Logger.log(getClass(), LogLevel.TRACE, "Searching per DNS guessing."); int index = fqdn.indexOf('.'); while (index != -1 && result == null) { fqdn = fqdn.substring(index + 1); // if we are already on TLD level then escape if (fqdn.indexOf('.') == -1) { break; } // Try to connect to URL try { URL lookupURL = new URL("http://wpad." + fqdn + "/wpad.dat"); Logger.log(getClass(), LogLevel.TRACE, "Trying url: {0}", lookupURL); HttpURLConnection con = (HttpURLConnection) lookupURL.openConnection(Proxy.NO_PROXY); con.setInstanceFollowRedirects(true); con.setRequestProperty("accept", "application/x-ns-proxy-autoconfig"); if (con.getResponseCode() == 200) { result = lookupURL.toString(); } con.disconnect(); } catch (UnknownHostException e) { Logger.log(getClass(), LogLevel.DEBUG, "Not available!"); // Not a real error, try next address } index = fqdn.indexOf('.'); } return result; } /************************************************************************* * Uses DHCP to find the script URL. * * @return the URL, null if not found. ************************************************************************/ private String detectScriptUrlPerDHCP() { Logger.log(getClass(), LogLevel.DEBUG, "Searching per DHCP not supported yet."); // TODO Rossi 28.04.2009 Not implemented yet. return null; } } WpadProxySearchStrategyWithDHPC.java000066400000000000000000000156151302662252000401250ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/wpadpackage com.github.markusbernhardt.proxy.search.wpad; import java.io.IOException; import java.net.HttpURLConnection; import java.net.InetAddress; import java.net.Proxy; import java.net.ProxySelector; import java.net.URL; import java.net.UnknownHostException; import java.util.Properties; import com.github.markusbernhardt.proxy.ProxySearchStrategy; import com.github.markusbernhardt.proxy.search.wpad.dhcp.DHCPMessage; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.ProxyException; import com.github.markusbernhardt.proxy.util.ProxyUtil; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; /***************************************************************************** * Uses automatic proxy script search (WPAD) to find an PAC file automatically. *

* Note: at the moment only the DNS name guessing schema is implemented. All * others are missing. *

*

* For more information about WPAD: * * Web_Proxy_Autodiscovery_Protocol *

*

* Outdated RFC draft: * draft-ietf-wrec-wpad-01.txt *

* * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class WpadProxySearchStrategyWithDHPC implements ProxySearchStrategy { /************************************************************************* * Constructor ************************************************************************/ public WpadProxySearchStrategyWithDHPC() { super(); } /************************************************************************* * Loads the proxy settings from a PAC file. The location of the PAC file is * determined automatically. * * @return a configured ProxySelector, null if none is found. * @throws ProxyException * on error. ************************************************************************/ @Override public ProxySelector getProxySelector() throws ProxyException { try { Logger.log(getClass(), LogLevel.TRACE, "Using WPAD to find a proxy"); String pacScriptUrl = detectScriptUrlPerDHCP(); if (pacScriptUrl == null) { pacScriptUrl = detectScriptUrlPerDNS(); } if (pacScriptUrl == null) { return null; } Logger.log(getClass(), LogLevel.TRACE, "PAC script url found: {0}", pacScriptUrl); return ProxyUtil.buildPacSelectorForUrl(pacScriptUrl); } catch (IOException e) { Logger.log(getClass(), LogLevel.ERROR, "Error during WPAD search.", e); throw new ProxyException(e); } } /************************************************************************* * Gets the printable name of the search strategy. * * @return the printable name of the search strategy ************************************************************************/ @Override public String getName() { return "wpad"; } /************************************************************************* * Loads the settings and stores them in a properties map. * * @return the settings. ************************************************************************/ public Properties readSettings() { try { String pacScriptUrl = detectScriptUrlPerDHCP(); if (pacScriptUrl == null) { pacScriptUrl = detectScriptUrlPerDNS(); } if (pacScriptUrl == null) { return null; } Properties result = new Properties(); result.setProperty("url", pacScriptUrl); return result; } catch (IOException e) { // Ignore and return empty properties. return new Properties(); } } /************************************************************************* * Uses DNS to find the script URL. Attention: this detection method is * known to have some severe security issues. * * @return the URL, null if not found. ************************************************************************/ private String detectScriptUrlPerDNS() throws IOException { String result = null; String fqdn = InetAddress.getLocalHost().getCanonicalHostName(); Logger.log(getClass(), LogLevel.TRACE, "Searching per DNS guessing."); int index = fqdn.indexOf('.'); while (index != -1 && result == null) { fqdn = fqdn.substring(index + 1); // if we are already on TLD level then escape if (fqdn.indexOf('.') == -1) { break; } // Try to connect to URL try { URL lookupURL = new URL("http://wpad." + fqdn + "/wpad.dat"); Logger.log(getClass(), LogLevel.TRACE, "Trying url: {0}", lookupURL); HttpURLConnection con = (HttpURLConnection) lookupURL.openConnection(Proxy.NO_PROXY); con.setInstanceFollowRedirects(true); con.setRequestProperty("accept", "application/x-ns-proxy-autoconfig"); if (con.getResponseCode() == 200) { result = lookupURL.toString(); } con.disconnect(); } catch (UnknownHostException e) { Logger.log(getClass(), LogLevel.DEBUG, "Not available!"); // Not a real error, try next address } index = fqdn.indexOf('.'); } return result; } /************************************************************************* * Uses DHCP to find the script URL. * * @return the URL, null if not found. ************************************************************************/ private String detectScriptUrlPerDHCP() { Logger.log(getClass(), LogLevel.DEBUG, "Searching per DHCP not supported yet."); // TODO Rossi 28.04.2009 Not implemented yet. return null; } // Sends DHCPREQUEST Message and returns server message @SuppressWarnings("unused") private DHCPMessage SendRequest(DHCPMessage offerMessageIn) { // DHCPSocket bindSocket = new DHCPSocket(DHCPMessage.CLIENT_PORT); // // DHCPMessage messageOut = new DHCPMessage(DHCPMessage.SERVER_PORT); // DHCPMessage messageIn = new DHCPMessage(DHCPMessage.CLIENT_PORT); // try { // messageOut = offerMessageIn; // messageOut.setOp((byte) 1); // setup message to send a DCHPREQUEST // byte[] opt = new byte[1]; // opt[0] = DHCPMessage.DHCPREQUEST; // messageOut.setOption(DHCPMessage.DHCPDISCOVER, opt); // change // message type // messageOut.setOption(REQUESTED_IP, offerMessageIn.getYiaddr()); // bindSocket.send(messageOut); // send DHCPREQUEST // System.out.print(this.getName()); // System.out.print(" sending DHCPREQUEST for "); // System.out.println(bytesToString(offerMessageIn // .getOption(REQUESTED_IP))); // boolean sentinal = true; // while (sentinal) { // if (bindSocket.receive(messageIn)) { // if (messageOut.getXid() == messageIn.getXid()) { // sentinal = false; // } else { // bindSocket.send(messageOut); // } // } else { // bindSocket.send(messageOut); // } // } // } catch (SocketException e) { // System.err.println(e); // } catch (IOException e) { // System.err.println(e); // } // end catch // return messageIn; return null; } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/wpad/dhcp/000077500000000000000000000000001302662252000321465ustar00rootroot00000000000000DHCPMessage.java000066400000000000000000000505261302662252000347650ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/wpad/dhcppackage com.github.markusbernhardt.proxy.search.wpad.dhcp; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; /** * This class represents a DHCP Message. * * @author Markus Bernhardt, Copyright 2016 * @author Jason Goldschmidt, Nick Stone and Simon Frankenberger * @author Bernd Rosstauscher, Copyright 2009 */ public class DHCPMessage { // ----------------------------------------------------------- // Constants // ----------------------------------------------------------- /** * Operation for a request */ public static final byte OP_REQUEST = 1; /** * Operation for a reply */ public static final byte OP_REPLY = 2; /** * Message Code representing a DHCPDISCOVER message */ public static final byte DHCPDISCOVER = 1; /** * Message Code representing a DHCPOFFER message */ public static final byte DHCPOFFER = 2; /** * Message Code representing a DHCPREQUEST message */ public static final byte DHCPREQUEST = 3; /** * Message Code representing a DHCPDECLINE message */ public static final byte DHCPDECLINE = 4; /** * Message Code representing a DHCPACK message */ public static final byte DHCPACK = 5; /** * Message Code representing a DHCPNAK message */ public static final byte DHCPNAK = 6; /** * Message Code representing a DHCPRELEASE message */ public static final byte DHCPRELEASE = 7; /** * Message Code representing a DHCPINFORM message */ public static final byte DHCPINFORM = 8; /** * Default DHCP client port */ public static final int CLIENT_PORT = 68; // client port (by default) /** * Default DHCP server port */ public static final int SERVER_PORT = 67; // server port (by default) /** * Broadcast Adress to send packets to */ public static InetAddress BROADCAST_ADDR = null; // ----------------------------------------------------------- // Fields defining a dhcp message // ----------------------------------------------------------- /** * Operation Code.
*
* Can either be {@link #OP_REQUEST} or {@link #OP_REPLY}. */ private byte op; /** * Networktype as defined by * RFC1340 page 54. */ private byte htype; /** * Hardware address length (e.g. '6' for ethernet). */ private byte hlen; /** * Client sets to zero, optionally used by relay-agents when booting via a * relay-agent. */ private byte hops; /** * Transaction ID, a random number chosen by the client, used by the client * and server to associate messages and responses between a client and a * server. */ private int xid; /** * Filled in by client, seconds elapsed since client started trying to boot. */ private short secs; /** * Flags for this message.
* The leftmost bit is defined as the BROADCAST (B) flag. */ private short flags; /** * Client IP address; filled in by client in DHCPREQUEST if verifying * previously allocated configuration parameters. */ private byte ciaddr[] = new byte[4]; /** * 'your' (client) IP address. */ private byte yiaddr[] = new byte[4]; /** * IP address of next server to use in bootstrap; returned in DHCPOFFER, * DHCPACK and DHCPNAK by server. */ private byte siaddr[] = new byte[4]; /** * Relay agent IP address, used in booting via a relay-agent. */ private byte giaddr[] = new byte[4]; /** * Client hardware address. */ private byte chaddr[] = new byte[16]; /** * Optional server host name, null terminated string. */ private byte sname[] = new byte[64]; /** * Boot file name, null terminated string; "generic" name or null in * DHCPDISCOVER, fully qualified directory-path name in DHCPOFFER. */ private byte file[] = new byte[128]; /** * Internal representation of the given DHCP options. */ private DHCPOptions optionsList = null; /** * global port variable for this message */ private int gPort; /** * The destination IP-Adress of this message */ private InetAddress destination_IP; static { try { BROADCAST_ADDR = InetAddress.getByName("255.255.255.255"); // broadcast address(by default) } catch (UnknownHostException e) { // Broadcast address must always exist } } // ----------------------------------------------------------- // Constructors // ----------------------------------------------------------- /** * Creates empty DHCPMessage object, initializes the object, sets the host * to the broadcast address, the local subnet, binds to the default server * port. */ public DHCPMessage() { initialize(); this.destination_IP = BROADCAST_ADDR; this.gPort = SERVER_PORT; } /** * Copy constructor creates DHCPMessage from inMessage * * @param inMessage * The message to be copied */ public DHCPMessage(DHCPMessage inMessage) { initialize(); this.destination_IP = BROADCAST_ADDR; this.gPort = SERVER_PORT; this.op = inMessage.getOp(); this.htype = inMessage.getHtype(); this.hlen = inMessage.getHlen(); this.hops = inMessage.getHops(); this.xid = inMessage.getXid(); this.secs = inMessage.getSecs(); this.flags = inMessage.getFlags(); this.ciaddr = inMessage.getCiaddr(); this.yiaddr = inMessage.getYiaddr(); this.siaddr = inMessage.getSiaddr(); this.giaddr = inMessage.getGiaddr(); this.chaddr = inMessage.getChaddr(); this.sname = inMessage.getSname(); this.file = inMessage.getFile(); this.optionsList.internalize(inMessage.getOptions()); } /** * Copy constructor creates DHCPMessage from inMessage and sets server and * port. * * @param inMessage * The message to be copied * @param inServername * The host name * @param inPort * The port number */ public DHCPMessage(DHCPMessage inMessage, InetAddress inServername, int inPort) { initialize(); this.destination_IP = inServername; this.gPort = inPort; this.op = inMessage.getOp(); this.htype = inMessage.getHtype(); this.hlen = inMessage.getHlen(); this.hops = inMessage.getHops(); this.xid = inMessage.getXid(); this.secs = inMessage.getSecs(); this.flags = inMessage.getFlags(); this.ciaddr = inMessage.getCiaddr(); this.yiaddr = inMessage.getYiaddr(); this.siaddr = inMessage.getSiaddr(); this.giaddr = inMessage.getGiaddr(); this.chaddr = inMessage.getChaddr(); this.sname = inMessage.getSname(); this.file = inMessage.getFile(); this.optionsList.internalize(inMessage.getOptions()); } /** * Copy constructor creates DHCPMessage from inMessage and sets server name. * * @param inMessage * The message to be copied * @param inServername * The host name */ public DHCPMessage(DHCPMessage inMessage, InetAddress inServername) { initialize(); this.destination_IP = inServername; this.gPort = SERVER_PORT; this.op = inMessage.getOp(); this.htype = inMessage.getHtype(); this.hlen = inMessage.getHlen(); this.hops = inMessage.getHops(); this.xid = inMessage.getXid(); this.secs = inMessage.getSecs(); this.flags = inMessage.getFlags(); this.ciaddr = inMessage.getCiaddr(); this.yiaddr = inMessage.getYiaddr(); this.siaddr = inMessage.getSiaddr(); this.giaddr = inMessage.getGiaddr(); this.chaddr = inMessage.getChaddr(); this.sname = inMessage.getSname(); this.file = inMessage.getFile(); this.optionsList.internalize(inMessage.getOptions()); } /** * Creates an empty DHCPMessage object, initializes the object, sets the * host to a specified host name, and binds to a specified port. * * @param inServername * The host name * @param inPort * The port number */ public DHCPMessage(InetAddress inServername, int inPort) { initialize(); this.destination_IP = inServername; this.gPort = inPort; } /** * Creates an empty DHCPMessage object, initializes the object, sets the * host to a specified host name, and binds to the default port. * * @param inServername * The host name */ public DHCPMessage(InetAddress inServername) { initialize(); this.destination_IP = inServername; this.gPort = SERVER_PORT; } /** * Creates an empty DHCPMessage object, initializes the object, sets the * host to the broadcast address, and binds to a specified port. * * @param inPort * The port number */ public DHCPMessage(int inPort) { initialize(); this.destination_IP = BROADCAST_ADDR; this.gPort = inPort; } /** * Creates an empty DHCPMessage object, initializes the object with a * specified byte array containing DHCP message information, sets the host * to default host name, the local subnet, and bind to the default server * port. * * @param ibuf * The byte array to initialize DHCPMessage object */ public DHCPMessage(byte[] ibuf) { initialize(); internalize(ibuf); this.destination_IP = BROADCAST_ADDR; this.gPort = SERVER_PORT; } /** * Creates an empty DHCPMessage object, initializes the object with a * specified byte array containing DHCP message information, sets the host * to specified host name, and binds to the specified port. * * @param ibuf * The byte array to initialize DHCPMessage object * @param inServername * The hostname * @param inPort * The port number */ public DHCPMessage(byte[] ibuf, InetAddress inServername, int inPort) { initialize(); internalize(ibuf); this.destination_IP = inServername; this.gPort = inPort; } /** * Creates an empty DHCPMessage object, initializes the object with a * specified byte array containing DHCP message information, sets the host * to broadcast address, and binds to the specified port. * * @param ibuf * The byte array to initialize DHCPMessage object * @param inPort * The port number */ public DHCPMessage(byte ibuf[], int inPort) { initialize(); internalize(ibuf); this.destination_IP = BROADCAST_ADDR; this.gPort = inPort; } /** * Creates an empty DHCPMessage object, initializes the object with a * specified byte array containing DHCP message information, sets the host * to specified host name, and binds to the specified port. * * @param ibuf * The byte array to initialize DHCPMessage object * @param inServername * The hostname */ public DHCPMessage(byte[] ibuf, InetAddress inServername) { initialize(); internalize(ibuf); this.destination_IP = inServername; this.gPort = SERVER_PORT; } /** * Creates a new DHCPMessage object from the giben DataInputStream. * * @param inStream * The stream to read from */ public DHCPMessage(DataInputStream inStream) { initialize(); try { this.op = inStream.readByte(); this.htype = inStream.readByte(); this.hlen = inStream.readByte(); this.hops = inStream.readByte(); this.xid = inStream.readInt(); this.secs = inStream.readShort(); this.flags = inStream.readShort(); inStream.readFully(this.ciaddr, 0, 4); inStream.readFully(this.yiaddr, 0, 4); inStream.readFully(this.siaddr, 0, 4); inStream.readFully(this.giaddr, 0, 4); inStream.readFully(this.chaddr, 0, 16); inStream.readFully(this.sname, 0, 64); inStream.readFully(this.file, 0, 128); byte[] options = new byte[312]; inStream.readFully(options, 0, 312); this.optionsList.internalize(options); } catch (IOException e) { System.err.println(e); } } // ----------------------------------------------------------- // Methods // ----------------------------------------------------------- /** * Initializes datamembers in the constructors every empty DHCPMessage * object will by default contain these params. Initializes options array * from linked list form. */ private void initialize() { this.optionsList = new DHCPOptions(); } /** * Converts a DHCPMessage object to a byte array. * * @return A byte array with information from DHCPMessage object, ready to * send. */ public synchronized byte[] externalize() { ByteArrayOutputStream outBStream = new ByteArrayOutputStream(); DataOutputStream outStream = new DataOutputStream(outBStream); try { outStream.writeByte(this.op); outStream.writeByte(this.htype); outStream.writeByte(this.hlen); outStream.writeByte(this.hops); outStream.writeInt(this.xid); outStream.writeShort(this.secs); outStream.writeShort(this.flags); outStream.write(this.ciaddr, 0, 4); outStream.write(this.yiaddr, 0, 4); outStream.write(this.siaddr, 0, 4); outStream.write(this.giaddr, 0, 4); outStream.write(this.chaddr, 0, 16); outStream.write(this.sname, 0, 64); outStream.write(this.file, 0, 128); byte[] options = new byte[312]; if (this.optionsList == null) { initialize(); } options = this.optionsList.externalize(); outStream.write(options, 0, 312); } catch (IOException e) { System.err.println(e); } // extract the byte array from the Stream byte data[] = outBStream.toByteArray(); return data; } /** * Convert a specified byte array containing a DHCP message into a * DHCPMessage object. * * @param ibuff * Byte array to convert to a DHCPMessage object * @return A DHCPMessage object with information from byte array. */ public synchronized DHCPMessage internalize(byte[] ibuff) { ByteArrayInputStream inBStream = new ByteArrayInputStream(ibuff, 0, ibuff.length); DataInputStream inStream = new DataInputStream(inBStream); try { this.op = inStream.readByte(); this.htype = inStream.readByte(); this.hlen = inStream.readByte(); this.hops = inStream.readByte(); this.xid = inStream.readInt(); this.secs = inStream.readShort(); this.flags = inStream.readShort(); inStream.readFully(this.ciaddr, 0, 4); inStream.readFully(this.yiaddr, 0, 4); inStream.readFully(this.siaddr, 0, 4); inStream.readFully(this.giaddr, 0, 4); inStream.readFully(this.chaddr, 0, 16); inStream.readFully(this.sname, 0, 64); inStream.readFully(this.file, 0, 128); byte[] options = new byte[312]; inStream.readFully(options, 0, 312); if (this.optionsList == null) { initialize(); } this.optionsList.internalize(options); } catch (IOException e) { System.err.println(e); } // end catch return this; } /** * Set message Op code / message type. * * @param inOp * message Op code / message type */ public void setOp(byte inOp) { this.op = inOp; } /** * Set hardware address type. * * @param inHtype * hardware address type */ public void setHtype(byte inHtype) { this.htype = inHtype; } /** * Set hardware address length. * * @param inHlen * hardware address length */ public void setHlen(byte inHlen) { this.hlen = inHlen; } /** * Set hops field. * * @param inHops * hops field */ public void setHops(byte inHops) { this.hops = inHops; } /** * Set transaction ID. * * @param inXid * transactionID */ public void setXid(int inXid) { this.xid = inXid; } /** * Set seconds elapsed since client began address acquisition or renewal * process. * * @param inSecs * Seconds elapsed since client began address acquisition or * renewal process */ public void setSecs(short inSecs) { this.secs = inSecs; } /** * Set flags field. * * @param inFlags * flags field */ public void setFlags(short inFlags) { this.flags = inFlags; } /** * Set client IP address. * * @param inCiaddr * client IP address */ public void setCiaddr(byte[] inCiaddr) { this.ciaddr = inCiaddr; } /** * Set 'your' (client) IP address. * * @param inYiaddr * 'your' (client) IP address */ public void setYiaddr(byte[] inYiaddr) { this.yiaddr = inYiaddr; } /** * Set address of next server to use in bootstrap. * * @param inSiaddr * address of next server to use in bootstrap */ public void setSiaddr(byte[] inSiaddr) { this.siaddr = inSiaddr; } /** * Set relay agent IP address. * * @param inGiaddr * relay agent IP address */ public void setGiaddr(byte[] inGiaddr) { this.giaddr = inGiaddr; } /** * Set client harware address. * * @param inChaddr * client hardware address */ public void setChaddr(byte[] inChaddr) { this.chaddr = inChaddr; } /** * Set optional server host name. * * @param inSname * server host name */ public void setSname(byte[] inSname) { this.sname = inSname; } /** * Set boot file name. * * @param inFile * boot file name */ public void setFile(byte[] inFile) { this.file = inFile; } /** * Set message destination port. * * @param inPortNum * port on message destination host */ public void setPort(int inPortNum) { this.gPort = inPortNum; } /** * Set message destination IP * * @param inHost * string representation of message destination IP or hostname */ public void setDestinationHost(String inHost) { try { this.destination_IP = InetAddress.getByName(inHost); } catch (Exception e) { System.err.println(e); } } /** * @return message Op code / message type. */ public byte getOp() { return this.op; } /** * @return hardware address type. */ public byte getHtype() { return this.htype; } /** * @return hardware address length. */ public byte getHlen() { return this.hlen; } /** * @return hops field. */ public byte getHops() { return this.hops; } /** * @return transaction ID. */ public int getXid() { return this.xid; } /** * @return seconds elapsed since client began address acquisition or renewal * process. */ public short getSecs() { return this.secs; } /** * @return flags field. */ public short getFlags() { return this.flags; } /** * @return client IP address. */ public byte[] getCiaddr() { return this.ciaddr; } /** * @return 'your' (client) IP address. */ public byte[] getYiaddr() { return this.yiaddr; } /** * @return address of next server to use in bootstrap. */ public byte[] getSiaddr() { return this.siaddr; } /** * @return relay agent IP address. */ public byte[] getGiaddr() { return this.giaddr; } /** * @return client harware address. */ public byte[] getChaddr() { return this.chaddr; } /** * @return optional server host name. */ public byte[] getSname() { return this.sname; } /** * @return boot file name. */ public byte[] getFile() { return this.file; } /** * @return a byte array containing options */ public byte[] getOptions() { if (this.optionsList == null) { initialize(); } return this.optionsList.externalize(); } /** * @return An interger representation of the message destination port */ public int getPort() { return this.gPort; } /** * Get message destination hostname * * @return A string representing the hostname of the message destination * server */ public String getDestinationAddress() { return this.destination_IP.getHostAddress(); } /** * Sets DHCP options in DHCPMessage. If option already exists then remove * old option and insert a new one. * * @param inOptNum * option number * @param inOptionData * option data */ public void setOption(int inOptNum, byte[] inOptionData) { this.optionsList.setOption((byte) inOptNum, inOptionData); } /** * Returns specified DHCP option that matches the input code. Null is * returned if option is not set. * * @param inOptNum * option number * * @return the option matching input code */ public byte[] getOption(int inOptNum) { if (this.optionsList == null) { initialize(); } return this.optionsList.getOption((byte) inOptNum); } /** * Removes the specified DHCP option that matches the input code. * * @param inOptNum * option number */ public void removeOption(int inOptNum) { if (this.optionsList == null) { initialize(); } this.optionsList.removeOption((byte) inOptNum); } /** * Report whether or not the input option is set. * * @param inOptNum * option number * * @return is the given option set? */ public boolean IsOptSet(int inOptNum) { if (this.optionsList == null) { initialize(); } return this.optionsList.contains((byte) inOptNum); } } DHCPOptions.java000066400000000000000000000203271302662252000350300ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/wpad/dhcppackage com.github.markusbernhardt.proxy.search.wpad.dhcp; import java.util.Enumeration; import java.util.Hashtable; /** * This class represents a linked list of options for a DHCP message. Its * purpose is to ease option handling such as add, remove or change. * * @author Markus Bernhardt, Copyright 2016 * @author Jason Goldschmidt and Simon Frankenberger * @author Bernd Rosstauscher, Copyright 2009 */ public class DHCPOptions { public static final int OPTION_PAD = 0; public static final int OPTION_NETMASK = 1; public static final int OPTION_TIME_OFFSET = 2; public static final int OPTION_ROUTERS = 3; public static final int OPTION_TIME_SERVERS = 4; public static final int OPTION_NAME_SERVERS = 5; public static final int OPTION_DNS_SERVERS = 6; public static final int OPTION_LOG_SERVERS = 7; public static final int OPTION_COOKIE_SERVERS = 8; public static final int OPTION_LPR_SERVERS = 9; public static final int OPTION_IMPRESS_SERVERS = 10; public static final int OPTION_RESSOURCE_LOCATION_SERVERS = 11; public static final int OPTION_HOSTNAME = 12; public static final int OPTION_BOOT_FILESIZE = 13; public static final int OPTION_MERIT_DUMPFILE = 14; public static final int OPTION_DOMAIN_NAME = 15; public static final int OPTION_SWAP_SERVER = 16; public static final int OPTION_ROOT_PATH = 17; public static final int OPTION_EXTENSIONS_PATH = 18; public static final int OPTION_END = 255; public static final int OPTION_IP_HOST_FORWARDING_ENABLE = 19; public static final int OPTION_IP_HOST_NON_LOCAL_SOURCE_ROUTING_ENABLE = 20; public static final int OPTION_IP_HOST_POLICY_FILTERS = 21; public static final int OPTION_IP_HOST_MAXIMUM_DATAGRAM_REASSEMBLY_SIZE = 22; public static final int OPTION_IP_HOST_DEFAULT_TTL = 23; public static final int OPTION_IP_HOST_MTU_AGEING_TIMEOUT = 24; public static final int OPTION_IP_HOST_MTU_PLATEAU_TABLE = 25; public static final int OPTION_IP_INTERFACE_MTU = 26; public static final int OPTION_IP_INTERFACE_ALL_SUBNETS_LOCAL_ENABLE = 27; public static final int OPTION_IP_INTERFACE_BROADCAST_ADDRESS = 28; public static final int OPTION_IP_INTERFACE_PERFORM_MASK_DISCOVERY_ENABLE = 29; public static final int OPTION_IP_INTERFACE_MASK_SUPPLIER_ENABLE = 30; public static final int OPTION_IP_INTERFACE_PERFORM_ROUTER_DISCOVERY_ENABLE = 31; public static final int OPTION_IP_INTERFACE_ROUTER_SOLICITATION_ADDRESS = 32; public static final int OPTION_IP_INTERFACE_STATIC_ROUTES = 33; public static final int OPTION_LINK_TRAILER_ENCAPSULATION_ENABLE = 34; public static final int OPTION_LINK_ARP_CACHE_TIMEOUT = 35; public static final int OPTION_LINK_ETHERNET_ENCAPSULATION_ENABLE = 36; public static final int OPTION_TCP_DEFAULT_TTL = 37; public static final int OPTION_TCP_KEEP_ALIVE_INTERVAL = 38; public static final int OPTION_TCP_KEEP_ALIVE_GERBAGE_ENABLE = 39; public static final int OPTION_NIS_DOMAIN = 40; public static final int OPTION_NIS_SERVERS = 41; public static final int OPTION_NTP_SERVERS = 42; public static final int OPTION_SERVICE_VENDOR_SPECIFIC_INFORMATIONS = 43; public static final int OPTION_SERVICE_NETBOIS_NAME_SERVERS = 44; public static final int OPTION_SERVICE_NETBOIS_DATAGRAM_DISTRIBUTION_SERVERS = 45; public static final int OPTION_SERVICE_NETBOIS_NODE_TYPE = 46; public static final int OPTION_SERVICE_NETBOIS_SCOPE_TYPE = 47; public static final int OPTION_SERVICE_X_FONT_SERVERS = 48; public static final int OPTION_SERVICE_X_DISPLAY_MANAGERS = 49; public static final int OPTION_DHCP_IP_ADRESS_REQUESTED = 50; public static final int OPTION_DHCP_IP_LEASE_TIME = 51; public static final int OPTION_DHCP_OVERLOAD = 52; public static final int OPTION_DHCP_MESSAGE_TYPE = 53; public static final int OPTION_DHCP_SERVER_IDENTIFIER = 54; public static final int OPTION_DHCP_PARAMETER_REQUEST_LIST = 55; public static final int OPTION_DHCP_MESSAGE = 56; public static final int OPTION_DHCP_MAXIMUM_MESSAGE_SIZE = 57; public static final int OPTION_DHCP_RENEWAL_TIME = 58; public static final int OPTION_DHCP_REBIND_TIME = 59; public static final int OPTION_DHCP_CLASS_IDENTIFIER = 60; public static final int OPTION_DHCP_CLIENT_IDENTIFIER = 61; /** * This inner class represent an entry in the Option Table */ class DHCPOptionsEntry { protected byte code; protected byte length; protected byte content[]; public DHCPOptionsEntry(byte entryCode, byte entryLength, byte entryContent[]) { this.code = entryCode; this.length = entryLength; this.content = entryContent; } @Override public String toString() { return "Code: " + this.code + "\nContent: " + new String(this.content); } } private Hashtable optionsTable = null; public DHCPOptions() { this.optionsTable = new Hashtable(); } /** * Removes option with specified bytecode * * @param entryCode * The code of option to be removed */ public void removeOption(byte entryCode) { this.optionsTable.remove(new Byte(entryCode)); } /** * Returns true if option code is set in list; false otherwise * * @param entryCode * The node's option code * @return true if option is set, otherwise false */ public boolean contains(byte entryCode) { return this.optionsTable.containsKey(new Byte(entryCode)); } /** * Determines if list is empty * * @return true if there are no options set, otherwise false */ public boolean isEmpty() { return this.optionsTable.isEmpty(); } /** * Fetches value of option by its option code * * @param entryCode * The node's option code * @return byte array containing the value of option entryCode. null is * returned if option is not set. */ public byte[] getOption(byte entryCode) { if (this.contains(entryCode)) { DHCPOptionsEntry ent = this.optionsTable.get(new Byte(entryCode)); return ent.content; } else { return null; } } /** * Changes an existing option to new value * * @param entryCode * The node's option code * @param value * Content of node option */ public void setOption(byte entryCode, byte value[]) { DHCPOptionsEntry opt = new DHCPOptionsEntry(entryCode, (byte) value.length, value); this.optionsTable.put(new Byte(entryCode), opt); } /** * Returns the option value of a specified option code in a byte array * * @param length * Length of option content * @param position * Location in array of option node * @param options * The byte array of options * @return byte array containing the value for the option */ private byte[] getArrayOption(int length, int position, byte options[]) { byte value[] = new byte[length]; for (int i = 0; i < length; i++) { value[i] = options[position + i]; } return value; } /** * Converts an options byte array to a linked list * * @param optionsArray * The byte array representation of the options list */ public void internalize(byte[] optionsArray) { /* Assume options valid and correct */ int pos = 4; // ignore vendor magic cookie byte code, length; byte value[]; while (optionsArray[pos] != (byte) 255) { // until end option code = optionsArray[pos++]; length = optionsArray[pos++]; value = getArrayOption(length, pos, optionsArray); setOption(code, value); pos += length; // increment position pointer } } /** * Converts a linked options list to a byte array * * @return array representation of optionsTable */ // todo provide overflow return public byte[] externalize() { byte[] options = new byte[312]; options[0] = (byte) 99; // insert vendor magic cookie options[1] = (byte) 130; options[2] = (byte) 83; options[3] = (byte) 99; int position = 4; Enumeration e = this.optionsTable.elements(); while (e.hasMoreElements()) { DHCPOptionsEntry entry = e.nextElement(); options[position++] = entry.code; options[position++] = entry.length; for (int i = 0; i < entry.length; ++i) { options[position++] = entry.content[i]; } } options[position] = (byte) 255; // insert end option return options; } /** * Prints the options linked list: For testing only. */ public void printList() { System.out.println(this.optionsTable.toString()); } } DHCPSocket.java000066400000000000000000000054201302662252000346220ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/search/wpad/dhcppackage com.github.markusbernhardt.proxy.search.wpad.dhcp; import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetAddress; import java.net.Socket; import java.net.SocketException; import java.net.UnknownHostException; /** * This class represents a Socket for sending DHCP Messages * * @author Markus Bernhardt, Copyright 2016 * @author Jason Goldschmidt and Simon Frankenberger * @author Bernd Rosstauscher, Copyright 2009 * * @see java.net.DatagramSocket */ public class DHCPSocket extends DatagramSocket { /** * Default socket timeout (1 second) */ private int SOCKET_TIMEOUT = 1000; /** * Default MTU (Maximum Transmission Unit) for ethernet (in bytes) */ private int mtu = 1500; /** * Constructor for creating DHCPSocket on a specific port on the local * machine. * * @param inPort * The port for the application to bind. * * @throws SocketException * As thrown by the {@link Socket} constructor */ public DHCPSocket(int inPort) throws SocketException { super(inPort); setSoTimeout(this.SOCKET_TIMEOUT); } /** * Sets the Maximum Transfer Unit for the UDP DHCP Packets to be set. * * @param inSize * Integer representing desired MTU */ public void setMTU(int inSize) { this.mtu = inSize; } /** * Returns the set MTU for this socket * * @return The Maximum Transfer Unit set for this socket */ public int getMTU() { return this.mtu; } /** * Sends a DHCPMessage object to a predifined host. * * @param inMessage * Well-formed DHCPMessage to be sent to a server * * @throws IOException * If the message could not be sent. */ public synchronized void send(DHCPMessage inMessage) throws IOException { byte data[] = new byte[this.mtu]; data = inMessage.externalize(); InetAddress dest = null; try { dest = InetAddress.getByName(inMessage.getDestinationAddress()); } catch (UnknownHostException e) { } DatagramPacket outgoing = new DatagramPacket(data, data.length, dest, inMessage.getPort()); send(outgoing); // send outgoing message } /** * Receives a datagram packet containing a DHCP Message into a DHCPMessage * object. * * @return true if message is received, false if * timeout occurs. * @param outMessage * DHCPMessage object to receive new message into */ public synchronized boolean receive(DHCPMessage outMessage) { try { DatagramPacket incoming = new DatagramPacket(new byte[this.mtu], this.mtu); // gSocket. receive(incoming); // block on receive for SOCKET_TIMEOUT outMessage.internalize(incoming.getData()); } catch (java.io.IOException e) { return false; } // end catch return true; } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/000077500000000000000000000000001302662252000306505ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/direct/000077500000000000000000000000001302662252000321225ustar00rootroot00000000000000NoProxySelector.java000066400000000000000000000040261302662252000360270ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/directpackage com.github.markusbernhardt.proxy.selector.direct; import java.io.IOException; import java.net.Proxy; import java.net.ProxySelector; import java.net.SocketAddress; import java.net.URI; import java.util.List; import com.github.markusbernhardt.proxy.util.ProxyUtil; /***************************************************************************** * This proxy selector will always return a "DIRECT" proxy. Implemented as * singleton. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class NoProxySelector extends ProxySelector { private static NoProxySelector instance; /************************************************************************* * Constructor ************************************************************************/ private NoProxySelector() { super(); } /************************************************************************* * Gets the one and only instance of this selector. * * @return a DirectSelector. ************************************************************************/ public static synchronized NoProxySelector getInstance() { if (NoProxySelector.instance == null) { NoProxySelector.instance = new NoProxySelector(); } return instance; } /************************************************************************* * connectFailed * * @see java.net.ProxySelector#connectFailed(java.net.URI, * java.net.SocketAddress, java.io.IOException) ************************************************************************/ @Override public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { // Not used. } /************************************************************************* * select * * @see java.net.ProxySelector#select(java.net.URI) ************************************************************************/ @Override public List select(URI uri) { return ProxyUtil.noProxyList(); } } /* * $Log: $ */proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/fixed/000077500000000000000000000000001302662252000317475ustar00rootroot00000000000000FixedProxySelector.java000066400000000000000000000044711302662252000363430ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/fixedpackage com.github.markusbernhardt.proxy.selector.fixed; import java.io.IOException; import java.net.InetSocketAddress; import java.net.Proxy; import java.net.ProxySelector; import java.net.SocketAddress; import java.net.URI; import java.util.ArrayList; import java.util.Collections; import java.util.List; /***************************************************************************** * This proxy selector is configured with a fixed proxy. This proxy will be * returned for all URIs passed to the select method. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class FixedProxySelector extends ProxySelector { private final List proxyList; /************************************************************************* * Constructor * * @param proxy * the proxy to use. ************************************************************************/ public FixedProxySelector(Proxy proxy) { super(); List list = new ArrayList(1); list.add(proxy); this.proxyList = Collections.unmodifiableList(list); } /************************************************************************* * Constructor * * @param proxyHost * the host name or IP address of the proxy to use. * @param proxyPort * the port of the proxy. ************************************************************************/ public FixedProxySelector(String proxyHost, int proxyPort) { this(new Proxy(Proxy.Type.HTTP, InetSocketAddress.createUnresolved(proxyHost, proxyPort))); } /************************************************************************* * connectFailed * * @see java.net.ProxySelector#connectFailed(java.net.URI, * java.net.SocketAddress, java.io.IOException) ************************************************************************/ @Override public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { // Not used } /************************************************************************* * select * * @see java.net.ProxySelector#select(java.net.URI) ************************************************************************/ @Override public List select(URI uri) { return this.proxyList; } } FixedSocksSelector.java000066400000000000000000000021271302662252000363000ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/fixedpackage com.github.markusbernhardt.proxy.selector.fixed; import java.net.InetSocketAddress; import java.net.Proxy; /***************************************************************************** * This proxy selector is configured with a fixed proxy. This proxy will be * returned for all URIs passed to the select method. This implementation can be * used for SOCKS 4 and 5 proxy support. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class FixedSocksSelector extends FixedProxySelector { /************************************************************************* * Constructor * * @param proxyHost * the host name or IP address of the proxy to use. * @param proxyPort * the port of the proxy. ************************************************************************/ public FixedSocksSelector(String proxyHost, int proxyPort) { super(new Proxy(Proxy.Type.SOCKS, InetSocketAddress.createUnresolved(proxyHost, proxyPort))); } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/misc/000077500000000000000000000000001302662252000316035ustar00rootroot00000000000000BufferedProxySelector.java000066400000000000000000000126071302662252000366620ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/miscpackage com.github.markusbernhardt.proxy.selector.misc; import java.io.IOException; import java.net.Proxy; import java.net.ProxySelector; import java.net.SocketAddress; import java.net.URI; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; /***************************************************************************** * Implements a cache that can be used to warp it around an existing * ProxySelector. You can specify a maximum cache size and a "time to live" for * positive resolves. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class BufferedProxySelector extends ProxySelector { /************************************************************************* * Define the available scopes of the cache key generation ************************************************************************/ public enum CacheScope { /********************************************************************* * Cache keys are generated by uri.getHost(). ********************************************************************/ CACHE_SCOPE_HOST, /********************************************************************* * Cache keys are generated by * uri.getHost() + ":" + uri.getPort(). ********************************************************************/ CACHE_SCOPE_HOST_PORT, /********************************************************************* * Cache keys are generated by uri.toString(). ********************************************************************/ CACHE_SCOPE_URL } private ProxySelector delegate; private ConcurrentHashMap cache; private int maxSize; private long ttl; private CacheScope cacheScope; private static class CacheEntry { List result; long expireAt; public CacheEntry(List r, long expireAt) { super(); this.result = new ArrayList(r.size()); this.result.addAll(r); this.result = Collections.unmodifiableList(this.result); this.expireAt = expireAt; } public boolean isExpired() { return System.nanoTime() >= this.expireAt; } } /************************************************************************* * Constructor * * @param maxSize * the max size for the cache. * @param ttl * the "time to live" for cache entries as amount in * milliseconds. * @param delegate * the delegate to use. * @param cacheScope * the desired cache scope. ************************************************************************/ public BufferedProxySelector(int maxSize, long ttl, ProxySelector delegate, CacheScope cacheScope) { super(); this.cache = new ConcurrentHashMap(); this.maxSize = maxSize; this.delegate = delegate; this.ttl = ttl; this.cacheScope = cacheScope; } /************************************************************************* * connectFailed * * @see java.net.ProxySelector#connectFailed(java.net.URI, * java.net.SocketAddress, java.io.IOException) ************************************************************************/ @Override public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { this.delegate.connectFailed(uri, sa, ioe); } /************************************************************************* * select * * @see java.net.ProxySelector#select(java.net.URI) ************************************************************************/ @Override public List select(URI uri) { String cacheKey; switch (cacheScope) { case CACHE_SCOPE_HOST: cacheKey = uri.getHost(); break; case CACHE_SCOPE_HOST_PORT: cacheKey = uri.getHost() + ":" + uri.getPort(); break; case CACHE_SCOPE_URL: cacheKey = uri.toString(); break; default: throw new RuntimeException("FixMe: Unhandled CacheScope enum constant."); } CacheEntry entry = this.cache.get(cacheKey); if (entry == null || entry.isExpired()) { List result = this.delegate.select(uri); entry = new CacheEntry(result, System.nanoTime() + this.ttl * 1000 * 1000); synchronized (this.cache) { if (this.cache.size() >= this.maxSize) { purgeCache(); } this.cache.put(cacheKey, entry); } } return entry.result; } /************************************************************************* * Purge cache to get some free space for a new entry. ************************************************************************/ private void purgeCache() { // Remove all expired entries and find the oldest. boolean removedOne = false; Entry oldest = null; Set> entries = this.cache.entrySet(); for (Iterator> it = entries.iterator(); it.hasNext();) { Entry entry = it.next(); if (entry.getValue().isExpired()) { it.remove(); removedOne = true; } else if (oldest == null || entry.getValue().expireAt < oldest.getValue().expireAt) { oldest = entry; } } // Remove oldest if no expired entries were found. if (!removedOne && oldest != null) { this.cache.remove(oldest.getKey()); } } } ProtocolDispatchSelector.java000066400000000000000000000110651302662252000373540ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/miscpackage com.github.markusbernhardt.proxy.selector.misc; import java.io.IOException; import java.net.Proxy; import java.net.ProxySelector; import java.net.SocketAddress; import java.net.URI; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import com.github.markusbernhardt.proxy.selector.direct.NoProxySelector; /***************************************************************************** * This is a facade for a list of ProxySelecor objects. You can register * different ProxySelectors per Protocol. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class ProtocolDispatchSelector extends ProxySelector { private Map selectors; private ProxySelector fallbackSelector; /************************************************************************* * Constructor ************************************************************************/ public ProtocolDispatchSelector() { super(); this.selectors = new ConcurrentHashMap(); this.fallbackSelector = NoProxySelector.getInstance(); } /************************************************************************* * Sets a selector responsible for the given protocol. * * @param protocol * the name of the protocol. * @param selector * the selector to use. ************************************************************************/ public void setSelector(String protocol, ProxySelector selector) { if (protocol == null) { throw new NullPointerException("Protocol must not be null."); } if (selector == null) { throw new NullPointerException("Selector must not be null."); } this.selectors.put(protocol, selector); } /************************************************************************* * Removes the selector installed for the given protocol. * * @param protocol * the protocol name. * @return the old selector that is removed. ************************************************************************/ public ProxySelector removeSelector(String protocol) { return this.selectors.remove(protocol); } /************************************************************************* * Gets the selector installed for the given protocol. * * @param protocol * the protocol name. * @return the selector for that protocol, null if none is currently set. ************************************************************************/ public ProxySelector getSelector(String protocol) { return this.selectors.get(protocol); } /************************************************************************* * Sets the fallback selector that is always called when no matching * protocol selector was found.. * * @param selector * the selector to use. ************************************************************************/ public void setFallbackSelector(ProxySelector selector) { if (selector == null) { throw new NullPointerException("Selector must not be null."); } this.fallbackSelector = selector; } /************************************************************************* * connectFailed * * @see java.net.ProxySelector#connectFailed(java.net.URI, * java.net.SocketAddress, java.io.IOException) ************************************************************************/ @Override public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { ProxySelector selector = this.fallbackSelector; String protocol = uri.getScheme(); if (protocol != null && this.selectors.get(protocol) != null) { selector = this.selectors.get(protocol); } selector.connectFailed(uri, sa, ioe); } /************************************************************************* * select * * @see java.net.ProxySelector#select(java.net.URI) ************************************************************************/ @Override public List select(URI uri) { ProxySelector selector = this.fallbackSelector; String protocol = uri.getScheme(); if (protocol != null && this.selectors.get(protocol) != null) { selector = this.selectors.get(protocol); } return selector.select(uri); } /************************************************************************* * Gets the size of the selector map. * * @return the size of the selector map. ************************************************************************/ public int size() { return this.selectors.size(); } } ProxyListFallbackSelector.java000066400000000000000000000130461302662252000374710ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/miscpackage com.github.markusbernhardt.proxy.selector.misc; import java.io.IOException; import java.net.Proxy; import java.net.ProxySelector; import java.net.SocketAddress; import java.net.URI; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; /***************************************************************************** * Implements a fallback selector to warp it around an existing ProxySelector. * This will remove proxies from a list of proxies and implement an automatic * retry mechanism. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class ProxyListFallbackSelector extends ProxySelector { // Retry a unresponsive proxy after 10 minutes per default. private static final int DEFAULT_RETRY_DELAY = 1000 * 60 * 10; private ProxySelector delegate; private ConcurrentHashMap failedDelayCache; private long retryAfterMs; /************************************************************************* * Constructor * * @param delegate * the delegate to use. ************************************************************************/ public ProxyListFallbackSelector(ProxySelector delegate) { this(DEFAULT_RETRY_DELAY, delegate); } /************************************************************************* * Constructor * * @param retryAfterMs * the "retry delay" as amount of milliseconds. * @param delegate * the delegate to use. ************************************************************************/ public ProxyListFallbackSelector(long retryAfterMs, ProxySelector delegate) { super(); this.failedDelayCache = new ConcurrentHashMap(); this.delegate = delegate; this.retryAfterMs = retryAfterMs; } /************************************************************************* * connectFailed * * @see java.net.ProxySelector#connectFailed(java.net.URI, * java.net.SocketAddress, java.io.IOException) ************************************************************************/ @Override public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { this.failedDelayCache.put(sa, System.currentTimeMillis()); } /************************************************************************* * select * * @see java.net.ProxySelector#select(java.net.URI) ************************************************************************/ @Override public List select(URI uri) { cleanupCache(); List proxyList = this.delegate.select(uri); List result = filterUnresponsiveProxiesFromList(proxyList); return result; } /************************************************************************* * Cleanup the entries from the cache that are no longer unresponsive. ************************************************************************/ private void cleanupCache() { Iterator> it = this.failedDelayCache.entrySet().iterator(); while (it.hasNext()) { Entry e = it.next(); Long lastFailTime = e.getValue(); if (retryDelayHasPassedBy(lastFailTime)) { it.remove(); } } } /************************************************************************* * Filters out proxies that are not reponding. * * @param proxyList * a list of proxies to test. * @return the filtered list. ************************************************************************/ private List filterUnresponsiveProxiesFromList(List proxyList) { if (this.failedDelayCache.isEmpty()) { return proxyList; } List result = new ArrayList(proxyList.size()); for (Proxy proxy : proxyList) { if (isDirect(proxy) || isNotUnresponsive(proxy)) { result.add(proxy); } } return result; } /************************************************************************* * Checks if the given proxy is representing a direct connection. * * @param proxy * to inspect. * @return true if it is direct else false. ************************************************************************/ private boolean isDirect(Proxy proxy) { return Proxy.NO_PROXY.equals(proxy); } /************************************************************************* * Tests that a given proxy is not "unresponsive". * * @param proxy * to test. * @return true if not unresponsive. ************************************************************************/ private boolean isNotUnresponsive(Proxy proxy) { Long lastFailTime = this.failedDelayCache.get(proxy.address()); return retryDelayHasPassedBy(lastFailTime); } /************************************************************************* * Checks if the retry delay has passed. * * @param lastFailTime * @return true if the delay has passed. ************************************************************************/ private boolean retryDelayHasPassedBy(Long lastFailTime) { return lastFailTime == null || lastFailTime + this.retryAfterMs < System.currentTimeMillis(); } /************************************************************************* * Only used for unit testing not part of the public API. * * @param retryAfterMs * The retryAfterMs to set. ************************************************************************/ final void setRetryAfterMs(long retryAfterMs) { this.retryAfterMs = retryAfterMs; } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/pac/000077500000000000000000000000001302662252000314135ustar00rootroot00000000000000JavaxPacScriptParser.java000066400000000000000000000125611302662252000362430ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/pacpackage com.github.markusbernhardt.proxy.selector.pac; import java.lang.reflect.Method; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; /***************************************************************************** * PAC parser using the Rhino JavaScript engine bundled with Java 1.6
* * More information about PAC can be found there:
* Proxy_auto-config *
* * web-browser-auto-proxy-configuration * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class JavaxPacScriptParser implements PacScriptParser { static final String SCRIPT_METHODS_OBJECT = "__pacutil"; private final PacScriptSource source; private final ScriptEngine engine; /************************************************************************* * Constructor * * @param source * the source for the PAC script. * @throws ProxyEvaluationException * on error. ************************************************************************/ public JavaxPacScriptParser(PacScriptSource source) throws ProxyEvaluationException { this.source = source; this.engine = setupEngine(); } /************************************************************************* * Initializes the JavaScript engine and adds aliases for the functions * defined in ScriptMethods. * * @throws ProxyEvaluationException * on error. ************************************************************************/ private ScriptEngine setupEngine() throws ProxyEvaluationException { ScriptEngineManager mng = new ScriptEngineManager(); ScriptEngine engine = mng.getEngineByMimeType("text/javascript"); engine.put(SCRIPT_METHODS_OBJECT, new PacScriptMethods()); Class scriptMethodsClazz = ScriptMethods.class; Method[] scriptMethods = scriptMethodsClazz.getMethods(); for (Method method : scriptMethods) { String name = method.getName(); int args = method.getParameterTypes().length; StringBuilder toEval = new StringBuilder(name).append(" = function("); for (int i = 0; i < args; i++) { if (i > 0) { toEval.append(","); } toEval.append("arg").append(i); } toEval.append(") {return "); String functionCall = buildFunctionCallCode(name, args); // If return type is java.lang.String convert it to a JS string if (String.class.isAssignableFrom(method.getReturnType())) { functionCall = "String(" + functionCall + ")"; } toEval.append(functionCall).append("; }"); try { engine.eval(toEval.toString()); } catch (ScriptException e) { Logger.log(getClass(), LogLevel.ERROR, "JS evaluation error when creating alias for " + name + ".", e); throw new ProxyEvaluationException("Error setting up script engine", e); } } return engine; } /************************************************************************* * Builds a JavaScript code snippet to call a function that we bind. * * @param functionName * of the bound function * @param args * of the bound function * @return the JS code to invoke the method. ************************************************************************/ private String buildFunctionCallCode(String functionName, int args) { StringBuilder functionCall = new StringBuilder(); functionCall.append(SCRIPT_METHODS_OBJECT).append(".").append(functionName).append("("); for (int i = 0; i < args; i++) { if (i > 0) { functionCall.append(","); } functionCall.append("arg").append(i); } functionCall.append(")"); return functionCall.toString(); } /*************************************************************************** * Gets the source of the PAC script used by this parser. * * @return a PacScriptSource. **************************************************************************/ public PacScriptSource getScriptSource() { return this.source; } /************************************************************************* * Evaluates the given URL and host against the PAC script. * * @param url * the URL to evaluate. * @param host * the host name part of the URL. * @return the script result. * @throws ProxyEvaluationException * on execution error. ************************************************************************/ public String evaluate(String url, String host) throws ProxyEvaluationException { try { StringBuilder script = new StringBuilder(this.source.getScriptContent()); String evalMethod = " ;FindProxyForURL (\"" + url + "\",\"" + host + "\")"; script.append(evalMethod); Object result = this.engine.eval(script.toString()); return (String) result; } catch (Exception e) { Logger.log(getClass(), LogLevel.ERROR, "JS evaluation error.", e); throw new ProxyEvaluationException("Error while executing PAC script: " + e.getMessage(), e); } } } PacProxySelector.java000066400000000000000000000142251302662252000354510ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/pacpackage com.github.markusbernhardt.proxy.selector.pac; import java.io.IOException; import java.net.InetSocketAddress; import java.net.Proxy; import java.net.ProxySelector; import java.net.SocketAddress; import java.net.URI; import java.util.ArrayList; import java.util.List; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; import com.github.markusbernhardt.proxy.util.ProxyUtil; /***************************************************************************** * ProxySelector that will use a PAC script to find an proxy for a given URI. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class PacProxySelector extends ProxySelector { // private static final String PAC_PROXY = "PROXY"; private static final String PAC_SOCKS = "SOCKS"; private static final String PAC_DIRECT = "DIRECT"; private PacScriptParser pacScriptParser; private static volatile boolean enabled = true; /************************************************************************* * Constructor * * @param pacSource * the source for the PAC file. ************************************************************************/ public PacProxySelector(PacScriptSource pacSource) { super(); selectEngine(pacSource); } /************************************************************************* * Can be used to enable / disable the proxy selector. If disabled it will * return DIRECT for all urls. * * @param enable * the new status to set. ************************************************************************/ public static void setEnabled(boolean enable) { enabled = enable; } /************************************************************************* * Checks if the selector is currently enabled. * * @return true if enabled else false. ************************************************************************/ public static boolean isEnabled() { return enabled; } /************************************************************************* * Selects one of the available PAC parser engines. * * @param pacSource * to use as input. ************************************************************************/ private void selectEngine(PacScriptSource pacSource) { try { Logger.log(getClass(), LogLevel.INFO, "Using javax.script JavaScript engine."); this.pacScriptParser = new JavaxPacScriptParser(pacSource); } catch (Exception e) { Logger.log(getClass(), LogLevel.ERROR, "PAC parser error.", e); } } /************************************************************************* * connectFailed * * @see java.net.ProxySelector#connectFailed(java.net.URI, * java.net.SocketAddress, java.io.IOException) ************************************************************************/ @Override public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { // Not used. } /************************************************************************* * select * * @see java.net.ProxySelector#select(java.net.URI) ************************************************************************/ @Override public List select(URI uri) { if (uri == null) { throw new IllegalArgumentException("URI must not be null."); } // Fix for Java 1.6.16+ where we get a infinite loop because // URL.connect(Proxy.NO_PROXY) does not work as expected. if (!enabled) { return ProxyUtil.noProxyList(); } return findProxy(uri); } /************************************************************************* * Evaluation of the given URL with the PAC-file. * * Two cases can be handled here: DIRECT Fetch the object directly from the * content HTTP server denoted by its URL PROXY name:port Fetch the object * via the proxy HTTP server at the given location (name and port) * * @param uri * URI to be evaluated. * @return Proxy-object list as result of the evaluation. ************************************************************************/ private List findProxy(URI uri) { try { List proxies = new ArrayList(); String parseResult = this.pacScriptParser.evaluate(uri.toString(), uri.getHost()); if (parseResult == null) { parseResult = PAC_DIRECT; } String[] proxyDefinitions = parseResult.split("[;]"); for (String proxyDef : proxyDefinitions) { if (proxyDef.trim().length() > 0) { proxies.add(buildProxyFromPacResult(proxyDef)); } } return proxies; } catch (ProxyEvaluationException e) { Logger.log(getClass(), LogLevel.ERROR, "PAC resolving error.", e); return ProxyUtil.noProxyList(); } } /************************************************************************* * The proxy evaluator will return a proxy string. This method will take * this string and build a matching Proxy for it. * * @param pacResult * the result from the PAC parser. * @return a Proxy ************************************************************************/ private Proxy buildProxyFromPacResult(String pacResult) { if (pacResult.trim().length() < 6) { return Proxy.NO_PROXY; } String proxyDef = pacResult.trim(); if (proxyDef.toUpperCase().startsWith(PAC_DIRECT)) { return Proxy.NO_PROXY; } // Check proxy type. Proxy.Type type = Proxy.Type.HTTP; if (proxyDef.toUpperCase().startsWith(PAC_SOCKS)) { type = Proxy.Type.SOCKS; } String host = proxyDef.substring(6); Integer port = ProxyUtil.DEFAULT_PROXY_PORT; // Split port from host int indexOfPort = host.indexOf(':'); int index2 = host.lastIndexOf(']'); if (indexOfPort != -1 && index2 < indexOfPort) { port = Integer.parseInt(host.substring(indexOfPort + 1).trim()); host = host.substring(0, indexOfPort).trim(); } SocketAddress adr = InetSocketAddress.createUnresolved(host, port); return new Proxy(type, adr); } } PacScriptMethods.java000066400000000000000000000624241302662252000354230ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/pacpackage com.github.markusbernhardt.proxy.selector.pac; import java.io.IOException; import java.math.BigInteger; import java.net.Inet4Address; import java.net.Inet6Address; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.UnknownHostException; import java.util.Arrays; import java.util.Calendar; import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.StringTokenizer; import java.util.TimeZone; import java.util.TreeMap; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; /*************************************************************************** * Implementation of PAC JavaScript functions. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 *************************************************************************** */ public class PacScriptMethods implements ScriptMethods { // TODO 30.03.2015 bros Test for IP6 compatibility public static final String OVERRIDE_LOCAL_IP = "com.btr.proxy.pac.overrideLocalIP"; private final static String GMT = "GMT"; private final static List DAYS = Collections .unmodifiableList(Arrays.asList("SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT")); private final static List MONTH = Collections.unmodifiableList( Arrays.asList("JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC")); private Calendar currentTime; /************************************************************************* * Constructor ************************************************************************/ public PacScriptMethods() { super(); } /************************************************************************* * isPlainHostName * * @see com.github.markusbernhardt.proxy.selector.pac.ScriptMethods#isPlainHostName(java.lang.String) ************************************************************************/ public boolean isPlainHostName(String host) { return host.indexOf(".") < 0; } /************************************************************************* * Tests if an URL is in a given domain. * * @param host * is the host name from the URL. * @param domain * is the domain name to test the host name against. * @return true if the domain of host name matches. ************************************************************************/ public boolean dnsDomainIs(String host, String domain) { return host.endsWith(domain); } /************************************************************************* * Is true if the host name matches exactly the specified host name, or if * there is no domain name part in the host name, but the unqualified host * name matches. * * @param host * the host name from the URL. * @param domain * fully qualified host name with domain to match against. * @return true if matches else false. ************************************************************************/ public boolean localHostOrDomainIs(String host, String domain) { return domain.startsWith(host); } /************************************************************************* * Tries to resolve the host name. Returns true if succeeds. * * @param host * is the host name from the URL. * @return true if resolvable else false. ************************************************************************/ public boolean isResolvable(String host) { try { InetAddress.getByName(host).getHostAddress(); return true; } catch (UnknownHostException ex) { Logger.log(JavaxPacScriptParser.class, LogLevel.DEBUG, "Hostname not resolveable {0}.", host); } return false; } /************************************************************************* * Returns true if 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. * * Example: isInNet(host, "198.95.0.0", "255.255.0.0") is true if the IP * address of the host matches 198.95.*.*. * * @param host * a DNS host name, or IP address. If a host name is passed, it * will be resolved into an IP address by this function. * @param pattern * an IP address pattern in the dot-separated format. * @param mask * mask for the IP address pattern informing which parts of the * IP address should be matched against. 0 means ignore, 255 * means match. * @return true if it matches else false. ************************************************************************/ public boolean isInNet(String host, String pattern, String mask) { host = dnsResolve(host); if (host == null || host.length() == 0) { return false; } long lhost = parseIpAddressToLong(host); long lpattern = parseIpAddressToLong(pattern); long lmask = parseIpAddressToLong(mask); return (lhost & lmask) == lpattern; } /************************************************************************* * Convert a string representation of a IP to a long. * * @param address * to convert. * @return the address as long. ************************************************************************/ private long parseIpAddressToLong(String address) { long result = 0; String[] parts = address.split("\\."); long shift = 24; for (String part : parts) { long lpart = Long.parseLong(part); result |= (lpart << shift); shift -= 8; } return result; } /************************************************************************* * Resolves the given DNS host name into an IP address, and returns it in * the dot separated format as a string. * * @param host * the host to resolve. * @return the resolved IP, empty string if not resolvable. ************************************************************************/ public String dnsResolve(String host) { try { InetAddress ina = InetAddress.getByName(host); return ina.getHostAddress(); } catch (UnknownHostException e) { Logger.log(JavaxPacScriptParser.class, LogLevel.DEBUG, "DNS name not resolvable {0}.", host); } return ""; } /************************************************************************* * Returns the IP address of the host that the process is running on, as a * string in the dot-separated integer format. * * @return an IP as string. ************************************************************************/ public String myIpAddress() { return getLocalAddressOfType(Inet4Address.class); } /************************************************************************* * Get the current IP address of the computer. This will return the first * address of the first network interface that is a "real" IP address of the * given type. * * @param cl * the type of address we are searching for. * @return the address as string or "" if not found. ************************************************************************/ private String getLocalAddressOfType(Class cl) { try { String overrideIP = System.getProperty(OVERRIDE_LOCAL_IP); if (overrideIP != null && overrideIP.trim().length() > 0) { return overrideIP.trim(); } Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements()) { NetworkInterface current = interfaces.nextElement(); if (!current.isUp() || current.isLoopback() || current.isVirtual()) { continue; } Enumeration addresses = current.getInetAddresses(); while (addresses.hasMoreElements()) { InetAddress adr = addresses.nextElement(); if (cl.isInstance(adr)) { Logger.log(JavaxPacScriptParser.class, LogLevel.TRACE, "Local address resolved to {0}", adr); return adr.getHostAddress(); } } } return ""; } catch (IOException e) { Logger.log(JavaxPacScriptParser.class, LogLevel.DEBUG, "Local address not resolvable."); return ""; } } /************************************************************************* * Returns the number of DNS domain levels (number of dots) in the host * name. * * @param host * is the host name from the URL. * @return number of DNS domain levels. ************************************************************************/ public int dnsDomainLevels(String host) { int count = 0; int startPos = 0; while ((startPos = host.indexOf(".", startPos + 1)) > -1) { count++; } return count; } /************************************************************************* * Returns true if the string matches the specified shell expression. * Actually, currently the patterns are shell expressions, not regular * expressions. * * @param str * is any string to compare (e.g. the URL, or the host name). * @param shexp * is a shell expression to compare against. * @return true if the string matches, else false. ************************************************************************/ public boolean shExpMatch(String str, String shexp) { StringTokenizer tokenizer = new StringTokenizer(shexp, "*"); int startPos = 0; while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); int temp = str.indexOf(token, startPos); // Must start with first token if (startPos == 0 && !shexp.startsWith("*") && temp != 0) { return false; } // Last one ends with last token if (!tokenizer.hasMoreTokens() && !shexp.endsWith("*") && !str.endsWith(token)) { return false; } if (temp == -1) { return false; } else { startPos = temp + token.length(); } } return true; } /************************************************************************* * 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 * yields 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 time zone. If both wd1 and wd2 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 time zone is used. * * @param wd1 * weekday 1 is one of SUN MON TUE WED THU FRI SAT * @param wd2 * weekday 2 is one of SUN MON TUE WED THU FRI SAT * @param gmt * "GMT" for gmt time format else "undefined" * @return true if current day matches the criteria. ************************************************************************/ public boolean weekdayRange(String wd1, String wd2, String gmt) { boolean useGmt = GMT.equalsIgnoreCase(wd2) || GMT.equalsIgnoreCase(gmt); Calendar cal = getCurrentTime(useGmt); int currentDay = cal.get(Calendar.DAY_OF_WEEK) - 1; int from = DAYS.indexOf(wd1 == null ? null : wd1.toUpperCase()); int to = DAYS.indexOf(wd2 == null ? null : wd2.toUpperCase()); if (to == -1) { to = from; } if (to < from) { return currentDay >= from || currentDay <= to; } else { return currentDay >= from && currentDay <= to; } } /************************************************************************* * Sets a calendar with the current time. If this is set all date and time * based methods will use this calendar to determine the current time * instead of the real time. This is only be used by unit tests and is not * part of the public API. * * @param cal * a Calendar to set. ************************************************************************/ public void setCurrentTime(Calendar cal) { this.currentTime = cal; } /************************************************************************* * Gets a calendar set to the current time. This is used by the date and * time based methods. * * @param useGmt * flag to indicate if the calendar is to be created in GMT time * or local time. * @return a Calendar set to the current time. ************************************************************************/ private Calendar getCurrentTime(boolean useGmt) { if (this.currentTime != null) { // Only used for unit tests return (Calendar) this.currentTime.clone(); } return Calendar.getInstance(useGmt ? TimeZone.getTimeZone(GMT) : TimeZone.getDefault()); } /************************************************************************* * Only the first parameter is mandatory. All other parameters can be left * out therefore the meaning of the parameters changes. The method * definition shows the version with the most possible parameters filled. * The real meaning of the parameters is guessed from it's value. If "from" * and "to" are specified then the bounds are inclusive. If the "GMT" * parameter is specified, times are taken to be in GMT, otherwise the local * time zone is used. * * @param day1 * is the day of month between 1 and 31 (as an integer). * @param month1 * one of JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC * @param year1 * is the full year number, for example 1995 (but not 95). * Integer. * @param day2 * is the day of month between 1 and 31 (as an integer). * @param month2 * one of JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC * @param year2 * is the full year number, for example 1995 (but not 95). * Integer. * @param gmt * "GMT" for gmt time format else "undefined" * @return true if the current date matches the given range. ************************************************************************/ public boolean dateRange(Object day1, Object month1, Object year1, Object day2, Object month2, Object year2, Object gmt) { // Guess the parameter meanings. Map params = new HashMap(); parseDateParam(params, day1); parseDateParam(params, month1); parseDateParam(params, year1); parseDateParam(params, day2); parseDateParam(params, month2); parseDateParam(params, year2); parseDateParam(params, gmt); // Get current date boolean useGmt = params.get("gmt") != null; Calendar cal = getCurrentTime(useGmt); Date current = cal.getTime(); // Build the "from" date if (params.get("day1") != null) { cal.set(Calendar.DAY_OF_MONTH, params.get("day1")); } if (params.get("month1") != null) { cal.set(Calendar.MONTH, params.get("month1")); } if (params.get("year1") != null) { cal.set(Calendar.YEAR, params.get("year1")); } Date from = cal.getTime(); // Build the "to" date Date to; if (params.get("day2") != null) { cal.set(Calendar.DAY_OF_MONTH, params.get("day2")); } if (params.get("month2") != null) { cal.set(Calendar.MONTH, params.get("month2")); } if (params.get("year2") != null) { cal.set(Calendar.YEAR, params.get("year2")); } to = cal.getTime(); // Need to increment to the next month? if (to.before(from)) { cal.add(Calendar.MONTH, +1); to = cal.getTime(); } // Need to increment to the next year? if (to.before(from)) { cal.add(Calendar.YEAR, +1); cal.add(Calendar.MONTH, -1); to = cal.getTime(); } return current.compareTo(from) >= 0 && current.compareTo(to) <= 0; } /************************************************************************* * Try to guess the type of the given parameter and put it into the params * map. * * @param params * a map to put the parsed parameters into. * @param value * to parse and specify the type for. ************************************************************************/ private void parseDateParam(Map params, Object value) { if (value instanceof Number) { int n = ((Number) value).intValue(); if (n <= 31) { // Its a day if (params.get("day1") == null) { params.put("day1", n); } else { params.put("day2", n); } } else { // Its a year if (params.get("year1") == null) { params.put("year1", n); } else { params.put("year2", n); } } } if (value instanceof String) { int n = MONTH.indexOf(((String) value).toUpperCase()); if (n > -1) { // Its a month if (params.get("month1") == null) { params.put("month1", n); } else { params.put("month2", n); } } } if (GMT.equalsIgnoreCase(String.valueOf(value))) { params.put("gmt", 1); } } /************************************************************************* * Some parameters can be left out therefore the meaning of the parameters * changes. The method definition shows the version with the most possible * parameters filled. The real meaning of the parameters is guessed from * it's value. If "from" and "to" are specified then the bounds are * inclusive. If the "GMT" parameter is specified, times are taken to be in * GMT, otherwise the local time zone is used.
* *
	 * 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)
	 * 
* * @param hour1 * is the hour from 0 to 23. (0 is midnight, 23 is 11 pm.) * @param min1 * minutes from 0 to 59. * @param sec1 * seconds from 0 to 59. * @param hour2 * is the hour from 0 to 23. (0 is midnight, 23 is 11 pm.) * @param min2 * minutes from 0 to 59. * @param sec2 * seconds from 0 to 59. * @param gmt * "GMT" for gmt time format else "undefined" * @return true if the current time matches the given range. ************************************************************************/ public boolean timeRange(Object hour1, Object min1, Object sec1, Object hour2, Object min2, Object sec2, Object gmt) { boolean useGmt = GMT.equalsIgnoreCase(String.valueOf(min1)) || GMT.equalsIgnoreCase(String.valueOf(sec1)) || GMT.equalsIgnoreCase(String.valueOf(min2)) || GMT.equalsIgnoreCase(String.valueOf(gmt)); Calendar cal = getCurrentTime(useGmt); cal.set(Calendar.MILLISECOND, 0); Date current = cal.getTime(); Date from; Date to; if (sec2 instanceof Number) { cal.set(Calendar.HOUR_OF_DAY, ((Number) hour1).intValue()); cal.set(Calendar.MINUTE, ((Number) min1).intValue()); cal.set(Calendar.SECOND, ((Number) sec1).intValue()); from = cal.getTime(); cal.set(Calendar.HOUR_OF_DAY, ((Number) hour2).intValue()); cal.set(Calendar.MINUTE, ((Number) min2).intValue()); cal.set(Calendar.SECOND, ((Number) sec2).intValue()); to = cal.getTime(); } else if (hour2 instanceof Number) { cal.set(Calendar.HOUR_OF_DAY, ((Number) hour1).intValue()); cal.set(Calendar.MINUTE, ((Number) min1).intValue()); cal.set(Calendar.SECOND, 0); from = cal.getTime(); cal.set(Calendar.HOUR_OF_DAY, ((Number) sec1).intValue()); cal.set(Calendar.MINUTE, ((Number) hour2).intValue()); cal.set(Calendar.SECOND, 59); to = cal.getTime(); } else if (min1 instanceof Number) { cal.set(Calendar.HOUR_OF_DAY, ((Number) hour1).intValue()); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); from = cal.getTime(); cal.set(Calendar.HOUR_OF_DAY, ((Number) min1).intValue()); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 59); to = cal.getTime(); } else { cal.set(Calendar.HOUR_OF_DAY, ((Number) hour1).intValue()); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); from = cal.getTime(); cal.set(Calendar.HOUR_OF_DAY, ((Number) hour1).intValue()); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 59); to = cal.getTime(); } if (to.before(from)) { cal.setTime(to); cal.add(Calendar.DATE, +1); to = cal.getTime(); } return current.compareTo(from) >= 0 && current.compareTo(to) <= 0; } // Microsoft PAC extensions for IPv6 support. /************************************************************************* * isResolvableEx * * @see com.github.markusbernhardt.proxy.selector.pac.ScriptMethods#isResolvableEx(java.lang.String) ************************************************************************/ public boolean isResolvableEx(String host) { return isResolvable(host); } // constants private static final BigInteger HIGH_32_INT = new BigInteger(new byte[] { -1, -1, -1, -1 }); private static final BigInteger HIGH_128_INT = new BigInteger( new byte[] { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }); /************************************************************************* * isInNetEx Implementation from * http://fhanik.blogspot.ch/2013/11/ip-magic-check-if-ipv6-address-is.html * * @see com.github.markusbernhardt.proxy.selector.pac.ScriptMethods#isInNetEx(java.lang.String, * java.lang.String) ************************************************************************/ public boolean isInNetEx(String ipOrHost, String cidr) { if (ipOrHost == null || ipOrHost.length() == 0 || cidr == null || cidr.length() == 0) { return false; } try { // Split CIDR, usually written like 2000::/64" String[] cidrParts = cidr.split("/"); if (cidrParts.length != 2) { return false; } String cidrRange = cidrParts[0]; int cidrBits = Integer.parseInt(cidrParts[1]); byte[] addressBytes = InetAddress.getByName(ipOrHost).getAddress(); BigInteger ip = new BigInteger(addressBytes); BigInteger mask = addressBytes.length == 4 ? HIGH_32_INT.shiftLeft(32 - cidrBits) : HIGH_128_INT.shiftLeft(128 - cidrBits); byte[] rangeBytes = InetAddress.getByName(cidrRange).getAddress(); BigInteger range = new BigInteger(rangeBytes); BigInteger lowIP = range.and(mask); BigInteger highIP = lowIP.add(mask.not()); return lowIP.compareTo(ip) <= 0 && highIP.compareTo(ip) >= 0; } catch (UnknownHostException e) { return false; } } /************************************************************************* * dnsResolveEx * * @see com.github.markusbernhardt.proxy.selector.pac.ScriptMethods#dnsResolveEx(java.lang.String) ************************************************************************/ public String dnsResolveEx(String host) { StringBuilder result = new StringBuilder(); try { InetAddress[] list = InetAddress.getAllByName(host); for (InetAddress inetAddress : list) { result.append(inetAddress.getHostAddress()); result.append("; "); } } catch (UnknownHostException e) { Logger.log(JavaxPacScriptParser.class, LogLevel.DEBUG, "DNS name not resolvable {0}.", host); } return result.toString(); } /************************************************************************* * myIpAddressEx * * @see com.github.markusbernhardt.proxy.selector.pac.ScriptMethods#myIpAddressEx() ************************************************************************/ public String myIpAddressEx() { return getLocalAddressOfType(Inet6Address.class); } /************************************************************************* * sortIpAddressList * * @see com.github.markusbernhardt.proxy.selector.pac.ScriptMethods#sortIpAddressList(java.lang.String) ************************************************************************/ public String sortIpAddressList(String ipAddressList) { if (ipAddressList == null || ipAddressList.trim().length() == 0) { return ""; } try { String[] ipAddressToken = ipAddressList.split(";"); TreeMap sorting = new TreeMap(new Comparator() { public int compare(byte[] b1, byte[] b2) { if (b1.length != b2.length) { return b2.length - b1.length; } return new BigInteger(b1).compareTo(new BigInteger(b2)); } }); for (String ip : ipAddressToken) { String cleanIP = ip.trim(); sorting.put(InetAddress.getByName(cleanIP).getAddress(), cleanIP); } StringBuilder result = new StringBuilder(); for (String ip : sorting.values()) { if (result.length() > 0) { result.append(";"); } result.append(ip); } return result.toString(); } catch (Exception e) { Logger.log(JavaxPacScriptParser.class, LogLevel.DEBUG, "Cannot sort invalid IP list: {0}.", ipAddressList); return ""; } } /************************************************************************* * getClientVersion * * @see com.github.markusbernhardt.proxy.selector.pac.ScriptMethods#getClientVersion() ************************************************************************/ public String getClientVersion() { return "1.0"; } } PacScriptParser.java000066400000000000000000000023151302662252000352450ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/pacpackage com.github.markusbernhardt.proxy.selector.pac; /*************************************************************************** * Common interface for PAC script parsers. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ***************************************************************************/ public interface PacScriptParser { /*************************************************************************** * Gets the source of the PAC script used by this parser. * * @return a PacScriptSource. **************************************************************************/ public PacScriptSource getScriptSource(); /************************************************************************* * Evaluates the given URL and host against the PAC script. * * @param url * the URL to evaluate. * @param host * the host name part of the URL. * @return the script result. * @throws ProxyEvaluationException * on execution error. ************************************************************************/ public String evaluate(String url, String host) throws ProxyEvaluationException; } PacScriptSource.java000066400000000000000000000022651302662252000352550ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/pacpackage com.github.markusbernhardt.proxy.selector.pac; import java.io.IOException; /***************************************************************************** * An source to fetch the PAC script from. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public interface PacScriptSource { /************************************************************************* * Gets the PAC script content as String. * * @return a script. * @throws IOException * on read error. ************************************************************************/ public String getScriptContent() throws IOException; /************************************************************************* * Checks if the content of the script is valid and if it is possible to use * this script source for a PAC selector. Note that this might trigger a * download of the script content from a remote location. * * @return true if everything is fine, else false. ************************************************************************/ public boolean isScriptValid(); }ProxyEvaluationException.java000066400000000000000000000033521302662252000372320ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/pacpackage com.github.markusbernhardt.proxy.selector.pac; import com.github.markusbernhardt.proxy.util.ProxyException; /***************************************************************************** * Exception for PAC script errors. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class ProxyEvaluationException extends ProxyException { private static final long serialVersionUID = 1L; /************************************************************************* * Constructor ************************************************************************/ public ProxyEvaluationException() { super(); } /************************************************************************* * Constructor * * @param message * the error message. * @param cause * the causing exception for exception chaining. ************************************************************************/ public ProxyEvaluationException(String message, Throwable cause) { super(message, cause); } /************************************************************************* * Constructor * * @param message * the error message. ************************************************************************/ public ProxyEvaluationException(String message) { super(message); } /************************************************************************* * Constructor * * @param cause * the causing exception for exception chaining. ************************************************************************/ public ProxyEvaluationException(Throwable cause) { super(cause); } } ScriptMethods.java000066400000000000000000000262411302662252000347740ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/pacpackage com.github.markusbernhardt.proxy.selector.pac; /*************************************************************************** * Defines the public interface for PAC scripts. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ***************************************************************************/ public interface ScriptMethods { public boolean isPlainHostName(String host); /************************************************************************* * Tests if an URL is in a given domain. * * @param host * is the host name from the URL. * @param domain * is the domain name to test the host name against. * @return true if the domain of host name matches. ************************************************************************/ public boolean dnsDomainIs(String host, String domain); /************************************************************************* * Is true if the host name matches exactly the specified host name, or if * there is no domain name part in the host name, but the unqualified host * name matches. * * @param host * the host name from the URL. * @param domain * fully qualified host name with domain to match against. * @return true if matches else false. ************************************************************************/ public boolean localHostOrDomainIs(String host, String domain); /************************************************************************* * Tries to resolve the host name. Returns true if succeeds. * * @param host * is the host name from the URL. * @return true if resolvable else false. ************************************************************************/ public boolean isResolvable(String host); /************************************************************************* * Tries to resolve the host name. Returns true if succeeds to resolve the * host to an IPv4 or IPv6 address. * * @param host * is the host name from the URL. * @return true if resolvable else false. ************************************************************************/ public boolean isResolvableEx(String host); /************************************************************************* * Returns true if 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. * * Example: isInNet(host, "198.95.0.0", "255.255.0.0") is true if the IP * address of the host matches 198.95.*.*. * * @param host * a DNS host name, or IP address. If a host name is passed, it * will be resolved into an IP address by this function. * @param pattern * an IP address pattern in the dot-separated format. * @param mask * mask for the IP address pattern informing which parts of the * IP address should be matched against. 0 means ignore, 255 * means match. * @return true if it matches else false. ************************************************************************/ public boolean isInNet(String host, String pattern, String mask); /************************************************************************* * Extension of the isInNet method to support IPv6. * * @param ipAddress * an IP4 or IP6 address * @param ipPrefix * A string containing colon delimited IP prefix with top n bits * specified in the bit field (i.e. 3ffe:8311:ffff::/48 or * 123.112.0.0/16). * @return true if the host is in the given subnet, else false. ************************************************************************/ public boolean isInNetEx(String ipAddress, String ipPrefix); /************************************************************************* * Resolves the given DNS host name into an IP address, and returns it in * the dot separated format as a string. * * @param host * the host to resolve. * @return the resolved IP, empty string if not resolvable. ************************************************************************/ public String dnsResolve(String host); /************************************************************************* * @param host * the host to resolve * @return a semicolon separated list of IP6 and IP4 addresses the host name * resolves to, empty string if not resolvable. ************************************************************************/ public String dnsResolveEx(String host); /************************************************************************* * Returns the IP address of the host that the process is running on, as a * string in the dot-separated integer format. * * @return an IP as string. ************************************************************************/ public String myIpAddress(); /************************************************************************* * Returns a list of IP4 and IP6 addresses of the host that the process is * running on. The list is separated with semicolons. * * @return the list, empty string if not available. ************************************************************************/ public String myIpAddressEx(); /************************************************************************* * Returns the number of DNS domain levels (number of dots) in the host * name. * * @param host * is the host name from the URL. * @return number of DNS domain levels. ************************************************************************/ public int dnsDomainLevels(String host); /************************************************************************* * Returns true if the string matches the specified shell expression. * Actually, currently the patterns are shell expressions, not regular * expressions. * * @param str * is any string to compare (e.g. the URL, or the host name). * @param shexp * is a shell expression to compare against. * @return true if the string matches, else false. ************************************************************************/ public boolean shExpMatch(String str, String shexp); /************************************************************************* * 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 * yields 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 time zone. If both wd1 and wd2 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 time zone is used. * * @param wd1 * weekday 1 is one of SUN MON TUE WED THU FRI SAT * @param wd2 * weekday 2 is one of SUN MON TUE WED THU FRI SAT * @param gmt * "GMT" for gmt time format else "undefined" * @return true if current day matches the criteria. ************************************************************************/ public boolean weekdayRange(String wd1, String wd2, String gmt); /************************************************************************* * Only the first parameter is mandatory. All other parameters can be left * out therefore the meaning of the parameters changes. The method * definition shows the version with the most possible parameters filled. * The real meaning of the parameters is guessed from it's value. If "from" * and "to" are specified then the bounds are inclusive. If the "GMT" * parameter is specified, times are taken to be in GMT, otherwise the local * time zone is used. * * @param day1 * is the day of month between 1 and 31 (as an integer). * @param month1 * one of JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC * @param year1 * is the full year number, for example 1995 (but not 95). * Integer. * @param day2 * is the day of month between 1 and 31 (as an integer). * @param month2 * one of JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC * @param year2 * is the full year number, for example 1995 (but not 95). * Integer. * @param gmt * "GMT" for gmt time format else "undefined" * @return true if the current date matches the given range. ************************************************************************/ public boolean dateRange(Object day1, Object month1, Object year1, Object day2, Object month2, Object year2, Object gmt); /************************************************************************* * Some parameters can be left out therefore the meaning of the parameters * changes. The method definition shows the version with the most possible * parameters filled. The real meaning of the parameters is guessed from * it's value. If "from" and "to" are specified then the bounds are * inclusive. If the "GMT" parameter is specified, times are taken to be in * GMT, otherwise the local time zone is used.
* *
	 * 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)
	 * 
* * @param hour1 * is the hour from 0 to 23. (0 is midnight, 23 is 11 pm.) * @param min1 * minutes from 0 to 59. * @param sec1 * seconds from 0 to 59. * @param hour2 * is the hour from 0 to 23. (0 is midnight, 23 is 11 pm.) * @param min2 * minutes from 0 to 59. * @param sec2 * seconds from 0 to 59. * @param gmt * "GMT" for gmt time format else "undefined" * @return true if the current time matches the given range. ************************************************************************/ public boolean timeRange(Object hour1, Object min1, Object sec1, Object hour2, Object min2, Object sec2, Object gmt); /************************************************************************* * Sorts a list of IP4 and IP6 addresses. Separated by semicolon. Dual * addresses first, then IPv6 and last IPv4. * * @param ipAddressList * the address list. * @return the sorted list, empty string if sort is not possible ************************************************************************/ public String sortIpAddressList(String ipAddressList); /************************************************************************* * Gets the version of the PAC extension that is available. * * @return the extension version, currently 1.0 ************************************************************************/ public String getClientVersion(); } UrlPacScriptSource.java000066400000000000000000000237071302662252000357440ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/pacpackage com.github.markusbernhardt.proxy.selector.pac; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.Proxy; import java.net.URISyntaxException; import java.net.URL; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; /***************************************************************************** * Script source that will load the content of a PAC file from an webserver. The * script content is cached once it was downloaded. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class UrlPacScriptSource implements PacScriptSource { private static final int DEFAULT_CONNECT_TIMEOUT = 15 * 1000; // seconds private static final int DEFAULT_READ_TIMEOUT = 20 * 1000; // seconds public static final String OVERRIDE_CONNECT_TIMEOUT = "com.btr.proxy.url.connectTimeout"; public static final String OVERRIDE_READ_TIMEOUT = "com.btr.proxy.url.readTimeout"; private final String scriptUrl; private String scriptContent; private long expireAtMillis; /************************************************************************* * Constructor * * @param url * the URL to download the script from. ************************************************************************/ public UrlPacScriptSource(String url) { super(); this.expireAtMillis = 0; this.scriptUrl = url; } /************************************************************************* * getScriptContent * * @see com.github.markusbernhardt.proxy.selector.pac.PacScriptSource#getScriptContent() ************************************************************************/ public synchronized String getScriptContent() throws IOException { if (this.scriptContent == null || (this.expireAtMillis > 0 && this.expireAtMillis < System.currentTimeMillis())) { try { // Reset it again with next download we should get a new expire // info this.expireAtMillis = 0; if (this.scriptUrl.startsWith("file:/") || this.scriptUrl.indexOf(":/") == -1) { this.scriptContent = readPacFileContent(this.scriptUrl); } else { this.scriptContent = downloadPacContent(this.scriptUrl); } } catch (IOException e) { Logger.log(getClass(), LogLevel.ERROR, "Loading script failed from: {0} with error {1}", this.scriptUrl, e); this.scriptContent = ""; throw e; } } return this.scriptContent; } /************************************************************************* * Reads a PAC script from a local file. * * @param scriptUrl * @return the content of the script file. * @throws IOException * @throws URISyntaxException ************************************************************************/ private String readPacFileContent(String scriptUrl) throws IOException { try { File file = null; if (scriptUrl.indexOf(":/") == -1) { file = new File(scriptUrl); } else { file = new File(new URL(scriptUrl).toURI()); } BufferedReader r = new BufferedReader(new FileReader(file)); StringBuilder result = new StringBuilder(); try { String line; while ((line = r.readLine()) != null) { result.append(line).append("\n"); } } finally { r.close(); } return result.toString(); } catch (Exception e) { System.out.println(System.getProperty("user.dir")); Logger.log(getClass(), LogLevel.ERROR, "File reading error.", e); throw new IOException(e.getMessage()); } } /************************************************************************* * Downloads the script from a webserver. * * @param url * the URL to the script file. * @return the script content. * @throws IOException * on read error. ************************************************************************/ private String downloadPacContent(String url) throws IOException { if (url == null) { throw new IOException("Invalid PAC script URL: null"); } setPacProxySelectorEnabled(false); HttpURLConnection con = null; try { con = setupHTTPConnection(url); if (con.getResponseCode() != 200) { throw new IOException("Server returned: " + con.getResponseCode() + " " + con.getResponseMessage()); } // Read expire date. this.expireAtMillis = con.getExpiration(); BufferedReader r = getReader(con); String result = readAllContent(r); r.close(); return result; } finally { setPacProxySelectorEnabled(true); if (con != null) { con.disconnect(); } } } /************************************************************************* * Enables/disables the PAC proxy selector while we download to prevent * recursion. See issue: 26 in the change tracker. ************************************************************************/ private void setPacProxySelectorEnabled(boolean enable) { PacProxySelector.setEnabled(enable); } /************************************************************************* * Reads the whole content available into a String. * * @param r * to read from. * @return the complete PAC file content. * @throws IOException ************************************************************************/ private String readAllContent(BufferedReader r) throws IOException { StringBuilder result = new StringBuilder(); String line; while ((line = r.readLine()) != null) { result.append(line).append("\n"); } return result.toString(); } /************************************************************************* * Build a BufferedReader around the open HTTP connection. * * @param con * to read from * @return the BufferedReader. * @throws UnsupportedEncodingException * @throws IOException ************************************************************************/ private BufferedReader getReader(HttpURLConnection con) throws UnsupportedEncodingException, IOException { String charsetName = parseCharsetFromHeader(con.getContentType()); BufferedReader r = new BufferedReader(new InputStreamReader(con.getInputStream(), charsetName)); return r; } /************************************************************************* * Configure the connection to download from. * * @param url * to get the pac file content from * @return a HTTPUrlConnecion to this url. * @throws IOException * @throws MalformedURLException ************************************************************************/ private HttpURLConnection setupHTTPConnection(String url) throws IOException, MalformedURLException { HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection(Proxy.NO_PROXY); con.setConnectTimeout(getTimeOut(OVERRIDE_CONNECT_TIMEOUT, DEFAULT_CONNECT_TIMEOUT)); con.setReadTimeout(getTimeOut(OVERRIDE_READ_TIMEOUT, DEFAULT_READ_TIMEOUT)); con.setInstanceFollowRedirects(true); con.setRequestProperty("accept", "application/x-ns-proxy-autoconfig, */*;q=0.8"); return con; } /************************************************************************* * Gets the timeout value from a property or uses the given default value if * the property cannot be parsed. * * @param overrideProperty * the property to define the timeout value in milliseconds * @param defaultValue * the default timeout value in milliseconds. * @return the value to use. ************************************************************************/ protected int getTimeOut(String overrideProperty, int defaultValue) { int timeout = defaultValue; String prop = System.getProperty(overrideProperty); if (prop != null && prop.trim().length() > 0) { try { timeout = Integer.parseInt(prop.trim()); } catch (NumberFormatException e) { Logger.log(getClass(), LogLevel.DEBUG, "Invalid override property : {0}={1}", overrideProperty, prop); // In this case use the default value. } } return timeout; } /************************************************************************* * Response Content-Type could be something like this: * application/x-ns-proxy-autoconfig; charset=UTF-8 * * @param contentType * header field. * @return the extracted charset if set else a default charset. ************************************************************************/ String parseCharsetFromHeader(String contentType) { String result = "ISO-8859-1"; if (contentType != null) { String[] paramList = contentType.split(";"); for (String param : paramList) { if (param.toLowerCase().trim().startsWith("charset") && param.indexOf("=") != -1) { result = param.substring(param.indexOf("=") + 1).trim(); } } } return result; } /*************************************************************************** * @see java.lang.Object#toString() **************************************************************************/ @Override public String toString() { return this.scriptUrl; } /************************************************************************* * isScriptValid * * @see com.github.markusbernhardt.proxy.selector.pac.PacScriptSource#isScriptValid() ************************************************************************/ public boolean isScriptValid() { try { String script = getScriptContent(); if (script == null || script.trim().length() == 0) { Logger.log(getClass(), LogLevel.DEBUG, "PAC script is empty. Skipping script!"); return false; } if (script.indexOf("FindProxyForURL") == -1) { Logger.log(getClass(), LogLevel.DEBUG, "PAC script entry point FindProxyForURL not found. Skipping script!"); return false; } return true; } catch (IOException e) { Logger.log(getClass(), LogLevel.DEBUG, "File reading error: {0}", e); return false; } } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/whitelist/000077500000000000000000000000001302662252000326645ustar00rootroot00000000000000DefaultWhiteListParser.java000066400000000000000000000070261302662252000400530ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/whitelistpackage com.github.markusbernhardt.proxy.selector.whitelist; import java.util.ArrayList; import java.util.List; import com.github.markusbernhardt.proxy.search.browser.ie.IELocalByPassFilter; import com.github.markusbernhardt.proxy.selector.whitelist.HostnameFilter.Mode; import com.github.markusbernhardt.proxy.util.UriFilter; /***************************************************************************** * Default implementation for an white list parser. This will support the most * common forms of filters found in white lists. The white list is a comma (or * space) separated list of domain names or IP addresses. The following section * shows some examples. * * .mynet.com - Filters all host names ending with .mynet.com *.mynet.com - * Filters all host names ending with .mynet.com www.mynet.* - Filters all host * names starting with www.mynet. 123.12.32.1 - Filters the IP 123.12.32.1 * 123.12.32.1/255 - Filters the IP range http://www.mynet.com - Filters only * HTTP protocol not FTP and no HTTPS * * Example of a list: * * .mynet.com, *.my-other-net.org, 123.55.23.222, 123.55.23.0/24 * * Some info about this topic can be found here: * http://kb.mozillazine.org/No_proxy_for * http://technet.microsoft.com/en-us/library/dd361953.aspx * * Note that this implementation does not cover all variations of all browsers * but should cover the most used formats. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class DefaultWhiteListParser implements WhiteListParser { /************************************************************************* * parseWhiteList * * @see com.github.markusbernhardt.proxy.selector.whitelist.WhiteListParser#parseWhiteList(java.lang.String) ************************************************************************/ public List parseWhiteList(String whiteList) { List result = new ArrayList(); String[] token = whiteList.split("[, ]+"); for (int i = 0; i < token.length; i++) { String tkn = token[i].trim(); if (isIP4SubnetFilter(tkn) || isIP6SubnetFilter(tkn)) { result.add(new IpRangeFilter(tkn)); continue; } else if (tkn.endsWith("*")) { tkn = tkn.substring(0, tkn.length() - 1); result.add(new HostnameFilter(Mode.BEGINS_WITH, tkn)); continue; } else if (tkn.trim().startsWith("*")) { tkn = tkn.substring(1); result.add(new HostnameFilter(Mode.ENDS_WITH, tkn)); } else if (tkn.trim().equals("")) { result.add(new IELocalByPassFilter()); } else { result.add(new HostnameFilter(Mode.ENDS_WITH, tkn)); } } return result; } /************************************************************************* * Checks if the given token is an IP6 subnet filter. * * @param token * to analyze. * @return true if it is a valid IP6 subnet filter else false. ************************************************************************/ private boolean isIP6SubnetFilter(String token) { return IPWithSubnetChecker.isValidIP6Range(token); } /************************************************************************* * Checks if the given token is an IP4 subnet filter. * * @param token * to analyze. * @return true if it is a valid IP4 subnet filter else false. ************************************************************************/ private boolean isIP4SubnetFilter(String token) { return IPWithSubnetChecker.isValidIP4Range(token); } } HostnameFilter.java000066400000000000000000000057741302662252000364110ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/whitelistpackage com.github.markusbernhardt.proxy.selector.whitelist; import java.net.URI; import com.github.markusbernhardt.proxy.util.UriFilter; /***************************************************************************** * Tests if a host name of a given URI matches some criteria. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class HostnameFilter implements UriFilter { private static final String PROTOCOL_ENDING = "://"; public enum Mode { BEGINS_WITH, ENDS_WITH, REGEX } private String matchTo; private String protocolFilter; private Mode mode; /************************************************************************* * Constructor * * @param mode * the filter mode. * @param matchTo * the match criteria. ************************************************************************/ public HostnameFilter(Mode mode, String matchTo) { super(); this.mode = mode; this.matchTo = matchTo.toLowerCase(); extractProtocolFilter(); } /************************************************************************* * Extracts the protocol if one is given to initialize the protocol matcher. ************************************************************************/ private void extractProtocolFilter() { int protocolIndex = this.matchTo.indexOf(PROTOCOL_ENDING); if (protocolIndex != -1) { this.protocolFilter = this.matchTo.substring(0, protocolIndex); this.matchTo = this.matchTo.substring(protocolIndex + PROTOCOL_ENDING.length()); } } /************************************************************************* * accept * * @see com.github.markusbernhardt.proxy.util.UriFilter#accept(java.net.URI) ************************************************************************/ public boolean accept(URI uri) { if (uri == null || uri.getAuthority() == null) { return false; } if (!isProtocolMatching(uri)) { return false; } String host = uri.getAuthority(); // Strip away port take special care for IP6. int index = host.indexOf(':'); int index2 = host.lastIndexOf(']'); if (index != -1 && index2 < index) { host = host.substring(0, index); } switch (this.mode) { case BEGINS_WITH: return host.toLowerCase().startsWith(this.matchTo); case ENDS_WITH: return host.toLowerCase().endsWith(this.matchTo); case REGEX: return host.toLowerCase().matches(this.matchTo); } return false; } /************************************************************************* * Applies the protocol filter if available to see if we have a match. * * @param uri * to test for a correct protocol. * @return true if passed else false. ************************************************************************/ private boolean isProtocolMatching(URI uri) { return this.protocolFilter == null || uri.getScheme() == null || uri.getScheme().equalsIgnoreCase(this.protocolFilter); } } IPWithSubnetChecker.java000066400000000000000000000034661302662252000372730ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/whitelistpackage com.github.markusbernhardt.proxy.selector.whitelist; import java.util.regex.Pattern; /***************************************************************************** * Checks if the given string is a IP4 range subnet definition of the format * 192.168.0/24 Based on a contribution by Jan Engler * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class IPWithSubnetChecker { private static Pattern IP_SUB_PATTERN = Pattern.compile("^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])/(\\d|([12]\\d|3[0-2]))$"); // Could be improved private static Pattern IP6_SUB_PATTERN = Pattern.compile("^[a-f0-9:]*/[0-9]+$"); /************************************************************************* * Tests if a given string is of in the correct format for an IP4 subnet * mask. * * @param possibleIPAddress * to test for valid format. * @return true if valid else false. ************************************************************************/ public static boolean isValidIP4Range(String possibleIPAddress) { return IP_SUB_PATTERN.matcher(possibleIPAddress).matches(); } /************************************************************************* * Tests if a given string is of in the correct format for an IP6 subnet * mask. * * @param possibleIPAddress * to test for valid format. * @return true if valid else false. ************************************************************************/ public static boolean isValidIP6Range(String possibleIPAddress) { return IP6_SUB_PATTERN.matcher(possibleIPAddress).matches(); } } IpRangeFilter.java000066400000000000000000000046121302662252000361460ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/whitelistpackage com.github.markusbernhardt.proxy.selector.whitelist; import java.net.InetAddress; import java.net.URI; import java.net.UnknownHostException; import com.github.markusbernhardt.proxy.util.UriFilter; /***************************************************************************** * Filters an URI by inspecting it's IP address is in a given range. The range * as must be defined in CIDR notation. e.g. 192.0.2.1/24, * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class IpRangeFilter implements UriFilter { private byte[] matchTo; int numOfBits; /************************************************************************* * Constructor * * @param matchTo * the match subnet in CIDR notation. ************************************************************************/ public IpRangeFilter(String matchTo) { super(); String[] parts = matchTo.split("/"); if (parts.length != 2) { throw new IllegalArgumentException("IP range is not valid:" + matchTo); } try { InetAddress address = InetAddress.getByName(parts[0].trim()); this.matchTo = address.getAddress(); } catch (UnknownHostException e) { throw new IllegalArgumentException("IP range is not valid:" + matchTo); } this.numOfBits = Integer.parseInt(parts[1].trim()); } /************************************************************************* * accept * * @see com.github.markusbernhardt.proxy.util.UriFilter#accept(java.net.URI) ************************************************************************/ public boolean accept(URI uri) { if (uri == null || uri.getHost() == null) { return false; } try { InetAddress address = InetAddress.getByName(uri.getHost()); byte[] addr = address.getAddress(); // Comparing IP6 against IP4? if (addr.length != this.matchTo.length) { return false; } int bit = 0; for (int nibble = 0; nibble < addr.length; nibble++) { for (int nibblePos = 7; nibblePos >= 0; nibblePos--) { int mask = 1 << nibblePos; if ((this.matchTo[nibble] & mask) != (addr[nibble] & mask)) { return false; } bit++; if (bit >= this.numOfBits) { return true; } } } } catch (UnknownHostException e) { // In this case we can not get the IP do not match. } return false; } } ProxyBypassListSelector.java000066400000000000000000000060611302662252000403130ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/whitelistpackage com.github.markusbernhardt.proxy.selector.whitelist; import java.io.IOException; import java.net.Proxy; import java.net.ProxySelector; import java.net.SocketAddress; import java.net.URI; import java.util.List; import com.github.markusbernhardt.proxy.util.ProxyUtil; import com.github.markusbernhardt.proxy.util.UriFilter; /***************************************************************************** * Special purpose ProxySelector used as Facade on top of a normal * ProxySelector. A wrapper that will first check the URI against a white list * and if it matches it will return DIRECT else it will pass the URI to an * delegate for inspection. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class ProxyBypassListSelector extends ProxySelector { private ProxySelector delegate; private List whiteListFilter; /************************************************************************* * Constructor * * @param whiteListFilter * a list of filters for whitelist URLs. * @param proxySelector * the proxy selector to use. ************************************************************************/ public ProxyBypassListSelector(List whiteListFilter, ProxySelector proxySelector) { super(); if (whiteListFilter == null) { throw new NullPointerException("Whitelist must not be null."); } if (proxySelector == null) { throw new NullPointerException("ProxySelector must not be null."); } this.delegate = proxySelector; this.whiteListFilter = whiteListFilter; } /************************************************************************* * Constructor * * @param whiteList * a list of filters for whitelist URLs as comma/space separated * string. * @param proxySelector * the proxy selector to use. ************************************************************************/ public ProxyBypassListSelector(String whiteList, ProxySelector proxySelector) { this(new DefaultWhiteListParser().parseWhiteList(whiteList), proxySelector); } /************************************************************************* * connectFailed * * @see java.net.ProxySelector#connectFailed(java.net.URI, * java.net.SocketAddress, java.io.IOException) ************************************************************************/ @Override public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { this.delegate.connectFailed(uri, sa, ioe); } /************************************************************************* * select * * @see java.net.ProxySelector#select(java.net.URI) ************************************************************************/ @Override public List select(URI uri) { // If in white list, use DIRECT connection. for (UriFilter filter : this.whiteListFilter) { if (filter.accept(uri)) { return ProxyUtil.noProxyList(); } } return this.delegate.select(uri); } } UseProxyWhiteListSelector.java000066400000000000000000000051171302662252000406100ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/whitelistpackage com.github.markusbernhardt.proxy.selector.whitelist; import java.io.IOException; import java.net.Proxy; import java.net.ProxySelector; import java.net.SocketAddress; import java.net.URI; import java.util.List; import com.github.markusbernhardt.proxy.util.ProxyUtil; import com.github.markusbernhardt.proxy.util.UriFilter; /***************************************************************************** * Special purpose ProxySelector used as Facade on top of a normal * ProxySelector. A wrapper that will first check the URI against a white list * and if it matches it will use a proxy as provided by the delegate * ProxySelector else it will return DIRECT. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class UseProxyWhiteListSelector extends ProxySelector { private ProxySelector delegate; private List whiteListFilter; /************************************************************************* * Constructor * * @param whiteList * the whitelist to use. * @param proxySelector * the proxy selector to use. ************************************************************************/ public UseProxyWhiteListSelector(String whiteList, ProxySelector proxySelector) { super(); if (whiteList == null) { throw new NullPointerException("Whitelist must not be null."); } if (proxySelector == null) { throw new NullPointerException("ProxySelector must not be null."); } this.delegate = proxySelector; WhiteListParser parser = new DefaultWhiteListParser(); this.whiteListFilter = parser.parseWhiteList(whiteList); } /************************************************************************* * connectFailed * * @see java.net.ProxySelector#connectFailed(java.net.URI, * java.net.SocketAddress, java.io.IOException) ************************************************************************/ @Override public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { this.delegate.connectFailed(uri, sa, ioe); } /************************************************************************* * select * * @see java.net.ProxySelector#select(java.net.URI) ************************************************************************/ @Override public List select(URI uri) { // If in white list, use proxy selector. for (UriFilter filter : this.whiteListFilter) { if (filter.accept(uri)) { return this.delegate.select(uri); } } return ProxyUtil.noProxyList(); } } WhiteListParser.java000066400000000000000000000016451302662252000365470ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/selector/whitelistpackage com.github.markusbernhardt.proxy.selector.whitelist; import java.util.List; import com.github.markusbernhardt.proxy.util.UriFilter; /***************************************************************************** * Interface for an white list parser. This will take an white list string and * parse it into a list of UriFilter rules. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public interface WhiteListParser { /************************************************************************* * Parses a list of host name and IP filters into UriFilter objects. * * @param whiteList * the string to parse. * @return a list of UriFilters ************************************************************************/ public List parseWhiteList(String whiteList); } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/ui/000077500000000000000000000000001302662252000274455ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/ui/ProxyTester.java000066400000000000000000000125741302662252000326310ustar00rootroot00000000000000package com.github.markusbernhardt.proxy.ui; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.net.Proxy; import java.net.ProxySelector; import java.net.URL; import java.text.MessageFormat; import java.util.List; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.UIManager; import com.github.markusbernhardt.proxy.ProxySearch; import com.github.markusbernhardt.proxy.ProxySearch.Strategy; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; /***************************************************************************** * Small test application that allows you to select a proxy search strategy and * then validate URLs against it. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class ProxyTester extends JFrame { private static final long serialVersionUID = 1L; private JComboBox modes; private JButton testButton; private JTextField urlField; private JTextArea logArea; /************************************************************************* * Constructor ************************************************************************/ public ProxyTester() { super(); init(); } /************************************************************************* * Initializes the GUI. ************************************************************************/ private void init() { setTitle("Proxy Vole Tester"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel p = new JPanel(); p.add(new JLabel("Mode:")); this.modes = new JComboBox(ProxySearch.Strategy.values()); p.add(this.modes); p.add(new JLabel("URL:")); this.urlField = new JTextField(30); this.urlField.setText("http://www.google.com/"); p.add(this.urlField); this.testButton = new JButton("Test"); this.testButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { testUrl(); } }); p.add(this.testButton); this.logArea = new JTextArea(5, 50); JPanel contenPane = new JPanel(new BorderLayout()); contenPane.add(p, BorderLayout.NORTH); contenPane.add(new JScrollPane(this.logArea), BorderLayout.CENTER); setContentPane(contenPane); pack(); setLocationRelativeTo(null); installLogger(); } /************************************************************************* * Install the framework logger. ************************************************************************/ private void installLogger() { Logger.setBackend(new Logger.LogBackEnd() { public void log(Class clazz, LogLevel loglevel, String msg, Object... params) { ProxyTester.this.logArea.append(loglevel + "\t" + MessageFormat.format(msg, params) + "\n"); } public boolean isLogginEnabled(LogLevel logLevel) { return true; } }); } /************************************************************************* * Test the given URL with the given Proxy Search. ************************************************************************/ protected void testUrl() { try { if (this.urlField.getText().trim().length() == 0) { ProxyTester.this.logArea.append("ERROR\tPlease enter an URL first.\n"); return; } this.logArea.setText(""); Strategy pss = (Strategy) this.modes.getSelectedItem(); ProxySearch ps = new ProxySearch(); ps.addStrategy(pss); ProxySelector psel = ps.getProxySelector(); if (psel == null) { ProxyTester.this.logArea.append("ERROR\tNo proxy settings available for this mode.\n"); return; } ProxySelector.setDefault(psel); URL url = new URL(this.urlField.getText().trim()); List result = psel.select(url.toURI()); if (result == null || result.size() == 0) { ProxyTester.this.logArea.append("INFO\tNo proxy found for this url.\n"); return; } ProxyTester.this.logArea.append("INFO\tProxy Settings found using " + pss + " strategy.\n"); ProxyTester.this.logArea.append("INFO\tProxy used for URL is: " + result.get(0) + "\n"); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Error:" + e.getMessage(), "Error checking URL.", JOptionPane.ERROR_MESSAGE); } } /************************************************************************* * Main entry point for the application. * * @param args * command line arguments. ************************************************************************/ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { setLookAndFeel(); ProxyTester mainFrame = new ProxyTester(); mainFrame.setVisible(true); } }); } /************************************************************************* * Change the L&F to the system default. ************************************************************************/ private static void setLookAndFeel() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { // Use default } } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/util/000077500000000000000000000000001302662252000300055ustar00rootroot00000000000000EmptyXMLResolver.java000066400000000000000000000020521302662252000337710ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/utilpackage com.github.markusbernhardt.proxy.util; import java.io.ByteArrayInputStream; import java.io.IOException; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import org.xml.sax.SAXException; /***************************************************************************** * This resolver is used to prevent network lookups of DTD or XML schemas. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class EmptyXMLResolver implements EntityResolver { /************************************************************************* * Overwritten to return an empty entity. * * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, * java.lang.String) ************************************************************************/ public InputSource resolveEntity(String arg0, String arg1) throws SAXException, IOException { return new InputSource(new ByteArrayInputStream("".getBytes())); } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/util/Logger.java000066400000000000000000000066611302662252000321000ustar00rootroot00000000000000package com.github.markusbernhardt.proxy.util; /***************************************************************************** * Simple logging support for the framework. You need to add an logging listener * that needs to send the logging events to an backend. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class Logger { public enum LogLevel { ERROR, WARNING, INFO, TRACE, DEBUG } /***************************************************************************** * Interface for an logging backend that can be attached to the logger. ****************************************************************************/ public interface LogBackEnd { /************************************************************************* * Invoked for every logging event. * * @param clazz * the class that sends the log message. * @param loglevel * the logging level. * @param msg * the message format string. * @param params * the message parameters for the format string. ************************************************************************/ public void log(Class clazz, LogLevel loglevel, String msg, Object... params); /************************************************************************* * Can be used to test if a given logging level is enabled. * * @param logLevel * the loglevel to test. * @return true if enabled, else false. ************************************************************************/ public boolean isLogginEnabled(LogLevel logLevel); } private static LogBackEnd backend; /************************************************************************* * Gets the currently attached logging backend. * * @return Returns the backend. ************************************************************************/ public static LogBackEnd getBackend() { return backend; } /************************************************************************* * Attaches a new logging backend replacing the existing one. * * @param backend * The backend to set. ************************************************************************/ public static void setBackend(LogBackEnd backend) { Logger.backend = backend; } /************************************************************************* * Logs a message. * * @param clazz * the class that sends the log message. * @param loglevel * the logging level. * @param msg * the message format string. * @param params * the message parameters for the format string. ************************************************************************/ public static void log(Class clazz, LogLevel loglevel, String msg, Object... params) { if (backend != null) { backend.log(clazz, loglevel, msg, params); } } /************************************************************************* * Can be used to test if a given logging level is enabled. * * @param logLevel * the loglevel to test. * @return true if enabled, else false. ************************************************************************/ public static boolean isLogginEnabled(LogLevel logLevel) { if (backend != null) { return backend.isLogginEnabled(logLevel); } return false; } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/util/PListParser.java000066400000000000000000000406021302662252000330620ustar00rootroot00000000000000package com.github.markusbernhardt.proxy.util; import java.io.Closeable; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.TimeZone; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import org.xml.sax.SAXException; /** * Plist xml handling (serialization and deserialization) *

* The xml plist dtd can be found at http://www.apple.com/DTDs/PropertyList-1.0.dtd *

* The plist spec handles 8 types of objects: booleans, real, integers, dates, * binary data, strings, arrays (lists) and dictionaries (maps). *

* The java Plist lib handles converting xml plists to a nested * {@code Map} that can be trivially read from java. It also * provides a simple way to convert a nested {@code Map} into an * xml plist representation. *

* The following mapping will be done when converting from plist to Map * : * *

 * true/false -> Boolean
 * real -> Double
 * integer -> Integer/Long (depends on size, values exceeding an int will be rendered as longs)
 * data -> byte[]
 * string -> String
 * array -> List
 * dict -> Map
 * 
*

* When converting from Map -> plist the conversion is as follows: * *

 * Boolean -> true/false
 * Float/Double -> real
 * Byte/Short/Integer/Long -> integer
 * byte[] -> data
 * List -> array
 * Map -> dict
 * 
* * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 * @author Christoffer Lerno / Modified by Bernd Rosstauscher */ public final class PListParser { /***************************************************************************** * Exception is used for XML parse problems. * * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 ****************************************************************************/ public static class XmlParseException extends Exception { /** Comment for serialVersionUID */ private static final long serialVersionUID = 1L; /************************************************************************* * Constructor ************************************************************************/ public XmlParseException() { super(); } /************************************************************************* * Constructor * * @param msg * the error message ************************************************************************/ public XmlParseException(String msg) { super(msg); } /************************************************************************* * Constructor * * @param msg * error message * @param e * the cause. ************************************************************************/ public XmlParseException(String msg, Exception e) { super(msg, e); } } /***************************************************************************** * Small helper class representing a tree node. * * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009 ****************************************************************************/ public static class Dict implements Iterable> { private Map children; /************************************************************************* * Constructor ************************************************************************/ public Dict() { super(); this.children = new HashMap(); } /************************************************************************* * @param key * of the child node. * @return the child node, null if not existing. ************************************************************************/ public Object get(String key) { return this.children.get(key); } /************************************************************************* * iterator * * @see java.lang.Iterable#iterator() ************************************************************************/ public Iterator> iterator() { return this.children.entrySet().iterator(); } /************************************************************************* * @return the size of this dictionary. ************************************************************************/ public int size() { return this.children.size(); } /************************************************************************* * Dumps a dictionary with all sub-nodes to the console. ************************************************************************/ public void dump() { System.out.println("PList"); dumpInternal(this, 1); } /************************************************************************* * @param plist * @param indent ************************************************************************/ private static void dumpInternal(Dict plist, int indent) { for (Map.Entry child : plist) { if (child.getValue() instanceof Dict) { for (int j = 0; j < indent; j++) { System.out.print(" "); } System.out.println(child.getKey()); dumpInternal((Dict) child.getValue(), indent + 1); } else { for (int j = 0; j < indent; j++) { System.out.print(" "); } System.out.println(child.getKey() + " = " + child.getValue()); } } } /************************************************************************* * Get a node at a given path. * * @param path * a / separated path into the plist hirarchy. * @return the object located at the given path, null if it does not * exist. ************************************************************************/ public Object getAtPath(String path) { Dict currentNode = this; String[] pathSegments = path.trim().split("/"); for (int i = 0; i < pathSegments.length; i++) { String segment = pathSegments[i].trim(); if (segment.length() == 0) { continue; } Object o = currentNode.get(segment); if (i >= pathSegments.length - 1) { return o; } if (o == null || !(o instanceof Dict)) { break; } currentNode = (Dict) o; } return null; } } /** * Singleton instance. */ private final static PListParser PLIST = new PListParser(); /** * All element types possible for a plist. */ private static enum ElementType { INTEGER, STRING, REAL, DATA, DATE, DICT, ARRAY, TRUE, FALSE, } private static final String BASE64_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; private static final char[] BASE64_CHARS = BASE64_STRING.toCharArray(); private final DateFormat m_dateFormat; private final Map, ElementType> m_simpleTypes; /** * Utility method to close a closeable. * * @param closeable * or null. */ static void silentlyClose(Closeable closeable) { try { if (closeable != null) { closeable.close(); } } catch (IOException e) { // Ignore } } /************************************************************************* * Reads from the given input stream and parses it to a Dict. * * @param input * the input stream to read from. * @return the parsed dictionary. * @throws XmlParseException * on parsing error. ************************************************************************/ private static Dict parse(InputSource input) throws XmlParseException { try { DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); documentBuilder.setEntityResolver(new EmptyXMLResolver()); Document doc = documentBuilder.parse(input); Element element = doc.getDocumentElement(); return PLIST.parse(element); } catch (ParserConfigurationException e) { throw new XmlParseException("Error reading input", e); } catch (SAXException e) { throw new XmlParseException("Error reading input", e); } catch (IOException e) { throw new XmlParseException("Error reading input", e); } } /** * Create a nested {@code map} from a plist xml file using * the default mapping. * * @param file * the File containing the the plist xml. * @return the resulting map as read from the plist data. * @throws XmlParseException * if the plist could not be properly parsed. * @throws IOException * if there was an issue reading the plist file. */ public static Dict load(File file) throws XmlParseException, IOException { FileInputStream byteStream = new FileInputStream(file); try { InputSource input = new InputSource(byteStream); return parse(input); } finally { silentlyClose(byteStream); } } /** * Create a plist handler. */ PListParser() { this.m_dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); this.m_dateFormat.setTimeZone(TimeZone.getTimeZone("Z")); this.m_simpleTypes = new HashMap, ElementType>(); this.m_simpleTypes.put(Integer.class, ElementType.INTEGER); this.m_simpleTypes.put(Byte.class, ElementType.INTEGER); this.m_simpleTypes.put(Short.class, ElementType.INTEGER); this.m_simpleTypes.put(Short.class, ElementType.INTEGER); this.m_simpleTypes.put(Long.class, ElementType.INTEGER); this.m_simpleTypes.put(String.class, ElementType.STRING); this.m_simpleTypes.put(Float.class, ElementType.REAL); this.m_simpleTypes.put(Double.class, ElementType.REAL); this.m_simpleTypes.put(byte[].class, ElementType.DATA); this.m_simpleTypes.put(Boolean.class, ElementType.TRUE); this.m_simpleTypes.put(Date.class, ElementType.DATE); } /** * Parses a plist top element into a map dictionary containing all the data * in the plist. * * @param element * the top plist element. * @return the resulting data tree structure. * @throws XmlParseException * if there was any error parsing the xml. */ Dict parse(Element element) throws XmlParseException { if (!"plist".equalsIgnoreCase(element.getNodeName())) { throw new XmlParseException("Expected plist top element, was: " + element.getNodeName()); } Node n = element.getFirstChild(); while (n != null && !n.getNodeName().equals("dict")) { n = n.getNextSibling(); } Dict result = (Dict) parseElement(n); return result; } /** * Parses a (non-top) xml element. * * @param element * the element to parse. * @return the resulting object. * @throws XmlParseException * if there was some error in the xml. */ private Object parseElement(Node element) throws XmlParseException { try { return parseElementRaw(element); } catch (Exception e) { throw new XmlParseException("Failed to parse: " + element.getNodeName(), e); } } /** * Parses a (non-top) xml element. * * @param element * the element to parse. * @return the resulting object. * @throws ParseException * if there was some error parsing the xml. */ private Object parseElementRaw(Node element) throws ParseException { ElementType type = ElementType.valueOf(element.getNodeName().toUpperCase()); switch (type) { case INTEGER: return parseInt(getValue(element)); case REAL: return Double.valueOf(getValue(element)); case STRING: return getValue(element); case DATE: return this.m_dateFormat.parse(getValue(element)); case DATA: return base64decode(getValue(element)); case ARRAY: return parseArray(element.getChildNodes()); case TRUE: return Boolean.TRUE; case FALSE: return Boolean.FALSE; case DICT: return parseDict(element.getChildNodes()); default: throw new RuntimeException("Unexpected type: " + element.getNodeName()); } } /************************************************************************* * Parses a string value from a node. * * @param n * the node to extract the value from. * @return the content of the node ************************************************************************/ private String getValue(Node n) { StringBuilder sb = new StringBuilder(); Node c = n.getFirstChild(); while (c != null) { if (c.getNodeType() == Node.TEXT_NODE) { sb.append(c.getNodeValue()); } c = c.getNextSibling(); } return sb.toString(); } /** * Parses a string into a Long or Integer depending on size. * * @param value * the value as a string. * @return the long value of this string is the value doesn't fit in an * integer, otherwise the int value of the string. */ private Number parseInt(String value) { Long l = Long.valueOf(value); if (l.intValue() == l) { return l.intValue(); } return l; } /** * Parse a list of xml elements as a plist dict. * * @param elements * the elements to parse. * @return the dict deserialized as a map. * @throws ParseException * if there are any problems deserializing the map. */ private Dict parseDict(NodeList elements) throws ParseException { Dict dict = new Dict(); for (int i = 0; i < elements.getLength(); i++) { Node key = elements.item(i); if (key.getNodeType() != Node.ELEMENT_NODE) { continue; } if (!"key".equals(key.getNodeName())) { throw new ParseException("Expected key but was " + key.getNodeName(), -1); } i++; Node value = elements.item(i); while (value.getNodeType() != Node.ELEMENT_NODE) { i++; value = elements.item(i); } Object o = parseElementRaw(value); String dictName = getValue(key); dict.children.put(dictName, o); } return dict; } /** * Parse a list of xml elements as a plist array. * * @param elements * the elements to parse. * @return the array deserialized as a list. * @throws ParseException * if there are any problems deserializing the list. */ private List parseArray(NodeList elements) throws ParseException { ArrayList list = new ArrayList(); for (int i = 0; i < elements.getLength(); i++) { Node o = elements.item(i); if (o.getNodeType() != Node.ELEMENT_NODE) { continue; } list.add(parseElementRaw(o)); } return list; } /** * Encode an array of bytes to a string using base64 encoding. * * @param bytes * the bytes to convert. * @return the base64 representation of the bytes. */ static String base64encode(byte[] bytes) { StringBuilder builder = new StringBuilder(((bytes.length + 2) / 3) * 4); for (int i = 0; i < bytes.length; i += 3) { byte b0 = bytes[i]; byte b1 = i < bytes.length - 1 ? bytes[i + 1] : 0; byte b2 = i < bytes.length - 2 ? bytes[i + 2] : 0; builder.append(BASE64_CHARS[(b0 & 0xFF) >> 2]); builder.append(BASE64_CHARS[((b0 & 0x03) << 4) | ((b1 & 0xF0) >> 4)]); builder.append(i < bytes.length - 1 ? BASE64_CHARS[((b1 & 0x0F) << 2) | ((b2 & 0xC0) >> 6)] : "="); builder.append(i < bytes.length - 2 ? BASE64_CHARS[b2 & 0x3F] : "="); } return builder.toString(); } /** * Converts a string to a byte array assuming the string uses * base64-encoding. * * @param base64 * the string to convert. * @return the resulting byte array. */ static byte[] base64decode(String base64) { base64 = base64.trim(); int endTrim = base64.endsWith("==") ? 2 : base64.endsWith("=") ? 1 : 0; int length = (base64.length() / 4) * 3 - endTrim; base64 = base64.replace('=', 'A'); byte[] result = new byte[length]; int stringLength = base64.length(); int index = 0; for (int i = 0; i < stringLength; i += 4) { int i0 = BASE64_STRING.indexOf(base64.charAt(i)); int i1 = BASE64_STRING.indexOf(base64.charAt(i + 1)); int i2 = BASE64_STRING.indexOf(base64.charAt(i + 2)); int i3 = BASE64_STRING.indexOf(base64.charAt(i + 3)); byte b0 = (byte) ((i0 << 2) | (i1 >> 4)); byte b1 = (byte) ((i1 << 4) | (i2 >> 2)); byte b2 = (byte) ((i2 << 6) | i3); result[index++] = b0; if (index < length) { result[index++] = b1; if (index < length) { result[index++] = b2; } } } return result; } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/util/PlatformUtil.java000066400000000000000000000112741302662252000332770ustar00rootroot00000000000000package com.github.markusbernhardt.proxy.util; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; /***************************************************************************** * Defines some helper methods to find the correct platform. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class PlatformUtil { public static final String OVERRIDE_HOME_DIR = "com.btr.proxy.user.home"; public enum Platform { WIN, LINUX, MAC_OS, SOLARIS, OTHER } public enum Desktop { WIN, KDE, GNOME, MAC_OS, OTHER } public enum Browser { IE, FIREFOX } /************************************************************************* * Gets the platform we are currently running on. * * @return a platform code. ************************************************************************/ public static Platform getCurrentPlattform() { String osName = System.getProperty("os.name"); Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detecting platform. Name is: {0}", osName); if (osName.toLowerCase().contains("windows")) { Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected Windows platform: {0}", osName); return Platform.WIN; } if (osName.toLowerCase().contains("linux")) { Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected Linux platform: {0}", osName); return Platform.LINUX; } if (osName.startsWith("Mac OS")) { Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected Mac OS platform: {0}", osName); return Platform.MAC_OS; } if (osName.startsWith("SunOS")) { Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected Solaris platform: {0}", osName); return Platform.SOLARIS; } return Platform.OTHER; } /************************************************************************* * Gets the ID for the platform default browser. * * @return a browser ID, null if no supported browser was detected. ************************************************************************/ public static Browser getDefaultBrowser() { // Use better logic to detect default browser? if (getCurrentPlattform() == Platform.WIN) { Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected Browser is InternetExplorer"); return Browser.IE; } else { Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected Browser Firefox. Fallback?"); return Browser.FIREFOX; } } /************************************************************************* * Gets the desktop that we are running on. * * @return the desktop identifier. ************************************************************************/ public static Desktop getCurrentDesktop() { Platform platf = getCurrentPlattform(); if (platf == Platform.WIN) { Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected Windows desktop"); return Desktop.WIN; } if (platf == Platform.MAC_OS) { Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected Mac OS desktop"); return Desktop.MAC_OS; } if (platf == Platform.LINUX || platf == Platform.SOLARIS || platf == Platform.OTHER) { if (isKDE()) { Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected KDE desktop"); return Desktop.KDE; } if (isGnome()) { Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected Gnome desktop"); return Desktop.GNOME; } } Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected Unknown desktop"); return Desktop.OTHER; } /************************************************************************* * Checks if we are currently running under Gnome desktop. * * @return true if it is a Gnome else false. ************************************************************************/ private static boolean isGnome() { return System.getenv("GNOME_DESKTOP_SESSION_ID") != null; } /************************************************************************* * Checks if we are currently running under KDE desktop. * * @return true if it is a KDE else false. ************************************************************************/ private static boolean isKDE() { return System.getenv("KDE_SESSION_VERSION") != null; } /************************************************************************* * Gets the user home directory where normally all the settings are stored. * * @return the path to the home directory. ************************************************************************/ public static String getUserHomeDir() { String result = System.getProperty("user.home"); String override = System.getProperty(OVERRIDE_HOME_DIR); if (override != null && override.trim().length() > 0) { result = override; } return result; } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/util/ProxyException.java000066400000000000000000000031731302662252000336540ustar00rootroot00000000000000package com.github.markusbernhardt.proxy.util; /***************************************************************************** * Indicates an exception in the proxy framework. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class ProxyException extends Exception { private static final long serialVersionUID = 1L; /************************************************************************* * Constructor ************************************************************************/ public ProxyException() { super(); } /************************************************************************* * Constructor * * @param message * the error message * @param cause * the causing exception for chaining exceptions. ************************************************************************/ public ProxyException(String message, Throwable cause) { super(message, cause); } /************************************************************************* * Constructor * * @param message * the error message ************************************************************************/ public ProxyException(String message) { super(message); } /************************************************************************* * Constructor * * @param cause * the causing exception for chaining exceptions. ************************************************************************/ public ProxyException(Throwable cause) { super(cause); } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/util/ProxyUtil.java000066400000000000000000000075331302662252000326370ustar00rootroot00000000000000package com.github.markusbernhardt.proxy.util; import java.net.MalformedURLException; import java.net.Proxy; import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.List; import com.github.markusbernhardt.proxy.selector.fixed.FixedProxySelector; import com.github.markusbernhardt.proxy.selector.pac.PacProxySelector; import com.github.markusbernhardt.proxy.selector.pac.PacScriptSource; import com.github.markusbernhardt.proxy.selector.pac.UrlPacScriptSource; /***************************************************************************** * Small helper class for some common utility methods. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class ProxyUtil { public static final int DEFAULT_PROXY_PORT = 80; private static List noProxyList; /************************************************************************* * Parse host and port out of a proxy variable. * * @param proxyVar * the proxy string. example: http://192.168.10.9:8080/ * @return a FixedProxySelector using this settings, null on parse error. ************************************************************************/ public static FixedProxySelector parseProxySettings(String proxyVar) { if (proxyVar == null || proxyVar.trim().length() == 0) { return null; } try { // Protocol missing then assume http and provide it if (proxyVar.indexOf(":/") == -1) { proxyVar = "http://" + proxyVar; } URL url = new URL(proxyVar); String host = cleanIPv6(url.getHost()); int port = url.getPort(); if (port == -1) { port = DEFAULT_PROXY_PORT; } return new FixedProxySelector(host.trim(), port); } catch (MalformedURLException e) { Logger.log(ProxyUtil.class, Logger.LogLevel.WARNING, "Cannot parse Proxy Settings {0}", proxyVar); return null; } } /************************************************************************* * Gets an unmodifiable proxy list that will have as it's only entry an * DIRECT proxy. * * @return a list with a DIRECT proxy in it. ************************************************************************/ public static synchronized List noProxyList() { if (noProxyList == null) { ArrayList list = new ArrayList(1); list.add(Proxy.NO_PROXY); noProxyList = Collections.unmodifiableList(list); } return noProxyList; } /************************************************************************* * Build a PAC proxy selector for the given URL. * * @param url * to fetch the PAC script from. * @return a PacProxySelector or null if it is not possible to build a * working selector. ************************************************************************/ public static PacProxySelector buildPacSelectorForUrl(String url) { PacProxySelector result = null; PacScriptSource pacSource = new UrlPacScriptSource(url); if (pacSource.isScriptValid()) { result = new PacProxySelector(pacSource); } return result; } /************************************************************************* * This method can be used to cleanup an IPv6 address. It will remove the * surrounding square brackets if found. e.g. [2001:4860:0:2001::68] will be * returned as 2001:4860:0:2001::68 * * @param hostOrIP * to cleanup * @return the raw host or IP without any IPv6 brackets. ************************************************************************/ public static String cleanIPv6(String hostOrIP) { if (hostOrIP == null) { return null; } hostOrIP = hostOrIP.trim(); if (hostOrIP.startsWith("[")) { hostOrIP = hostOrIP.substring(1); } if (hostOrIP.endsWith("]")) { hostOrIP = hostOrIP.substring(0, hostOrIP.length() - 1); } return hostOrIP; } } proxy-vole-proxy-vole-1.0.3/src/main/java/com/github/markusbernhardt/proxy/util/UriFilter.java000066400000000000000000000013461302662252000325610ustar00rootroot00000000000000package com.github.markusbernhardt.proxy.util; import java.net.URI; /***************************************************************************** * Interface for an URI filter. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public interface UriFilter { /************************************************************************* * Tests an URI against a given matching criteria. * * @param uri * the URI to test. * @return true if it matches the criteria else false. ************************************************************************/ public abstract boolean accept(URI uri); } proxy-vole-proxy-vole-1.0.3/src/main/resources/000077500000000000000000000000001302662252000215045ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/main/resources/LICENSE.md000066400000000000000000000243761302662252000231240ustar00rootroot00000000000000Apache License ============== _Version 2.0, January 2004_ _<>_ ### Terms and Conditions for use, reproduction, and distribution #### 1. Definitions “License” shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. “Licensor” shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. “Legal Entity” shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, “control” means **(i)** the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the outstanding shares, or **(iii)** beneficial ownership of such entity. “You” (or “Your”) shall mean an individual or Legal Entity exercising permissions granted by this License. “Source” form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. “Object” form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. “Work” shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). “Derivative Works” shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. “Contribution” shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, “submitted” means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as “Not a Contribution.” “Contributor” shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. #### 2. Grant of Copyright License Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. #### 3. Grant of Patent License Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. #### 4. Redistribution You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: * **(a)** You must give any other recipients of the Work or Derivative Works a copy of this License; and * **(b)** You must cause any modified files to carry prominent notices stating that You changed the files; and * **(c)** You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and * **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. #### 5. Submission of Contributions Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. #### 6. Trademarks This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. #### 7. Disclaimer of Warranty Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. #### 8. Limitation of Liability In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. #### 9. Accepting Warranty or Additional Liability While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. _END OF TERMS AND CONDITIONS_ ### APPENDIX: How to apply the Apache License to your work To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets `[]` replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same “printed page” as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. proxy-vole-proxy-vole-1.0.3/src/main/resources/NOTICE.md000066400000000000000000000040731302662252000230130ustar00rootroot00000000000000##Copyright 2016 Markus Bernhardt Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ##Copyright 2009 Bernd Rosstauscher All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY BERND ROSSTAUSCHER ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BERND ROSSTAUSCHER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. proxy-vole-proxy-vole-1.0.3/src/site/000077500000000000000000000000001302662252000175125ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/site/screenshots/000077500000000000000000000000001302662252000220525ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/site/screenshots/proxy-vole-tester.png000066400000000000000000001214261302662252000262160ustar00rootroot00000000000000PNG  IHDRT[bsRGBgAMA a pHYsodIDATx^ E% *KbX(fq00:*Ψ nQ%PD\`83QDYm$3T`L¢BHK =}y}|^SUݷt?[M6}$+GJNJn1Q2z*r ?q:P:qS'rELk*Ӯ#(yQ?\yj?Ke qQ^&ep--?;xJc:=>A$+5K\֭|wTd^"gd&R'aj ^2! m#:$ a/*j5w G$Xήȷ;gZBU"M _&X{!Ce1HJu0arfEx F/f_5XD3"eנYc7ft%H,~FÆ=u࿜%5PR:vi=Gw,W-,,ѻ/#hIRNIS8㱕8m{[xާp G¯7|Tij0r* ^;Sg?אbz2] ?14'jT*ev:bTc -)B;c{IU $Z[šb`5PZReARSyk) kU{+^t@%),AsK;/9I0k?K:ӮO:,Z( {[i&4MvKOOwo7ٳnX%ݞG_KWT޾s.;{g7F )X8(`}g߱c;h*Jr.jřut9*`H;13i644"M}Erz1a3Jz\v`Zh~qeCB6f^D]|Xr,!R9-s?Ŋ|lTlVIN\X #[~B,sIQSajPge4HBKTDJӘBdb#غJ{/qWtmr;dJM. T"䖔8#gE%R<qhKS]a֋5C{z9O+= OxAh%E$j5tRFIo/W$ټuV{W9s߲}OF#$-hxX;r#ߝ 4zQ;ȉ#$H")ƉĭHZnCX"Fo>W =-jKR> fQS3U_]mPuT(fPr[{,7?&;6;jVnoko/c)Ä\ON"r4̔iQxVD!2qcqțuqDe40ȑ G5?".Yf f?逵?̕ bL)%D,+emP.+m}&Ȳ?Wk5RAh`9 )cTOC5]k0el!??Obd܆ʪeg*-Z+^s8 $kKBtj]lri& )[*?L/T  #dYFv*J\Qud% Pp+ wDӕ>Eqh"WҢ.o]hIJI Bk/јޓz42Cތ#<%S/8wzBlnW9QMin~}O<I~|kqs(4S:yG/CXQ !`\so'yr /u-'O=Cpߺ xo{`C~7{d~MOo{V!u'Y؁Pũ1 󴣣S:ڹ@P{ĺ"`|#]؋wfvHL ~%*g9bg8P8v_L0T\%FԮK{p^?Ԯ&ZtZN4 @_?: N"Nz4:U D9HL1OPJ3 L'.Q2TGDza@QI%iBTlPTW'jiJY 樗)$wj$ؗ]7 # 8q@*h%VR ~)$4*JKeYfG L Aʢ[R PW\2UATp!ŕҧɤb%SAZM<<^dK3R"D+$Hį8rqJb .,>N5UY>>tϳO3*LﶧE#SK}ņG/$/ܸWO{\g_o%G<}}}8ՍG[^t!<,ͣX jcݫ_!,QdKxSUh4nœn)5d+@v!>:TI.c?q+zeU†'TI9C k ,71c<0dt^[u2Ja%#AJŌK#VFB(=tc"' l9&v(KM4'$dE(dI$6kƐ!9Sҹ(T PՄQ%,G8:Ny+ꬉѭRG"ActIJQJA+Uj܉ºS,?dڽ,HH2ACKH^!OXYz|HM3u@)&NViJLLAͼԄʡNpoG[ '^Gυ7^@rj,{q^-OowXsQ{z~뾼c[,>qڞ`A~ѧ.UI`'/Yo>M#xV\p#h[Jd@|wOϦ)eOy{M-R/hvpC^/+'4~qfr^%9x!GA\#xg|^&M5,G~ D@s#9aGlȘ +a,rY\xOƈu^. Iʢ3~&L:]H.Gzz/ZgJI$TuZ1)kYI4:ޔw5yWE!6)6& eQR)Fe`Sb6^ġu ;fұ ү2iOu{Itw`.<:۱F3mY`af1jOi%wB,%`LMF5_;Av(++ɚh}9 G?&wbw$,`L׻d7Df"-jBJ`ˍTy7 j;>m=^n5Rdzev`Z V8#b^,9B&>X\95 E.?̐8IRnğu^yYBh(6GH꭮]r=]xk.UA‡$~B_C$!8>y%X.u,^$X;MAřϯ/ƍ_2 l߷EΨTJ.Δy/\5H4GB)㵼ITOt Bj'.W A#etr'KfD;F\uDbCJ[Kw-d'Jԓm&ڃ%ϦUiHz|FR?=A]/~RÕ9w^/Un|0Ej6o<n}9+!e'/vvQs=g_cY߮znϺaTDCdsnh":9?y?̪{E \WٲHP(m2a'7ă$`*P+^{ ZJ8bO>dϿ}Vrw=A݀)frI: tT,n=2)SsS !;!cyj evV5:) >8loM\8"5 :ʥ1,Ѱ.ut;:0BcE,QӅ8DfRg2 zd,q$$0<1\O!".Sv.b$ICֺq-aCCT-rQ)%!!~I.tI("HF0f̜&KckqS⠄2u^mQBA%<@dG*j L.@VSCUd'ЕfPeq!LVnbJ!"4GV tAN Dw?9߹i|: "hkVZ./J=| ^ ,_,nxѨ?NY܈j`>ً4 7$WL1qrloǛz xFS~uxϮ "SO?zPn|Ù}]yթ$ ̍KJm^[Ϳ֗쯺!!ai]%YҬ3BiEʂd-$Z 4CjrC%v3s^qȥz#쐗6Dc|Rކ>] P+Hc uv#1sAq_, ̭ŭgzw2a:'V`3"Jh?Y5gG?۟bƴ"!-Dc eM7S1& V";&P"hL$v%QU;닅[XwZ;Ťђʼ+MjhEBBЀ&/X 6 Xf4߉, 6*o̲.M0zy"$$ĬYCx!Vކ@t51av+ 8i4sLA🪱0HE";ap&#x"uq)blܐ+?^<֓Y,< +QEBʫv;|t: -Twɹd+E!tΝ;նJ]2ikN(~upR<)ݝpµm_٧J\{c8k[vW ~ysO>:'{&t3^}q>~wgx 8ݏ#s,E\~0νQV<mC<c,W^00.Mp(Iry3 rۏoM>jqswȲݏ׼74vg+NBddada&O\B,*g8`a!rUH(UVN † JCݒ k\h[_Ҫ2-[A jR Z$)lkK[@ϭ<]C"*CD.&h?Q;ԃps '.j]<ςWRC4+Jr@W&W[%89eI*Aw;d=4mʤIɥIS))8&M$,wuSǯYykBddY`L-ҹ[yn)X TmRfWyv<3.o/Y wWOqL{۷wͷ=r>p_x8_O~P@RIWַi'kߟwÿ=omn飫MM%vϯ#^lչ/>|oaԋ,_~ɏ߃8^|OT6S{{仿K//WD%WM Tx"'58/=؊XTBN_H<\g`a3ӗ0 %0NLE\Y^h 92C)P^ۇ踎el.wV #FmJUx D>K ǙKAa(f'*B«K8(pDJtVC$]SW!*T?.NSGx pg~8| D?I.w5wT̶oW=K+< t7|䒋wcmODZMyS#3VOfom۶ :'w מ?{ߥǝwQ\sg`s_ϴ$9 z&7&Wݪv:[𾈰DaaWTw󇿲j%"y[Swз~GgzMJrϹkR_ӡ/Ŀ䧽9!-ABIwJ>>͵p)|?ܣůڿ?Fw3kdϛ G`%FALvr{2.;BW=qK\k|O[vn;v(\U 3vG_no ѹj/7|pm!FO',8J!5q+/)?{Ew|ƁXTťv/ݿ~ HĭUW-O="<=i_z$Z~硭pxW9U_C_~Y/*xK:iryߗI:"CZ?Anc E\)L"h1K%/G}$V%>F/TW jJ[] >N suhr;.|\k%2GHci̬P*cϽzv6ϙ|>vÇpz:{9S2t_˫yYן?sΛe{Yk|y_Uqྟ=??>6~5}M|_y(?wK;yy$rӇb:?~;[oe'O%2jՖ7?w[z#MZŷ }rO䞿[ak"gRī$˻^vW?}:4&0- 86}˼s)$-J ',2Ѥsu_?~d>v>w޿E!^zLa5\;v&.]BqZwO7*#ků%m*m'YkU^$St`c'~) '2\ZmTѾd\BJ"$j6HI]=}_>遃HD bةѸET- 4zb8%nPb)ɑ"pZkyX P :ԥӑ EUՒ} LFE8k"$Gv3ld,;JCB %;X2 |5v,V^DwP?frvdr*&.o`"e`u'Z?c?Ibo6vf#J8s#4j s6#9:AP@!4m0G;{]a+L3ry+4&* +{AЙMFP+I\BuδicfB/bs{eJn'zEG0H˻hTu) V3X9Ghߗc5L\9>_Ls TE #?Ƣ!`Z)Oe̢ʖrTP\KSI*q!*5 Q%bvX) +B,k{iS5) 2_#G136+MDzRZ2H \*&P#LdH( gK~ Q (Jtd/Ww3fC)UBP_S<9[%7pmtHJ4&T5jEq8w nHpfybKӴRL Aqnjth=ĭ @2mH/ xAKي#QZƇ6ͣ)8q}@$#ޟݹGQaSO~լYgD,?)Uz qWJYfG=0d?4)Rְ t~"z@GHR YTbYR `* K=d"NV^=9dyB7B~ػ#aA"f#̘ITGg/_I6aT*`W =`*ϠqdqI(hca4Z5~'oTg++#;I*:p0+ "WK5;H92㗐df|`.xT&zvn߹z{YF2b\3KapIL[Ʊ0unFq̷Z@SAHh UrTo!\9#Eč]ܯ^).ss NGѭƹQB䎪iy*]϶8i&\]LG::sx,FUJeR@IWiJ7·)Mxmn; v&Uv,,k$hcl߯98``\c^C43;@Jq!rG2MJL@70~ @1O"bY@v2ӂv1'y,eQ$Ek2j %!2Re,WhiqS" Ҷ'6 rpxOYiVR& ƥ~-ϊ1 ̑ob' 3ə#PU3Gh,1;ngUؾ?4dJJ SnP&RwF" v1^ tmΕZh!o?G 򆁡Gt2έXɗhmRW [rw`FI=^U.^,[]I#"r@IWʱf x\5:CLpdmLsXA\ӈ Ă_W-mo964> ģٱ D8]k)XY~Mi2\桿 *X)Q_ e7̀ =eCtq!_f"o*ڄev2:ud-bA.F:ԕղ>bmgZ'5hmXacqDK#)RXqHt_^JnXCc/d"ɳU`; ^FbĒA-k5=F;0B0akFw-5L@Es [ ʜc$rVVi((E8RU6] QH5A .g' pw"ěSK &P&GVqQ|Gf d$qprPΌ0W42@Q>i44D,BcWKI&z⬫IE9$*ڦD2QWQ}/h8IF iߤ[RzNT; Mn"epqy]RqQ=(0q!K0ksE l&#/%#ez)&V Nu*6QC;|QӀhEO_̭4+JD˲~Q-+n_žQX?"CbPWP(G>G(f#I\ifEQf"i 6ɟpÃPS00L.$9c@ /׼" M׊(^$m%Qy%6?xO -۹|F}=JEԅB9 pS䚬6 P32@QW`HcƤRrB(|qڡ;9qȿ?A< n;7ĞI_l8,*"#OHN PȺ{TPrRB8##NHrdtda?+L^^\txO^ w .YIbˎɥ AK桝_|yTlXu0Z`͓e !K`$._hr'%l<"uTr'[d@B!iGzvF1 O樦84Ztq[7Y;^Dv6Y1 "r2wDzE\%ŏ-aCjV}NxDB_TB}E4 Z';$5ik3eLcT!t[H>san^.o-BYAZ>08E W$F :KWǣЫ* W@hX`µ\YDJ [S(ڈΟ(2I T~RNb%kI#݋<7yBĞE#I(Ss% [-:$h\K閸nҦ>;SOsYft;'6ňKB%MRDpI'JɬA61Z(x?zR'Iӈ 4d:BTi.b6iL*Y℄)@O(:auAwR4, 0ypzbAS\RϐS2 mlsd[S5/waZD_ǝ;w:2iҤ:]z۞:k tx>{}u ͛oFg8a/7՞D_ݦL;=msu+.}ϙ95~vs0o}DuG 0 cHyb˖1R"| 8v<-t%ʭg^pw8S5XOat(xDzoNy985HwXB2$5 4:>>d 뇱d9+ffFhniP$;S^9w"tS߰x֬+ ^vd7G=|]3DӧNzF؈Ϙ`ӬM[0cdYhH~Z)Z=R$D\Yߵ*{vz*sjբY&$`3 qcٓM?{w?pƍ_~S$<ӑs?SߦM+ +b\? xgTp{Oԇ^CQy7ݺA@>񑔎~O O>wtLvn{əm_~TO? nYgg$.SO}ݟ'5ݻkڪ[X\pm1 w\0S3Λ/~k;f->Oc,oΙsO{~dScFTܸnƙM_ kaӧ5)ό eV"3f-[$ɲ9`+aKӛGvQZpilXӍ̎ϨWk& ^fͯy C7>)\r3d7Fإ{g/y͇0{mk\JkАC9A4RoK:y*+׽[7(rNz1{/~MVJP} _i<􁯽?cֿC'41H詖׵7,#8v㓾%;]0?lNx6w~}iñN>c%uC_qچyPw`,#*/ t{.}9B-_{\ٴet?ze  y\~$*{ィ)Pq3Z^9iӾJB S_4wiּ{Orz2鈻L?uz\v hV2g(`#8b~8?l9 56/j^iřa^ӈo! .+~9'?9K ?O]}􈡛g2G~Ç"j\rBsÃ:kI\+y/ +A6/K5XeH#ag3~w!I^zUmZϘµXcۋ}rb ]]]{M0z˗r16a }CC=Dʡs]s5'3O_J''?o=7Wcs.ԞD^{I^ܹܖɽ=d`>& 0 _“O>9F{?8QJ-{# 3 0EiSs/GaƸĿ?38m5 0&.2SS0 0ZsDTJ0y4{63 02Ӂ_<'0 0ZZ7BG|mh=+^~ev90 hY6vч_kl0 h9]yGjPnyMOa%zE?0 02ː?׆a1~Pʲ0"aa/*y.s۳?0 03|7} 0 ua>[5~aT Q}a8ru+Uy#?C1t Kf f Ij)q@*taбdUykR íР) ءV_yA_e]x:1}a_F.JgT*+&sW#0gtgiX9c?t,_VXN8NOD»O[©o0"[}ľf}Ti}gnM1Tz!+%.vztApޏsp袭&t3?oz 䍣UL9oqni9si OG=ⓓט 1YzGZ;-f/{KfxģN,XtH8-r4y!, "W:ㄹ |*YcCӥEmǺE\BrYn-v(h=PsSXOr[~oQULT ^_, Hn?*'wjO?׀Hq_"7U>p@#'c 3T=޷nSo<ֻ޿y/1% MqY[9w\!RR(_=Px #I  j!U UUĥC!N!b,/Q*+WBy)zݯ1Wՠ:]NPnyS\=E퐦k⩭Q:*Q=sg-?؇JNQ̗j2DTUX/dsJ"{qhV#ĩWW,4B` <۷^,e{O? 3~?9!sDQSg]'ARwuʡ5(,R-KG≈ԦCO)ūDJ' eJ0v( Ba-.vn;WKz_ά"&FiA{U6 hj`P6Zu4MC/HEw%9T ԯoC1'탍S3_lRRа>nϭzUa̾jŲďOs3=Y~1gpTo\3QszcWeerޱ)תyӖw0F4M;p;3$j!fM?ƹvQQH{.Y\4˦omgl2/D/=ݲ^"z7uEK1sorC㠟88Ex]s̔3P%ϔ:C#}R\݁:+IZJp`tkú\a9R]CSSi(vh*(ZV ]^5[ߴ|ƙuDq GaҮWZ5oyyZBWɫ1<2 =xFomմÇ[ f:&"ɵyI]:9=D6QZ4YSUz+#F"@0 Υ[Ң+Xg.uʙn)(g]UƪrԫWT7M[z+nseX<5ۭp֫^y SuȶC&InPU9$Eby&ґ8?1t۞Ѵmf&ŝ?|79 7ckHk$jռγ=b4wgmyI{g۞W`1DxUz.;kfADp2dSa LyAB~) ;Akf^_wNV9FN_f 0 B*۟*2 0*X0>{ga d\GY?0 c?S7Dƀ63 0Z*k]U8)aa:Љ s'$aa0bq2?>۞RX>~p'kP4 :#9ײɢ)ZbH(Ckau-ô}QC*_Q4RSu G+ƀQH(ORM`l~aoek B?;p_=T׮4 j> WΝ,緘YA9F'ônDRXUA+#@!? AĶÝT']X3~>}3X.+0\KsG5 w}&wQ \pbf f - W|Ju͞-[ W9?HDmGM*]lL W̞'\ *[fMa }}0kX[?iԵXE&Yr΂x"7X?'ڸ.)K>X=01u .l9cqOwSO8igoxlzGyk3gâl0EkSswATբ*46{څ3V =QH8UPVQHeSՅ^n|dܫUhY?-%m@<3{@ -)C5NjC Ou{pۺmw|߯ycOr_tiGLc 0>B3kam]ywɿr̴gIe,eޓMc3#pϬm*`Jlmp#wyH`K@50 cCW+Fk /.?aF ˧79OnHaa4)Mn{¥#? 0 ő.I[)l c ekaMSIxN>oMgag8o3Pz ?u`[?6}艪Iɝd/gr/->ӷDcE Rћq^E0FX|?tY6{9cS8v!<78f csFy} `LDgQtpzL顚im9 [ 36t?u\/ff7Z5no钑gupl&*=a 5n5ih=xR|6;)&nOQqΡh.I\R0!{܏o';j`~spIyn +6aʢ+Grvcnt=E'7{G}IYl۩?0ad8oklw6'S==3ʦm}=lgwQ>~aDr2 cbnyKo?xK/#CaJ/B䧬at-߂Qha-M_i0R僅+:84 0ևV>\F~b(䚳93 0jdGGC'FFO\TdaؿJ>YCwoLa1лjS46a5|zPdCoGMZtWi?ݡThV2pVtmπgoOl*C6{.uF^gϐf\9wVzf`~ cr4~O^WjݎI9\C>LAM|-SЮ5EQ \pbч}J"/i`x6qztͲ1 .b?o(5l& wsQ_u- !$y3w}u.{͐X2'Qjꥭ\o-"w?ؚҫ cQWb8}ÿB”8+<}׸93w#$}37͜GzPLfz!Qf~7]xÓFPM_Oh8C Y>RZ=& Cz U 'D#& cq3~+lɽ^ 0^ģ %7wmϻ]O[=JG\dTǿpʅ_l3M6,}@ӟ a`ѕW^|ѯy=JWhϓO9U$޾,6i˻|%!0 áoSǩzvvׇŅcy]蝠ca{>T*k?ٻcg=a/@ 7 0GLl];ٱgN,۷g 0C>yWZOizi#?0 c\̧ng~ /a8B?>ybQaƸ@u²u"ne 0 c@3;?ڹR^no/wutS*iaaKKm:'M4mr[[=5~\`ğ~0: u{&H;mߐ}Ua|Gǚ/!7~쯪iHa ;v~ <yS&wLܱۤ)`bg}6{ VLɝ>cy0F5v ,_۔\vkm p鉪Iɝd/å<^'l3[|oƊ.-li+G7㼊bI63a y0z\+*+w`,yfrr7gLz g.gF'܌63a8r'J_ϺpT8KJζvNy԰ S_, NOɽ"=T7v:-gakᙾ[yZ؆F ASr=iJ0ve :m{Vg37P3}Omfv+f L_O?ͮƯ~#7;לg "l&w^ 8ozLmy0F ~~ pғn7}{w?ܺg~ɲ)_[/GSz0O [giy>"tԯos(Kff7b`oo}>;4k?@~袋N8pVly0EW^}}Oޱ,8ySO[ Wamq0; ѷ=F@0! #aZ7I,Ϳ=0 c@Wjk+34{>0 h9h|ԇa?8ʫ6~2;aF#Od@h0 h}xNvFa%d\ja Ԭa-c;EC1΋aa2j9RE힬0 0Za㬟xh𼑓0Es䓀Q@S(itLH;mߐ}Ua|]Wvpu5 c" ?D#?HY@$̦>h3b37.;S:wt0ZkMGxj}xj`;Pɝd)aN0Hit/v^#3 QK&zke%qti=3MX3˷ӯ :[,oX3lh`e趧 ”Ma^vcH3ɷ`$0wj)a}i㨎 SD޸sl&*=hf ڧ~NlWe`Y0AM_97Ko{" fre3PX_gM?o)-b1Ufroffy0ZxSO7LN-LQz93שo""g1LiQy U4a- ;>xǶ/s.[әOod%Sfr7&6a3]yG6]|Ek~_n%6a{Y6a;I_3 0?jʌa11gaL]O3~a1gaL8aόa1vOxn5|bKH^8 =;" blwih>_AtFYhm&\A3OiЋl3;l&w#grj gZOC;e҂].iSvPRy\y R '_P sS\Πf9-P\N0Z7Kg~6{yBILyzj_Qr ϑι.Ic:0~GRZʋ*ԟ 6?fKq9%dڹa.j”Bk`3֑o8t74pWp9K)V[u um/''|/vn} }a=GG/JtdQ"3*fHf(!/߱ʹac oon{L$Sw%{CK |oތ:} 鍷C~Qda"6{Dނ(~myzj2(ʵZTY@VJ^KRe5٧ɷ0< 0h\^E01߽)]Vl&dÒt^w.i A;1L\r=DSw6{^k=ޡ+liv.!ig0O@^vᝠ赍xv6 cLv/ca3~aƄÌa17=~Ča1ӧV3 07Ɍ3~a'ca7frf<6(r3TE}0&6φF~Õ9RNb)sK<@o U~$JiƄCԁSU_b33] 73kQg#Â0qj&Qj5k'HBq׉Uxv37P|W jrM|x~m&whio׮Co.%chfb 5pڴ] [ գ#cvF"$3a! y/`5YUЎ8(Mzt喓M/dy MLj!{®06zt7friIWXuh6tiM~̺E.zInf`t:g)b3WKΌB!AgL㜥M&S꒣J#YTΩdIhYe3cW-1<ɺy+͘>dU+d&1<IT?rhZf`5dg6`)ϪWgn!9gr_v\ Eٛ.[69#ukgFiR]<{4;@QQg͝K$[kiF4Y3d֑CM~R'~ _/X8.sc5rMi3Q%4 cL3߿y{q'볙܍Ff67 Й/]7T_vSN=u4%0?^q4 :a1}1f 0Xt3 0&f 0 3 090ymgaόa1^{BG3d0V>È/VQg/aY'44 ;/OL LNo ǵA3 7StUe2ao1IQ~1 c0CYLUh( D`)*XOP0T8T3ץv4O->"iQ}̀Ƒ\= jOgTYc:WT>U]{ ;37.dKQ9 - T8aܘɽfgZ//K:hAϨ^f9G։T*\_4; l|{}jlkroռ]煐\gTov?nc?U')1<{5ÐfgZo6vvڐq tȝ2DRK% |ɐ7X/y4 ct۞c}&UW-!,Gӝ,nEU$Ψ0 ]D |lnuLுa(Q ~;aLɽ&X{6, Io f S^<=5wIOZ-B#3y* y,7aU/dPyz)P%[L ,UҠA:4 c$љu;vɽ(jfTf$Z5oFFH0DgrKx_;N>fro«#6:r\/ #+q/C68~1 cO3~/ԫ#cZh2~1 cH0gaL]azy;_J0gaL8mOF.\\0`kG\t٥ܯo{b5밎O9F~aƄÌa1Q3&9(F#"ɓ^RhL5%O9@cHΣA*Fk#/=f{iܫjg*h>-\٢3SG ߱ ZoGƵ"Cq K]"b~fe⿷Vs3Pfr/+[{&7ub<~J0./(~z: #wm(NMɑ8R;F{9vy$E t)OCþzVϕDo }2 GNl|G:/#KT9S|& WүPfri?gӇDJbGu/v<>yu^?]@gf-5{ BzWgh6~ ݌Klp/O~y4 q*{`VGOfI9~ubxDo,Y]UassKot J3Hy%{7a ~!/l3c{ь>Ô":-Osþ|֭妤~?'Tc,W7FvKjΟVYo)>y`G2PϗDO&qwz\zL)?Ys皛~$)G~%8P#˖rY4}}m"}|rX'Uf;lZV۞_v-ɨ򧇶|)eIaL0TwC84_N\VicGnE!3s)p0Eou)Q w9[?oH< #x͚5+IrϻKfs4 0Zws4O==uv@Taax3 KG~i+laC<>kok G}63 0UV,TKIF.0 07<a>saa1PY??G\ԟ2 ?T~wG~x/&3U5R? 9U_zXz oPLϛYwa?~V)a :+~C\>;:+Jd !J—qq*V2TF~!!7KiݚB?a _,%a? cLRg#ۧg>ʛ߃ބG`CgƦV+h0Ue0l:t~qHn;4O.ታ&2,37C^;DMXeIV; @m-g==yFo{)7j䌥+ SUdϓ;6ܴ<:y9g֌8+ht]Tt!$5refֿvP=n eP-:A y\7#Tg.e#3uz ?&%skh>6jcSgn90Z۳K`y]ˣY<<ΫF303r:#%˓^:]r ZN7Wpf6ҁI7.Vؙ3;deZ`2T]Dkobח5Cu|)02g8NbۇU|~ D˛=E'8^v&U+͘^wH2lXֹon9hh:3,9O;UI4\0tCYnkvp}(GجdM|Z1?pZ?l]xcHT]C }Ò٧1?~1ЌL,Y4$ gX&lEK2×|4nt!TA;L̙>k ɐJUj1\;d3Cu|/=1^ijz;w=k{ٮww٧?S~2%'}/ iHUU_E/f/Ӈ.Uՠ0DǫsՋ@Uzb5sҝICcAz$*(JՐ X<OɴO,o?0 c| xI'C>~4}3 0ZIE3hhlga%}gBG{ga+g nT2o{ :aa.bᲰq9z%0 0ZqQVM*o{VپWي|O?~LR__j[U&8ĭ:lDLkVZd?gFk@W*C,e2;]9j"fro_)98Өw:g>-{ɹ2ʓW](΄nX=)dҊ3ѕD?:"D 5-N4X8%(݈$$M>L=ߺbl|Uz4[q;Ty s-DK3+) =E2;gFu0%bҜy To{2-v1Zp&wDg7fFN淃ftߠ_L޺HZʊV`B?pRyތ|urs4UPnhfp4A4|/= ґ}_y31i.F.,"MʼUȍ"3#]P)ݽĽajք9KWӡ͐>gi%- s5C|əq Y:}0Pyۭ .3?Dn]*!]|?V.&'PhjRD4Aay g;-毺WY3zיQ0qX`’$G'[uG²g~GLɭU 'TTG2AH/I/fȷ^yqQO)n"˓iA_iQq ڳތa#``6nzf͚j Iy…e37ɪyםKTf7 ¢+.{݉9s)_>l4/[^, c8/ 1;(F(H 3oA aaj:] 0 QsVeJ= 0 cS:Ysk8A=.\xܑ۞lr.cmb |󁇯|=DI{4da3~aƄg e6,\aΜGtEAjӋݞ'Q@0Hs3ߠ*~rPHsڡH>nV]϶a(1pn~1У?\gCwLiwW)|KX$8u?.b{C31a (7G?)#؞ 2ych ]J@=U*)52n~taMg\4Ι3zXt5vpY[j%?'~agK ]FU >F;i@v"y.ÒoƵ6cE$r37}6a:`2?x`9 a41bh:7zŁZУ е#hN3Ì6w gBCLMΐ^$/b-j\0v;ҁܕ|^.~@tؗa&u ?r/tj"aܪyrζFܔz3}s:f"-"zmތEr.QΜ^Ȯ[w\D0,En|9Ƙ8e1r}4DXG^cW^Üu"#]y"5Tz  Ef0ky4[z631ę7Ag-,m ^X=ݙ9Eh#.>5BCA!3}W0˹aY~* KЯH͛H^HUSfH;sz4fA,Z,6nJS3a>++`"aӗ5~*8 M.οوz]D@/SX PxmVaL1a QqPܸ3!;ٴ3B-y5ޅz,Ũ ׹MKɫ+r͖QtT$e-j9缮U ߢvGzv Y cùsIk߿}ELt…;оi̓EžcY12,uvS%ɬ#:f۞z\*uHP<0Ennhh渨+s#p۞1؛X#+Xas섬tm~&J/K__Oia-L+ko퉰>^B' 0 _/Fwb Uz{z{az *cl cT`6`x +]'C?0"&̟KmE>]&_JI?|M* ɽ)tN;#؞ ?霆a}i\8X =$2O=u@ yl&wL{4Gs'x*+F= c!/Tdd l _Y7y}|tU}fr4()3)|W wҀճ\%lk m< +7Hd0rwO 47͠z 6;)j\0v;ҁnƀp'6N^goT^E-~ /Al&LEnƠȚ5 z ~n[Od`37P)frO5lgc1i:T-MT^#HpLc3La4ỉ̶l8alo_;7?SUq8-063>frm&w0}úw6q*}܋ܱ{귮:._h4Ł>&Ȱʫ#W\7u;Qf|L`1 J0@4|a.e;8` 1%X6xEha-q'fڸtJ`?sᥗN;ia.zÏ]q ['rSOG:tcAF1 0F̛·9 /j2La1΍𰨽/8,5 0V'nVa10gaL8 v0 0|*BB~L_@UjM !U䈓iRg( )8崖4$Mz^tUSe>/x^Kt ڱ* ڕyJ#q| Ư2{]]!ռ9EEnl!.7^FWiqY/#`urw|f`إ|$ha EHM|B+4(%tiZs>I?Փ)hireKK~%U+vˡ?s<4L:RFȠFϸh9]\H>kA9/ {^e'& :g$GƋ.$'BaƏ{%.X yp§#fxg-# M:h&r673{~PTj\"xhg֫97}FnT lgDO~K ;O \ #4y^EmϦc3_U?2W˻߄7m3܍3I8]rklu; gBBcVM{]6ޫL9UmB@;9'0m 3<Ǭ[Z?"k/ 1dyy0כzFWLV,1=BKz%X|`6,\j;dUK%Mb`ccFs'29x<0ʶ[ 0Yoe8,-0'PpM:x*;W5 ^Iwnڏ>OC/ d@^rn9}S܍27p=EbC2s^}gtfaQ$o7IbK̆f3h轟A̞UnEC?mPZlcZgpՃٿL KΩ>j_cyM<1fn}z&,\p٧?Ή(2 B"~a]@*l)(Oneʃ^4S= STё~Yɳ?, TXyIRŋY$d]q͝ DQy!Ζ3-N]aPDۭi Ғǵ2U5bʽL% .BN9)e2Ci.A^q\S]9zH~#UeA[ɾ?]Q+;dדtSߦ4jUf;o0"9'k1Xr8',z#|'2grw*{7; ӗ^_9k5En0myc6>ݏ604&8xGe(o6# w?ڨ?{lC*lbC?{LM"YlbLp\Æ?0 cQ祗N=41… 0FQ90TX-Ϳia3~aƄ p0q)Is chhNLnBV^b9i7SU#xW'~-kcM!|q>Ef8? 7Q=âD0"9hx׺$1ғ8{ԦgGVla%U Ǟm& ˰ʹkfOܝ1J4UoH9q(ڜ~#-b8‡ o4Z\F+IeZy2sxG=m&w/w]zI4*U5.0&HHK2gZ*mA3Ů'T7n1%-nDx%ǁZekUP$%oEl\tRg0Q < 3}Vhә7ՍOB?ȯ +~ZL4MD6t93\<3P779`v2 4KN-n]a9~AӡE6)O_$o>eqt<X3]DXNn4u ^o&al&weƷf%W]ټN}hA+)"rw۪]5B[S"D3> {dgc2L'ޝkQg,VgO;\M=Xl'+n6pCzzvtf o gm&Fgr'~/[a f9ԝi)ԵCDo@#л 3r5@y6aE_-yȑ!3Os0:[SQB‹U[!r< c,?Ónw}SOJ|:6)>5kp+0=K.y±m/vio4FqmO߽sG;ܹ]XFCgK<5q~=\p-2 hS,K__O|f4 0~%^ҡGM_^yl İ|>K.d'3?0 uYtm^rHyL7_T.eldͭ 0 qR(K1uMr 2 0Eoj"rThloĺcmmf 0G{|%v'_{$.&c]nkaFBۇ^mRǤI:'MOa h=1;;;;:;3 0bE)320~X:;:ƧbaJ%zgX}F:a->~?EpV3 0ZZ8ڴmϤ2_aFBAJ H\0 hqxw&.rc_6aʨ틡E۞bclga9&P>\aF[7]o 0 c`0 Øp3 0&f 0 ?0 ca0 Øp3 0&f 0 ?0 ca0 Øp3 0&f 0 ?0 cQz;ox 䄃&]zeS 0 5Ȧ+._ <䓝цg<ɴ'ݼƻ~ 7 0d֟z_'+;t0~:ۜw#CL-ᘨb,$cP]BC4MFܤbzY# T=v$[w/, 7syZp|fG Jm:|ilLe᱀ce)H7Ff H4au_|FT*@s#y D]eUFݷ~s5/~|G<}jaq` 1V#--'KeКb ckճA =;QGgZ/ *:n wO`8{[)}:THd4ˉN0Fg 0FCD`NxzsU6V >c(.X=J?XM=ܳg>k;?9cgoīlNn\M,FFzPtc4. R4)x>Sn"'7"lȺ; 2F<]e LNw&Go~d?ؼC9dw?9hݵrIENDB`proxy-vole-proxy-vole-1.0.3/src/test/000077500000000000000000000000001302662252000175255ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/000077500000000000000000000000001302662252000204465ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/000077500000000000000000000000001302662252000212245ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/000077500000000000000000000000001302662252000225065ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/000077500000000000000000000000001302662252000257025ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/000077500000000000000000000000001302662252000270635ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/Examples.java000066400000000000000000000027221302662252000315070ustar00rootroot00000000000000package com.github.markusbernhardt.proxy; import java.net.ProxySelector; import com.github.markusbernhardt.proxy.ProxySearch; import com.github.markusbernhardt.proxy.ProxySearch.Strategy; import com.github.markusbernhardt.proxy.util.PlatformUtil; import com.github.markusbernhardt.proxy.util.PlatformUtil.Platform; /***************************************************************************** * Some examples on how to use the API * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class Examples { public void example1() { ProxySearch proxySearch = ProxySearch.getDefaultProxySearch(); ProxySelector myProxySelector = proxySearch.getProxySelector(); ProxySelector.setDefault(myProxySelector); } public void example2() { ProxySearch proxySearch = new ProxySearch(); if (PlatformUtil.getCurrentPlattform() == Platform.WIN) { proxySearch.addStrategy(Strategy.IE); proxySearch.addStrategy(Strategy.FIREFOX); proxySearch.addStrategy(Strategy.JAVA); } else if (PlatformUtil.getCurrentPlattform() == Platform.LINUX) { proxySearch.addStrategy(Strategy.GNOME); proxySearch.addStrategy(Strategy.KDE); proxySearch.addStrategy(Strategy.FIREFOX); } else { proxySearch.addStrategy(Strategy.OS_DEFAULT); } ProxySelector myProxySelector = proxySearch.getProxySelector(); ProxySelector.setDefault(myProxySelector); } } proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/TestUtil.java000066400000000000000000000053101302662252000315020ustar00rootroot00000000000000package com.github.markusbernhardt.proxy; import java.io.File; import java.net.InetSocketAddress; import java.net.Proxy; import java.net.Proxy.Type; import com.github.markusbernhardt.proxy.util.PlatformUtil; import java.net.URI; import java.net.URISyntaxException; /***************************************************************************** * This class defines some constants and helper methods for the unit tests. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class TestUtil { public static final String TEST_DATA_FOLDER = "src" + File.separator + "test" + File.separator + "resources" + File.separator; public static final Proxy HTTP_TEST_PROXY = new Proxy(Type.HTTP, InetSocketAddress.createUnresolved("http_proxy.unit-test.invalid", 8090)); public static final Proxy HTTPS_TEST_PROXY = new Proxy(Type.HTTP, InetSocketAddress.createUnresolved("https_proxy.unit-test.invalid", 8091)); public static final Proxy FTP_TEST_PROXY = new Proxy(Type.HTTP, InetSocketAddress.createUnresolved("ftp_proxy.unit-test.invalid", 8092)); public static final Proxy SOCKS_TEST_PROXY = new Proxy(Type.SOCKS, InetSocketAddress.createUnresolved("socks_proxy.unit-test.invalid", 8095)); public static final URI NO_PROXY_TEST_URI; public static final URI HTTP_TEST_URI; public static final URI HTTPS_TEST_URI; public static final URI FTP_TEST_URI; public static final URI SOCKS_TEST_URI; public static final URI LOCAL_TEST_URI; public static final URI SOCKET_TEST_URI; // Setup some testing constants. static { try { NO_PROXY_TEST_URI = new URI("http://no_proxy.unit-test.invalid/"); HTTP_TEST_URI = new URI("http://host1.unit-test.invalid/"); HTTPS_TEST_URI = new URI("https://host1.unit-test.invalid/"); FTP_TEST_URI = new URI("ftp://host1.unit-test.invalid/"); SOCKS_TEST_URI = new URI("socks://host1.unit-test.invalid/"); LOCAL_TEST_URI = new URI("http://myhost"); SOCKET_TEST_URI = new URI("socket://host1.unit-test.invalid/"); } catch (URISyntaxException e) { throw new RuntimeException("URI error" + e.getMessage()); } } /************************************************************************* * Switch the current user home directory to the to the given test folder. * * @param folder * the name of the test folder. ************************************************************************/ public static final void setTestDataFolder(String folder) { System.setProperty(PlatformUtil.OVERRIDE_HOME_DIR, System.getProperty("user.dir") + File.separator + TestUtil.TEST_DATA_FOLDER + folder); } } proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/search/000077500000000000000000000000001302662252000303305ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/search/browser/000077500000000000000000000000001302662252000320135ustar00rootroot00000000000000FirefoxTest.java000066400000000000000000000125021302662252000350410ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/search/browserpackage com.github.markusbernhardt.proxy.search.browser; import static org.junit.Assert.assertEquals; import java.net.Proxy; import java.net.ProxySelector; import java.net.URISyntaxException; import java.util.List; import org.junit.BeforeClass; import org.junit.Test; import com.github.markusbernhardt.proxy.TestUtil; import com.github.markusbernhardt.proxy.search.browser.firefox.FirefoxProxySearchStrategy; import com.github.markusbernhardt.proxy.util.ProxyException; /***************************************************************************** * Unit tests for the firefox search. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class FirefoxTest { /************************************************************************* * Setup environment for tests. ************************************************************************/ @BeforeClass public static void setup() { // Fake the OS for this tests. System.setProperty("os.name", "Linux"); } /************************************************************************* * Test method. * * @throws ProxyException * on error. ************************************************************************/ @Test public void testNone() throws ProxyException { TestUtil.setTestDataFolder("ff3_none"); FirefoxProxySearchStrategy ff = new FirefoxProxySearchStrategy(); ProxySelector ps = ff.getProxySelector(); List result = ps.select(TestUtil.HTTPS_TEST_URI); assertEquals(Proxy.NO_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testManualHttp() throws ProxyException, URISyntaxException { TestUtil.setTestDataFolder("ff3_manual"); ProxySelector ps = new FirefoxProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.HTTP_TEST_URI); assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testManualHttps() throws ProxyException, URISyntaxException { TestUtil.setTestDataFolder("ff3_manual"); ProxySelector ps = new FirefoxProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.HTTPS_TEST_URI); assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testManualFtp() throws ProxyException, URISyntaxException { TestUtil.setTestDataFolder("ff3_manual"); ProxySelector ps = new FirefoxProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.FTP_TEST_URI); assertEquals(TestUtil.FTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testManualSocks() throws ProxyException, URISyntaxException { TestUtil.setTestDataFolder("ff3_manual"); ProxySelector ps = new FirefoxProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.SOCKS_TEST_URI); assertEquals(TestUtil.SOCKS_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testPac() throws ProxyException, URISyntaxException { TestUtil.setTestDataFolder("ff3_pac_script"); ProxySelector ps = new FirefoxProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.HTTP_TEST_URI); assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testWhiteList() throws ProxyException, URISyntaxException { TestUtil.setTestDataFolder("ff3_white_list"); ProxySelector ps = new FirefoxProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.NO_PROXY_TEST_URI); assertEquals(Proxy.NO_PROXY, result.get(0)); } } IeTest.java000066400000000000000000000045721302662252000340040ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/search/browserpackage com.github.markusbernhardt.proxy.search.browser; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; import org.junit.Test; import com.github.markusbernhardt.proxy.TestUtil; import com.github.markusbernhardt.proxy.search.browser.ie.IELocalByPassFilter; import com.github.markusbernhardt.proxy.search.browser.ie.IEProxySearchStrategy; import com.github.markusbernhardt.proxy.util.PlatformUtil; import com.github.markusbernhardt.proxy.util.ProxyException; import com.github.markusbernhardt.proxy.util.UriFilter; import com.github.markusbernhardt.proxy.util.PlatformUtil.Platform; /***************************************************************************** * Unit tests for the InternetExplorer search. Only limited testing as this only * runs on windwos and needs a installed IE and IE proxy settings written to the * registry. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class IeTest { /************************************************************************* * Test method. * * @throws ProxyException * on proxy detection error. ************************************************************************/ @Test public void testInvoke() throws ProxyException { if (Platform.WIN.equals(PlatformUtil.getCurrentPlattform())) { IEProxySearchStrategy st = new IEProxySearchStrategy(); // Try at least to invoke it and test if the dll does not crash st.getProxySelector(); } } /************************************************************************* * Test method. * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * if url syntax is wrong. * @throws MalformedURLException * on wrong url format. ************************************************************************/ @Test public void testLocalByPassFilter() throws ProxyException, MalformedURLException, URISyntaxException { UriFilter filter = new IELocalByPassFilter(); assertTrue(filter.accept(TestUtil.LOCAL_TEST_URI)); assertFalse(filter.accept(TestUtil.HTTP_TEST_URI)); assertFalse(filter.accept(new URL("http://123.45.55.6").toURI())); } } proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/search/desktop/000077500000000000000000000000001302662252000320015ustar00rootroot00000000000000DesktopProxySearchTest.java000066400000000000000000000032331302662252000372270ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/search/desktoppackage com.github.markusbernhardt.proxy.search.desktop; import java.net.ProxySelector; import java.net.URI; import java.net.URISyntaxException; import org.junit.Test; import com.github.markusbernhardt.proxy.ProxySearch; import com.github.markusbernhardt.proxy.search.desktop.DesktopProxySearchStrategy; import com.github.markusbernhardt.proxy.util.ProxyException; /***************************************************************************** * Unit tests for the desktop facade search strategy. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class DesktopProxySearchTest { /************************************************************************* * Test method. * * @throws ProxyException * on error. ************************************************************************/ @Test public void testDesktopStrategsIsWorking() throws ProxyException { new DesktopProxySearchStrategy().getProxySelector(); } /************************************************************************* * Test method. * * @throws URISyntaxException * on error parsing the URI. * @throws ProxyException * on selector error. ************************************************************************/ @Test public void emptyURIShouldNotRaiseNPE() throws URISyntaxException, ProxyException { ProxySearch proxySearch = ProxySearch.getDefaultProxySearch(); ProxySelector myProxySelector = proxySearch.getProxySelector(); if (myProxySelector != null) { myProxySelector.select(new URI("")); } } } proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/search/gnome/000077500000000000000000000000001302662252000314355ustar00rootroot00000000000000GnomeProxySearchTest.java000066400000000000000000000110151302662252000363140ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/search/gnomepackage com.github.markusbernhardt.proxy.search.gnome; import static org.junit.Assert.assertEquals; import java.net.Proxy; import java.net.ProxySelector; import java.net.URISyntaxException; import java.util.List; import org.junit.Test; import com.github.markusbernhardt.proxy.TestUtil; import com.github.markusbernhardt.proxy.search.desktop.gnome.GnomeProxySearchStrategy; import com.github.markusbernhardt.proxy.util.ProxyException; /***************************************************************************** * Unit tests for the Gnome settings search strategy. For every test the * "user.home" system property is switched to the test/data folder where we * provide some Gnome config files prepared for the test cases. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class GnomeProxySearchTest { /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. ************************************************************************/ @Test public void testNone() throws ProxyException { TestUtil.setTestDataFolder("gnome_none"); ProxySelector ps = new GnomeProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.HTTP_TEST_URI); assertEquals(Proxy.NO_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testManualHttp() throws ProxyException, URISyntaxException { TestUtil.setTestDataFolder("gnome_manual"); ProxySelector ps = new GnomeProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.HTTP_TEST_URI); assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testManualHttps() throws ProxyException, URISyntaxException { TestUtil.setTestDataFolder("gnome_manual"); ProxySelector ps = new GnomeProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.HTTPS_TEST_URI); assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testManualFtp() throws ProxyException, URISyntaxException { TestUtil.setTestDataFolder("gnome_manual"); ProxySelector ps = new GnomeProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.FTP_TEST_URI); assertEquals(TestUtil.FTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testPac() throws ProxyException, URISyntaxException { TestUtil.setTestDataFolder("gnome_pac_script"); ProxySelector ps = new GnomeProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.HTTP_TEST_URI); assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testWhiteList() throws ProxyException, URISyntaxException { TestUtil.setTestDataFolder("gnome_white_list"); ProxySelector ps = new GnomeProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.NO_PROXY_TEST_URI); assertEquals(Proxy.NO_PROXY, result.get(0)); } } proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/search/java/000077500000000000000000000000001302662252000312515ustar00rootroot00000000000000JavaProxySearchTest.java000066400000000000000000000123021302662252000357440ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/search/javapackage com.github.markusbernhardt.proxy.search.java; import static org.junit.Assert.assertEquals; import java.net.Proxy; import java.net.ProxySelector; import java.net.URI; import java.net.URISyntaxException; import java.util.List; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import com.github.markusbernhardt.proxy.TestUtil; import com.github.markusbernhardt.proxy.search.java.JavaProxySearchStrategy; /***************************************************************************** * Unit tests for the Java proxy search strategy. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class JavaProxySearchTest { private ProxySelector selector; /************************************************************************* * Setup before the tests. ************************************************************************/ @BeforeClass public static void setupClass() { System.setProperty("http.proxyHost", "http_proxy.unit-test.invalid"); System.setProperty("http.proxyPort", "8090"); System.setProperty("http.nonProxyHosts", "no_proxy.unit-test.invalid"); System.setProperty("https.proxyHost", "https_proxy.unit-test.invalid"); System.setProperty("https.proxyPort", "8091"); System.setProperty("ftp.proxyHost", "ftp_proxy.unit-test.invalid"); System.setProperty("ftp.nonProxyHosts", "no_proxy.unit-test.invalid"); System.setProperty("ftp.proxyPort", "8092"); System.setProperty("socksProxyHost", "socks_proxy.unit-test.invalid"); System.setProperty("socksProxyPort", "8095"); } /************************************************************************* * Setup before the tests. ************************************************************************/ @AfterClass public static void teardownClass() { System.clearProperty("http.proxyHost"); System.clearProperty("http.proxyPort"); System.clearProperty("http.nonProxyHosts"); System.clearProperty("https.proxyHost"); System.clearProperty("https.proxyPort"); System.clearProperty("ftp.proxyHost"); System.clearProperty("ftp.nonProxyHosts"); System.clearProperty("ftp.proxyPort"); System.clearProperty("socksProxyHost"); System.clearProperty("socksProxyPort"); } /************************************************************************* * Setup before every single test ************************************************************************/ @Before public void setup() { this.selector = new JavaProxySearchStrategy().getProxySelector(); } /************************************************************************* * Test method ************************************************************************/ @Test public void testHTTP() { List result = this.selector.select(TestUtil.HTTP_TEST_URI); assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws URISyntaxException * on wrong URI. ************************************************************************/ @Test public void testHTTPnoProxy() throws URISyntaxException { List result = this.selector.select(new URI("http://no_proxy.unit-test.invalid")); assertEquals(Proxy.NO_PROXY, result.get(0)); } /************************************************************************* * Test method ************************************************************************/ @Test public void testHTTPS() { List result = this.selector.select(TestUtil.HTTPS_TEST_URI); assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws URISyntaxException * on wrong URI. ************************************************************************/ @Test public void testHTTPSnoProxy() throws URISyntaxException { List result = this.selector.select(new URI("https://no_proxy.unit-test.invalid")); assertEquals(Proxy.NO_PROXY, result.get(0)); } /************************************************************************* * Test method ************************************************************************/ @Test public void testFTP() { List result = this.selector.select(TestUtil.FTP_TEST_URI); assertEquals(TestUtil.FTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws URISyntaxException * on wrong URI. ************************************************************************/ @Test public void testFTPnoProxy() throws URISyntaxException { List result = this.selector.select(new URI("ftp://no_proxy.unit-test.invalid")); assertEquals(Proxy.NO_PROXY, result.get(0)); } /************************************************************************* * Test method ************************************************************************/ @Test public void testSOCKS() { List result = this.selector.select(TestUtil.SOCKS_TEST_URI); assertEquals(TestUtil.SOCKS_TEST_PROXY, result.get(0)); } } proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/search/kde/000077500000000000000000000000001302662252000310735ustar00rootroot00000000000000KdeProxySearchTest.java000066400000000000000000000163201302662252000354140ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/search/kdepackage com.github.markusbernhardt.proxy.search.kde; import static org.junit.Assert.assertEquals; import java.net.Proxy; import java.net.ProxySelector; import java.net.URISyntaxException; import java.util.List; import org.junit.Ignore; import org.junit.Test; import com.github.markusbernhardt.proxy.TestUtil; import com.github.markusbernhardt.proxy.search.desktop.kde.KdeProxySearchStrategy; import com.github.markusbernhardt.proxy.util.ProxyException; /***************************************************************************** * Unit tests for the KDE settings search strategy. For every test the * "user.home" system property is switched to the test/data folder where we * provide some KDE config files prepared for the test cases. * * If the env tests fail you need to set the followingenvironment variables: *

* HTTP_PROXY = http://http_proxy.unit-test.invalid:8090
* HTTPS_PROXY = http://https_proxy.unit-test.invalid:8091
* FTP_PROXY = http://ftp_proxy.unit-test.invalid:8092
*

* * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class KdeProxySearchTest { /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. ************************************************************************/ @Test public void testNone() throws ProxyException { TestUtil.setTestDataFolder("kde_none"); ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.HTTP_TEST_URI); assertEquals(Proxy.NO_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testManualHttp() throws ProxyException, URISyntaxException { TestUtil.setTestDataFolder("kde_manual"); ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.HTTP_TEST_URI); assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testManualHttps() throws ProxyException, URISyntaxException { TestUtil.setTestDataFolder("kde_manual"); ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.HTTPS_TEST_URI); assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testManualFtp() throws ProxyException, URISyntaxException { TestUtil.setTestDataFolder("kde_manual"); ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.FTP_TEST_URI); assertEquals(TestUtil.FTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testPac() throws ProxyException, URISyntaxException { TestUtil.setTestDataFolder("kde_pac_script"); ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.HTTP_TEST_URI); assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test @Ignore public void testEnvHttp() throws ProxyException, URISyntaxException { // There is no good was to initialize environment variables in the // running process. // System.getenv().put("HTTP_PROXY", // "http://http_proxy.unit-test.invalid:8090"); // Does not work TestUtil.setTestDataFolder("kde_env"); ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.HTTP_TEST_URI); assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test @Ignore public void testEnvHttps() throws ProxyException, URISyntaxException { // There is no good was to initialize environment variables in the // running process. // System.getenv().put("HTTPS_PROXY", // "http://http_proxy.unit-test.invalid:8090"); // Does not work TestUtil.setTestDataFolder("kde_env"); ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.HTTPS_TEST_URI); assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test @Ignore public void testEnvFtp() throws ProxyException, URISyntaxException { // there is no good was to initialize environment variables in the // running process. // System.getenv().put("FTP_PROXY", // "http://http_proxy.unit-test.invalid:8090"); // Does not work TestUtil.setTestDataFolder("kde_env"); ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.FTP_TEST_URI); assertEquals(TestUtil.FTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testWhiteList() throws ProxyException, URISyntaxException { TestUtil.setTestDataFolder("kde_white_list"); ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.NO_PROXY_TEST_URI); assertEquals(Proxy.NO_PROXY, result.get(0)); } } proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/search/osx/000077500000000000000000000000001302662252000311415ustar00rootroot00000000000000OsxProxySearchTest.java000066400000000000000000000137541302662252000355400ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/search/osxpackage com.github.markusbernhardt.proxy.search.osx; import static org.junit.Assert.assertEquals; import java.io.File; import java.net.Proxy; import java.net.ProxySelector; import java.net.URISyntaxException; import java.util.List; import org.junit.Test; import com.github.markusbernhardt.proxy.TestUtil; import com.github.markusbernhardt.proxy.search.desktop.osx.OsxProxySearchStrategy; import com.github.markusbernhardt.proxy.util.ProxyException; /***************************************************************************** * Unit tests for the OSX settings search strategy. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class OsxProxySearchTest { /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testManualHttp() throws ProxyException, URISyntaxException { System.setProperty(OsxProxySearchStrategy.OVERRIDE_SETTINGS_FILE, TestUtil.TEST_DATA_FOLDER + File.separator + "osx" + File.separator + "osx_manual.plist"); System.setProperty(OsxProxySearchStrategy.OVERRIDE_ACCEPTED_DEVICES, "en0"); ProxySelector ps = new OsxProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.HTTP_TEST_URI); assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void wrongIntfaceShouldBeSkipped() throws ProxyException, URISyntaxException { System.setProperty(OsxProxySearchStrategy.OVERRIDE_SETTINGS_FILE, TestUtil.TEST_DATA_FOLDER + File.separator + "osx" + File.separator + "osx_manual.plist"); System.setProperty(OsxProxySearchStrategy.OVERRIDE_ACCEPTED_DEVICES, "junit"); ProxySelector ps = new OsxProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.HTTP_TEST_URI); assertEquals(Proxy.NO_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testManualHttps() throws ProxyException, URISyntaxException { System.setProperty(OsxProxySearchStrategy.OVERRIDE_SETTINGS_FILE, TestUtil.TEST_DATA_FOLDER + "osx" + File.separator + "osx_manual.plist"); ProxySelector ps = new OsxProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.HTTPS_TEST_URI); assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testManualFtp() throws ProxyException, URISyntaxException { System.setProperty(OsxProxySearchStrategy.OVERRIDE_SETTINGS_FILE, TestUtil.TEST_DATA_FOLDER + "osx" + File.separator + "osx_manual.plist"); ProxySelector ps = new OsxProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.FTP_TEST_URI); assertEquals(TestUtil.FTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testManualSocks() throws ProxyException, URISyntaxException { System.setProperty(OsxProxySearchStrategy.OVERRIDE_SETTINGS_FILE, TestUtil.TEST_DATA_FOLDER + "osx" + File.separator + "osx_manual.plist"); ProxySelector ps = new OsxProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.SOCKS_TEST_URI); assertEquals(TestUtil.SOCKS_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testNoProxyList() throws ProxyException, URISyntaxException { System.setProperty(OsxProxySearchStrategy.OVERRIDE_SETTINGS_FILE, TestUtil.TEST_DATA_FOLDER + "osx" + File.separator + "osx_manual.plist"); ProxySelector ps = new OsxProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.NO_PROXY_TEST_URI); assertEquals(Proxy.NO_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testSimpleHostTest() throws ProxyException, URISyntaxException { System.setProperty(OsxProxySearchStrategy.OVERRIDE_SETTINGS_FILE, TestUtil.TEST_DATA_FOLDER + "osx" + File.separator + "osx_manual.plist"); ProxySelector ps = new OsxProxySearchStrategy().getProxySelector(); List result = ps.select(TestUtil.LOCAL_TEST_URI); assertEquals(Proxy.NO_PROXY, result.get(0)); } } proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/000077500000000000000000000000001302662252000307035ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/fixed/000077500000000000000000000000001302662252000320025ustar00rootroot00000000000000FixedProxyTest.java000066400000000000000000000034431302662252000355330ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/fixedpackage com.github.markusbernhardt.proxy.selector.fixed; import static org.junit.Assert.assertEquals; import java.net.Proxy; import java.net.ProxySelector; import java.util.List; import org.junit.Test; import com.github.markusbernhardt.proxy.TestUtil; import com.github.markusbernhardt.proxy.selector.fixed.FixedProxySelector; /***************************************************************************** * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class FixedProxyTest { /************************************************************************* * Test method ************************************************************************/ @Test public void testFixedProxy() { ProxySelector ps = new FixedProxySelector("http_proxy.unit-test.invalid", 8090); List result = ps.select(TestUtil.HTTP_TEST_URI); assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method ************************************************************************/ @Test public void testFixedProxy2() { ProxySelector ps = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); List result = ps.select(TestUtil.HTTP_TEST_URI); assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method ************************************************************************/ @Test public void testFixedProxy3() { ProxySelector ps = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); List result = ps.select(TestUtil.HTTPS_TEST_URI); assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); } } proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/java/000077500000000000000000000000001302662252000316245ustar00rootroot00000000000000JavaProxySelectorTest.java000066400000000000000000000016121302662252000366740ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/javapackage com.github.markusbernhardt.proxy.selector.java; import static org.junit.Assert.assertNull; import java.net.ProxySelector; import org.junit.Test; import com.github.markusbernhardt.proxy.search.java.JavaProxySearchStrategy; /***************************************************************************** * Some unit tests for the Java Proxy search strategy. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class JavaProxySelectorTest { /************************************************************************* * Test method ************************************************************************/ @Test public void withoutSystemPropertyShouldReturnNull() { ProxySelector ps = new JavaProxySearchStrategy().getProxySelector(); assertNull(ps); } } proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/misc/000077500000000000000000000000001302662252000316365ustar00rootroot00000000000000ProtocolDispatchTest.java000066400000000000000000000061211302662252000365430ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/miscpackage com.github.markusbernhardt.proxy.selector.misc; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import java.net.Proxy; import java.util.List; import org.junit.BeforeClass; import org.junit.Test; import com.github.markusbernhardt.proxy.TestUtil; import com.github.markusbernhardt.proxy.selector.fixed.FixedProxySelector; import com.github.markusbernhardt.proxy.selector.misc.ProtocolDispatchSelector; /***************************************************************************** * Unit Tests for the ProtocolDispatchSelector * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class ProtocolDispatchTest { private static ProtocolDispatchSelector ps; @BeforeClass public static void setup() { ps = new ProtocolDispatchSelector(); ps.setSelector("http", new FixedProxySelector(TestUtil.HTTP_TEST_PROXY)); ps.setSelector("https", new FixedProxySelector(TestUtil.HTTPS_TEST_PROXY)); ps.setSelector("ftp", new FixedProxySelector(TestUtil.FTP_TEST_PROXY)); } /************************************************************************* * Test method ************************************************************************/ @Test public void testDispatchHttp() { List result = ps.select(TestUtil.HTTP_TEST_URI); assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method ************************************************************************/ @Test public void testDispatchHttps() { List result = ps.select(TestUtil.HTTPS_TEST_URI); assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method ************************************************************************/ @Test public void testDispatchFtp() { List result = ps.select(TestUtil.FTP_TEST_URI); assertEquals(TestUtil.FTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method ************************************************************************/ @Test public void testRemove() { ProtocolDispatchSelector px = new ProtocolDispatchSelector(); FixedProxySelector selector = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); px.setSelector("http", selector); assertEquals(selector, px.getSelector("http")); px.removeSelector("http"); assertNull(px.getSelector("http")); } /************************************************************************* * Test method ************************************************************************/ @Test public void testFallback() { ProtocolDispatchSelector px = new ProtocolDispatchSelector(); FixedProxySelector selector = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); px.setFallbackSelector(selector); List proxies = px.select(TestUtil.HTTP_TEST_URI); assertEquals(TestUtil.HTTP_TEST_PROXY, proxies.get(0)); } } ProxyListFallbackSelectorTest.java000066400000000000000000000060331302662252000403620ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/miscpackage com.github.markusbernhardt.proxy.selector.misc; import static org.junit.Assert.assertEquals; import java.io.IOException; import java.net.Proxy; import java.net.ProxySelector; import java.net.SocketAddress; import java.net.URI; import java.util.Arrays; import java.util.List; import org.junit.Before; import org.junit.Test; import com.github.markusbernhardt.proxy.TestUtil; import com.github.markusbernhardt.proxy.selector.misc.ProxyListFallbackSelector; /***************************************************************************** * Unit Tests for the ProxyListFallbackSelector * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class ProxyListFallbackSelectorTest { private ProxyListFallbackSelector selector; /************************************************************************* * Setup before tests. ************************************************************************/ @Before public void setup() { this.selector = new ProxyListFallbackSelector(new ProxySelector() { @Override public List select(URI uri) { return Arrays.asList(TestUtil.HTTP_TEST_PROXY, TestUtil.HTTPS_TEST_PROXY, Proxy.NO_PROXY); } @Override public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { // Not used on the delegate } }); } /************************************************************************* * Test method ************************************************************************/ @Test public void testList() { List result = this.selector.select(TestUtil.HTTP_TEST_URI); assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(1)); assertEquals(Proxy.NO_PROXY, result.get(2)); } /************************************************************************* * Test method ************************************************************************/ @Test public void testFailedProxy() { this.selector.connectFailed(TestUtil.HTTP_TEST_URI, TestUtil.HTTP_TEST_PROXY.address(), new IOException("TEST")); List result = this.selector.select(TestUtil.HTTP_TEST_URI); assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0)); assertEquals(Proxy.NO_PROXY, result.get(1)); } /************************************************************************* * Test method * * @throws InterruptedException * if the test wait period was interrupted ************************************************************************/ @Test public void testFailedProxyRetry() throws InterruptedException { this.selector.setRetryAfterMs(100); this.selector.connectFailed(TestUtil.HTTP_TEST_URI, TestUtil.HTTP_TEST_PROXY.address(), new IOException("TEST")); List result = this.selector.select(TestUtil.HTTP_TEST_URI); assertEquals(2, result.size()); Thread.sleep(200); result = this.selector.select(TestUtil.HTTP_TEST_URI); assertEquals(3, result.size()); } } proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/pac/000077500000000000000000000000001302662252000314465ustar00rootroot00000000000000JavaxPacScriptParserTest.java000066400000000000000000000142151302662252000371340ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/pacpackage com.github.markusbernhardt.proxy.selector.pac; import java.io.File; import java.net.MalformedURLException; import java.util.Calendar; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; import com.github.markusbernhardt.proxy.TestUtil; import com.github.markusbernhardt.proxy.selector.pac.JavaxPacScriptParser; import com.github.markusbernhardt.proxy.selector.pac.PacScriptParser; import com.github.markusbernhardt.proxy.selector.pac.UrlPacScriptSource; import com.github.markusbernhardt.proxy.util.ProxyException; /***************************************************************************** * Tests for the javax.script PAC script parser. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class JavaxPacScriptParserTest { /************************************************************************* * Set calendar for date and time base tests. Current date for all tests is: * 15. December 1994 12:00.00 its a Thursday ************************************************************************/ @BeforeClass public static void setup() { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, 1994); cal.set(Calendar.MONTH, Calendar.DECEMBER); cal.set(Calendar.DAY_OF_MONTH, 15); cal.set(Calendar.HOUR_OF_DAY, 12); cal.set(Calendar.MINUTE, 00); cal.set(Calendar.SECOND, 00); cal.set(Calendar.MILLISECOND, 00); // TODO Rossi 26.08.2010 need to fake time // JavaxPacScriptParser.setCurrentTime(cal); } /************************************************************************* * Cleanup after the tests. ************************************************************************/ @AfterClass public static void teadDown() { // JavaxPacScriptParser.setCurrentTime(null); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws MalformedURLException * on URL erros ************************************************************************/ @Test public void testScriptExecution() throws ProxyException, MalformedURLException { PacScriptParser p = new JavaxPacScriptParser(new UrlPacScriptSource(toUrl("test1.pac"))); p.evaluate(TestUtil.HTTP_TEST_URI.toString(), "host1.unit-test.invalid"); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws MalformedURLException * on URL erros ************************************************************************/ @Test public void testCommentsInScript() throws ProxyException, MalformedURLException { PacScriptParser p = new JavaxPacScriptParser(new UrlPacScriptSource(toUrl("test2.pac"))); p.evaluate(TestUtil.HTTP_TEST_URI.toString(), "host1.unit-test.invalid"); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws MalformedURLException * on URL erros ************************************************************************/ @Test @Ignore // Test deactivated because it will not run in Java 1.5 and time // based test are unstable public void testScriptWeekDayScript() throws ProxyException, MalformedURLException { PacScriptParser p = new JavaxPacScriptParser(new UrlPacScriptSource(toUrl("testWeekDay.pac"))); p.evaluate(TestUtil.HTTP_TEST_URI.toString(), "host1.unit-test.invalid"); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws MalformedURLException * on URL erros ************************************************************************/ @Test @Ignore // Test deactivated because it will not run in Java 1.5 and time // based test are unstable public void testDateRangeScript() throws ProxyException, MalformedURLException { PacScriptParser p = new JavaxPacScriptParser(new UrlPacScriptSource(toUrl("testDateRange.pac"))); p.evaluate(TestUtil.HTTP_TEST_URI.toString(), "host1.unit-test.invalid"); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws MalformedURLException * on URL erros ************************************************************************/ @Test @Ignore // Test deactivated because it will not run in Java 1.5 and time // based test are unstable public void testTimeRangeScript() throws ProxyException, MalformedURLException { PacScriptParser p = new JavaxPacScriptParser(new UrlPacScriptSource(toUrl("testTimeRange.pac"))); p.evaluate(TestUtil.HTTP_TEST_URI.toString(), "host1.unit-test.invalid"); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws MalformedURLException * on URL erros ************************************************************************/ @Test public void methodsShouldReturnJsStrings() throws ProxyException, MalformedURLException { PacScriptParser p = new JavaxPacScriptParser(new UrlPacScriptSource(toUrl("testReturnTypes.pac"))); String actual = p.evaluate(TestUtil.HTTP_TEST_URI.toString(), "host1.unit-test.invalid"); Assert.assertEquals("number boolean string", actual); } /************************************************************************* * Helper method to build the url to the given test file * * @param testFile * the name of the test file. * @return the URL. * @throws MalformedURLException ************************************************************************/ private String toUrl(String testFile) throws MalformedURLException { return new File(TestUtil.TEST_DATA_FOLDER + "pac", testFile).toURI().toURL().toString(); } } PacPerProtocolTest.java000066400000000000000000000034071302662252000357720ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/pacpackage com.github.markusbernhardt.proxy.selector.pac; import static org.junit.Assert.assertEquals; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.Proxy; import java.net.URI; import java.net.URISyntaxException; import java.util.List; import org.junit.Test; import com.github.markusbernhardt.proxy.TestUtil; import com.github.markusbernhardt.proxy.selector.pac.PacProxySelector; import com.github.markusbernhardt.proxy.selector.pac.UrlPacScriptSource; /** * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 */ public class PacPerProtocolTest { /************************************************************************* * Test the PAC selector for a given protocol. * * @throws IOException * of read error. * @throws URISyntaxException * on uri syntax error. ************************************************************************/ @Test public void testPacForSocket() throws IOException, URISyntaxException { new URI("socket://host1.unit-test.invalid/"); List result = new PacProxySelector(new UrlPacScriptSource(toUrl("test1.pac"))) .select(TestUtil.SOCKET_TEST_URI); assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Helper method to build the url to the given test file * * @param testFile * the name of the test file. * @return the URL. * @throws MalformedURLException ************************************************************************/ private String toUrl(String testFile) throws MalformedURLException { return new File(TestUtil.TEST_DATA_FOLDER + "pac", testFile).toURI().toURL().toString(); } } PacProxyDebugging.java000066400000000000000000000074101302662252000356150ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/pacpackage com.github.markusbernhardt.proxy.selector.pac; import java.io.InputStream; import java.io.InputStreamReader; import java.io.LineNumberReader; import java.net.ProxySelector; import java.net.URL; import java.net.URLConnection; import java.text.MessageFormat; import com.github.markusbernhardt.proxy.ProxySearch; import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; /***************************************************************************** * Test program submitted to test the issue 27 with PAC proxy selector that is * while downloading the PAC file invoking itself. This has lead to a endless * loop. The issue is now solved but I keep this test program for future PAC * testing. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class PacProxyDebugging { private static final String TEST_URL = "http://www.asetune.com"; /************************************************************************* * Setup a console logger. ************************************************************************/ private void installLogger() { Logger.setBackend(new Logger.LogBackEnd() { public void log(Class clazz, LogLevel loglevel, String msg, Object... params) { System.out.println(loglevel + "\t" + MessageFormat.format(msg, params)); } public boolean isLogginEnabled(LogLevel logLevel) { return true; } }); } /************************************************************************* * Main entry point for the test application. * * @param args * the command line arguments. ************************************************************************/ public static void main(String[] args) { // System.setProperty("http.proxyHost", "10.65.12.21"); // System.setProperty("http.proxyPort", "8080"); // System.setProperty("java.net.useSystemProxies", "true"); PacProxyDebugging pt = new PacProxyDebugging(); pt.installLogger(); ProxySearch proxySearch = ProxySearch.getDefaultProxySearch(); // ProxySearch proxySearch = new ProxySearch(); // proxySearch.addStrategy(Strategy.JAVA); // proxySearch.addStrategy(Strategy.BROWSER); // proxySearch.addStrategy(Strategy.OS_DEFAULT); // proxySearch.addStrategy(Strategy.ENV_VAR); ProxySelector myProxySelector = proxySearch.getProxySelector(); ProxySelector.setDefault(myProxySelector); System.out.println("Using proxy selector: " + myProxySelector); // String webAddress = "http://www.google.com"; String webAddress = TEST_URL; try { URL url = new URL(webAddress); // List result = myProxySelector.select(url.toURI()); // if (result == null || result.size() == 0) // { // System.out.println("No proxy found for this url."); // return; // } // System.out.println("Proxy Settings found using 'xxx' strategy.\n" // + // "Proxy used for URL is: "+result.get(0)); System.out.println("Now open a connection to the url: " + webAddress); System.out.println("=============================================="); // open the connection and prepare it to POST URLConnection conn = url.openConnection(); conn.setConnectTimeout(10 * 1000); // Return the response InputStream in = conn.getInputStream(); LineNumberReader lr = new LineNumberReader(new InputStreamReader(in)); String line; while ((line = lr.readLine()) != null) { System.out.println("response line " + lr.getLineNumber() + ": " + line); } System.out.println("---- END -------------------------------------"); } catch (Exception e) { e.printStackTrace(); } } } PacProxySelectorTest.java000066400000000000000000000131011302662252000363340ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/pacpackage com.github.markusbernhardt.proxy.selector.pac; import static org.junit.Assert.assertEquals; import java.io.File; import java.io.IOException; import java.net.InetSocketAddress; import java.net.MalformedURLException; import java.net.Proxy; import java.net.Proxy.Type; import java.net.ProxySelector; import java.net.SocketAddress; import java.net.URI; import java.util.List; import org.junit.Test; import com.github.markusbernhardt.proxy.TestUtil; import com.github.markusbernhardt.proxy.selector.pac.PacProxySelector; import com.github.markusbernhardt.proxy.selector.pac.PacScriptMethods; import com.github.markusbernhardt.proxy.selector.pac.UrlPacScriptSource; import com.github.markusbernhardt.proxy.util.ProxyException; /***************************************************************************** * Tests for the Pac script parser and proxy selector. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class PacProxySelectorTest { /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws MalformedURLException * on URL erros ************************************************************************/ @Test public void testScriptExecution() throws ProxyException, MalformedURLException { List result = new PacProxySelector(new UrlPacScriptSource(toUrl("test1.pac"))) .select(TestUtil.HTTP_TEST_URI); assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws MalformedURLException * on URL erros ************************************************************************/ @Test public void testScriptExecution2() throws ProxyException, MalformedURLException { PacProxySelector pacProxySelector = new PacProxySelector(new UrlPacScriptSource(toUrl("test2.pac"))); List result = pacProxySelector.select(TestUtil.HTTP_TEST_URI); assertEquals(Proxy.NO_PROXY, result.get(0)); result = pacProxySelector.select(TestUtil.HTTPS_TEST_URI); assertEquals(Proxy.NO_PROXY, result.get(0)); } /************************************************************************* * Test download fix to prevent infinite loop. * * @throws ProxyException * on proxy detection error. * @throws MalformedURLException * on URL erros ************************************************************************/ @Test public void pacDownloadFromURLShouldNotUseProxy() throws ProxyException, MalformedURLException { ProxySelector oldOne = ProxySelector.getDefault(); try { ProxySelector.setDefault(new ProxySelector() { @Override public List select(URI uri) { throw new IllegalStateException("Should not download via proxy"); } @Override public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { // Not used } }); PacProxySelector pacProxySelector = new PacProxySelector( new UrlPacScriptSource("http://www.test.invalid/wpad.pac")); pacProxySelector.select(TestUtil.HTTPS_TEST_URI); } finally { ProxySelector.setDefault(oldOne); } } /************************************************************************* * Test method * * @throws ProxyException * on proxy detection error. * @throws MalformedURLException * on URL erros ************************************************************************/ @Test public void testScriptMuliProxy() throws ProxyException, MalformedURLException { PacProxySelector pacProxySelector = new PacProxySelector(new UrlPacScriptSource(toUrl("testMultiProxy.pac"))); List result = pacProxySelector.select(TestUtil.HTTP_TEST_URI); assertEquals(2, result.size()); assertEquals(new Proxy(Type.HTTP, InetSocketAddress.createUnresolved("my-proxy.com", 80)), result.get(0)); assertEquals(new Proxy(Type.HTTP, InetSocketAddress.createUnresolved("my-proxy2.com", 8080)), result.get(1)); } /************************************************************************* * Test method for the override local IP feature. * * @throws ProxyException * on proxy detection error. * @throws MalformedURLException * on URL erros ************************************************************************/ @Test public void testLocalIPOverride() throws ProxyException, MalformedURLException { System.setProperty(PacScriptMethods.OVERRIDE_LOCAL_IP, "123.123.123.123"); try { PacProxySelector pacProxySelector = new PacProxySelector(new UrlPacScriptSource(toUrl("testLocalIP.pac"))); List result = pacProxySelector.select(TestUtil.HTTP_TEST_URI); assertEquals(result.get(0), new Proxy(Type.HTTP, InetSocketAddress.createUnresolved("123.123.123.123", 8080))); } finally { System.setProperty(PacScriptMethods.OVERRIDE_LOCAL_IP, ""); } } /************************************************************************* * Helper method to build the url to the given test file * * @param testFile * the name of the test file. * @return the URL. * @throws MalformedURLException ************************************************************************/ private String toUrl(String testFile) throws MalformedURLException { return new File(TestUtil.TEST_DATA_FOLDER + "pac", testFile).toURI().toURL().toString(); } } PacScriptMethodsTest.java000066400000000000000000000241221302662252000363070ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/pacpackage com.github.markusbernhardt.proxy.selector.pac; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import java.net.Inet4Address; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Calendar; import org.junit.Test; import com.github.markusbernhardt.proxy.TestUtil; import com.github.markusbernhardt.proxy.selector.pac.PacScriptMethods; /***************************************************************************** * Tests for the global PAC script methods that are used as context inside of * the scripts. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class PacScriptMethodsTest { /************************************************************************* * Get a methods implementation with a calendar for date and time base tests * set to a hardcoded data. Current date for all tests is: 15. December 1994 * 12:00.00 its a Thursday ************************************************************************/ private PacScriptMethods buildParser() { PacScriptMethods result = new PacScriptMethods(); Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, 1994); cal.set(Calendar.MONTH, Calendar.DECEMBER); cal.set(Calendar.DAY_OF_MONTH, 15); cal.set(Calendar.HOUR_OF_DAY, 12); cal.set(Calendar.MINUTE, 00); cal.set(Calendar.SECOND, 00); cal.set(Calendar.MILLISECOND, 00); result.setCurrentTime(cal); return result; } /************************************************************************* * Test method ************************************************************************/ @Test public void testDnsDomainIs() { assertEquals(true, buildParser().dnsDomainIs("host1.unit-test.invalid", "unit-test.invalid")); } /************************************************************************* * Test method ************************************************************************/ @Test public void testDnsDomainLevels() { assertEquals(2, buildParser().dnsDomainLevels(TestUtil.HTTP_TEST_URI.toString())); } /************************************************************************* * Test method * * @throws UnknownHostException * on resolve error. ************************************************************************/ @Test public void testDnsResolve() throws UnknownHostException { InetAddress adr = Inet4Address.getLocalHost(); assertEquals(adr.getHostAddress(), buildParser().dnsResolve(adr.getHostName())); } /************************************************************************* * Test method ************************************************************************/ @Test public void testIsInNet() { assertEquals(true, buildParser().isInNet("192.168.0.122", "192.168.0.0", "255.255.255.0")); } /************************************************************************* * Test method ************************************************************************/ @Test public void testIsInNet2() { assertEquals(true, buildParser().isInNet("10.13.75.47", "10.13.72.0", "255.255.252.0")); } /************************************************************************* * Test method ************************************************************************/ @Test public void testIsInNetExForIP4() { // isInNetEx(host, "198.95.249.79/32"); // true if the IP address of host matches exactly 198.95.249.79 assertEquals(true, buildParser().isInNetEx("198.95.249.79", "198.95.249.79/32")); assertEquals(false, buildParser().isInNetEx("198.95.249.80", "198.95.249.79/32")); // isInNetEx(host, "198.95.0.0/16"); // true if the IP address of the host matches 198.95.*.* assertEquals(true, buildParser().isInNetEx("198.95.249.79", "198.95.0.0/16")); assertEquals(true, buildParser().isInNetEx("198.95.249.80", "198.95.0.0/16")); assertEquals(false, buildParser().isInNetEx("198.96.249.80", "198.95.0.0/16")); } /************************************************************************* * Test method ************************************************************************/ @Test public void testIsInNetExForIP6() { // isInNetEx(host, "3ffe:8311:ffff/48"); // true if the IP address of the host matches 3ffe:8311:fff:*:*:*:*:* assertEquals(true, buildParser().isInNetEx("3ffe:8311:ffff::", "3ffe:8311:ffff::/48")); assertEquals(true, buildParser().isInNetEx("3ffe:8311:ffff:1111:0:0:0:0", "3ffe:8311:ffff::/48")); assertEquals(false, buildParser().isInNetEx("3ffe:8312:ffff:1111:0:0:0:0", "3ffe:8311:ffff::/48")); } /************************************************************************* * Test Method sortIpAddressList(2001:4898:28:3:201:2ff:feea:fc14; * 157.59.139.22; fe80::5efe:157.59.139.22"); returns * "fe80::5efe:157.59.139.22;2001:4898:28:3:201:2ff:feea:fc14;157.59.139.22" * A list of sorted IP addresses. If there both IPv6 and IPv4 IP addresses * are passed as input to this function, then the sorted IPv6 addresses are * followed by sorted IPv4 addresses * ************************************************************************/ @Test public void testSortIpAddressList() { assertEquals("fe80::5efe:157.59.139.22;2001:4898:28:3:201:2ff:feea:fc14;157.59.139.22", buildParser() .sortIpAddressList("2001:4898:28:3:201:2ff:feea:fc14; 157.59.139.22; fe80::5efe:157.59.139.22")); } /************************************************************************* * Test method ************************************************************************/ @Test public void testIsPlainHostName() { assertEquals(false, buildParser().isPlainHostName("host1.unit-test.invalid")); assertEquals(true, buildParser().isPlainHostName("host1")); } /************************************************************************* * Test method * * @throws UnknownHostException * on resolve error. ************************************************************************/ @Test public void testIsResolveable() throws UnknownHostException { InetAddress adr = Inet4Address.getLocalHost(); assertEquals(true, buildParser().isResolvable(adr.getHostName())); } /************************************************************************* * Test method ************************************************************************/ @Test public void testLocalHostOrDomainIs() { assertEquals(true, buildParser().localHostOrDomainIs("host1.unit-test.invalid", "host1.unit-test.invalid")); } /************************************************************************* * Test method * * @throws UnknownHostException * on resolve error. ************************************************************************/ @Test public void testMyIpAddress() throws UnknownHostException { String myIP = buildParser().myIpAddress(); assertFalse("127.0.0.1".equals(myIP)); assertFalse("".equals(myIP)); assertNotNull(myIP); } /************************************************************************* * Test method ************************************************************************/ @Test public void testShExpMatch() { assertEquals(true, buildParser().shExpMatch("host1.unit-test.invalid", "host1.unit-test.*")); assertEquals(true, buildParser().shExpMatch("host1.unit-test.invalid", "*.unit-test.invalid")); assertEquals(true, buildParser().shExpMatch("host1.unit-test.invalid", "*.unit*.invalid")); assertEquals(false, buildParser().shExpMatch("202.310.65.6", "10.*")); assertEquals(false, buildParser().shExpMatch("202.310.65.6", "*.65")); } /************************************************************************* * Test method ************************************************************************/ @Test public void testWeekdayRange() { assertEquals(true, buildParser().weekdayRange("MON", "SUN", "GMT")); assertEquals(true, buildParser().weekdayRange("SUN", "SAT", null)); assertEquals(false, buildParser().weekdayRange("MON", "WED", null)); } /************************************************************************* * Test method ************************************************************************/ @Test public void testDateRange() { assertEquals(true, buildParser().dateRange(15, "undefined", "undefined", "undefined", "undefined", "undefined", "undefined")); assertEquals(true, buildParser().dateRange(15, "DEC", "undefined", "undefined", "undefined", "undefined", "undefined")); assertEquals(true, buildParser().dateRange(15, "DEC", 1994, "undefined", "undefined", "undefined", "undefined")); assertEquals(true, buildParser().dateRange(15, 17, "undefined", "undefined", "undefined", "undefined", "undefined")); assertEquals(true, buildParser().dateRange("OCT", "JAN", "undefined", "undefined", "undefined", "undefined", "undefined")); assertEquals(true, buildParser().dateRange(1994, 1994, "undefined", "undefined", "undefined", "undefined", "undefined")); assertEquals(true, buildParser().dateRange(1, "DEC", 1994, 1, "JAN", 1995, "GTM")); assertEquals(false, buildParser().dateRange(16, "DEC", 1994, 1, "JAN", 1995, "GTM")); } /************************************************************************* * Test method ************************************************************************/ @Test public void testTimeRange() { assertEquals(true, buildParser().timeRange(12, "undefined", "undefined", "undefined", "undefined", "undefined", "undefined")); assertEquals(true, buildParser().timeRange(11, 13, "undefined", "undefined", "undefined", "undefined", "undefined")); assertEquals(true, buildParser().timeRange(11, 13, "gmt", "undefined", "undefined", "undefined", "undefined")); assertEquals(true, buildParser().timeRange(11, 30, 13, 30, "undefined", "undefined", "undefined")); assertEquals(true, buildParser().timeRange(11, 30, 15, 13, 30, 15, "undefined")); assertEquals(true, buildParser().timeRange(11, 30, 15, 13, 30, 15, "GMT")); assertEquals(false, buildParser().timeRange(12, 50, 00, 9, 30, 00, "GMT")); } } UrlPacScriptSourceTest.java000066400000000000000000000046371302662252000366400ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/pacpackage com.github.markusbernhardt.proxy.selector.pac; import static org.junit.Assert.assertEquals; import org.junit.Test; import com.github.markusbernhardt.proxy.selector.pac.UrlPacScriptSource; /***************************************************************************** * Tests for the UrlPacScriptSource. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class UrlPacScriptSourceTest { /************************************************************************* * Unit Test ************************************************************************/ @Test public void testHttpCharsetParser() { UrlPacScriptSource scriptSource = new UrlPacScriptSource(""); String charset = scriptSource.parseCharsetFromHeader("application/x-ns-proxy-autoconfig; charset=UTF-8"); assertEquals("UTF-8", charset); } /************************************************************************* * Unit Test ************************************************************************/ @Test public void testHttpCharsetParserDefault() { UrlPacScriptSource scriptSource = new UrlPacScriptSource(""); String charset = scriptSource.parseCharsetFromHeader("application/octet-stream;"); assertEquals("ISO-8859-1", charset); } /************************************************************************* * Unit Test ************************************************************************/ @Test public void overrideTimeoutShouldWork() { System.setProperty(UrlPacScriptSource.OVERRIDE_CONNECT_TIMEOUT, "5000"); UrlPacScriptSource scriptSource = new UrlPacScriptSource(""); int timeout = scriptSource.getTimeOut(UrlPacScriptSource.OVERRIDE_CONNECT_TIMEOUT, 1000); System.clearProperty(UrlPacScriptSource.OVERRIDE_CONNECT_TIMEOUT); assertEquals(5000, timeout); } /************************************************************************* * Unit Test ************************************************************************/ @Test public void timeoutShouldUseDefault() { System.setProperty(UrlPacScriptSource.OVERRIDE_CONNECT_TIMEOUT, "XXX"); UrlPacScriptSource scriptSource = new UrlPacScriptSource(""); int timeout = scriptSource.getTimeOut(UrlPacScriptSource.OVERRIDE_CONNECT_TIMEOUT, 1000); System.clearProperty(UrlPacScriptSource.OVERRIDE_CONNECT_TIMEOUT); assertEquals(1000, timeout); } } proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/whitelist/000077500000000000000000000000001302662252000327175ustar00rootroot00000000000000DefaultWhiteListParserTest.java000066400000000000000000000102321302662252000407370ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/whitelistpackage com.github.markusbernhardt.proxy.selector.whitelist; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.net.URI; import java.net.URISyntaxException; import java.util.List; import org.junit.Test; import com.github.markusbernhardt.proxy.selector.whitelist.DefaultWhiteListParser; import com.github.markusbernhardt.proxy.util.UriFilter; /***************************************************************************** * Unit tests for DefaultWhiteListParser * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class DefaultWhiteListParserTest { private DefaultWhiteListParser parser = new DefaultWhiteListParser(); /************************************************************************* * Test method * * @throws URISyntaxException * on error ************************************************************************/ @Test public void shouldAllowAllPrefix() throws URISyntaxException { List l = this.parser.parseWhiteList("*.mynet.com"); UriFilter filter = l.get(0); assertTrue(filter.accept(new URI("http://rossi.mynet.com"))); assertFalse(filter.accept(new URI("http://rossi.mynet.com.test"))); } /************************************************************************* * Test method * * @throws URISyntaxException * on error ************************************************************************/ @Test public void shouldAllowAllPostfix() throws URISyntaxException { List l = this.parser.parseWhiteList("mynet.*"); UriFilter filter = l.get(0); assertFalse(filter.accept(new URI("http://rossi.mynet.com"))); assertTrue(filter.accept(new URI("http://mynet.junit.test"))); } /************************************************************************* * Test method * * @throws URISyntaxException * on error ************************************************************************/ @Test public void shouldSplitMultipleEntries() throws URISyntaxException { List l = this.parser.parseWhiteList("*.mynet.com; *.rossi.invalid; junit*"); assertEquals(3, l.size()); } /************************************************************************* * Test method * * @throws URISyntaxException * on error ************************************************************************/ @Test public void shouldAllowIpRange() throws URISyntaxException { List l = this.parser.parseWhiteList("192.168.0.0/24"); UriFilter filter = l.get(0); assertTrue(filter.accept(new URI("http://192.168.0.1"))); assertTrue(filter.accept(new URI("http://192.168.0.11"))); assertFalse(filter.accept(new URI("http://rossi.mynet.com"))); assertFalse(filter.accept(new URI("http://145.5.5.1"))); } /************************************************************************* * Test method * * @throws URISyntaxException * on error ************************************************************************/ @Test public void shouldHandleInvalidWithoutException() throws URISyntaxException { List l = this.parser.parseWhiteList("http://10.*.*.*"); UriFilter filter = l.get(0); assertFalse(filter.accept(new URI("http://10.0.0.1"))); } /************************************************************************* * Test method * * @throws URISyntaxException * on error ************************************************************************/ @Test public void shouldHandleLocalBypass() throws URISyntaxException { List l = this.parser.parseWhiteList(""); UriFilter filter = l.get(0); assertTrue(filter.accept(new URI("http://localhost"))); } // // // .mynet.com - Filters all host names ending with .mynet.com // * *.mynet.com - Filters all host names ending with .mynet.com // * www.mynet.* - Filters all host names starting with www.mynet. // * 123.12.32.1 - Filters the IP 123.12.32.1 // * 123.12.32.1/255 - Filters the IP range // * http://www.mynet.com // } IPv4WithSubnetCheckerTest.java000066400000000000000000000053041302662252000404310ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/whitelistpackage com.github.markusbernhardt.proxy.selector.whitelist; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.proxy.selector.whitelist.IPWithSubnetChecker; /***************************************************************************** * Some unit tests for the IP subnet mask checker. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class IPv4WithSubnetCheckerTest { /************************************************************************* * Test method. ************************************************************************/ @Test public void testIsValidIP4() { assertTrue("Accept 127.0.0.1/8", IPWithSubnetChecker.isValidIP4Range("127.0.0.1/8")); assertTrue("Accept 127.0.0.1/32", IPWithSubnetChecker.isValidIP4Range("127.0.0.1/32")); assertTrue("Accept 255.255.255.255/32", IPWithSubnetChecker.isValidIP4Range("255.255.255.255/32")); assertTrue("Accept 0.0.0.0/0", IPWithSubnetChecker.isValidIP4Range("0.0.0.0/0")); assertFalse("Reject 127.0.0.1", IPWithSubnetChecker.isValidIP4Range("127.0.0.1")); assertFalse("Reject localhost", IPWithSubnetChecker.isValidIP4Range("localhost")); assertFalse("Reject http://www.sick.de", IPWithSubnetChecker.isValidIP4Range("http://www.sick.de")); assertFalse("Reject test.sick.de", IPWithSubnetChecker.isValidIP4Range("test.sick.de")); assertFalse("Reject 400.400.400.400", IPWithSubnetChecker.isValidIP4Range("400.400.400.400")); assertFalse("Reject 127.0.0.1/33", IPWithSubnetChecker.isValidIP4Range("127.0.0.1/33")); assertFalse("Reject 127.0.0.*", IPWithSubnetChecker.isValidIP4Range("127.0.0.*")); assertFalse("Reject 127.0.0.*/8", IPWithSubnetChecker.isValidIP4Range("127.0.0.*/8")); assertFalse("Reject www.test.com/8", IPWithSubnetChecker.isValidIP4Range("www.test.com/8")); assertFalse("Reject 127.0.0.1/33.html", IPWithSubnetChecker.isValidIP4Range("127.0.0.1/33.html")); } /************************************************************************* * Test method. ************************************************************************/ @Test public void testIsValidIP6() { assertTrue("Accept 2001:db8::/32", IPWithSubnetChecker.isValidIP6Range("2001:db8::/32")); assertTrue("Accept 0::0/0", IPWithSubnetChecker.isValidIP6Range("0::0/0")); assertTrue("Accept 2001:db8::/128", IPWithSubnetChecker.isValidIP6Range("2001:db8::/128")); assertFalse("Reject 2001:zb8::/32", IPWithSubnetChecker.isValidIP6Range("2001:zb8::/32")); assertFalse("Reject localhost", IPWithSubnetChecker.isValidIP6Range("localhost")); } } NoProxyTest.java000066400000000000000000000120041302662252000357560ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/selector/whitelistpackage com.github.markusbernhardt.proxy.selector.whitelist; import static org.junit.Assert.assertEquals; import java.net.Proxy; import java.net.ProxySelector; import java.net.URI; import java.net.URISyntaxException; import java.util.List; import org.junit.Test; import com.github.markusbernhardt.proxy.TestUtil; import com.github.markusbernhardt.proxy.selector.fixed.FixedProxySelector; import com.github.markusbernhardt.proxy.selector.whitelist.ProxyBypassListSelector; /***************************************************************************** * Some unit tests for the white list selector. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class NoProxyTest { /************************************************************************* * Test method ************************************************************************/ @Test public void testWhiteList() { ProxySelector delegate = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); ProxyBypassListSelector ps = new ProxyBypassListSelector("no_prox.*", delegate); assertEquals(delegate.select(TestUtil.HTTP_TEST_URI).get(0), ps.select(TestUtil.HTTP_TEST_URI).get(0)); } /************************************************************************* * Test method ************************************************************************/ @Test public void testWhiteList2() { ProxySelector delegate = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); ProxyBypassListSelector ps = new ProxyBypassListSelector("*.unit-test.invalid", delegate); List result = ps.select(TestUtil.HTTP_TEST_URI); assertEquals(Proxy.NO_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testWhiteList3() throws URISyntaxException { ProxySelector delegate = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); ProxyBypassListSelector ps = new ProxyBypassListSelector("*.unit-test.invalid, localhost, 127.0.0.1", delegate); List result = ps.select(new URI("http://localhost:65/getDocument")); assertEquals(Proxy.NO_PROXY, result.get(0)); result = ps.select(new URI("http://127.0.0.1:65/getDocument")); assertEquals(Proxy.NO_PROXY, result.get(0)); } /************************************************************************* * Test method ************************************************************************/ @Test public void testWhiteList4() { ProxySelector delegate = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); ProxyBypassListSelector ps = new ProxyBypassListSelector("*.unit-test.invalid, ", delegate); List result = ps.select(TestUtil.HTTP_TEST_URI); assertEquals(Proxy.NO_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testWhiteList5() throws URISyntaxException { ProxySelector delegate = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); ProxyBypassListSelector ps = new ProxyBypassListSelector("*.unit-test.invalid localhost 127.0.0.1", delegate); List result = ps.select(new URI("http://localhost:65/getDocument")); assertEquals(Proxy.NO_PROXY, result.get(0)); result = ps.select(new URI("http://127.0.0.1:65/getDocument")); assertEquals(Proxy.NO_PROXY, result.get(0)); } /************************************************************************* * Test method * * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testIpRange() throws URISyntaxException { ProxySelector delegate = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); ProxyBypassListSelector ps = new ProxyBypassListSelector("192.168.0.0/24", delegate); List result = ps.select(new URI("http://192.168.0.100:81/test.data")); assertEquals(Proxy.NO_PROXY, result.get(0)); result = ps.select(new URI("http://192.168.1.100:81/test.data")); assertEquals(delegate.select(TestUtil.HTTP_TEST_URI).get(0), result.get(0)); } /************************************************************************* * Test method for issue 31 * * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void ipRangeShouldNotMatchHttp() throws URISyntaxException { ProxySelector delegate = new FixedProxySelector(TestUtil.HTTP_TEST_PROXY); ProxyBypassListSelector ps = new ProxyBypassListSelector("http://192.*", delegate); List result = ps.select(new URI("http://192.168.0.100:81/test.data")); assertEquals(Proxy.NO_PROXY, result.get(0)); } } proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/util/000077500000000000000000000000001302662252000300405ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/util/PListParserTest.java000066400000000000000000000063601302662252000337600ustar00rootroot00000000000000package com.github.markusbernhardt.proxy.util; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import org.junit.BeforeClass; import org.junit.Test; import com.github.markusbernhardt.proxy.TestUtil; import com.github.markusbernhardt.proxy.util.PListParser.Dict; import com.github.markusbernhardt.proxy.util.PListParser.XmlParseException; /***************************************************************************** * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class PListParserTest { private static final String TEST_SETTINGS = TestUtil.TEST_DATA_FOLDER + File.separator + "osx" + File.separator + "osx_all.plist"; private static Dict pList; /************************************************************************* * Setup the dictionary from the test data file. ************************************************************************/ @BeforeClass public static void setupClass() throws XmlParseException, IOException { pList = PListParser.load(new File(TEST_SETTINGS)); } /** * Test method for {@link com.btr.proxy.util.PListParser#load(java.io.File)} * . */ @Test public void testLoadFile() { assertTrue(pList.size() > 0); } /************************************************************************* * Test method ************************************************************************/ @Test public void testStructure() { String currentSet = (String) pList.get("CurrentSet"); assertNotNull(currentSet); Object networkServices = pList.get("NetworkServices"); assertTrue(networkServices instanceof Dict); } /************************************************************************* * Test method ************************************************************************/ @Test public void testNavigate() { Object result = pList.getAtPath("NetworkServices/299B07C0-D0E0-4840-8486-9E77B9ED84DB/AppleTalk"); assertNotNull(result); assertTrue(result instanceof Dict); } /************************************************************************* * Test method ************************************************************************/ @Test public void testNavigate2() { Object result = pList.getAtPath("/NetworkServices/299B07C0-D0E0-4840-8486-9E77B9ED84DB/AppleTalk"); assertNotNull(result); assertTrue(result instanceof Dict); } /************************************************************************* * Test method ************************************************************************/ @Test public void testNavigate3() { Object result = pList.getAtPath("/NetworkServices/299B07C0-D0E0-4840-8486-9E77B9ED84DB/AppleTalk/"); assertNotNull(result); assertTrue(result instanceof Dict); } /************************************************************************* * Test method ************************************************************************/ @Test public void testNavigate4() { Object result = pList.getAtPath("/NetworkServices/299B07C0-D0E0-4840-8486-9E77B9ED84DB/AppleTalkXXX/"); assertNull(result); } } proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/util/ProxyUtilTest.java000066400000000000000000000074701302662252000335320ustar00rootroot00000000000000package com.github.markusbernhardt.proxy.util; import static org.junit.Assert.assertEquals; import java.net.Proxy; import java.util.List; import org.junit.Test; import com.github.markusbernhardt.proxy.TestUtil; import com.github.markusbernhardt.proxy.selector.fixed.FixedProxySelector; import com.github.markusbernhardt.proxy.util.ProxyUtil; /***************************************************************************** * Unit tests for proxy util methods * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class ProxyUtilTest { /************************************************************************* * Test parsing method. ************************************************************************/ @Test public void testParseProxySettings() { FixedProxySelector rs = ProxyUtil.parseProxySettings("http://http_proxy.unit-test.invalid/"); List psList = rs.select(TestUtil.HTTP_TEST_URI); assertEquals("HTTP @ http_proxy.unit-test.invalid:80", psList.get(0).toString()); } /************************************************************************* * Test parsing method. ************************************************************************/ @Test public void testParseProxySettings2() { FixedProxySelector rs = ProxyUtil.parseProxySettings("http://http_proxy.unit-test.invalid:8080/"); List psList = rs.select(TestUtil.HTTP_TEST_URI); assertEquals("HTTP @ http_proxy.unit-test.invalid:8080", psList.get(0).toString()); } /************************************************************************* * Test parsing method. ************************************************************************/ @Test public void testParseProxySettings3() { FixedProxySelector rs = ProxyUtil.parseProxySettings("http_proxy.unit-test.invalid"); List psList = rs.select(TestUtil.HTTP_TEST_URI); assertEquals("HTTP @ http_proxy.unit-test.invalid:80", psList.get(0).toString()); } /************************************************************************* * Test parsing method. ************************************************************************/ @Test public void testParseProxySettings4() { FixedProxySelector rs = ProxyUtil.parseProxySettings("http_proxy.unit-test.invalid:8080"); List psList = rs.select(TestUtil.HTTP_TEST_URI); assertEquals("HTTP @ http_proxy.unit-test.invalid:8080", psList.get(0).toString()); } /************************************************************************* * Test parsing method. ************************************************************************/ @Test public void testParseProxySettings5() { FixedProxySelector rs = ProxyUtil.parseProxySettings("192.123.123.1:8080"); List psList = rs.select(TestUtil.HTTP_TEST_URI); assertEquals("HTTP @ 192.123.123.1:8080", psList.get(0).toString()); } /************************************************************************* * Test parsing method. ************************************************************************/ @Test public void testParseIPv6WithoutProtocol() { FixedProxySelector rs = ProxyUtil.parseProxySettings("[2001:4860:0:2001::68]:8080"); List psList = rs.select(TestUtil.HTTP_TEST_URI); assertEquals("HTTP @ 2001:4860:0:2001::68:8080", psList.get(0).toString()); } /************************************************************************* * Test parsing method. ************************************************************************/ @Test public void testParseIPv6WithProtocol() { FixedProxySelector rs = ProxyUtil.parseProxySettings("http://[2001:4860:0:2001::68]:8080/"); List psList = rs.select(TestUtil.HTTP_TEST_URI); assertEquals("HTTP @ 2001:4860:0:2001::68:8080", psList.get(0).toString()); } } proxy-vole-proxy-vole-1.0.3/src/test/java/com/github/markusbernhardt/proxy/util/UriFilterTest.java000066400000000000000000000135661302662252000334630ustar00rootroot00000000000000package com.github.markusbernhardt.proxy.util; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.net.URI; import java.net.URISyntaxException; import org.junit.Test; import com.github.markusbernhardt.proxy.TestUtil; import com.github.markusbernhardt.proxy.selector.whitelist.HostnameFilter; import com.github.markusbernhardt.proxy.selector.whitelist.IpRangeFilter; import com.github.markusbernhardt.proxy.selector.whitelist.HostnameFilter.Mode; import com.github.markusbernhardt.proxy.util.UriFilter; /***************************************************************************** * Some unit tests for the UriFilter class. * * @author Markus Bernhardt, Copyright 2016 * @author Bernd Rosstauscher, Copyright 2009 ****************************************************************************/ public class UriFilterTest { /************************************************************************* * Test method ************************************************************************/ @Test public void testBeginsWithFilter1() { UriFilter filter = new HostnameFilter(Mode.BEGINS_WITH, "no_proxy"); assertTrue(filter.accept(TestUtil.NO_PROXY_TEST_URI)); } /************************************************************************* * Test method ************************************************************************/ @Test public void testBeginsWithFilter2() { UriFilter filter = new HostnameFilter(Mode.BEGINS_WITH, "no_proxy"); assertFalse(filter.accept(TestUtil.HTTP_TEST_URI)); } /************************************************************************* * Test method * * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testBeginsWithFilter3() throws URISyntaxException { UriFilter filter = new HostnameFilter(Mode.BEGINS_WITH, "192.168.0"); assertTrue(filter.accept(new URI("http://192.168.0.100:81/test.data"))); } /************************************************************************* * Test method * * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testBeginsWithFilter4() throws URISyntaxException { UriFilter filter = new HostnameFilter(Mode.BEGINS_WITH, "192.168.0"); assertFalse(filter.accept(new URI("http://192.168.1.100:81/test.data"))); } /************************************************************************* * Test method ************************************************************************/ @Test public void testBeginsWithFilter() { UriFilter filter = new HostnameFilter(Mode.BEGINS_WITH, "no_proxy"); assertTrue(filter.accept(TestUtil.NO_PROXY_TEST_URI)); assertFalse(filter.accept(TestUtil.HTTP_TEST_URI)); } /************************************************************************* * Test method * * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testEndsWithFilter() throws URISyntaxException { UriFilter filter = new HostnameFilter(Mode.ENDS_WITH, ".unit-test.invalid"); assertTrue(filter.accept(TestUtil.NO_PROXY_TEST_URI)); } /************************************************************************* * Test method * * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testEndsWithFilter2() throws URISyntaxException { UriFilter filter = new HostnameFilter(Mode.ENDS_WITH, ".unit-test.invalid"); assertFalse(filter.accept(new URI("http://test.no-host.invalid:81/test.data"))); } /************************************************************************* * Test method * * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testEndsWithFilter3() throws URISyntaxException { UriFilter filter = new HostnameFilter(Mode.ENDS_WITH, ".100"); assertTrue(filter.accept(new URI("http://192.168.1.100:81/test.data"))); } /************************************************************************* * Test method * * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testIpRangeFilter() throws URISyntaxException { UriFilter filter = new IpRangeFilter("192.168.0.0/24"); assertTrue(filter.accept(new URI("http://192.168.0.100:81/test.data"))); assertFalse(filter.accept(new URI("http://192.168.1.100:81/test.data"))); } /************************************************************************* * Test method * * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testIp6RangeFilter() throws URISyntaxException { UriFilter filter = new IpRangeFilter("2001:4860:0:2001::/24"); assertTrue(filter.accept(new URI("http://[2001:4860:0:2001::68]:81/test.data"))); assertFalse(filter.accept(new URI("http://[3001:4860:0:2001::68]:81/test.data"))); } /************************************************************************* * Test method * * @throws URISyntaxException * on invalid URL syntax. ************************************************************************/ @Test public void testWithProtocolFilter() throws URISyntaxException { UriFilter filter = new HostnameFilter(Mode.BEGINS_WITH, "http://192.168.0.100"); assertTrue(filter.accept(new URI("http://192.168.0.100:81/test.data"))); assertFalse(filter.accept(new URI("ftp://192.168.0.100:81/test.data"))); assertFalse(filter.accept(new URI("http://192.168.1.100:81/test.data"))); } } proxy-vole-proxy-vole-1.0.3/src/test/resources/000077500000000000000000000000001302662252000215375ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_manual/000077500000000000000000000000001302662252000235525ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_manual/.mozilla/000077500000000000000000000000001302662252000252775ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_manual/.mozilla/firefox/000077500000000000000000000000001302662252000267415ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_manual/.mozilla/firefox/9f1uyzzu.default/000077500000000000000000000000001302662252000321125ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_manual/.mozilla/firefox/9f1uyzzu.default/prefs.js000066400000000000000000000126211302662252000335710ustar00rootroot00000000000000# Mozilla User Preferences /* Do not edit this file. * * If you make changes to this file while the application is running, * the changes will be overwritten when the application exits. * * To make a manual change to preferences, you can visit the URL about:config * For more information, see http://www.mozilla.org/unix/customizing.html#prefs */ user_pref("accessibility.typeaheadfind.flashBar", 0); user_pref("app.update.auto", false); user_pref("app.update.lastUpdateTime.addon-background-update-timer", 1243108090); user_pref("app.update.lastUpdateTime.background-update-timer", 1243108090); user_pref("app.update.lastUpdateTime.blocklist-background-update-timer", 1243108090); user_pref("app.update.lastUpdateTime.microsummary-generator-update-timer", 1242676783); user_pref("app.update.lastUpdateTime.search-engine-update-timer", 1243156646); user_pref("browser.download.dir", "/home/rossi/Downloads"); user_pref("browser.download.folderList", 2); user_pref("browser.download.lastDir", "/home/rossi/Dokumente"); user_pref("browser.download.save_converter_index", 0); user_pref("browser.feeds.showFirstRunUI", false); user_pref("browser.history_expire_days.mirror", 180); user_pref("browser.history_expire_days_min", 3); user_pref("browser.migration.version", 1); user_pref("browser.places.importBookmarksHTML", false); user_pref("browser.places.importDefaults", false); user_pref("browser.places.leftPaneFolderId", -1); user_pref("browser.places.migratePostDataAnnotations", false); user_pref("browser.places.smartBookmarksVersion", 1); user_pref("browser.places.updateRecentTagsUri", false); user_pref("browser.preferences.advanced.selectedTabIndex", 1); user_pref("browser.rights.3.shown", true); user_pref("browser.startup.homepage_override.mstone", "rv:1.9.0.10"); user_pref("browser.startup.page", 0); user_pref("capability.policy.maonoscript.javascript.enabled", "allAccess"); user_pref("capability.policy.maonoscript.sites", "addons.mozilla.org cineplex.de flashgot.net google.com googlesyndication.com hotmail.com informaction.com live.com maone.net msn.com noscript.net passport.com passport.net passportimages.com yahoo.com yimg.com about: about:blank about:certerror about:config about:credits about:neterror about:plugins about:privatebrowsing about:sessionrestore chrome: file://cineplex.de file://flashgot.net file://google.com file://googlesyndication.com file://hotmail.com file://informaction.com file://live.com file://maone.net file://msn.com file://noscript.net file://passport.com file://passport.net file://passportimages.com file://yahoo.com file://yimg.com http://cineplex.de http://flashgot.net http://google.com http://googlesyndication.com http://hotmail.com http://informaction.com http://live.com http://maone.net http://msn.com http://noscript.net http://passport.com http://passport.net http://passportimages.com http://yahoo.com http://yimg.com https://cineplex.de https://flashgot.net https://google.com https://googlesyndication.com https://hotmail.com https://informaction.com https://live.com https://maone.net https://msn.com https://noscript.net https://passport.com https://passport.net https://passportimages.com https://yahoo.com https://yimg.com resource:"); user_pref("distribution.canonical.bookmarksProcessed", true); user_pref("dom.disable_window_move_resize", true); user_pref("dom.event.contextmenu.enabled", false); user_pref("extensions.adblockplus.currentVersion", "1.0.2"); user_pref("extensions.enabledItems", "{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}:1.0.2,langpack-de@firefox-3.0.ubuntu.com:3.0.7,langpack-en-GB@firefox-3.0.ubuntu.com:3.0.7,{73a6fe31-595d-460b-a920-fcc0f8843232}:1.9.2.8,langpack-de@xulrunner-1.9.ubuntu.com:1.9.0.8,langpack-en-GB@xulrunner-1.9.ubuntu.com:1.9.0.8,{972ce4c6-7e08-4474-a285-3208198ce6fd}:3.0.10"); user_pref("extensions.lastAppVersion", "3.0.10"); user_pref("extensions.update.notifyUser", false); user_pref("intl.charsetmenu.browser.cache", "us-ascii, ISO-8859-15, ISO-8859-1, UTF-8, windows-1252"); user_pref("javascript.enabled", true); user_pref("network.cookie.lifetimePolicy", 2); user_pref("network.cookie.prefsMigrated", true); user_pref("network.proxy.autoconfig_url", "http://www.xxx.de/"); user_pref("network.proxy.ftp", "ftp_proxy.unit-test.invalid"); user_pref("network.proxy.ftp_port", 8092); user_pref("network.proxy.gopher", "gopher_proxy.unit-test.invalid"); user_pref("network.proxy.gopher_port", 8093); user_pref("network.proxy.http", "http_proxy.unit-test.invalid"); user_pref("network.proxy.http_port", 8090); user_pref("network.proxy.socks", "socks_proxy.unit-test.invalid"); user_pref("network.proxy.socks_port", 8095); user_pref("network.proxy.socks_version", 4); user_pref("network.proxy.ssl", "https_proxy.unit-test.invalid"); user_pref("network.proxy.ssl_port", 8091); user_pref("network.proxy.type", 1); user_pref("noscript.badInstall", false); user_pref("noscript.global", true); user_pref("noscript.gtemp", ""); user_pref("noscript.notify", false); user_pref("noscript.options.tabSelectedIndexes", "5,4,1"); user_pref("noscript.policynames", ""); user_pref("noscript.temp", ""); user_pref("noscript.version", "1.9.2.8"); user_pref("pref.advanced.javascript.disable_button.advanced", false); user_pref("pref.downloads.disable_button.edit_actions", false); user_pref("privacy.item.offlineApps", true); user_pref("signon.rememberSignons", false); user_pref("spellchecker.dictionary", "de_AT"); user_pref("urlclassifier.keyupdatetime.https://sb-ssl.google.com/safebrowsing/newkey", 1243725238); proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_manual/.mozilla/firefox/profiles.ini000066400000000000000000000001361302662252000312650ustar00rootroot00000000000000[General] StartWithLastProfile=1 [Profile0] Name=default IsRelative=1 Path=9f1uyzzu.default proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_none/000077500000000000000000000000001302662252000232345ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_none/.mozilla/000077500000000000000000000000001302662252000247615ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_none/.mozilla/firefox/000077500000000000000000000000001302662252000264235ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_none/.mozilla/firefox/9f1uyzzu.default/000077500000000000000000000000001302662252000315745ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_none/.mozilla/firefox/9f1uyzzu.default/prefs.js000066400000000000000000000125471302662252000332620ustar00rootroot00000000000000# Mozilla User Preferences /* Do not edit this file. * * If you make changes to this file while the application is running, * the changes will be overwritten when the application exits. * * To make a manual change to preferences, you can visit the URL about:config * For more information, see http://www.mozilla.org/unix/customizing.html#prefs */ user_pref("accessibility.typeaheadfind.flashBar", 0); user_pref("app.update.auto", false); user_pref("app.update.lastUpdateTime.addon-background-update-timer", 1243108090); user_pref("app.update.lastUpdateTime.background-update-timer", 1243108090); user_pref("app.update.lastUpdateTime.blocklist-background-update-timer", 1243108090); user_pref("app.update.lastUpdateTime.microsummary-generator-update-timer", 1242676783); user_pref("app.update.lastUpdateTime.search-engine-update-timer", 1243156646); user_pref("browser.download.dir", "/home/rossi/Downloads"); user_pref("browser.download.folderList", 2); user_pref("browser.download.lastDir", "/home/rossi/Dokumente"); user_pref("browser.download.save_converter_index", 0); user_pref("browser.feeds.showFirstRunUI", false); user_pref("browser.history_expire_days.mirror", 180); user_pref("browser.history_expire_days_min", 3); user_pref("browser.migration.version", 1); user_pref("browser.places.importBookmarksHTML", false); user_pref("browser.places.importDefaults", false); user_pref("browser.places.leftPaneFolderId", -1); user_pref("browser.places.migratePostDataAnnotations", false); user_pref("browser.places.smartBookmarksVersion", 1); user_pref("browser.places.updateRecentTagsUri", false); user_pref("browser.preferences.advanced.selectedTabIndex", 1); user_pref("browser.rights.3.shown", true); user_pref("browser.startup.homepage_override.mstone", "rv:1.9.0.10"); user_pref("browser.startup.page", 0); user_pref("capability.policy.maonoscript.javascript.enabled", "allAccess"); user_pref("capability.policy.maonoscript.sites", "addons.mozilla.org cineplex.de flashgot.net google.com googlesyndication.com hotmail.com informaction.com live.com maone.net msn.com noscript.net passport.com passport.net passportimages.com yahoo.com yimg.com about: about:blank about:certerror about:config about:credits about:neterror about:plugins about:privatebrowsing about:sessionrestore chrome: file://cineplex.de file://flashgot.net file://google.com file://googlesyndication.com file://hotmail.com file://informaction.com file://live.com file://maone.net file://msn.com file://noscript.net file://passport.com file://passport.net file://passportimages.com file://yahoo.com file://yimg.com http://cineplex.de http://flashgot.net http://google.com http://googlesyndication.com http://hotmail.com http://informaction.com http://live.com http://maone.net http://msn.com http://noscript.net http://passport.com http://passport.net http://passportimages.com http://yahoo.com http://yimg.com https://cineplex.de https://flashgot.net https://google.com https://googlesyndication.com https://hotmail.com https://informaction.com https://live.com https://maone.net https://msn.com https://noscript.net https://passport.com https://passport.net https://passportimages.com https://yahoo.com https://yimg.com resource:"); user_pref("distribution.canonical.bookmarksProcessed", true); user_pref("dom.disable_window_move_resize", true); user_pref("dom.event.contextmenu.enabled", false); user_pref("extensions.adblockplus.currentVersion", "1.0.2"); user_pref("extensions.enabledItems", "{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}:1.0.2,langpack-de@firefox-3.0.ubuntu.com:3.0.7,langpack-en-GB@firefox-3.0.ubuntu.com:3.0.7,{73a6fe31-595d-460b-a920-fcc0f8843232}:1.9.2.8,langpack-de@xulrunner-1.9.ubuntu.com:1.9.0.8,langpack-en-GB@xulrunner-1.9.ubuntu.com:1.9.0.8,{972ce4c6-7e08-4474-a285-3208198ce6fd}:3.0.10"); user_pref("extensions.lastAppVersion", "3.0.10"); user_pref("extensions.update.notifyUser", false); user_pref("intl.charsetmenu.browser.cache", "us-ascii, ISO-8859-15, ISO-8859-1, UTF-8, windows-1252"); user_pref("javascript.enabled", true); user_pref("network.cookie.lifetimePolicy", 2); user_pref("network.cookie.prefsMigrated", true); user_pref("network.proxy.autoconfig_url", "http://www.xxx.de/"); user_pref("network.proxy.ftp", "Test2"); user_pref("network.proxy.ftp_port", 222); user_pref("network.proxy.gopher", "Test3"); user_pref("network.proxy.gopher_port", 333); user_pref("network.proxy.http", "TEST"); user_pref("network.proxy.http_port", 999); user_pref("network.proxy.no_proxies_on", "localhost, 127.0.0.1, test4454,"); user_pref("network.proxy.socks", "Test4"); user_pref("network.proxy.socks_port", 444); user_pref("network.proxy.socks_version", 4); user_pref("network.proxy.ssl", "Test1"); user_pref("network.proxy.ssl_port", 111); user_pref("network.proxy.type", 0); user_pref("noscript.badInstall", false); user_pref("noscript.global", true); user_pref("noscript.gtemp", ""); user_pref("noscript.notify", false); user_pref("noscript.options.tabSelectedIndexes", "5,4,1"); user_pref("noscript.policynames", ""); user_pref("noscript.temp", ""); user_pref("noscript.version", "1.9.2.8"); user_pref("pref.advanced.javascript.disable_button.advanced", false); user_pref("pref.downloads.disable_button.edit_actions", false); user_pref("privacy.item.offlineApps", true); user_pref("signon.rememberSignons", false); user_pref("spellchecker.dictionary", "de_AT"); user_pref("urlclassifier.keyupdatetime.https://sb-ssl.google.com/safebrowsing/newkey", 1243725238); proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_none/.mozilla/firefox/profiles.ini000066400000000000000000000001361302662252000307470ustar00rootroot00000000000000[General] StartWithLastProfile=1 [Profile0] Name=default IsRelative=1 Path=9f1uyzzu.default proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_pac_script/000077500000000000000000000000001302662252000244245ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_pac_script/.mozilla/000077500000000000000000000000001302662252000261515ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_pac_script/.mozilla/firefox/000077500000000000000000000000001302662252000276135ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_pac_script/.mozilla/firefox/9f1uyzzu.default/000077500000000000000000000000001302662252000327645ustar00rootroot00000000000000prefs.js000066400000000000000000000126371302662252000343730ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_pac_script/.mozilla/firefox/9f1uyzzu.default# Mozilla User Preferences /* Do not edit this file. * * If you make changes to this file while the application is running, * the changes will be overwritten when the application exits. * * To make a manual change to preferences, you can visit the URL about:config * For more information, see http://www.mozilla.org/unix/customizing.html#prefs */ user_pref("accessibility.typeaheadfind.flashBar", 0); user_pref("app.update.auto", false); user_pref("app.update.lastUpdateTime.addon-background-update-timer", 1243108090); user_pref("app.update.lastUpdateTime.background-update-timer", 1243108090); user_pref("app.update.lastUpdateTime.blocklist-background-update-timer", 1243108090); user_pref("app.update.lastUpdateTime.microsummary-generator-update-timer", 1242676783); user_pref("app.update.lastUpdateTime.search-engine-update-timer", 1243156646); user_pref("browser.download.dir", "/home/rossi/Downloads"); user_pref("browser.download.folderList", 2); user_pref("browser.download.lastDir", "/home/rossi/Dokumente"); user_pref("browser.download.save_converter_index", 0); user_pref("browser.feeds.showFirstRunUI", false); user_pref("browser.history_expire_days.mirror", 180); user_pref("browser.history_expire_days_min", 3); user_pref("browser.migration.version", 1); user_pref("browser.places.importBookmarksHTML", false); user_pref("browser.places.importDefaults", false); user_pref("browser.places.leftPaneFolderId", -1); user_pref("browser.places.migratePostDataAnnotations", false); user_pref("browser.places.smartBookmarksVersion", 1); user_pref("browser.places.updateRecentTagsUri", false); user_pref("browser.preferences.advanced.selectedTabIndex", 1); user_pref("browser.rights.3.shown", true); user_pref("browser.startup.homepage_override.mstone", "rv:1.9.0.10"); user_pref("browser.startup.page", 0); user_pref("capability.policy.maonoscript.javascript.enabled", "allAccess"); user_pref("capability.policy.maonoscript.sites", "addons.mozilla.org cineplex.de flashgot.net google.com googlesyndication.com hotmail.com informaction.com live.com maone.net msn.com noscript.net passport.com passport.net passportimages.com yahoo.com yimg.com about: about:blank about:certerror about:config about:credits about:neterror about:plugins about:privatebrowsing about:sessionrestore chrome: file://cineplex.de file://flashgot.net file://google.com file://googlesyndication.com file://hotmail.com file://informaction.com file://live.com file://maone.net file://msn.com file://noscript.net file://passport.com file://passport.net file://passportimages.com file://yahoo.com file://yimg.com http://cineplex.de http://flashgot.net http://google.com http://googlesyndication.com http://hotmail.com http://informaction.com http://live.com http://maone.net http://msn.com http://noscript.net http://passport.com http://passport.net http://passportimages.com http://yahoo.com http://yimg.com https://cineplex.de https://flashgot.net https://google.com https://googlesyndication.com https://hotmail.com https://informaction.com https://live.com https://maone.net https://msn.com https://noscript.net https://passport.com https://passport.net https://passportimages.com https://yahoo.com https://yimg.com resource:"); user_pref("distribution.canonical.bookmarksProcessed", true); user_pref("dom.disable_window_move_resize", true); user_pref("dom.event.contextmenu.enabled", false); user_pref("extensions.adblockplus.currentVersion", "1.0.2"); user_pref("extensions.enabledItems", "{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}:1.0.2,langpack-de@firefox-3.0.ubuntu.com:3.0.7,langpack-en-GB@firefox-3.0.ubuntu.com:3.0.7,{73a6fe31-595d-460b-a920-fcc0f8843232}:1.9.2.8,langpack-de@xulrunner-1.9.ubuntu.com:1.9.0.8,langpack-en-GB@xulrunner-1.9.ubuntu.com:1.9.0.8,{972ce4c6-7e08-4474-a285-3208198ce6fd}:3.0.10"); user_pref("extensions.lastAppVersion", "3.0.10"); user_pref("extensions.update.notifyUser", false); user_pref("intl.charsetmenu.browser.cache", "us-ascii, ISO-8859-15, ISO-8859-1, UTF-8, windows-1252"); user_pref("javascript.enabled", true); user_pref("network.cookie.lifetimePolicy", 2); user_pref("network.cookie.prefsMigrated", true); user_pref("network.proxy.autoconfig_url", "src/test/resources/pac/test1.pac"); user_pref("network.proxy.ftp", "ftp_proxy.unit-test.invalid"); user_pref("network.proxy.ftp_port", 8092); user_pref("network.proxy.gopher", "gopher_proxy.unit-test.invalid"); user_pref("network.proxy.gopher_port", 8093); user_pref("network.proxy.http", "http_proxy.unit-test.invalid"); user_pref("network.proxy.http_port", 8090); user_pref("network.proxy.socks", "socks_proxy.unit-test.invalid"); user_pref("network.proxy.socks_port", 8095); user_pref("network.proxy.socks_version", 4); user_pref("network.proxy.ssl", "https_proxy.unit-test.invalid"); user_pref("network.proxy.ssl_port", 8091); user_pref("network.proxy.type", 2); user_pref("noscript.badInstall", false); user_pref("noscript.global", true); user_pref("noscript.gtemp", ""); user_pref("noscript.notify", false); user_pref("noscript.options.tabSelectedIndexes", "5,4,1"); user_pref("noscript.policynames", ""); user_pref("noscript.temp", ""); user_pref("noscript.version", "1.9.2.8"); user_pref("pref.advanced.javascript.disable_button.advanced", false); user_pref("pref.downloads.disable_button.edit_actions", false); user_pref("privacy.item.offlineApps", true); user_pref("signon.rememberSignons", false); user_pref("spellchecker.dictionary", "de_AT"); user_pref("urlclassifier.keyupdatetime.https://sb-ssl.google.com/safebrowsing/newkey", 1243725238); proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_pac_script/.mozilla/firefox/profiles.ini000066400000000000000000000001361302662252000321370ustar00rootroot00000000000000[General] StartWithLastProfile=1 [Profile0] Name=default IsRelative=1 Path=9f1uyzzu.default proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_white_list/000077500000000000000000000000001302662252000244505ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_white_list/.mozilla/000077500000000000000000000000001302662252000261755ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_white_list/.mozilla/firefox/000077500000000000000000000000001302662252000276375ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_white_list/.mozilla/firefox/9f1uyzzu.default/000077500000000000000000000000001302662252000330105ustar00rootroot00000000000000prefs.js000066400000000000000000000127631302662252000344170ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_white_list/.mozilla/firefox/9f1uyzzu.default# Mozilla User Preferences /* Do not edit this file. * * If you make changes to this file while the application is running, * the changes will be overwritten when the application exits. * * To make a manual change to preferences, you can visit the URL about:config * For more information, see http://www.mozilla.org/unix/customizing.html#prefs */ user_pref("accessibility.typeaheadfind.flashBar", 0); user_pref("app.update.auto", false); user_pref("app.update.lastUpdateTime.addon-background-update-timer", 1243108090); user_pref("app.update.lastUpdateTime.background-update-timer", 1243108090); user_pref("app.update.lastUpdateTime.blocklist-background-update-timer", 1243108090); user_pref("app.update.lastUpdateTime.microsummary-generator-update-timer", 1242676783); user_pref("app.update.lastUpdateTime.search-engine-update-timer", 1243156646); user_pref("browser.download.dir", "/home/rossi/Downloads"); user_pref("browser.download.folderList", 2); user_pref("browser.download.lastDir", "/home/rossi/Dokumente"); user_pref("browser.download.save_converter_index", 0); user_pref("browser.feeds.showFirstRunUI", false); user_pref("browser.history_expire_days.mirror", 180); user_pref("browser.history_expire_days_min", 3); user_pref("browser.migration.version", 1); user_pref("browser.places.importBookmarksHTML", false); user_pref("browser.places.importDefaults", false); user_pref("browser.places.leftPaneFolderId", -1); user_pref("browser.places.migratePostDataAnnotations", false); user_pref("browser.places.smartBookmarksVersion", 1); user_pref("browser.places.updateRecentTagsUri", false); user_pref("browser.preferences.advanced.selectedTabIndex", 1); user_pref("browser.rights.3.shown", true); user_pref("browser.startup.homepage_override.mstone", "rv:1.9.0.10"); user_pref("browser.startup.page", 0); user_pref("capability.policy.maonoscript.javascript.enabled", "allAccess"); user_pref("capability.policy.maonoscript.sites", "addons.mozilla.org cineplex.de flashgot.net google.com googlesyndication.com hotmail.com informaction.com live.com maone.net msn.com noscript.net passport.com passport.net passportimages.com yahoo.com yimg.com about: about:blank about:certerror about:config about:credits about:neterror about:plugins about:privatebrowsing about:sessionrestore chrome: file://cineplex.de file://flashgot.net file://google.com file://googlesyndication.com file://hotmail.com file://informaction.com file://live.com file://maone.net file://msn.com file://noscript.net file://passport.com file://passport.net file://passportimages.com file://yahoo.com file://yimg.com http://cineplex.de http://flashgot.net http://google.com http://googlesyndication.com http://hotmail.com http://informaction.com http://live.com http://maone.net http://msn.com http://noscript.net http://passport.com http://passport.net http://passportimages.com http://yahoo.com http://yimg.com https://cineplex.de https://flashgot.net https://google.com https://googlesyndication.com https://hotmail.com https://informaction.com https://live.com https://maone.net https://msn.com https://noscript.net https://passport.com https://passport.net https://passportimages.com https://yahoo.com https://yimg.com resource:"); user_pref("distribution.canonical.bookmarksProcessed", true); user_pref("dom.disable_window_move_resize", true); user_pref("dom.event.contextmenu.enabled", false); user_pref("extensions.adblockplus.currentVersion", "1.0.2"); user_pref("extensions.enabledItems", "{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}:1.0.2,langpack-de@firefox-3.0.ubuntu.com:3.0.7,langpack-en-GB@firefox-3.0.ubuntu.com:3.0.7,{73a6fe31-595d-460b-a920-fcc0f8843232}:1.9.2.8,langpack-de@xulrunner-1.9.ubuntu.com:1.9.0.8,langpack-en-GB@xulrunner-1.9.ubuntu.com:1.9.0.8,{972ce4c6-7e08-4474-a285-3208198ce6fd}:3.0.10"); user_pref("extensions.lastAppVersion", "3.0.10"); user_pref("extensions.update.notifyUser", false); user_pref("intl.charsetmenu.browser.cache", "us-ascii, ISO-8859-15, ISO-8859-1, UTF-8, windows-1252"); user_pref("javascript.enabled", true); user_pref("network.cookie.lifetimePolicy", 2); user_pref("network.cookie.prefsMigrated", true); user_pref("network.proxy.autoconfig_url", "file://~/wpad/wpad.txt"); user_pref("network.proxy.ftp", "ftp_proxy.unit-test.invalid"); user_pref("network.proxy.ftp_port", 8092); user_pref("network.proxy.gopher", "gopher_proxy.unit-test.invalid"); user_pref("network.proxy.gopher_port", 8093); user_pref("network.proxy.http", "http_proxy.unit-test.invalid"); user_pref("network.proxy.http_port", 8090); user_pref("network.proxy.no_proxies_on", "localhost, 127.0.0.1, no_proxy.unit-test.invalid"); user_pref("network.proxy.socks", "socks_proxy.unit-test.invalid"); user_pref("network.proxy.socks_port", 8095); user_pref("network.proxy.socks_version", 4); user_pref("network.proxy.ssl", "https_proxy.unit-test.invalid"); user_pref("network.proxy.ssl_port", 8091); user_pref("network.proxy.type", 1); user_pref("noscript.badInstall", false); user_pref("noscript.global", true); user_pref("noscript.gtemp", ""); user_pref("noscript.notify", false); user_pref("noscript.options.tabSelectedIndexes", "5,4,1"); user_pref("noscript.policynames", ""); user_pref("noscript.temp", ""); user_pref("noscript.version", "1.9.2.8"); user_pref("pref.advanced.javascript.disable_button.advanced", false); user_pref("pref.downloads.disable_button.edit_actions", false); user_pref("privacy.item.offlineApps", true); user_pref("signon.rememberSignons", false); user_pref("spellchecker.dictionary", "de_AT"); user_pref("urlclassifier.keyupdatetime.https://sb-ssl.google.com/safebrowsing/newkey", 1243725238); proxy-vole-proxy-vole-1.0.3/src/test/resources/ff3_white_list/.mozilla/firefox/profiles.ini000066400000000000000000000001361302662252000321630ustar00rootroot00000000000000[General] StartWithLastProfile=1 [Profile0] Name=default IsRelative=1 Path=9f1uyzzu.default proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_manual/000077500000000000000000000000001302662252000242015ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_manual/.gconf/000077500000000000000000000000001302662252000253535ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_manual/.gconf/system/000077500000000000000000000000001302662252000266775ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_manual/.gconf/system/http_proxy/000077500000000000000000000000001302662252000311175ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_manual/.gconf/system/http_proxy/%gconf.xml000077500000000000000000000016411302662252000330070ustar00rootroot00000000000000
  • localhost
  • 127.0.0.0/8
  • *.local
  • http_proxy.unit-test.invalid
    proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_manual/.gconf/system/proxy/000077500000000000000000000000001302662252000300605ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_manual/.gconf/system/proxy/%gconf.xml000077500000000000000000000031341302662252000317470ustar00rootroot00000000000000 sodddddd ftpproxy sslproxy socks_proxy.unit-test.invalid ftp_proxy.unit-test.invalid https_proxy.unit-test.invalid manual proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_none/000077500000000000000000000000001302662252000236635ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_none/.gconf/000077500000000000000000000000001302662252000250355ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_none/.gconf/system/000077500000000000000000000000001302662252000263615ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_none/.gconf/system/http_proxy/000077500000000000000000000000001302662252000306015ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_none/.gconf/system/http_proxy/%gconf.xml000077500000000000000000000014771302662252000325000ustar00rootroot00000000000000
  • localhost
  • 127.0.0.0/8
  • *.local
  • test.proxy.invalid
    proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_pac_script/000077500000000000000000000000001302662252000250535ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_pac_script/.gconf/000077500000000000000000000000001302662252000262255ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_pac_script/.gconf/system/000077500000000000000000000000001302662252000275515ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_pac_script/.gconf/system/http_proxy/000077500000000000000000000000001302662252000317715ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_pac_script/.gconf/system/http_proxy/%gconf.xml000077500000000000000000000020501302662252000336540ustar00rootroot00000000000000
  • localhost
  • 127.0.0.0/8
  • *.local
  • no_proxy.unit-test.invalid
  • http_proxy.unit-test.invalid
    proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_pac_script/.gconf/system/proxy/000077500000000000000000000000001302662252000307325ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_pac_script/.gconf/system/proxy/%gconf.xml000077500000000000000000000033761302662252000326310ustar00rootroot00000000000000 src/test/resources/pac/test1.pac sodddddd ftpproxy sslproxy socks_proxy.unit-test.invalid ftp_proxy.unit-test.invalid https_proxy.unit-test.invalid auto proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_white_list/000077500000000000000000000000001302662252000250775ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_white_list/.gconf/000077500000000000000000000000001302662252000262515ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_white_list/.gconf/system/000077500000000000000000000000001302662252000275755ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_white_list/.gconf/system/http_proxy/000077500000000000000000000000001302662252000320155ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_white_list/.gconf/system/http_proxy/%gconf.xml000077500000000000000000000020501302662252000337000ustar00rootroot00000000000000
  • localhost
  • 127.0.0.0/8
  • *.local
  • no_proxy.unit-test.invalid
  • http_proxy.unit-test.invalid
    proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_white_list/.gconf/system/proxy/000077500000000000000000000000001302662252000307565ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/gnome_white_list/.gconf/system/proxy/%gconf.xml000077500000000000000000000031341302662252000326450ustar00rootroot00000000000000 sodddddd ftpproxy sslproxy socks_proxy.unit-test.invalid ftp_proxy.unit-test.invalid https_proxy.unit-test.invalid manual proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_env/000077500000000000000000000000001302662252000231525ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_env/.kde/000077500000000000000000000000001302662252000237735ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_env/.kde/share/000077500000000000000000000000001302662252000250755ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_env/.kde/share/config/000077500000000000000000000000001302662252000263425ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_env/.kde/share/config/kioslaverc000066400000000000000000000005201302662252000304240ustar00rootroot00000000000000PersistentProxyConnection=false [$Version] update_info=kioslave.upd:kde2.2/r1,kioslave.upd:kde2.2/r2,kioslave.upd:kde2.2/r3 [Notification Messages] WarnOnLeaveSSLMode=false [Proxy Settings] AuthMode=0 NoProxyFor= Proxy Config Script= ProxyType=4 ReversedException=false ftpProxy=FTP_PROXY httpProxy=HTTP_PROXY httpsProxy=HTTPS_PROXY proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_manual/000077500000000000000000000000001302662252000236375ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_manual/.kde/000077500000000000000000000000001302662252000244605ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_manual/.kde/share/000077500000000000000000000000001302662252000255625ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_manual/.kde/share/config/000077500000000000000000000000001302662252000270275ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_manual/.kde/share/config/kioslaverc000066400000000000000000000006521302662252000311170ustar00rootroot00000000000000PersistentProxyConnection=false [$Version] update_info=kioslave.upd:kde2.2/r1,kioslave.upd:kde2.2/r2,kioslave.upd:kde2.2/r3 [Notification Messages] WarnOnLeaveSSLMode=false [Proxy Settings] AuthMode=0 NoProxyFor= Proxy Config Script= ProxyType=1 ReversedException=false ftpProxy=ftp://ftp_proxy.unit-test.invalid:8092 httpProxy=http://http_proxy.unit-test.invalid:8090 httpsProxy=https://https_proxy.unit-test.invalid:8091 proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_none/000077500000000000000000000000001302662252000233215ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_none/.kde/000077500000000000000000000000001302662252000241425ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_none/.kde/share/000077500000000000000000000000001302662252000252445ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_none/.kde/share/config/000077500000000000000000000000001302662252000265115ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_none/.kde/share/config/kioslaverc000066400000000000000000000004621302662252000306000ustar00rootroot00000000000000PersistentProxyConnection=false [$Version] update_info=kioslave.upd:kde2.2/r1,kioslave.upd:kde2.2/r2,kioslave.upd:kde2.2/r3 [Notification Messages] WarnOnLeaveSSLMode=false [Proxy Settings] AuthMode=0 NoProxyFor= Proxy Config Script= ProxyType=0 ReversedException=false ftpProxy= httpProxy= httpsProxy= proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_pac_script/000077500000000000000000000000001302662252000245115ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_pac_script/.kde/000077500000000000000000000000001302662252000253325ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_pac_script/.kde/share/000077500000000000000000000000001302662252000264345ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_pac_script/.kde/share/config/000077500000000000000000000000001302662252000277015ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_pac_script/.kde/share/config/kioslaverc000066400000000000000000000005221302662252000317650ustar00rootroot00000000000000PersistentProxyConnection=false [$Version] update_info=kioslave.upd:kde2.2/r1,kioslave.upd:kde2.2/r2,kioslave.upd:kde2.2/r3 [Notification Messages] WarnOnLeaveSSLMode=false [Proxy Settings] AuthMode=0 NoProxyFor= Proxy Config Script=src/test/resources/pac/test1.pac ProxyType=2 ReversedException=false ftpProxy= httpProxy= httpsProxy= proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_white_list/000077500000000000000000000000001302662252000245355ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_white_list/.kde/000077500000000000000000000000001302662252000253565ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_white_list/.kde/share/000077500000000000000000000000001302662252000264605ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_white_list/.kde/share/config/000077500000000000000000000000001302662252000277255ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/kde_white_list/.kde/share/config/kioslaverc000066400000000000000000000007271302662252000320200ustar00rootroot00000000000000PersistentProxyConnection=false [$Version] update_info=kioslave.upd:kde2.2/r1,kioslave.upd:kde2.2/r2,kioslave.upd:kde2.2/r3 [Notification Messages] WarnOnLeaveSSLMode=false [Proxy Settings] AuthMode=0 NoProxyFor=no_proxy.unit-test.invalid,.unit-test.invalid Proxy Config Script= ProxyType=1 ReversedException=false ftpProxy=ftp://ftp_proxy.unit-test.invalid:8092 httpProxy=http://http_proxy.unit-test.invalid:8090 httpsProxy=https://https_proxy.unit-test.invalid:8091 proxy-vole-proxy-vole-1.0.3/src/test/resources/osx/000077500000000000000000000000001302662252000223505ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/osx/osx_all.plist000066400000000000000000000067641302662252000251030ustar00rootroot00000000000000 CurrentSet /Sets/8458B09B-93EA-44C2-AD05-0B4E4A4D9651 NetworkServices 299B07C0-D0E0-4840-8486-9E77B9ED84DB AppleTalk DNS IPv4 ConfigMethod DHCP IPv6 ConfigMethod Automatic Interface DeviceName en0 Hardware Ethernet Type Ethernet UserDefinedName Ethernet Proxies ExceptionsList *.local 169.254/16 ExcludeSimpleHostnames 1 FTPEnable 1 FTPPassive 1 FTPPort 8092 FTPProxy ftp_proxy.unit-test.invalid GopherEnable 1 GopherPort 8090 GopherProxy http_proxy.unit-test.invalid HTTPEnable 1 HTTPPort 8090 HTTPProxy http_proxy.unit-test.invalid HTTPSEnable 1 HTTPSPort 8091 HTTPSProxy http_proxy.unit-test.invalid ProxyAutoConfigEnable 1 ProxyAutoConfigURLString http://http_proxy.unit-test.invalid/wpad.pac ProxyAutoDiscoveryEnable 1 RTSPEnable 1 RTSPPort 8094 RTSPProxy rtsp_proxy.unit-test.invalid SOCKSEnable 1 SOCKSPort 8095 SOCKSProxy socks_proxy.unit-test.invalid SMB UserDefinedName Ethernet Sets 8458B09B-93EA-44C2-AD05-0B4E4A4D9651 Network Global IPv4 ServiceOrder 299B07C0-D0E0-4840-8486-9E77B9ED84DB Service 299B07C0-D0E0-4840-8486-9E77B9ED84DB __LINK__ /NetworkServices/299B07C0-D0E0-4840-8486-9E77B9ED84DB UserDefinedName Automatic System Network HostNames LocalHostName rossis-Mac-mini System ComputerName rossi’s Mac mini ComputerNameEncoding 0 proxy-vole-proxy-vole-1.0.3/src/test/resources/osx/osx_manual.plist000066400000000000000000000070051302662252000255750ustar00rootroot00000000000000 CurrentSet /Sets/8458B09B-93EA-44C2-AD05-0B4E4A4D9651 NetworkServices 299B07C0-D0E0-4840-8486-9E77B9ED84DB AppleTalk DNS IPv4 ConfigMethod DHCP IPv6 ConfigMethod Automatic Interface DeviceName en0 Hardware Ethernet Type Ethernet UserDefinedName Ethernet Proxies ExceptionsList *.local no_proxy.unit-test.invalid ExcludeSimpleHostnames 1 FTPEnable 1 FTPPassive 1 FTPPort 8092 FTPProxy ftp_proxy.unit-test.invalid GopherEnable 1 GopherPort 8090 GopherProxy http_proxy.unit-test.invalid HTTPEnable 1 HTTPPort 8090 HTTPProxy http_proxy.unit-test.invalid HTTPSEnable 1 HTTPSPort 8091 HTTPSProxy https_proxy.unit-test.invalid ProxyAutoConfigEnable 0 ProxyAutoConfigURLString http://http_proxy.unit-test.invalid/wpad.pac ProxyAutoDiscoveryEnable 0 RTSPEnable 1 RTSPPort 8094 RTSPProxy rtsp_proxy.unit-test.invalid SOCKSEnable 1 SOCKSPort 8095 SOCKSProxy socks_proxy.unit-test.invalid SMB UserDefinedName Ethernet Sets 8458B09B-93EA-44C2-AD05-0B4E4A4D9651 Network Global IPv4 ServiceOrder 299B07C0-D0E0-4840-8486-9E77B9ED84DB Service 299B07C0-D0E0-4840-8486-9E77B9ED84DB __LINK__ /NetworkServices/299B07C0-D0E0-4840-8486-9E77B9ED84DB UserDefinedName Automatic System Network HostNames LocalHostName rossis-Mac-mini System ComputerName rossi’s Mac mini ComputerNameEncoding 0 proxy-vole-proxy-vole-1.0.3/src/test/resources/osx/osx_pac.plist000066400000000000000000000067651302662252000250770ustar00rootroot00000000000000 CurrentSet /Sets/8458B09B-93EA-44C2-AD05-0B4E4A4D9651 NetworkServices 299B07C0-D0E0-4840-8486-9E77B9ED84DB AppleTalk DNS IPv4 ConfigMethod DHCP IPv6 ConfigMethod Automatic Interface DeviceName en0 Hardware Ethernet Type Ethernet UserDefinedName Ethernet Proxies ExceptionsList *.local 169.254/16 ExcludeSimpleHostnames 1 FTPEnable 1 FTPPassive 1 FTPPort 8092 FTPProxy ftp_proxy.unit-test.invalid GopherEnable 1 GopherPort 8090 GopherProxy http_proxy.unit-test.invalid HTTPEnable 1 HTTPPort 8090 HTTPProxy http_proxy.unit-test.invalid HTTPSEnable 1 HTTPSPort 8091 HTTPSProxy https_proxy.unit-test.invalid ProxyAutoConfigEnable 1 ProxyAutoConfigURLString http://http_proxy.unit-test.invalid/wpad.pac ProxyAutoDiscoveryEnable 0 RTSPEnable 1 RTSPPort 8094 RTSPProxy rtsp_proxy.unit-test.invalid SOCKSEnable 1 SOCKSPort 8095 SOCKSProxy socks_proxy.unit-test.invalid SMB UserDefinedName Ethernet Sets 8458B09B-93EA-44C2-AD05-0B4E4A4D9651 Network Global IPv4 ServiceOrder 299B07C0-D0E0-4840-8486-9E77B9ED84DB Service 299B07C0-D0E0-4840-8486-9E77B9ED84DB __LINK__ /NetworkServices/299B07C0-D0E0-4840-8486-9E77B9ED84DB UserDefinedName Automatic System Network HostNames LocalHostName rossis-Mac-mini System ComputerName rossi’s Mac mini ComputerNameEncoding 0 proxy-vole-proxy-vole-1.0.3/src/test/resources/pac/000077500000000000000000000000001302662252000223025ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/pac/test1.pac000066400000000000000000000001341302662252000240250ustar00rootroot00000000000000 function FindProxyForURL(url, host) { return "PROXY http_proxy.unit-test.invalid:8090"; }proxy-vole-proxy-vole-1.0.3/src/test/resources/pac/test2.pac000066400000000000000000000002431302662252000240270ustar00rootroot00000000000000// Test comments in scripts function FindProxyForURL(url, host) { /* * This is a multiline comment */ return "DIRECT"; // This returns always DIRECT }proxy-vole-proxy-vole-1.0.3/src/test/resources/pac/testDateRange.pac000066400000000000000000000003771302662252000255300ustar00rootroot00000000000000// Test date range functions function FindProxyForURL(url, host) { dateRange(1, 30); dateRange("JUN", "JUL"); dateRange(2008, 2009); dateRange("JUN", "JUL", "GMT"); dateRange(1, "JUN", 2008, 30, "JUL", 2099, "GMT"); return "DIRECT"; }proxy-vole-proxy-vole-1.0.3/src/test/resources/pac/testLocalIP.pac000066400000000000000000000001221302662252000251450ustar00rootroot00000000000000 function FindProxyForURL(url, host) { return "PROXY "+ myIpAddress()+":8080"; }proxy-vole-proxy-vole-1.0.3/src/test/resources/pac/testMultiProxy.pac000066400000000000000000000001521302662252000260210ustar00rootroot00000000000000function FindProxyForURL(url, host) { return "PROXY my-proxy.com:80 ; PROXY my-proxy2.com: 8080; "; }proxy-vole-proxy-vole-1.0.3/src/test/resources/pac/testReturnTypes.pac000066400000000000000000000003501302662252000261710ustar00rootroot00000000000000// Test that we have JS data types: e.g string and not java.lang.String function FindProxyForURL(url, host) { return typeof dnsDomainLevels(host) + " " + typeof isResolvable(host) + " " + typeof myIpAddress(); }proxy-vole-proxy-vole-1.0.3/src/test/resources/pac/testTimeRange.pac000066400000000000000000000003441302662252000255430ustar00rootroot00000000000000// Test weekday functions function FindProxyForURL(url, host) { timeRange(12); timeRange(11, 16); timeRange(10, 30, 17, 30, "gmt"); timeRange(10, 30, 00, 17, 30, 30, "GMT"); timeRange(19, 9); return "DIRECT"; }proxy-vole-proxy-vole-1.0.3/src/test/resources/pac/testWeekDay.pac000066400000000000000000000003221302662252000252150ustar00rootroot00000000000000// Test weekday functions function FindProxyForURL(url, host) { weekdayRange("MON"); weekdayRange("MON", "GMT"); weekdayRange("FRI", "MON"); weekdayRange("MON", "WED", "GMT"); return "DIRECT"; }proxy-vole-proxy-vole-1.0.3/src/test/resources/wpad/000077500000000000000000000000001302662252000224725ustar00rootroot00000000000000proxy-vole-proxy-vole-1.0.3/src/test/resources/wpad/wpad.pac000066400000000000000000000001341302662252000241100ustar00rootroot00000000000000 function FindProxyForURL(url, host) { return "PROXY http_proxy.unit-test.invalid:8090"; }