Package org.gnome.gio
Interface Proxy
- All Superinterfaces:
Proxy
- All Known Implementing Classes:
Proxy.Proxy$Impl
A
GProxy handles connecting to a remote host via a given type of
proxy server. It is implemented by the gio-proxy extension point.
The extensions are named after their proxy protocol name. As an
example, a SOCKS5 proxy implementation can be retrieved with the
name socks5 using the function
IOExtensionPoint.getExtensionByName(java.lang.String).- Since:
- 2.26
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classThe Proxy$Impl type represents a native instance of the Proxy interface.static classProvides an interface for handling proxy connection and payload. -
Method Summary
Modifier and TypeMethodDescriptiondefault IOStreamconnect(IOStream connection, ProxyAddress proxyAddress, @Nullable Cancellable cancellable) Givenconnectionto communicate with a proxy (eg, aGSocketConnectionthat is connected to the proxy server), this does the necessary handshake to connect toproxyAddress,and if required, wraps theGIOStreamto handle proxy payload.default voidconnectAsync(IOStream connection, ProxyAddress proxyAddress, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronous version of g_proxy_connect().default IOStreamconnectFinish(AsyncResult result) See g_proxy_connect().static @Nullable ProxygetDefaultForProtocol(String protocol) Find thegio-proxyextension point for a proxy implementation that supports the specified protocol.static @Nullable TypegetType()Get the GType of the Proxy classdefault booleanSome proxy protocols expect to be passed a hostname, which they will resolve to an IP address themselves.
-
Method Details
-
getType
-
getDefaultForProtocol
Find thegio-proxyextension point for a proxy implementation that supports the specified protocol.- Parameters:
protocol- the proxy protocol name (e.g. http, socks, etc)- Returns:
- return a
GProxyor NULL if protocol is not supported. - Since:
- 2.26
-
connect
default IOStream connect(IOStream connection, ProxyAddress proxyAddress, @Nullable Cancellable cancellable) throws GErrorException Givenconnectionto communicate with a proxy (eg, aGSocketConnectionthat is connected to the proxy server), this does the necessary handshake to connect toproxyAddress,and if required, wraps theGIOStreamto handle proxy payload.- Parameters:
connection- aGIOStreamproxyAddress- aGProxyAddresscancellable- aGCancellable- Returns:
- a
GIOStreamthat will replaceconnection.This might be the same asconnection,in which case a reference will be added. - Throws:
GErrorException- seeGError- Since:
- 2.26
-
connectAsync
default void connectAsync(IOStream connection, ProxyAddress proxyAddress, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronous version of g_proxy_connect().- Parameters:
connection- aGIOStreamproxyAddress- aGProxyAddresscancellable- aGCancellablecallback- aGAsyncReadyCallback- Since:
- 2.26
-
connectFinish
See g_proxy_connect().- Parameters:
result- aGAsyncResult- Returns:
- a
GIOStream. - Throws:
GErrorException- seeGError- Since:
- 2.26
-
supportsHostname
default boolean supportsHostname()Some proxy protocols expect to be passed a hostname, which they will resolve to an IP address themselves. Others, like SOCKS4, do not allow this. This function will returnfalseif this Proxy is implementing such a protocol. Whenfalseis returned, the caller should resolve the destination hostname first, and then pass aGProxyAddresscontaining the stringified IP address to g_proxy_connect() or g_proxy_connect_async().- Returns:
trueif hostname resolution is supported.- Since:
- 2.26
-