Upgrade quinn to 0.9

This commit is contained in:
Travis Burtrum 2023-02-19 20:49:27 -05:00
parent 7c50b1bd18
commit 01a29bd2a2
5 changed files with 45 additions and 45 deletions

68
Cargo.lock generated
View File

@ -452,15 +452,6 @@ dependencies = [
"xmpp-proxy", "xmpp-proxy",
] ]
[[package]]
name = "fxhash"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
dependencies = [
"byteorder",
]
[[package]] [[package]]
name = "generic-array" name = "generic-array"
version = "0.14.5" version = "0.14.5"
@ -923,16 +914,15 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
[[package]] [[package]]
name = "quinn" name = "quinn"
version = "0.8.3" version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7542006acd6e057ff632307d219954c44048f818898da03113d6c0086bfddd9" checksum = "445cbfe2382fa023c4f2f3c7e1c95c03dcc1df2bf23cebcb2b13e1402c4394d1"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures-channel", "pin-project-lite",
"futures-util",
"fxhash",
"quinn-proto", "quinn-proto",
"quinn-udp", "quinn-udp",
"rustc-hash",
"rustls", "rustls",
"thiserror", "thiserror",
"tokio", "tokio",
@ -942,17 +932,16 @@ dependencies = [
[[package]] [[package]]
name = "quinn-proto" name = "quinn-proto"
version = "0.8.3" version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a13a5c0a674c1ce7150c9df7bc4a1e46c2fbbe7c710f56c0dc78b1a810e779e" checksum = "72ef4ced82a24bb281af338b9e8f94429b6eca01b4e66d899f40031f074e74c9"
dependencies = [ dependencies = [
"bytes", "bytes",
"fxhash",
"rand", "rand",
"ring", "ring",
"rustc-hash",
"rustls", "rustls",
"rustls-native-certs", "rustls-native-certs",
"rustls-pemfile 0.2.1",
"slab", "slab",
"thiserror", "thiserror",
"tinyvec", "tinyvec",
@ -962,16 +951,15 @@ dependencies = [
[[package]] [[package]]
name = "quinn-udp" name = "quinn-udp"
version = "0.1.2" version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3149f7237331015f1a6adf065c397d1be71e032fcf110ba41da52e7926b882f" checksum = "641538578b21f5e5c8ea733b736895576d0fe329bb883b937db6f4d163dbaaf4"
dependencies = [ dependencies = [
"futures-util",
"libc", "libc",
"quinn-proto", "quinn-proto",
"socket2", "socket2",
"tokio",
"tracing", "tracing",
"windows-sys 0.42.0",
] ]
[[package]] [[package]]
@ -1085,7 +1073,7 @@ dependencies = [
"pin-project-lite", "pin-project-lite",
"rustls", "rustls",
"rustls-native-certs", "rustls-native-certs",
"rustls-pemfile 1.0.0", "rustls-pemfile",
"serde", "serde",
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
@ -1126,6 +1114,12 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]] [[package]]
name = "rustc_version" name = "rustc_version"
version = "0.4.0" version = "0.4.0"
@ -1168,20 +1162,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50"
dependencies = [ dependencies = [
"openssl-probe", "openssl-probe",
"rustls-pemfile 1.0.0", "rustls-pemfile",
"schannel", "schannel",
"security-framework", "security-framework",
] ]
[[package]]
name = "rustls-pemfile"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9"
dependencies = [
"base64",
]
[[package]] [[package]]
name = "rustls-pemfile" name = "rustls-pemfile"
version = "1.0.0" version = "1.0.0"
@ -1879,6 +1864,21 @@ dependencies = [
"windows_x86_64_msvc 0.36.1", "windows_x86_64_msvc 0.36.1",
] ]
[[package]]
name = "windows-sys"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc 0.42.1",
"windows_i686_gnu 0.42.1",
"windows_i686_msvc 0.42.1",
"windows_x86_64_gnu 0.42.1",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc 0.42.1",
]
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.45.0" version = "0.45.0"
@ -2021,7 +2021,7 @@ dependencies = [
"ring", "ring",
"rustls", "rustls",
"rustls-native-certs", "rustls-native-certs",
"rustls-pemfile 1.0.0", "rustls-pemfile",
"serde", "serde",
"serde_derive", "serde_derive",
"serde_json", "serde_json",

View File

@ -56,7 +56,7 @@ rustls-native-certs = { version = "0.6", optional = true }
reqwest = { version = "0.11", optional = true, default-features = false, features = ["rustls-tls-native-roots", "json", "gzip", "trust-dns"] } reqwest = { version = "0.11", optional = true, default-features = false, features = ["rustls-tls-native-roots", "json", "gzip", "trust-dns"] }
# quic deps # quic deps
quinn = { version = "0.8", optional = true } quinn = { version = "0.9", optional = true }
# shared deps needed by quic and incoming # shared deps needed by quic and incoming
rustls = { version = "0.20.2", optional = true } rustls = { version = "0.20.2", optional = true }

View File

@ -47,7 +47,7 @@ pub type ServerCerts = ();
pub enum ServerCerts { pub enum ServerCerts {
Tls(&'static ServerConnection), Tls(&'static ServerConnection),
#[cfg(feature = "quic")] #[cfg(feature = "quic")]
Quic(quinn::Connection), Quic(Arc<quinn::Connection>),
} }
#[cfg(feature = "s2s-incoming")] #[cfg(feature = "s2s-incoming")]

View File

@ -5,31 +5,31 @@ use crate::{
}; };
use anyhow::Result; use anyhow::Result;
use die::Die; use die::Die;
use futures::StreamExt;
use log::{error, info}; use log::{error, info};
use quinn::{Endpoint, EndpointConfig, ServerConfig}; use quinn::{Endpoint, EndpointConfig, ServerConfig, TokioRuntime};
use std::{net::UdpSocket, sync::Arc}; use std::{net::UdpSocket, sync::Arc};
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
pub fn spawn_quic_listener(udp_socket: UdpSocket, config: CloneableConfig, server_config: ServerConfig) -> JoinHandle<Result<()>> { pub fn spawn_quic_listener(udp_socket: UdpSocket, config: CloneableConfig, server_config: ServerConfig) -> JoinHandle<Result<()>> {
let local_addr = udp_socket.local_addr().die("cannot get local_addr for quic socket"); let local_addr = udp_socket.local_addr().die("cannot get local_addr for quic socket");
let (_endpoint, mut incoming) = Endpoint::new(EndpointConfig::default(), Some(server_config), udp_socket).die("cannot listen on port/interface"); let incoming = Endpoint::new(EndpointConfig::default(), Some(server_config), udp_socket, TokioRuntime).die("cannot listen on port/interface");
tokio::spawn(async move { tokio::spawn(async move {
// when could this return None, do we quit? // when could this return None, do we quit?
while let Some(incoming_conn) = incoming.next().await { while let Some(incoming_conn) = incoming.accept().await {
let config = config.clone(); let config = config.clone();
tokio::spawn(async move { tokio::spawn(async move {
if let Ok(mut new_conn) = incoming_conn.await { if let Ok(new_conn) = incoming_conn.await {
let client_addr = Context::new("quic-in", new_conn.connection.remote_address()); let client_addr = Context::new("quic-in", new_conn.remote_address());
let new_conn = Arc::new(new_conn);
#[cfg(feature = "s2s-incoming")] #[cfg(feature = "s2s-incoming")]
let server_certs = ServerCerts::Quic(new_conn.connection); let server_certs = ServerCerts::Quic(new_conn.clone());
#[cfg(not(feature = "s2s-incoming"))] #[cfg(not(feature = "s2s-incoming"))]
let server_certs = (); let server_certs = ();
info!("{} connected new connection", client_addr.log_from()); info!("{} connected new connection", client_addr.log_from());
while let Some(Ok((wrt, rd))) = new_conn.bi_streams.next().await { while let Ok((wrt, rd)) = new_conn.accept_bi().await {
let config = config.clone(); let config = config.clone();
let mut client_addr = client_addr.clone(); let mut client_addr = client_addr.clone();
let server_certs = server_certs.clone(); let server_certs = server_certs.clone();

View File

@ -15,7 +15,7 @@ pub async fn quic_connect(target: SocketAddr, server_name: &str, config: Outgoin
endpoint.set_default_client_config(quinn::ClientConfig::new(client_cfg)); endpoint.set_default_client_config(quinn::ClientConfig::new(client_cfg));
// connect to server // connect to server
let quinn::NewConnection { connection, .. } = endpoint.connect(target, server_name)?.await?; let connection = endpoint.connect(target, server_name)?.await?;
trace!("quic connected: addr={}", connection.remote_address()); trace!("quic connected: addr={}", connection.remote_address());
let (wrt, rd) = connection.open_bi().await?; let (wrt, rd) = connection.open_bi().await?;