Class ProxyUtil
- java.lang.Object
-
- com.github.markusbernhardt.proxy.util.ProxyUtil
-
public class ProxyUtil extends Object
Small helper class for some common utility methods.- Author:
- Markus Bernhardt, Copyright 2016, Bernd Rosstauscher, Copyright 2009
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_PROXY_PORTstatic StringPAC_URL_SANITIZATION_PROP
-
Constructor Summary
Constructors Constructor Description ProxyUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PacProxySelectorbuildPacSelectorForUrl(String url)Build a PAC proxy selector for the given URL.static PacProxySelectorbuildPacSelectorForUrl(String url, boolean useUrlSanitization)Build a PAC proxy selector for the given URL.static StringcleanIPv6(String hostOrIP)This method can be used to cleanup an IPv6 address.static booleanisPacUrlSanitizationEnabled()static List<Proxy>noProxyList()Gets an unmodifiable proxy list that will have as it's only entry an DIRECT proxy.static FixedProxySelectorparseProxySettings(String proxyVar)Parse host and port out of a proxy variable.
-
-
-
Field Detail
-
PAC_URL_SANITIZATION_PROP
public static final String PAC_URL_SANITIZATION_PROP
- See Also:
- Constant Field Values
-
DEFAULT_PROXY_PORT
public static final int DEFAULT_PROXY_PORT
- See Also:
- Constant Field Values
-
-
Method Detail
-
parseProxySettings
public static FixedProxySelector parseProxySettings(String proxyVar)
Parse host and port out of a proxy variable.- Parameters:
proxyVar- the proxy string. example: http://192.168.10.9:8080/- Returns:
- a FixedProxySelector using this settings, null on parse error.
-
noProxyList
public static List<Proxy> noProxyList()
Gets an unmodifiable proxy list that will have as it's only entry an DIRECT proxy.- Returns:
- a list with a DIRECT proxy in it.
-
buildPacSelectorForUrl
public static PacProxySelector buildPacSelectorForUrl(String url)
Build a PAC proxy selector for the given URL.- Parameters:
url- to fetch the PAC script from.- Returns:
- a PacProxySelector or null if it is not possible to build a working selector.
-
buildPacSelectorForUrl
public static PacProxySelector buildPacSelectorForUrl(String url, boolean useUrlSanitization)
Build a PAC proxy selector for the given URL.- Parameters:
url- to fetch the PAC script from.useUrlSanitization- whether to use URL sanitization prior to evaluating the PAC script on the provided URL. SeeSafePacProxySelectorfor details.- Returns:
- a PacProxySelector or null if it is not possible to build a working selector.
-
cleanIPv6
public static String cleanIPv6(String hostOrIP)
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- Parameters:
hostOrIP- to cleanup- Returns:
- the raw host or IP without any IPv6 brackets.
-
isPacUrlSanitizationEnabled
public static boolean isPacUrlSanitizationEnabled()
-
-