:right-sidebar: True Proxy =================================================================== .. currentmodule:: gi.repository.Gio .. versionadded:: 2.26 .. class:: Proxy(*args, **kwargs) :no-contents-entry: 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 :obj:`~gi.repository.Gio.IOExtensionPoint.get_extension_by_name`\. Methods ------- .. rst-class:: interim-class .. class:: Proxy :no-index: .. method:: connect(connection: ~gi.repository.Gio.IOStream, proxy_address: ~gi.repository.Gio.ProxyAddress, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.IOStream Given ``connection`` to communicate with a proxy (eg, a :obj:`~gi.repository.Gio.SocketConnection` that is connected to the proxy server), this does the necessary handshake to connect to ``proxy_address``\, and if required, wraps the :obj:`~gi.repository.Gio.IOStream` to handle proxy payload. .. versionadded:: 2.26 :param connection: a :obj:`~gi.repository.Gio.IOStream` :param proxy_address: a :obj:`~gi.repository.Gio.ProxyAddress` :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` .. method:: connect_async(connection: ~gi.repository.Gio.IOStream, proxy_address: ~gi.repository.Gio.ProxyAddress, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronous version of :func:`~gi.repository.Gio.Proxy.connect`. .. versionadded:: 2.26 :param connection: a :obj:`~gi.repository.Gio.IOStream` :param proxy_address: a :obj:`~gi.repository.Gio.ProxyAddress` :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` :param user_data: callback data .. method:: connect_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.IOStream See :func:`~gi.repository.Gio.Proxy.connect`. .. versionadded:: 2.26 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. classmethod:: get_default_for_protocol() -> ~gi.repository.Gio.Proxy | None Find the ``gio-proxy`` extension point for a proxy implementation that supports the specified protocol. .. versionadded:: 2.26 .. method:: 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 :const:`False` if ``proxy`` is implementing such a protocol. When :const:`False` is returned, the caller should resolve the destination hostname first, and then pass a :obj:`~gi.repository.Gio.ProxyAddress` containing the stringified IP address to :func:`~gi.repository.Gio.Proxy.connect` or :func:`~gi.repository.Gio.Proxy.connect_async`. .. versionadded:: 2.26 Virtual Methods --------------- .. rst-class:: interim-class .. class:: Proxy :no-index: .. method:: do_connect(connection: ~gi.repository.Gio.IOStream, proxy_address: ~gi.repository.Gio.ProxyAddress, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.IOStream Given ``connection`` to communicate with a proxy (eg, a :obj:`~gi.repository.Gio.SocketConnection` that is connected to the proxy server), this does the necessary handshake to connect to ``proxy_address``\, and if required, wraps the :obj:`~gi.repository.Gio.IOStream` to handle proxy payload. .. versionadded:: 2.26 :param connection: a :obj:`~gi.repository.Gio.IOStream` :param proxy_address: a :obj:`~gi.repository.Gio.ProxyAddress` :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` .. method:: do_connect_async(connection: ~gi.repository.Gio.IOStream, proxy_address: ~gi.repository.Gio.ProxyAddress, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronous version of :func:`~gi.repository.Gio.Proxy.connect`. .. versionadded:: 2.26 :param connection: a :obj:`~gi.repository.Gio.IOStream` :param proxy_address: a :obj:`~gi.repository.Gio.ProxyAddress` :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` :param user_data: callback data .. method:: do_connect_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.IOStream See :func:`~gi.repository.Gio.Proxy.connect`. .. versionadded:: 2.26 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: 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 :const:`False` if ``proxy`` is implementing such a protocol. When :const:`False` is returned, the caller should resolve the destination hostname first, and then pass a :obj:`~gi.repository.Gio.ProxyAddress` containing the stringified IP address to :func:`~gi.repository.Gio.Proxy.connect` or :func:`~gi.repository.Gio.Proxy.connect_async`. .. versionadded:: 2.26