[ENG-1399] Upgrade Rust workspace + IPv6 mDNS (#1729)

Upgrade Rust workspace + IPv6 mDNS
This commit is contained in:
Oscar Beaumont 2023-11-04 21:20:22 +11:00 committed by GitHub
parent 395e0ee3da
commit 6941912891
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 817 additions and 633 deletions

1311
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -49,14 +49,14 @@ tauri-specta = { version = "1.0.2" }
swift-rs = { version = "1.0.6" } swift-rs = { version = "1.0.6" }
tokio = { version = "1.32.0" } tokio = { version = "1.33.0" }
uuid = { version = "1.4.1", features = ["v4", "serde"] } uuid = { version = "1.5.0", features = ["v4", "serde"] }
serde = { version = "1.0" } serde = { version = "1.0" }
serde_json = { version = "1.0" } serde_json = { version = "1.0" }
[patch.crates-io] [patch.crates-io]
# Proper IOS Support # Proper IOS Support
if-watch = { git = "https://github.com/oscartbeaumont/if-watch.git", rev = "f804ad9b2005e4e760732a708aa95b4bfb376ddf" } if-watch = { git = "https://github.com/oscartbeaumont/if-watch.git", rev = "f732786057e57250e863a9ea0b1874e4cc9907c2" }
# Beta features # Beta features
specta = { git = "https://github.com/oscartbeaumont/specta", rev = "4bc6e46fc8747cd8d8a07597c1fe13c52aa16a41" } specta = { git = "https://github.com/oscartbeaumont/specta", rev = "4bc6e46fc8747cd8d8a07597c1fe13c52aa16a41" }

View file

@ -6,8 +6,8 @@ repository = { workspace = true }
edition = { workspace = true } edition = { workspace = true }
[dependencies] [dependencies]
indoc = "2.0.3" indoc = "2.0.4"
clap = { version = "4.4.2", features = ["derive"] } clap = { version = "4.4.7", features = ["derive"] }
anyhow = "1.0.75" anyhow = "1.0.75"
hex = "0.4.3" hex = "0.4.3"
sd-crypto = { path = "../../crates/crypto" } sd-crypto = { path = "../../crates/crypto" }

View file

@ -6,7 +6,7 @@ repository = { workspace = true }
edition = { workspace = true } edition = { workspace = true }
[dependencies] [dependencies]
thiserror = "1.0.48" thiserror = "1.0.50"
normpath = "1.1.1" normpath = "1.1.1"
libc = "0.2" libc = "0.2"

View file

@ -30,12 +30,12 @@ sd-core = { path = "../../../core", features = [
] } ] }
tokio = { workspace = true, features = ["sync"] } tokio = { workspace = true, features = ["sync"] }
tracing = { workspace = true } tracing = { workspace = true }
serde = "1.0.188" serde = "1.0.190"
http = "0.2.9" http = "0.2.9"
opener = { version = "0.6.1", features = ["reveal"] } opener = { version = "0.6.1", features = ["reveal"] }
specta = { workspace = true } specta = { workspace = true }
tauri-specta = { workspace = true, features = ["typescript"] } tauri-specta = { workspace = true, features = ["typescript"] }
uuid = { version = "1.4.1", features = ["serde"] } uuid = { version = "1.5.0", features = ["serde"] }
futures = "0.3" futures = "0.3"
axum = { version = "0.6.20", features = ["headers", "query"] } axum = { version = "0.6.20", features = ["headers", "query"] }
rand = "0.8.5" rand = "0.8.5"

View file

@ -14,7 +14,7 @@ sd-core = { path = "../../../../../core", features = [
rspc = { workspace = true } rspc = { workspace = true }
serde_json = { workspace = true } serde_json = { workspace = true }
tokio = { workspace = true } tokio = { workspace = true }
futures = "0.3.28" futures = "0.3.29"
tracing = { workspace = true } tracing = { workspace = true }
futures-channel = "0.3.28" futures-channel = "0.3.29"
futures-locks = "0.7.1" futures-locks = "0.7.1"

View file

@ -57,29 +57,29 @@ tokio = { workspace = true, features = [
"process", "process",
] } ] }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
chrono = { version = "0.4.30", features = ["serde"] } chrono = { version = "0.4.31", features = ["serde"] }
serde_json = { workspace = true } serde_json = { workspace = true }
futures = "0.3" futures = "0.3"
rmp-serde = "^1.1.2" rmp-serde = "^1.1.2"
rmpv = "^1.0.1" rmpv = "^1.0.1"
blake3 = "1.4.1" blake3 = "1.5.0"
hostname = "0.3.1" hostname = "0.3.1"
uuid = { workspace = true } uuid = { workspace = true }
sysinfo = "0.29.10" sysinfo = "0.29.10"
thiserror = "1.0.48" thiserror = "1.0.50"
async-trait = "^0.1.73" async-trait = "^0.1.74"
image = "0.24.7" image = "0.24.7"
webp = "0.2.6" webp = "0.2.6"
tracing = { workspace = true } tracing = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] } tracing-subscriber = { workspace = true, features = ["env-filter"] }
async-stream = "0.3.5" async-stream = "0.3.5"
once_cell = "1.18.0" once_cell = "1.18.0"
ctor = "0.2.4" ctor = "0.2.5"
globset = { version = "^0.4.13", features = ["serde1"] } globset = { version = "^0.4.13", features = ["serde1"] }
itertools = "^0.11.0" itertools = "^0.11.0"
http-range = "0.1.5" http-range = "0.1.5"
mini-moka = "0.10.2" mini-moka = "0.10.2"
serde_with = "3.3.0" serde_with = "3.4.0"
notify = { version = "=5.2.0", default-features = false, features = [ notify = { version = "=5.2.0", default-features = false, features = [
"macos_fsevent", "macos_fsevent",
], optional = true } ], optional = true }
@ -89,21 +89,21 @@ normpath = { version = "1.1.1", features = ["localization"] }
tracing-appender = { workspace = true } tracing-appender = { workspace = true }
strum = { version = "0.25", features = ["derive"] } strum = { version = "0.25", features = ["derive"] }
strum_macros = "0.25" strum_macros = "0.25"
regex = "1.9.5" regex = "1.10.2"
int-enum = "0.5.0" int-enum = "0.5.0"
tokio-stream = { version = "0.1.14", features = ["fs"] } tokio-stream = { version = "0.1.14", features = ["fs"] }
futures-concurrency = "7.4.3" futures-concurrency = "7.4.3"
async-channel = "2.0.0" async-channel = "2.0.0"
tokio-util = { version = "0.7.8", features = ["io"] } tokio-util = { version = "0.7.10", features = ["io"] }
slotmap = "1.0.6" slotmap = "1.0.6"
flate2 = "1.0.27" flate2 = "1.0.28"
tar = "0.4.40" tar = "0.4.40"
tempfile = "^3.8.0" tempfile = "^3.8.1"
axum = "0.6.20" axum = "0.6.20"
http-body = "0.4.5" http-body = "0.4.5"
pin-project-lite = "0.2.13" pin-project-lite = "0.2.13"
bytes = "1.5.0" bytes = "1.5.0"
reqwest = { version = "0.11.20", features = ["json", "native-tls-vendored"] } reqwest = { version = "0.11.22", features = ["json", "native-tls-vendored"] }
directories = "5.0.1" directories = "5.0.1"
async-recursion = "1.0.5" async-recursion = "1.0.5"
@ -119,7 +119,7 @@ features = ["vendored"]
plist = "1" plist = "1"
[target.'cfg(windows)'.dependencies.winapi-util] [target.'cfg(windows)'.dependencies.winapi-util]
version = "0.1.5" version = "0.1.6"
[dev-dependencies] [dev-dependencies]
tracing-test = "^0.2.4" tracing-test = "^0.2.4"

View file

@ -8,9 +8,9 @@ repository = { workspace = true }
edition = { workspace = true } edition = { workspace = true }
[dependencies] [dependencies]
reqwest = { version = "0.11.20", features = ["blocking"] } reqwest = { version = "0.11.22", features = ["blocking"] }
clap = { version = "4.4.2", features = ["derive"] } clap = { version = "4.4.7", features = ["derive"] }
anyhow = "1.0.75" anyhow = "1.0.75"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
cargo_metadata = "0.18.0" cargo_metadata = "0.18.1"

View file

@ -13,10 +13,10 @@ edition = { workspace = true }
ffmpeg-sys-next = "6.0.1" ffmpeg-sys-next = "6.0.1"
tracing = { workspace = true } tracing = { workspace = true }
thiserror = "1.0.48" thiserror = "1.0.50"
webp = "0.2.6" webp = "0.2.6"
tokio = { workspace = true, features = ["fs", "rt"] } tokio = { workspace = true, features = ["fs", "rt"] }
[dev-dependencies] [dev-dependencies]
tempfile = "3.8.0" tempfile = "3.8.1"
tokio = { workspace = true, features = ["fs", "rt", "macros"] } tokio = { workspace = true, features = ["fs", "rt", "macros"] }

View file

@ -10,7 +10,7 @@ repository = { workspace = true }
edition = { workspace = true } edition = { workspace = true }
[dependencies] [dependencies]
serde = { version = "1.0.188", features = ["derive"] } serde = { version = "1.0.190", features = ["derive"] }
serde_json = { workspace = true } serde_json = { workspace = true }
strum = { version = "0.25", features = ["derive"] } strum = { version = "0.25", features = ["derive"] }
tokio = { workspace = true, features = ["fs", "rt", "io-util"] } tokio = { workspace = true, features = ["fs", "rt", "io-util"] }

View file

@ -14,7 +14,7 @@ heif = ["dep:libheif-rs", "dep:libheif-sys"]
[dependencies] [dependencies]
image = "0.24.7" image = "0.24.7"
thiserror = "1.0.49" thiserror = "1.0.50"
resvg = "0.36.0" resvg = "0.36.0"
rspc = { workspace = true, optional = true } # error conversion rspc = { workspace = true, optional = true } # error conversion
specta = { workspace = true, optional = true } specta = { workspace = true, optional = true }
@ -30,4 +30,4 @@ tracing = { workspace = true }
# this broke builds as we build our own liibheif, so i disabled their default features # this broke builds as we build our own liibheif, so i disabled their default features
libheif-rs = { version = "0.22.0", default-features = false, optional = true } libheif-rs = { version = "0.22.0", default-features = false, optional = true }
libheif-sys = { version = "2.0.0", default-features = false, optional = true } libheif-sys = { version = "2.0.0", default-features = false, optional = true }
pdfium-render = { version = "0.8.8", features = ["image"] } pdfium-render = { version = "0.8.14", features = ["image"] }

View file

@ -6,9 +6,9 @@ edition = "2021"
[dependencies] [dependencies]
kamadak-exif = "0.5.5" kamadak-exif = "0.5.5"
thiserror = "1.0.49" thiserror = "1.0.50"
image-rs = { package = "image", version = "0.24.7" } image-rs = { package = "image", version = "0.24.7" }
serde = { version = "1.0.188", features = ["derive"] } serde = { version = "1.0.190", features = ["derive"] }
serde_json = { workspace = true } serde_json = { workspace = true }
specta = { workspace = true, features = ["chrono"] } specta = { workspace = true, features = ["chrono"] }
chrono = { version = "0.4.31", features = ["serde"] } chrono = { version = "0.4.31", features = ["serde"] }

View file

@ -21,30 +21,30 @@ tokio = { workspace = true, features = [
"io-util", "io-util",
"fs", "fs",
] } ] }
libp2p = { version = "0.52.3", features = ["tokio", "serde"] } libp2p = { version = "0.52.4", features = ["tokio", "serde"] }
libp2p-quic = { version = "0.9.2", features = ["tokio"] } libp2p-quic = { version = "0.9.3", features = ["tokio"] }
if-watch = { version = "=3.0.1", features = [ if-watch = { version = "=3.1.0", features = [
"tokio", "tokio",
] } # Override the features of if-watch which is used by libp2p-quic ] } # Override the features of if-watch which is used by libp2p-quic
mdns-sd = "0.7.4" mdns-sd = "0.9.3"
thiserror = "1.0.48" thiserror = "1.0.50"
tracing = { workspace = true } tracing = { workspace = true }
serde = { version = "1.0.188", features = ["derive"] } # TODO: Optional or remove feature serde = { version = "1.0.190", features = [
"derive",
] } # TODO: Optional or remove feature
specta = { workspace = true } specta = { workspace = true }
flume = "0.10.0" # Must match version used by `mdns-sd` flume = "0.10.0" # Must match version used by `mdns-sd`
tokio-util = { version = "0.7.8", features = ["compat"] } tokio-util = { version = "0.7.10", features = ["compat"] }
ed25519-dalek = { version = "2.0.0", features = [] } ed25519-dalek = { version = "2.0.0", features = [] }
rand_core = { version = "0.6.4" } rand_core = { version = "0.6.4" }
uuid = "1.4.1" uuid = "1.5.0"
streamunordered = "0.5.3" streamunordered = "0.5.3"
futures-core = "0.3.29" futures-core = "0.3.29"
tokio-stream = { version = "0.1.14", features = ["sync"] } tokio-stream = { version = "0.1.14", features = ["sync"] }
pin-project-lite = "0.2.13" pin-project-lite = "0.2.13"
base64 = "0.21.5" base64 = "0.21.5"
# chacha20poly1305 = "0.10.1"
# rand = "0.8.5"
[dev-dependencies] [dev-dependencies]
tokio = { workspace = true, features = ["rt-multi-thread"] } tokio = { workspace = true, features = ["rt-multi-thread"] }
tracing-subscriber = { workspace = true, features = ["env-filter"] } tracing-subscriber = { workspace = true, features = ["env-filter"] }
uuid = { version = "1.4.1", features = ["v4"] } uuid = { version = "1.5.0", features = ["v4"] }

View file

@ -1,6 +1,6 @@
use std::{ use std::{
collections::HashMap, collections::HashMap,
net::{IpAddr, SocketAddr}, net::SocketAddr,
pin::Pin, pin::Pin,
str::FromStr, str::FromStr,
sync::PoisonError, sync::PoisonError,
@ -64,13 +64,6 @@ impl Mdns {
let mut ports_to_service = HashMap::new(); let mut ports_to_service = HashMap::new();
for addr in listen_addrs.iter() { for addr in listen_addrs.iter() {
let addr = match addr {
SocketAddr::V4(addr) => addr,
// TODO: Our mdns library doesn't support Ipv6. This code has the infra to support it so once this issue is fixed upstream we can just flip it on.
// Refer to issue: https://github.com/keepsimple1/mdns-sd/issues/61
SocketAddr::V6(_) => continue,
};
ports_to_service ports_to_service
.entry(addr.port()) .entry(addr.port())
.or_insert_with(Vec::new) .or_insert_with(Vec::new)
@ -254,7 +247,7 @@ impl Mdns {
addresses: info addresses: info
.get_addresses() .get_addresses()
.iter() .iter()
.map(|addr| SocketAddr::new(IpAddr::V4(*addr), info.get_port())) .map(|addr| SocketAddr::new(*addr, info.get_port()))
.collect(), .collect(),
}, },
); );

View file

@ -1,5 +1,6 @@
use std::{ use std::{
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
convert::Infallible,
fmt, fmt,
net::SocketAddr, net::SocketAddr,
sync::{ sync::{
@ -10,8 +11,7 @@ use std::{
use libp2p::{ use libp2p::{
core::{muxing::StreamMuxerBox, transport::ListenerId, ConnectedPoint}, core::{muxing::StreamMuxerBox, transport::ListenerId, ConnectedPoint},
swarm::SwarmBuilder, PeerId, SwarmBuilder, Transport,
PeerId, Transport,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specta::Type; use specta::Type;
@ -94,15 +94,16 @@ impl Manager {
event_stream_tx2, event_stream_tx2,
}); });
let mut swarm = SwarmBuilder::with_tokio_executor( let mut swarm = ok(ok(SwarmBuilder::with_existing_identity(keypair.inner())
libp2p_quic::GenTransport::<libp2p_quic::tokio::Provider>::new( .with_tokio()
libp2p_quic::Config::new(&keypair.inner()), .with_other_transport(|keypair| {
) libp2p_quic::GenTransport::<libp2p_quic::tokio::Provider>::new(
.map(|(p, c), _| (p, StreamMuxerBox::new(c))) libp2p_quic::Config::new(keypair),
.boxed(), )
SpaceTime::new(this.clone()), .map(|(p, c), _| (p, StreamMuxerBox::new(c)))
keypair.peer_id(), .boxed()
) }))
.with_behaviour(|_| SpaceTime::new(this.clone())))
.build(); .build();
ManagerStream::refresh_listeners( ManagerStream::refresh_listeners(
@ -280,6 +281,8 @@ pub enum ManagerError {
InvalidAppName, InvalidAppName,
#[error("error with mdns discovery: {0}")] #[error("error with mdns discovery: {0}")]
Mdns(#[from] mdns_sd::Error), Mdns(#[from] mdns_sd::Error),
// #[error("todo")]
// Manager(#[from] ManagerError),
} }
/// The configuration for the P2P Manager /// The configuration for the P2P Manager
@ -302,3 +305,10 @@ impl Default for ManagerConfig {
} }
} }
} }
fn ok<T>(v: Result<T, Infallible>) -> T {
match v {
Ok(v) => v,
Err(_) => unreachable!(),
}
}

View file

@ -28,6 +28,7 @@ const SUBSTREAM_TIMEOUT: Duration = Duration::from_secs(10); // TODO: Tune value
pub struct SpaceTimeConnection { pub struct SpaceTimeConnection {
peer_id: PeerId, peer_id: PeerId,
manager: Arc<Manager>, manager: Arc<Manager>,
#[allow(deprecated)]
pending_events: VecDeque< pending_events: VecDeque<
ConnectionHandlerEvent< ConnectionHandlerEvent<
OutboundProtocol, OutboundProtocol,
@ -91,6 +92,7 @@ impl ConnectionHandler for SpaceTimeConnection {
KeepAlive::Yes // TODO: Make this work how the old one did with storing it on `self` and updating on events KeepAlive::Yes // TODO: Make this work how the old one did with storing it on `self` and updating on events
} }
#[allow(deprecated)]
fn poll( fn poll(
&mut self, &mut self,
_cx: &mut Context<'_>, _cx: &mut Context<'_>,

View file

@ -8,5 +8,5 @@ edition = { workspace = true }
[dependencies] [dependencies]
nom = "7.1.3" nom = "7.1.3"
prisma-client-rust-sdk = { workspace = true } prisma-client-rust-sdk = { workspace = true }
serde = { version = "1.0.188", features = ["derive"] } serde = { version = "1.0.190", features = ["derive"] }
thiserror = "1.0.48" thiserror = "1.0.50"

View file

@ -7,8 +7,8 @@ edition = { workspace = true }
[dependencies] [dependencies]
specta = { workspace = true, features = ["uuid", "uhlc"] } specta = { workspace = true, features = ["uuid", "uhlc"] }
serde = "1.0.188" serde = "1.0.190"
serde_json = { workspace = true } serde_json = { workspace = true }
uhlc = "=0.5.2" uhlc = "=0.5.2"
uuid = { version = "1.4.1", features = ["serde", "v4"] } uuid = { version = "1.5.0", features = ["serde", "v4"] }
prisma-client-rust = { workspace = true } prisma-client-rust = { workspace = true }