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§
sourcefn update(&mut self) -> Result<Vec<TorEvent>, Error>
fn update(&mut self) -> Result<Vec<TorEvent>, Error>
Process and return TorEvent
s 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 CircuitToken
s are required to use different circuits through the Tor Network. However, connections made with identical CircuitToken
s 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
.