Trait tor_interface::tor_provider::TorProvider

source ·
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);
}
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§

source

fn update(&mut self) -> Result<Vec<TorEvent>, Error>

Process and return TorEvents handled by this TorProvider.

source

fn bootstrap(&mut self) -> Result<(), Error>

Begin connecting to the Tor Network.

source

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.

source

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.

source

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.

source

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.

source

fn generate_token(&mut self) -> CircuitToken

Create a new CircuitToken.

source

fn release_token(&mut self, token: CircuitToken)

Releaes a previously generated CircuitToken.

Implementors§