Class PacProxySelector
java.lang.Object
java.net.ProxySelector
com.github.markusbernhardt.proxy.selector.pac.PacProxySelector
ProxySelector that will use a PAC script to find an proxy for a given URI.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static boolean
private static final String
private static final String
private PacScriptParser
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Proxy
buildProxyFromPacResult
(String pacResult) The proxy evaluator will return a proxy string.private static String
void
connectFailed
(URI uri, SocketAddress sa, IOException ioe) connectFailedEvaluation of the given URL with the PAC-file.static boolean
Checks if the selector is currently enabled.selectprivate void
selectEngine
(PacScriptSource pacSource) Selects one of the available PAC parser engines.static void
setEnabled
(boolean enable) Can be used to enable / disable the proxy selector.Methods inherited from class java.net.ProxySelector
getDefault, of, setDefault
-
Field Details
-
PAC_SOCKS
- See Also:
-
PAC_DIRECT
- See Also:
-
pacScriptParser
-
enabled
private static volatile boolean enabled
-
-
Constructor Details
-
PacProxySelector
Constructor- Parameters:
pacSource
- the source for the PAC file.
-
-
Method Details
-
setEnabled
public static void setEnabled(boolean enable) Can be used to enable / disable the proxy selector. If disabled it will return DIRECT for all urls.- Parameters:
enable
- the new status to set.
-
isEnabled
public static boolean isEnabled()Checks if the selector is currently enabled.- Returns:
- true if enabled else false.
-
selectEngine
Selects one of the available PAC parser engines.- Parameters:
pacSource
- to use as input.
-
connectFailed
connectFailed- Specified by:
connectFailed
in classProxySelector
- See Also:
-
select
select- Specified by:
select
in classProxySelector
- See Also:
-
findProxy
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)- Parameters:
uri
-URI
to be evaluated.- Returns:
Proxy
-object list as result of the evaluation.
-
buildProxyFromPacResult
The proxy evaluator will return a proxy string. This method will take this string and build a matchingProxy
for it.- Parameters:
pacResult
- the result from the PAC parser.- Returns:
- a Proxy
-
concat
-