Gio.Proxy¶
interface
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.get_extension_by_name.
Methods¶
connect¶
def connect(self, connection: IOStream, proxy_address: ProxyAddress, cancellable: Cancellable | None = ...) -> IOStream
Given connection to communicate with a proxy (eg, a
SocketConnection that is connected to the proxy server), this
does the necessary handshake to connect to proxy_address, and if
required, wraps the IOStream to handle proxy payload.
Parameters:
connection— aIOStreamproxy_address— aProxyAddresscancellable— aCancellable
connect_async¶
def connect_async(self, connection: IOStream, proxy_address: ProxyAddress, cancellable: Cancellable | None = ..., callback: Callable[[Proxy | None, AsyncResult], None] | None = ...) -> None
Asynchronous version of Proxy.connect.
Parameters:
connection— aIOStreamproxy_address— aProxyAddresscancellable— aCancellablecallback— aGAsyncReadyCallback
connect_finish¶
See Proxy.connect.
Parameters:
result— aAsyncResult
supports_hostname¶
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 return False if proxy is
implementing such a protocol. When False is returned, the caller
should resolve the destination hostname first, and then pass a
ProxyAddress containing the stringified IP address to
Proxy.connect or Proxy.connect_async.
Static functions¶
get_default_for_protocol¶
Find the gio-proxy extension point for a proxy implementation that supports
the specified protocol.
Parameters:
protocol— the proxy protocol name (e.g. http, socks, etc)
Virtual methods¶
do_connect¶
def do_connect(self, connection: IOStream, proxy_address: ProxyAddress, cancellable: Cancellable | None = ...) -> IOStream
Given connection to communicate with a proxy (eg, a
SocketConnection that is connected to the proxy server), this
does the necessary handshake to connect to proxy_address, and if
required, wraps the IOStream to handle proxy payload.
Parameters:
connection— aIOStreamproxy_address— aProxyAddresscancellable— aCancellable
do_connect_async¶
def do_connect_async(self, connection: IOStream, proxy_address: ProxyAddress, cancellable: Cancellable | None = ..., callback: Callable[[Proxy | None, AsyncResult], None] | None = ...) -> None
Asynchronous version of Proxy.connect.
Parameters:
connection— aIOStreamproxy_address— aProxyAddresscancellable— aCancellablecallback— aGAsyncReadyCallback
do_connect_finish¶
See Proxy.connect.
Parameters:
result— aAsyncResult
do_supports_hostname¶
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 return False if proxy is
implementing such a protocol. When False is returned, the caller
should resolve the destination hostname first, and then pass a
ProxyAddress containing the stringified IP address to
Proxy.connect or Proxy.connect_async.