pub trait ProxyExt: IsA<Proxy> + Sealed + 'static {
// Provided methods
fn connect(
&self,
connection: &impl IsA<IOStream>,
proxy_address: &impl IsA<ProxyAddress>,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<IOStream, Error> { ... }
fn connect_async<P: FnOnce(Result<IOStream, Error>) + 'static>(
&self,
connection: &impl IsA<IOStream>,
proxy_address: &impl IsA<ProxyAddress>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
) { ... }
fn connect_future(
&self,
connection: &(impl IsA<IOStream> + Clone + 'static),
proxy_address: &(impl IsA<ProxyAddress> + Clone + 'static)
) -> Pin<Box_<dyn Future<Output = Result<IOStream, Error>> + 'static>> { ... }
fn supports_hostname(&self) -> bool { ... }
}
Expand description
Provided Methods§
sourcefn connect(
&self,
connection: &impl IsA<IOStream>,
proxy_address: &impl IsA<ProxyAddress>,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<IOStream, Error>
fn connect( &self, connection: &impl IsA<IOStream>, proxy_address: &impl IsA<ProxyAddress>, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<IOStream, Error>
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.
connection
a IOStream
proxy_address
cancellable
Returns
a IOStream
that will replace connection
. This might
be the same as connection
, in which case a reference
will be added.
sourcefn connect_async<P: FnOnce(Result<IOStream, Error>) + 'static>(
&self,
connection: &impl IsA<IOStream>,
proxy_address: &impl IsA<ProxyAddress>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
fn connect_async<P: FnOnce(Result<IOStream, Error>) + 'static>( &self, connection: &impl IsA<IOStream>, proxy_address: &impl IsA<ProxyAddress>, cancellable: Option<&impl IsA<Cancellable>>, callback: P )
Asynchronous version of connect()
.
connection
a IOStream
proxy_address
cancellable
callback
a GAsyncReadyCallback
fn connect_future( &self, connection: &(impl IsA<IOStream> + Clone + 'static), proxy_address: &(impl IsA<ProxyAddress> + Clone + 'static) ) -> Pin<Box_<dyn Future<Output = Result<IOStream, Error>> + 'static>>
sourcefn supports_hostname(&self) -> bool
fn supports_hostname(&self) -> 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 false
if self
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
connect()
or connect_async()
.
Returns
true
if hostname resolution is supported.