From 3d3605ac55004ecf2deeaba4cbe698fe7afa7838 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Wed, 4 Dec 2024 21:03:02 +0100 Subject: [PATCH] update bones_framework --- Cargo.lock | 47 ++----------------- framework_crates/bones_framework/Cargo.toml | 1 - .../bones_framework/src/networking.rs | 17 ++++--- .../bones_framework/src/networking/lan.rs | 2 +- .../bones_framework/src/networking/online.rs | 4 +- .../bones_framework/src/networking/socket.rs | 12 ++--- 6 files changed, 21 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f4bd7eebc..f7dd1cdb61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1489,7 +1489,6 @@ dependencies = [ "instant", "intl-memoizer", "iroh", - "iroh-quinn 0.11.3", "kira", "mdns-sd", "noise", @@ -4044,8 +4043,8 @@ dependencies = [ "iroh-base", "iroh-metrics", "iroh-net-report", - "iroh-quinn 0.12.0", - "iroh-quinn-proto 0.12.0", + "iroh-quinn", + "iroh-quinn-proto", "iroh-quinn-udp", "iroh-relay", "libc", @@ -4184,24 +4183,6 @@ dependencies = [ "url", ] -[[package]] -name = "iroh-quinn" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fd590a39a14cfc168efa4d894de5039d65641e62d8da4a80733018ababe3c33" -dependencies = [ - "bytes", - "iroh-quinn-proto 0.11.6", - "iroh-quinn-udp", - "pin-project-lite", - "rustc-hash 2.0.0", - "rustls 0.23.12", - "socket2 0.5.7", - "thiserror 1.0.63", - "tokio", - "tracing", -] - [[package]] name = "iroh-quinn" version = "0.12.0" @@ -4209,7 +4190,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35ba75a5c57cff299d2d7ca1ddee053f66339d1756bd79ec637bcad5aa61100e" dependencies = [ "bytes", - "iroh-quinn-proto 0.12.0", + "iroh-quinn-proto", "iroh-quinn-udp", "pin-project-lite", "rustc-hash 2.0.0", @@ -4220,24 +4201,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "iroh-quinn-proto" -version = "0.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd0538ff12efe3d61ea1deda2d7913f4270873a519d43e6995c6e87a1558538" -dependencies = [ - "bytes", - "rand", - "ring", - "rustc-hash 2.0.0", - "rustls 0.23.12", - "rustls-platform-verifier", - "slab", - "thiserror 1.0.63", - "tinyvec", - "tracing", -] - [[package]] name = "iroh-quinn-proto" version = "0.12.0" @@ -4295,8 +4258,8 @@ dependencies = [ "hyper-util", "iroh-base", "iroh-metrics", - "iroh-quinn 0.12.0", - "iroh-quinn-proto 0.12.0", + "iroh-quinn", + "iroh-quinn-proto", "libc", "num_enum 0.7.3", "once_cell", diff --git a/framework_crates/bones_framework/Cargo.toml b/framework_crates/bones_framework/Cargo.toml index 38cb65f68a..9c50d09cfa 100644 --- a/framework_crates/bones_framework/Cargo.toml +++ b/framework_crates/bones_framework/Cargo.toml @@ -153,7 +153,6 @@ postcard = { version = "1.0", features = ["alloc"] } rcgen = "0.12" rustls = { version = "0.21", features = ["dangerous_configuration", "quic"] } smallvec = "1.10" -iroh-quinn = { version = "0.11" } tokio = { version = "1", features = ["rt-multi-thread", "macros"] } turborand = { version = "0.10.0", features = ["atomic"] } iroh = { workspace = true, features = ["discovery-local-network"] } diff --git a/framework_crates/bones_framework/src/networking.rs b/framework_crates/bones_framework/src/networking.rs index 8f52b20191..6b5775b10d 100644 --- a/framework_crates/bones_framework/src/networking.rs +++ b/framework_crates/bones_framework/src/networking.rs @@ -110,26 +110,25 @@ impl ggrs::Config for GgrsConfig { } /// The network endpoint used for all network communications. -static NETWORK_ENDPOINT: tokio::sync::OnceCell = - tokio::sync::OnceCell::const_new(); +static NETWORK_ENDPOINT: tokio::sync::OnceCell = tokio::sync::OnceCell::const_new(); /// Get the network endpoint used for all communications. -pub async fn get_network_endpoint() -> &'static iroh_net::Endpoint { +pub async fn get_network_endpoint() -> &'static iroh::Endpoint { NETWORK_ENDPOINT .get_or_init(|| async move { - let secret_key = iroh_net::key::SecretKey::generate(); - iroh_net::Endpoint::builder() + let secret_key = iroh::key::SecretKey::generate(); + iroh::Endpoint::builder() .alpns(vec![MATCH_ALPN.to_vec(), PLAY_ALPN.to_vec()]) .discovery(Box::new( - iroh_net::discovery::ConcurrentDiscovery::from_services(vec![ + iroh::discovery::ConcurrentDiscovery::from_services(vec![ Box::new( - iroh_net::discovery::local_swarm_discovery::LocalSwarmDiscovery::new( + iroh::discovery::local_swarm_discovery::LocalSwarmDiscovery::new( secret_key.public(), ) .unwrap(), ), - Box::new(iroh_net::discovery::dns::DnsDiscovery::n0_dns()), - Box::new(iroh_net::discovery::pkarr::PkarrPublisher::n0_dns( + Box::new(iroh::discovery::dns::DnsDiscovery::n0_dns()), + Box::new(iroh::discovery::pkarr::PkarrPublisher::n0_dns( secret_key.clone(), )), ]), diff --git a/framework_crates/bones_framework/src/networking/lan.rs b/framework_crates/bones_framework/src/networking/lan.rs index f67039a380..7a1a3231f9 100644 --- a/framework_crates/bones_framework/src/networking/lan.rs +++ b/framework_crates/bones_framework/src/networking/lan.rs @@ -12,7 +12,7 @@ use std::{net::IpAddr, time::Duration}; -use iroh_net::{endpoint::get_remote_node_id, NodeAddr}; +use iroh::{endpoint::get_remote_node_id, NodeAddr}; use mdns_sd::{ServiceDaemon, ServiceInfo}; use smallvec::SmallVec; use tracing::warn; diff --git a/framework_crates/bones_framework/src/networking/online.rs b/framework_crates/bones_framework/src/networking/online.rs index ce807bc2bf..09781eeee4 100644 --- a/framework_crates/bones_framework/src/networking/online.rs +++ b/framework_crates/bones_framework/src/networking/online.rs @@ -9,9 +9,7 @@ use crate::{ pub use bones_matchmaker_proto::{ GameID, LobbyId, LobbyInfo, LobbyListItem, MatchInfo, PlayerIdxAssignment, MATCH_ALPN, }; -use iroh_net::Endpoint; -use iroh_net::NodeId; -use iroh_quinn::Connection; +use iroh::{endpoint::Connection, Endpoint, NodeId}; use once_cell::sync::Lazy; use tracing::{info, warn}; diff --git a/framework_crates/bones_framework/src/networking/socket.rs b/framework_crates/bones_framework/src/networking/socket.rs index 13f7def97e..4a578b9efb 100644 --- a/framework_crates/bones_framework/src/networking/socket.rs +++ b/framework_crates/bones_framework/src/networking/socket.rs @@ -3,7 +3,7 @@ use bones_matchmaker_proto::PLAY_ALPN; use bytes::Bytes; -use iroh_net::NodeAddr; +use iroh::NodeAddr; use tracing::{info, warn}; use crate::networking::get_network_endpoint; @@ -13,7 +13,7 @@ use super::{GameMessage, NetworkSocket, SocketTarget, RUNTIME}; /// The [`NetworkSocket`] implementation. #[derive(Debug, Clone)] pub struct Socket { - pub connections: Vec<(u32, iroh_quinn::Connection)>, + pub connections: Vec<(u32, iroh::endpoint::Connection)>, pub ggrs_receiver: async_channel::Receiver<(u32, GameMessage)>, pub reliable_receiver: async_channel::Receiver<(u32, Vec)>, pub player_idx: u32, @@ -23,7 +23,7 @@ pub struct Socket { } impl Socket { - pub fn new(player_idx: u32, connections: Vec<(u32, iroh_quinn::Connection)>) -> Self { + pub fn new(player_idx: u32, connections: Vec<(u32, iroh::endpoint::Connection)>) -> Self { let (ggrs_sender, ggrs_receiver) = async_channel::unbounded(); let (reliable_sender, reliable_receiver) = async_channel::unbounded(); @@ -129,7 +129,7 @@ impl Socket { } } - fn get_connection(&self, idx: u32) -> &iroh_quinn::Connection { + fn get_connection(&self, idx: u32) -> &iroh::endpoint::Connection { debug_assert!(idx < self.player_count); // TODO: if this is too slow, optimize storage self.connections @@ -217,8 +217,8 @@ pub(super) async fn establish_peer_connections( player_idx: u32, player_count: u32, peer_addrs: Vec<(u32, NodeAddr)>, - conn: Option, -) -> anyhow::Result> { + conn: Option, +) -> anyhow::Result> { let mut peer_connections = Vec::new(); let had_og_conn = conn.is_some(); if let Some(conn) = conn {