Upgrade quinn to 0.9
This commit is contained in:
parent
7c50b1bd18
commit
01a29bd2a2
68
Cargo.lock
generated
68
Cargo.lock
generated
@ -452,15 +452,6 @@ dependencies = [
|
||||
"xmpp-proxy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fxhash"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.5"
|
||||
@ -923,16 +914,15 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
||||
|
||||
[[package]]
|
||||
name = "quinn"
|
||||
version = "0.8.3"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7542006acd6e057ff632307d219954c44048f818898da03113d6c0086bfddd9"
|
||||
checksum = "445cbfe2382fa023c4f2f3c7e1c95c03dcc1df2bf23cebcb2b13e1402c4394d1"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"fxhash",
|
||||
"pin-project-lite",
|
||||
"quinn-proto",
|
||||
"quinn-udp",
|
||||
"rustc-hash",
|
||||
"rustls",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
@ -942,17 +932,16 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "quinn-proto"
|
||||
version = "0.8.3"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3a13a5c0a674c1ce7150c9df7bc4a1e46c2fbbe7c710f56c0dc78b1a810e779e"
|
||||
checksum = "72ef4ced82a24bb281af338b9e8f94429b6eca01b4e66d899f40031f074e74c9"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"fxhash",
|
||||
"rand",
|
||||
"ring",
|
||||
"rustc-hash",
|
||||
"rustls",
|
||||
"rustls-native-certs",
|
||||
"rustls-pemfile 0.2.1",
|
||||
"slab",
|
||||
"thiserror",
|
||||
"tinyvec",
|
||||
@ -962,16 +951,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "quinn-udp"
|
||||
version = "0.1.2"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3149f7237331015f1a6adf065c397d1be71e032fcf110ba41da52e7926b882f"
|
||||
checksum = "641538578b21f5e5c8ea733b736895576d0fe329bb883b937db6f4d163dbaaf4"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"libc",
|
||||
"quinn-proto",
|
||||
"socket2",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1085,7 +1073,7 @@ dependencies = [
|
||||
"pin-project-lite",
|
||||
"rustls",
|
||||
"rustls-native-certs",
|
||||
"rustls-pemfile 1.0.0",
|
||||
"rustls-pemfile",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
@ -1126,6 +1114,12 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.4.0"
|
||||
@ -1168,20 +1162,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50"
|
||||
dependencies = [
|
||||
"openssl-probe",
|
||||
"rustls-pemfile 1.0.0",
|
||||
"rustls-pemfile",
|
||||
"schannel",
|
||||
"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]]
|
||||
name = "rustls-pemfile"
|
||||
version = "1.0.0"
|
||||
@ -1879,6 +1864,21 @@ dependencies = [
|
||||
"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]]
|
||||
name = "windows-sys"
|
||||
version = "0.45.0"
|
||||
@ -2021,7 +2021,7 @@ dependencies = [
|
||||
"ring",
|
||||
"rustls",
|
||||
"rustls-native-certs",
|
||||
"rustls-pemfile 1.0.0",
|
||||
"rustls-pemfile",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
|
@ -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"] }
|
||||
|
||||
# quic deps
|
||||
quinn = { version = "0.8", optional = true }
|
||||
quinn = { version = "0.9", optional = true }
|
||||
|
||||
# shared deps needed by quic and incoming
|
||||
rustls = { version = "0.20.2", optional = true }
|
||||
|
@ -47,7 +47,7 @@ pub type ServerCerts = ();
|
||||
pub enum ServerCerts {
|
||||
Tls(&'static ServerConnection),
|
||||
#[cfg(feature = "quic")]
|
||||
Quic(quinn::Connection),
|
||||
Quic(Arc<quinn::Connection>),
|
||||
}
|
||||
|
||||
#[cfg(feature = "s2s-incoming")]
|
||||
|
@ -5,31 +5,31 @@ use crate::{
|
||||
};
|
||||
use anyhow::Result;
|
||||
use die::Die;
|
||||
use futures::StreamExt;
|
||||
use log::{error, info};
|
||||
use quinn::{Endpoint, EndpointConfig, ServerConfig};
|
||||
use quinn::{Endpoint, EndpointConfig, ServerConfig, TokioRuntime};
|
||||
use std::{net::UdpSocket, sync::Arc};
|
||||
use tokio::task::JoinHandle;
|
||||
|
||||
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 (_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 {
|
||||
// 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();
|
||||
tokio::spawn(async move {
|
||||
if let Ok(mut new_conn) = incoming_conn.await {
|
||||
let client_addr = Context::new("quic-in", new_conn.connection.remote_address());
|
||||
if let Ok(new_conn) = incoming_conn.await {
|
||||
let client_addr = Context::new("quic-in", new_conn.remote_address());
|
||||
|
||||
let new_conn = Arc::new(new_conn);
|
||||
#[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"))]
|
||||
let server_certs = ();
|
||||
|
||||
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 mut client_addr = client_addr.clone();
|
||||
let server_certs = server_certs.clone();
|
||||
|
@ -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));
|
||||
|
||||
// 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());
|
||||
|
||||
let (wrt, rd) = connection.open_bi().await?;
|
||||
|
Loading…
Reference in New Issue
Block a user