From 67d6615f836198c03601ca1901a99c04fa20d6cf Mon Sep 17 00:00:00 2001 From: Richard Pospesel Date: Mon, 19 Feb 2024 14:57:01 +0000 Subject: [PATCH] build: reduced required rustc version to 1.63 (from 1.66) --- README.md | 2 +- source/bindings/cpp/Cargo.toml | 9 +-- source/bindings/java/Cargo.toml | 11 +-- source/bindings/python/Cargo.toml | 11 +-- source/gosling/crates/cgosling/Cargo.toml | 22 +++--- .../gosling/crates/cgosling/fuzz/Cargo.toml | 3 +- .../crates/cgosling/src/object_registry.rs | 35 +++++++--- source/gosling/crates/gosling/Cargo.toml | 41 +++++------ source/gosling/crates/gosling/fuzz/Cargo.toml | 9 +-- source/gosling/crates/honk-rpc/Cargo.toml | 14 ++-- .../gosling/crates/honk-rpc/fuzz/Cargo.toml | 5 +- .../gosling/crates/tor-interface/Cargo.toml | 34 ++++----- .../crates/tor-interface/fuzz/Cargo.toml | 3 +- .../tor-interface/src/mock_tor_client.rs | 70 ++++++++++++------- 14 files changed, 158 insertions(+), 111 deletions(-) diff --git a/README.md b/README.md index 387c56ea..738cae67 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ It is meant to generalize (and improve upon) the authentication scheme [Ricochet Gosling currently has the following required build dependencies: - [cmake >= 3.17](https://cmake.org) -- [rust >= 1.66.0](https://rust-lang.org) +- [rust >= 1.63.0](https://rust-lang.org) Cargo will automatically download and build the required Rust crates. The list of current dependencies can be found in each crate's Cargo.toml file: diff --git a/source/bindings/cpp/Cargo.toml b/source/bindings/cpp/Cargo.toml index bd88d44b..371c5182 100644 --- a/source/bindings/cpp/Cargo.toml +++ b/source/bindings/cpp/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "build_cpp_bindings" version = "0.1.0" +rust-version = "1.63" edition = "2021" [[bin]] @@ -8,7 +9,7 @@ name = "build_cpp_bindings" path = "./build_cpp_bindings.rs" [dependencies] -handlebars = "4.5.0" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -regex = "1.10" +handlebars = "^4.3.0" +regex = ">= 1.9, <= 1.9.6" +serde = { version = "^1.0", features = ["derive"] } +serde_json = "^1.0" diff --git a/source/bindings/java/Cargo.toml b/source/bindings/java/Cargo.toml index 96b031cb..d715e7b1 100644 --- a/source/bindings/java/Cargo.toml +++ b/source/bindings/java/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "build_java_bindings" version = "0.1.0" +rust-version = "1.63" edition = "2021" [[bin]] @@ -8,8 +9,8 @@ name = "build_java_bindings" path = "./build_java_bindings.rs" [dependencies] -handlebars = "4.5.0" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -regex = "1.10" -heck = "0.4.1" +handlebars = "^4.3.0" +heck = "^0.4" +regex = ">= 1.9, <= 1.9.6" +serde = { version = "^1.0", features = ["derive"] } +serde_json = "^1.0" diff --git a/source/bindings/python/Cargo.toml b/source/bindings/python/Cargo.toml index 60e3f4eb..5ae27eef 100644 --- a/source/bindings/python/Cargo.toml +++ b/source/bindings/python/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "build_python_bindings" version = "0.1.0" +rust-version = "1.63" edition = "2021" [[bin]] @@ -8,8 +9,8 @@ name = "build_python_bindings" path = "./build_python_bindings.rs" [dependencies] -handlebars = "4.5.0" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -regex = "1.10" -heck = "0.4.1" +handlebars = "^4.3.0" +heck = "^0.4" +regex = ">= 1.9, <= 1.9.6" +serde = { version = "^1.0", features = ["derive"] } +serde_json = "^1.0" diff --git a/source/gosling/crates/cgosling/Cargo.toml b/source/gosling/crates/cgosling/Cargo.toml index a4ba28f7..06fec0a8 100644 --- a/source/gosling/crates/cgosling/Cargo.toml +++ b/source/gosling/crates/cgosling/Cargo.toml @@ -2,25 +2,27 @@ name = "cgosling" build = "build.rs" authors = ["Richard Pospesel "] -version = "0.2.0" -rust-version = "1.66" +version = "0.2.1" +rust-version = "1.63" edition = "2021" [build-dependencies] cbindgen = "0.20.0" -regex = "1.10.2" +regex = "<= 1.9.6" serde = "1.0.193" serde_json = "1.0" [dependencies] -anyhow = "1.0" -bson = "2.2.0" -gosling = { version = "0.1.0", path = "../gosling" } -paste = "1.0" -static_assertions = "1.1.0" -tor-interface = { version = "0.2.0", path = "../tor-interface" } -which = "4.3.0" +anyhow = "^1" +backtrace = ">= 0.3, <= 0.3.67" +bson = ">= 2.0, <= 2.4.0" +gosling = { version = "^0.1.0", path = "../gosling" } +home = ">= 0.5, <= 0.5.5" +paste = "^1.0" +static_assertions = "^1.1" +tor-interface = { version = "^0.2.0", path = "../tor-interface" } +which = ">= 4.4.2, <= 5.0.0" [lib] name = "cgosling" diff --git a/source/gosling/crates/cgosling/fuzz/Cargo.toml b/source/gosling/crates/cgosling/fuzz/Cargo.toml index b729839f..f6819092 100644 --- a/source/gosling/crates/cgosling/fuzz/Cargo.toml +++ b/source/gosling/crates/cgosling/fuzz/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "cgosling-fuzz" version = "0.0.0" +rust-version = "1.63" publish = false edition = "2021" @@ -8,7 +9,7 @@ edition = "2021" cargo-fuzz = true [dependencies] -libfuzzer-sys = { version = "0.4.0", features = ["arbitrary-derive"] } +libfuzzer-sys = { version = "^0.4", features = ["arbitrary-derive"] } [dependencies.cgosling] path = ".." diff --git a/source/gosling/crates/cgosling/src/object_registry.rs b/source/gosling/crates/cgosling/src/object_registry.rs index 592b5d37..682242f2 100644 --- a/source/gosling/crates/cgosling/src/object_registry.rs +++ b/source/gosling/crates/cgosling/src/object_registry.rs @@ -15,7 +15,7 @@ use std::option::Option; // for the unique id portion of the returne dkeys) pub struct ObjectRegistry { // our internal mapping from handles to Ts - map: BTreeMap, + map: Option>, // number of Ts registered to this registry over its lifetime counter: usize, } @@ -41,38 +41,57 @@ impl ObjectRegistry assert!(TAG_BITS == 0 || (TAG << Self::COUNTER_BITS) >> Self::COUNTER_BITS == TAG); ObjectRegistry { - map: BTreeMap::new(), + map: None, counter: 0, } } // determine if the registry has an object with the specified key pub fn contains_key(&self, key: usize) -> bool { - self.map.contains_key(&key) + match &self.map { + Some(map) => map.contains_key(&key), + None => false, + } } // remove and return an object with the specified key pub fn remove(&mut self, key: usize) -> Option { - self.map.remove(&key) + match &mut self.map { + Some(map) => map.remove(&key), + None => None, + } } // add object into registry and return key to reference it pub fn insert(&mut self, val: T) -> usize { let key = self.next_key(); - if self.map.insert(key, val).is_some() { - panic!(); + match &mut self.map { + Some(map) => if map.insert(key, val).is_some() { + panic!(); + }, + None => { + let mut map = BTreeMap::new(); + map.insert(key, val); + self.map = Some(map); + } } key } // gets a reference to a value by the given key pub fn get(&self, key: usize) -> Option<&T> { - self.map.get(&key) + match &self.map { + Some(map) => map.get(&key), + None => None, + } } // gets a mutable reference to a value by the given key pub fn get_mut(&mut self, key: usize) -> Option<&mut T> { - self.map.get_mut(&key) + match &mut self.map { + Some(map) => map.get_mut(&key), + None => None, + } } #[cfg(test)] diff --git a/source/gosling/crates/gosling/Cargo.toml b/source/gosling/crates/gosling/Cargo.toml index bf5c3163..c47e163f 100644 --- a/source/gosling/crates/gosling/Cargo.toml +++ b/source/gosling/crates/gosling/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "gosling" authors = ["Richard Pospesel "] -version = "0.1.0" -rust-version = "1.66" +version = "0.1.1" +rust-version = "1.63" edition = "2021" license = "BSD-3-Clause" description = "A library for developing fully anonymous, peer-to-peer, metadata-resistant applications using tor onion services" @@ -10,28 +10,29 @@ homepage = "https://blueprint-freespeech.github.io/gosling/index.xhtml" repository = "https://github.com/blueprint-freespeech/gosling" [dependencies] -bson = "2.2.0" -data-encoding = "2.3.2" -data-encoding-macro = "0.1.12" +bson = ">= 2.0, <= 2.4.0" +data-encoding = "^2" +data-encoding-macro = "^0.1" honk-rpc = { version = "0.1.0", path = "../honk-rpc" } -num_enum = "0.5.6" -paste = "1.0" -rand = "0.8.5" -rand_core = "0.6.3" -regex = "1.5.5" -signature = "1.5.0" -socks = "0.3.4" -static_assertions = "1.1.0" -tor-interface = { version = "0.2.0", path = "../tor-interface" } -tor-llcrypto = { version = "0.2.0", features = ["relay"] } -url = "2.2.2" +num_enum = "^0.6" +paste = "^1.0" +rand = "^0.8" +rand_core = "^0.6" +regex = ">= 1.9, <= 1.9.6" +signature = "^1.5" +socks = "^0.3" +static_assertions = "^1.1" +thiserror = "^1" +tor-interface = { version = "^0.2.0", path = "../tor-interface" } +tor-llcrypto = { version = ">= 0.3, <= 0.4.4", features = ["relay"] } +url = "^2.3" zeroize = "^1" -thiserror = "1.0" [dev-dependencies] -anyhow = "1.0" -serial_test = "0.9.0" -which = "4.3.0" +anyhow = "^1" +dashmap = ">= 5, <= 5.4.0" +serial_test = "0.9.*" +which = ">= 4.4.2, <= 5.0.0" [features] offline-test = ["tor-interface/offline-test"] \ No newline at end of file diff --git a/source/gosling/crates/gosling/fuzz/Cargo.toml b/source/gosling/crates/gosling/fuzz/Cargo.toml index a3bf36e3..33fe1b6e 100644 --- a/source/gosling/crates/gosling/fuzz/Cargo.toml +++ b/source/gosling/crates/gosling/fuzz/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "gosling-fuzz" version = "0.0.0" +rust-version = "1.63" publish = false edition = "2021" @@ -8,11 +9,11 @@ edition = "2021" cargo-fuzz = true [dependencies] -bson = "2.2.0" -data-encoding = "2.3.2" -libfuzzer-sys = { version = "0.4.0", features = ["arbitrary-derive"] } -tor-interface = { path = "../../tor-interface" } +bson = ">= 2.0, <= 2.4.0" +data-encoding = "^2" honk-rpc = { path = "../../honk-rpc" } +libfuzzer-sys = { version = "^0.4", features = ["arbitrary-derive"] } +tor-interface = { path = "../../tor-interface" } [dependencies.gosling] path = ".." diff --git a/source/gosling/crates/honk-rpc/Cargo.toml b/source/gosling/crates/honk-rpc/Cargo.toml index 08490e0e..af4d0494 100644 --- a/source/gosling/crates/honk-rpc/Cargo.toml +++ b/source/gosling/crates/honk-rpc/Cargo.toml @@ -1,18 +1,18 @@ [package] name = "honk-rpc" authors = ["Richard Pospesel "] -version = "0.1.0" -rust-version = "1.66" +version = "0.1.1" +rust-version = "1.63" edition = "2021" license = "BSD-3-Clause" description = "A library implementing an asynchrynous, bi-directional, dynamic, and BSON-based remote procedure call system" repository = "https://github.com/blueprint-freespeech/gosling" [dependencies] -bson = "2.2.0" -thiserror = "1.0" +bson = ">= 2.0, <= 2.4.0" +thiserror = "^1" [dev-dependencies] -anyhow = "1.0" -data-encoding = "2.3.2" -sha3 = "0.10.8" +anyhow = "^1" +data-encoding = "^2" +sha3 = "^0.10" diff --git a/source/gosling/crates/honk-rpc/fuzz/Cargo.toml b/source/gosling/crates/honk-rpc/fuzz/Cargo.toml index 54946d2f..db6d41f5 100644 --- a/source/gosling/crates/honk-rpc/fuzz/Cargo.toml +++ b/source/gosling/crates/honk-rpc/fuzz/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "honk-rpc-fuzz" version = "0.0.0" +rust-version = "1.63" publish = false edition = "2021" @@ -8,8 +9,8 @@ edition = "2021" cargo-fuzz = true [dependencies] -bson = "2.2.0" -libfuzzer-sys = { version = "0.4.0", features = ["arbitrary-derive"] } +bson = ">= 2.0, <= 2.4.0" +libfuzzer-sys = { version = "^0.4", features = ["arbitrary-derive"] } [dependencies.honk-rpc] path = ".." diff --git a/source/gosling/crates/tor-interface/Cargo.toml b/source/gosling/crates/tor-interface/Cargo.toml index e14598ce..44ca759c 100644 --- a/source/gosling/crates/tor-interface/Cargo.toml +++ b/source/gosling/crates/tor-interface/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "tor-interface" authors = ["Richard Pospesel "] -version = "0.2.0" -rust-version = "1.66" +version = "0.2.1" +rust-version = "1.63" edition = "2021" license = "BSD-3-Clause" description = "A library providing a Rust interface to interact with the legacy tor daemon" @@ -10,22 +10,24 @@ keywords = ["tor", "anonymity"] repository = "https://github.com/blueprint-freespeech/gosling" [dependencies] -data-encoding = "2.3.2" -data-encoding-macro = "0.1.12" -rand = "0.8.5" -rand_core = "0.6.3" -regex = "1.5.5" -sha1 = "0.10.6" -sha3 = "0.10.8" -signature = "1.5.0" -socks = "0.3.4" -tor-llcrypto = { version = "0.2.0", features = ["relay"] } -thiserror = "1.0" +data-encoding = "^2" +data-encoding-macro = "^0.1" +rand = "^0.8" +rand_core = "^0.6" +regex = ">= 1.9, <= 1.9.6" +sha1 = "^0.10" +sha3 = "^0.10" +signature = "^1.5" +socks = "^0.3" +thiserror = "^1" +time-macros = ">= 0.2, <= 0.2.8" +tor-llcrypto = { version = ">= 0.3, <= 0.4.4", features = ["relay"] } [dev-dependencies] -anyhow = "1.0" -serial_test = "0.9.0" -which = "4.3.0" +anyhow = "^1" +dashmap = ">= 5, <= 5.4.0" +serial_test = "0.9.*" +which = ">= 4.4.2, <= 5.0.0" [features] offline-test = [] diff --git a/source/gosling/crates/tor-interface/fuzz/Cargo.toml b/source/gosling/crates/tor-interface/fuzz/Cargo.toml index dbc71cc0..0960929f 100644 --- a/source/gosling/crates/tor-interface/fuzz/Cargo.toml +++ b/source/gosling/crates/tor-interface/fuzz/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "tor-interface-fuzz" version = "0.0.0" +rust-version = "1.63" publish = false edition = "2021" @@ -8,7 +9,7 @@ edition = "2021" cargo-fuzz = true [dependencies] -libfuzzer-sys = { version = "0.4.0", features = ["arbitrary-derive"] } +libfuzzer-sys = { version = "^0.4", features = ["arbitrary-derive"] } [dependencies.tor-interface] path = ".." diff --git a/source/gosling/crates/tor-interface/src/mock_tor_client.rs b/source/gosling/crates/tor-interface/src/mock_tor_client.rs index 88e9e9e3..7bc33d02 100644 --- a/source/gosling/crates/tor-interface/src/mock_tor_client.rs +++ b/source/gosling/crates/tor-interface/src/mock_tor_client.rs @@ -21,7 +21,7 @@ pub enum Error { OnionServiceNotFound(OnionAddr), #[error("onion service not published: {}", .0)] - OnionServiceNoPublished(OnionAddr), + OnionServiceNotPublished(OnionAddr), #[error("onion service requires onion auth")] OnionServiceRequiresOnionAuth(), @@ -77,13 +77,13 @@ impl Drop for MockOnionListener { } struct MockTorNetwork { - onion_services: BTreeMap, SocketAddr)>, + onion_services: Option, SocketAddr)>>, } impl MockTorNetwork { const fn new() -> MockTorNetwork { MockTorNetwork { - onion_services: BTreeMap::new(), + onion_services: None, } } @@ -94,29 +94,35 @@ impl MockTorNetwork { client_auth: Option<&X25519PublicKey>, ) -> Result { let onion_addr = OnionAddr::V3(OnionAddrV3::new(service_id.clone(), virt_port)); - if let Some((client_auth_keys, socket_addr)) = self.onion_services.get(&onion_addr) { - match (client_auth_keys.len(), client_auth) { - (0, None) => (), - (_, None) => return Err(Error::OnionServiceRequiresOnionAuth()), - (0, Some(_)) => return Err(Error::OnionServiceAuthInvalid()), - (_, Some(client_auth)) => { - if !client_auth_keys.contains(client_auth) { - return Err(Error::OnionServiceAuthInvalid()); + + match &mut self.onion_services { + Some(onion_services) => { + if let Some((client_auth_keys, socket_addr)) = onion_services.get(&onion_addr) { + match (client_auth_keys.len(), client_auth) { + (0, None) => (), + (_, None) => return Err(Error::OnionServiceRequiresOnionAuth()), + (0, Some(_)) => return Err(Error::OnionServiceAuthInvalid()), + (_, Some(client_auth)) => { + if !client_auth_keys.contains(client_auth) { + return Err(Error::OnionServiceAuthInvalid()); + } + } } - } - } - if let Ok(stream) = TcpStream::connect(socket_addr) { - Ok(OnionStream { - stream, - local_addr: None, - peer_addr: Some(TargetAddr::OnionService(onion_addr)), - }) - } else { - Err(Error::OnionServiceNotFound(onion_addr)) - } - } else { - Err(Error::OnionServiceNoPublished(onion_addr)) + if let Ok(stream) = TcpStream::connect(socket_addr) { + Ok(OnionStream { + stream, + local_addr: None, + peer_addr: Some(TargetAddr::OnionService(onion_addr)), + }) + } else { + Err(Error::OnionServiceNotFound(onion_addr)) + } + } else { + Err(Error::OnionServiceNotPublished(onion_addr)) + } + }, + None => Err(Error::OnionServiceNotPublished(onion_addr)) } } @@ -128,12 +134,22 @@ impl MockTorNetwork { address: SocketAddr, ) { let onion_addr = OnionAddr::V3(OnionAddrV3::new(service_id, virt_port)); - self.onion_services - .insert(onion_addr, (client_auth_keys, address)); + match &mut self.onion_services { + Some(onion_services) => { + onion_services.insert(onion_addr, (client_auth_keys, address)); + }, + None => { + let mut onion_services = BTreeMap::new(); + onion_services.insert(onion_addr, (client_auth_keys, address)); + self.onion_services = Some(onion_services); + } + } } fn stop_onion(&mut self, onion_addr: &OnionAddr) { - self.onion_services.remove(onion_addr); + if let Some(onion_services) = &mut self.onion_services { + onion_services.remove(onion_addr); + } } }