diff --git a/crates/arti-bench/src/main.rs b/crates/arti-bench/src/main.rs index 7e6832f7e3aa7a3555263de2f147ad8b7e5f111e..80114f9ac62b9cc018908bc45789befbdc1adf54 100644 --- a/crates/arti-bench/src/main.rs +++ b/crates/arti-bench/src/main.rs @@ -684,7 +684,7 @@ impl<R: Runtime> Benchmark<R> { self.run(BenchmarkType::Arti, |run| { let mut prefs = arti_client::StreamPrefs::new(); - prefs.set_isolation_group(iso.next_in(run)); + prefs.set_isolation(iso.next_in(run)); tor_client.connect(addr.clone()) }) diff --git a/crates/arti-client/src/client.rs b/crates/arti-client/src/client.rs index f2c7f5c20f0a3b92f83149e365fdb2cc255d94ce..d0c95183a820ab45b48502c6966b084a44f9cec9 100644 --- a/crates/arti-client/src/client.rs +++ b/crates/arti-client/src/client.rs @@ -215,7 +215,7 @@ impl StreamPrefs { /// 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_group` is specified via the `ConnectionPrefs` in force. + /// `isolation` is specified via the `ConnectionPrefs` in force. pub fn new_isolation_group(&mut self) -> &mut Self { self.isolation = StreamIsolationPreference::Explicit(Box::new(IsolationToken::new())); self @@ -225,17 +225,17 @@ impl StreamPrefs { /// as this one. /// /// By default all connections made on all clones of a `TorClient` may share connections. - /// Connections made with a particular `isolation_group` may share circuits with each other. + /// 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_group` is specified via the `ConnectionPrefs` in force. - pub fn set_isolation_group<T>(&mut self, isolation_group: T) -> &mut Self + /// `isolation` is specified via the `ConnectionPrefs` in force. + pub fn set_isolation<T>(&mut self, isolation: T) -> &mut Self where T: Into<Box<dyn Isolation>>, { - self.isolation = StreamIsolationPreference::Explicit(isolation_group.into()); + self.isolation = StreamIsolationPreference::Explicit(isolation.into()); self } @@ -250,7 +250,7 @@ impl StreamPrefs { /// circuits. The only benefit is that these circuits will not be shared /// by multiple streams.) /// - /// This can be undone by calling `set_isolation_group` or `new_isolation_group` on these + /// This can be undone by calling `set_isolation` or `new_isolation_group` on these /// preferences. pub fn isolate_every_stream(&mut self) -> &mut Self { self.isolation = StreamIsolationPreference::EveryStream; @@ -259,7 +259,7 @@ impl StreamPrefs { /// Return a token to describe which connections might use /// the same circuit as this one. - fn isolation_group(&self) -> Option<Box<dyn Isolation>> { + fn isolation(&self) -> Option<Box<dyn Isolation>> { use StreamIsolationPreference as SIP; match self.isolation { SIP::None => None, @@ -824,7 +824,7 @@ impl<R: Runtime> TorClient<R> { // Always consider our client_isolation. b.owner_token(self.client_isolation); // Consider stream isolation too, if it's set. - if let Some(tok) = prefs.isolation_group() { + if let Some(tok) = prefs.isolation() { b.stream_token(tok); } // Failure should be impossible with this builder. diff --git a/crates/arti/src/dns.rs b/crates/arti/src/dns.rs index c43bf5cf4a59558dcc4f29286be66eb72554994d..203a204311f4e94ed24d7d6bfae22da89592102c 100644 --- a/crates/arti/src/dns.rs +++ b/crates/arti/src/dns.rs @@ -69,7 +69,7 @@ where let mut answers = Vec::new(); let mut prefs = StreamPrefs::new(); - prefs.set_isolation_group(DnsIsolationKey(socket_id, addr.ip())); + prefs.set_isolation(DnsIsolationKey(socket_id, addr.ip())); for query in query.queries() { let mut a = Vec::new(); diff --git a/crates/arti/src/socks.rs b/crates/arti/src/socks.rs index b8be57330a77f256186f3bc12a0864808a783bfe..1349c62b406c2d6477b47c5dbe46b25f1db16852 100644 --- a/crates/arti/src/socks.rs +++ b/crates/arti/src/socks.rs @@ -176,7 +176,7 @@ See <a href="https://gitlab.torproject.org/tpo/core/arti/#todo-need-to-change-wh // Determine whether we want to ask for IPv4/IPv6 addresses. let mut prefs = stream_preference(&request, &addr); - prefs.set_isolation_group(SocksIsolationKey(source_address, ip, auth)); + prefs.set_isolation(SocksIsolationKey(source_address, ip, auth)); match request.command() { SocksCmd::CONNECT => { diff --git a/crates/tor-circmgr/src/mgr.rs b/crates/tor-circmgr/src/mgr.rs index 562756b34b55ea1553236fb62a6d93e665437174..e82014e5cc7aaef50461c03244b079e8b4c07eeb 100644 --- a/crates/tor-circmgr/src/mgr.rs +++ b/crates/tor-circmgr/src/mgr.rs @@ -1380,14 +1380,14 @@ mod test { #[derive(Clone, Debug, Eq, PartialEq, Hash)] struct FakeSpec { ports: BTreeSet<u16>, - isolation_group: Option<u8>, + isolation: Option<u8>, } impl AbstractSpec for FakeSpec { type Usage = FakeSpec; fn supports(&self, other: &FakeSpec) -> bool { let ports_ok = self.ports.is_superset(&other.ports); - let iso_ok = match (self.isolation_group, other.isolation_group) { + let iso_ok = match (self.isolation, other.isolation) { (None, _) => true, (_, None) => true, (Some(a), Some(b)) => a == b, @@ -1398,14 +1398,14 @@ mod test { if !self.ports.is_superset(&other.ports) { return Err(bad_api_usage!("not supported").into()); } - let new_iso = match (self.isolation_group, other.isolation_group) { + let new_iso = match (self.isolation, other.isolation) { (None, x) => x, (x, None) => x, (Some(a), Some(b)) if a == b => Some(a), (_, _) => return Err(bad_api_usage!("not supported").into()), }; - self.isolation_group = new_iso; + self.isolation = new_iso; Ok(()) } } @@ -1419,13 +1419,13 @@ mod test { let ports = ports.into_iter().map(Into::into).collect(); FakeSpec { ports, - isolation_group: None, + isolation: None, } } fn isolated(self, group: u8) -> Self { FakeSpec { ports: self.ports, - isolation_group: Some(group), + isolation: Some(group), } } } diff --git a/crates/tor-circmgr/src/usage.rs b/crates/tor-circmgr/src/usage.rs index 2ae39a1e59ba40e89bf4ab5bfe454a98f218079b..b55fde792b2a437c0893f2c2cf1351a5995ecb43 100644 --- a/crates/tor-circmgr/src/usage.rs +++ b/crates/tor-circmgr/src/usage.rs @@ -242,10 +242,10 @@ pub trait IsolationHelper: Sized { /// let token_2 = IsolationToken::new(); /// /// let mut prefs_1 = StreamPrefs::new(); -/// prefs_1.set_isolation_group(token_1); +/// prefs_1.set_isolation(token_1); /// /// let mut prefs_2 = StreamPrefs::new(); -/// prefs_2.set_isolation_group(token_2); +/// prefs_2.set_isolation(token_2); /// /// // These two connections will come from different source IP addresses. /// tor_client.connect(("example.com", 80), Some(prefs_1)).await?;