Proxy#
Added in version 2.26.
- class Proxy(*args, **kwargs)#
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
get_extension_by_name.
Methods#
- class Proxy
- connect(connection: IOStream, proxy_address: ProxyAddress, cancellable: Cancellable | None = None) IOStream#
Given
connectionto communicate with a proxy (eg, aSocketConnectionthat is connected to the proxy server), this does the necessary handshake to connect toproxy_address, and if required, wraps theIOStreamto handle proxy payload.Added in version 2.26.
- Parameters:
connection – a
IOStreamproxy_address – a
ProxyAddresscancellable – a
Cancellable
- async connect_async(self, connection: IOStream, proxy_address: ProxyAddress) IOStream#
This is the awaitable version of
connect_async().Added in version 2.26.
- Parameters:
connection – a
IOStreamproxy_address – a
ProxyAddress
- connect_async(connection: IOStream, proxy_address: ProxyAddress, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Asynchronous version of
connect().Added in version 2.26.
- Parameters:
connection – a
IOStreamproxy_address – a
ProxyAddresscancellable – a
Cancellablecallback – a
AsyncReadyCallbackuser_data – callback data
- connect_finish(result: AsyncResult) IOStream#
See
connect().Added in version 2.26.
- Parameters:
result – a
AsyncResult
- classmethod get_default_for_protocol() Proxy | None#
Find the
gio-proxyextension point for a proxy implementation that supports the specified protocol.Added in version 2.26.
- supports_hostname() bool#
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
Falseifproxyis implementing such a protocol. WhenFalseis returned, the caller should resolve the destination hostname first, and then pass aProxyAddresscontaining the stringified IP address toconnect()orconnect_async().Added in version 2.26.
Virtual Methods#
- class Proxy
- do_connect(connection: IOStream, proxy_address: ProxyAddress, cancellable: Cancellable | None = None) IOStream#
Given
connectionto communicate with a proxy (eg, aSocketConnectionthat is connected to the proxy server), this does the necessary handshake to connect toproxy_address, and if required, wraps theIOStreamto handle proxy payload.Added in version 2.26.
- Parameters:
connection – a
IOStreamproxy_address – a
ProxyAddresscancellable – a
Cancellable
- do_connect_async(connection: IOStream, proxy_address: ProxyAddress, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Asynchronous version of
connect().Added in version 2.26.
- Parameters:
connection – a
IOStreamproxy_address – a
ProxyAddresscancellable – a
Cancellablecallback – a
AsyncReadyCallbackuser_data – callback data
- do_connect_finish(result: AsyncResult) IOStream#
See
connect().Added in version 2.26.
- Parameters:
result – a
AsyncResult
- do_supports_hostname() bool#
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
Falseifproxyis implementing such a protocol. WhenFalseis returned, the caller should resolve the destination hostname first, and then pass aProxyAddresscontaining the stringified IP address toconnect()orconnect_async().Added in version 2.26.