pub struct StreamPrefs { /* private fields */ }
Expand description
Preferences for how to route a stream over the Tor network.
Implementations§
Source§impl StreamPrefs
impl StreamPrefs
Sourcepub fn ipv6_preferred(&mut self) -> &mut Self
pub fn ipv6_preferred(&mut self) -> &mut Self
Indicate that a stream may be made over IPv4 or IPv6, but that we’d prefer IPv6.
Sourcepub fn ipv6_only(&mut self) -> &mut Self
pub fn ipv6_only(&mut self) -> &mut Self
Indicate that a stream may only be made over IPv6.
When this option is set, we will only pick exit relays that support IPv6, and we will tell them to only give us IPv6 connections.
Sourcepub fn ipv4_preferred(&mut self) -> &mut Self
pub fn ipv4_preferred(&mut self) -> &mut Self
Indicate that a stream may be made over IPv4 or IPv6, but that we’d prefer IPv4.
This is the default.
Sourcepub fn ipv4_only(&mut self) -> &mut Self
pub fn ipv4_only(&mut self) -> &mut Self
Indicate that a stream may only be made over IPv4.
When this option is set, we will only pick exit relays that support IPv4, and we will tell them to only give us IPv4 connections.
Sourcepub fn exit_country(&mut self, country_code: CountryCode) -> &mut Self
Available on crate feature geoip
only.
pub fn exit_country(&mut self, country_code: CountryCode) -> &mut Self
geoip
only.Indicate that a stream should appear to come from the given country.
When this option is set, we will only pick exit relays that have an IP address that matches the country in our GeoIP database.
Sourcepub fn any_exit_country(&mut self) -> &mut Self
pub fn any_exit_country(&mut self) -> &mut Self
Indicate that we don’t care which country a stream appears to come from.
This is available even in the case where GeoIP support is compiled out, to make things easier.
Sourcepub fn optimistic(&mut self) -> &mut Self
pub fn optimistic(&mut self) -> &mut Self
Indicate that the stream should be opened “optimistically”.
By default, streams are not “optimistic”. When you call
TorClient::connect()
, it won’t give you a stream until the
exit node has confirmed that it has successfully opened a
connection to your target address. It’s safer to wait in this
way, but it is slower: it takes an entire round trip to get
your confirmation.
If a stream is configured to be “optimistic”, on the other
hand, then TorClient::connect()
will return the stream
immediately, without waiting for an answer from the exit. You
can start sending data on the stream right away, though of
course this data will be lost if the connection is not
actually successful.
Sourcepub fn is_optimistic(&self) -> bool
pub fn is_optimistic(&self) -> bool
Return true if this stream has been configured as “optimistic”.
See StreamPrefs::optimistic
for more info.
Sourcepub fn connect_to_onion_services(
&mut self,
connect_to_onion_services: BoolOrAuto,
) -> &mut Self
Available on crate feature onion-service-client
only.
pub fn connect_to_onion_services( &mut self, connect_to_onion_services: BoolOrAuto, ) -> &mut Self
onion-service-client
only.Indicate whether connection to a hidden service (.onion
service) should be allowed
If Explicit(false)
, attempts to connect to Onion Services will be forced to fail with
an error of kind InvalidStreamTarget
.
If Explicit(true)
, Onion Service connections are enabled.
If Auto
, the behaviour depends on the address_filter.allow_onion_addrs
configuration option, which is in turn disabled by default.
Note: Arti currently lacks the “vanguards” feature that Tor uses to prevent guard discovery attacks over time. As such, you should probably stick with C Tor if you need to make a large number of onion service connections, or if you are using the Tor protocol in a way that lets an attacker control how many onion services connections that you make - for example, when using Arti’s SOCKS support from a web browser such as Tor Browser.
Sourcepub fn new_isolation_group(&mut self) -> &mut Self
pub fn new_isolation_group(&mut self) -> &mut Self
Indicate that connections with these preferences should have their own isolation group
This is a convenience method which creates a fresh IsolationToken
and sets it for these preferences.
This connection preference is orthogonal to isolation established by
TorClient::isolated_client
. Connections made with an isolated_client
(and its
clones) will not share circuits with the original client, even if the same
isolation
is specified via the ConnectionPrefs
in force.
Sourcepub fn set_isolation<T>(&mut self, isolation: T) -> &mut Self
pub fn set_isolation<T>(&mut self, isolation: T) -> &mut Self
Indicate which other connections might use the same circuit as this one.
By default all connections made on all clones of a TorClient
may share connections.
Connections made with a particular isolation
may share circuits with each other.
This connection preference is orthogonal to isolation established by
TorClient::isolated_client
. Connections made with an isolated_client
(and its
clones) will not share circuits with the original client, even if the same
isolation
is specified via the ConnectionPrefs
in force.
Sourcepub fn isolate_every_stream(&mut self) -> &mut Self
pub fn isolate_every_stream(&mut self) -> &mut Self
Indicate that no connection should share a circuit with any other.
Use with care: This is likely to have poor performance, and imposes a much greater load on the Tor network. Use this option only to make small numbers of connections each of which needs to be isolated from all other connections.
(Don’t just use this as a “get more privacy!!” method: the circuits that it put connections on will have no more privacy than any other circuits. The only benefit is that these circuits will not be shared by multiple streams.)
This can be undone by calling set_isolation
or new_isolation_group
on these
preferences.
Trait Implementations§
Source§impl Clone for StreamPrefs
impl Clone for StreamPrefs
Source§fn clone(&self) -> StreamPrefs
fn clone(&self) -> StreamPrefs
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for StreamPrefs
impl Debug for StreamPrefs
Source§impl Default for StreamPrefs
impl Default for StreamPrefs
Source§fn default() -> StreamPrefs
fn default() -> StreamPrefs
Auto Trait Implementations§
impl Freeze for StreamPrefs
impl !RefUnwindSafe for StreamPrefs
impl Send for StreamPrefs
impl Sync for StreamPrefs
impl Unpin for StreamPrefs
impl !UnwindSafe for StreamPrefs
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.