pub trait TorProvider: Send {
// Required methods
fn update(&mut self) -> Result<Vec<TorEvent>, Error>;
fn bootstrap(&mut self) -> Result<(), Error>;
fn add_client_auth(
&mut self,
service_id: &V3OnionServiceId,
client_auth: &X25519PrivateKey,
) -> Result<(), Error>;
fn remove_client_auth(
&mut self,
service_id: &V3OnionServiceId,
) -> Result<(), Error>;
fn connect(
&mut self,
target: TargetAddr,
circuit: Option<CircuitToken>,
) -> Result<OnionStream, Error>;
fn listener(
&mut self,
private_key: &Ed25519PrivateKey,
virt_port: u16,
authorised_clients: Option<&[X25519PublicKey]>,
) -> Result<OnionListener, Error>;
fn generate_token(&mut self) -> CircuitToken;
fn release_token(&mut self, token: CircuitToken);
// Provided method
fn connect_async(
&mut self,
_target: TargetAddr,
_circuit: Option<CircuitToken>,
) -> Result<ConnectHandle, Error> { ... }
}Expand description
The TorProvider trait allows for high-level Tor Network functionality. Implementations ay connect to the Tor Network, anonymously connect to both clearnet and onion-service endpoints, and host onion-services.
Required Methods§
Sourcefn update(&mut self) -> Result<Vec<TorEvent>, Error>
fn update(&mut self) -> Result<Vec<TorEvent>, Error>
Process and return TorEvents handled by this TorProvider.
Sourcefn add_client_auth(
&mut self,
service_id: &V3OnionServiceId,
client_auth: &X25519PrivateKey,
) -> Result<(), Error>
fn add_client_auth( &mut self, service_id: &V3OnionServiceId, client_auth: &X25519PrivateKey, ) -> Result<(), Error>
Add v3 onion-service authorisation credentials, allowing this TorProvider to connect to an onion-service whose service-descriptor is encrypted using the assocciated x25519 public key.
Sourcefn remove_client_auth(
&mut self,
service_id: &V3OnionServiceId,
) -> Result<(), Error>
fn remove_client_auth( &mut self, service_id: &V3OnionServiceId, ) -> Result<(), Error>
Remove a previously added client authorisation credential. This TorProvider will be unable to connect to the onion-service associated with the removed credentail.
Sourcefn connect(
&mut self,
target: TargetAddr,
circuit: Option<CircuitToken>,
) -> Result<OnionStream, Error>
fn connect( &mut self, target: TargetAddr, circuit: Option<CircuitToken>, ) -> Result<OnionStream, Error>
Anonymously connect to the address specified by target over the Tor Network and return the associated OnionStream.
When conecting to clearnet targets, an optional CircuitToken may be used to enforce usage of different circuits through the Tor Network. If circuit is None, the default circuit is used.
Connections made with different CircuitTokens are required to use different circuits through the Tor Network. However, connections made with identical CircuitTokens are not required to use identical circuits through the Tor Network.
Specifying a circuit token when connecting to an onion-service has no effect on the resulting circuit.
Sourcefn listener(
&mut self,
private_key: &Ed25519PrivateKey,
virt_port: u16,
authorised_clients: Option<&[X25519PublicKey]>,
) -> Result<OnionListener, Error>
fn listener( &mut self, private_key: &Ed25519PrivateKey, virt_port: u16, authorised_clients: Option<&[X25519PublicKey]>, ) -> Result<OnionListener, Error>
Anonymously start an onion-service and return the associated OnionListener.
The resulting onion-service will not be reachable by clients until TorProvider::update() returns a TorEvent::OnionServicePublished event. The optional authorised_clients parameter may be used to require client authorisation keys to connect to resulting onion-service. For further information, see the Tor Project’s onion-services client-auth documentation.
Sourcefn generate_token(&mut self) -> CircuitToken
fn generate_token(&mut self) -> CircuitToken
Create a new CircuitToken.
Sourcefn release_token(&mut self, token: CircuitToken)
fn release_token(&mut self, token: CircuitToken)
Releaes a previously generated CircuitToken.
Provided Methods§
Sourcefn connect_async(
&mut self,
_target: TargetAddr,
_circuit: Option<CircuitToken>,
) -> Result<ConnectHandle, Error>
fn connect_async( &mut self, _target: TargetAddr, _circuit: Option<CircuitToken>, ) -> Result<ConnectHandle, Error>
Anonymously connect to the address specified by target over the Tor Network. The resulting OnionStream (or failure) will be returned as a TorEvent from TorProvider::update().
When conecting to clearnet targets, an optional CircuitToken may be used to enforce usage of different circuits through the Tor Network. If circuit is None, the default circuit is used.
Connections made with different CircuitTokens are required to use different circuits through the Tor Network. However, connections made with identical CircuitTokens are not required to use identical circuits through the Tor Network.
Specifying a circuit token when connecting to an onion-service has no effect on the resulting circuit.