Class ProxyUtil
java.lang.Object
com.github.markusbernhardt.proxy.util.ProxyUtil
Small helper class for some common utility methods.
- Author:
- Markus Bernhardt, Copyright 2016, Bernd Rosstauscher, Copyright 2009
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PacProxySelectorBuild a PAC proxy selector for the given URL.static PacProxySelectorbuildPacSelectorForUrl(String url, boolean useUrlSanitization) Build a PAC proxy selector for the given URL.static StringThis method can be used to cleanup an IPv6 address.static booleanGets 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 Details
-
PAC_URL_SANITIZATION_PROP
- See Also:
-
DEFAULT_PROXY_PORT
public static final int DEFAULT_PROXY_PORT- See Also:
-
-
Constructor Details
-
ProxyUtil
public ProxyUtil()
-
-
Method Details
-
parseProxySettings
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
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
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
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
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()
-