diff --git a/Cargo.lock b/Cargo.lock index 719dac4513..1328bfc168 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4732,6 +4732,7 @@ version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dac4581f0fc0e0efd529d069e8189ec7b90b8e7680e21beb35141bdc45f36040" dependencies = [ + "log", "ring", "sct 0.7.0", "webpki 0.22.0", @@ -6229,6 +6230,7 @@ dependencies = [ "quinn", "rand 0.8.4", "rcgen", + "rustls 0.20.1", "serde", "shellexpand", "tokio", diff --git a/client/Cargo.toml b/client/Cargo.toml index 5904522dc1..8a39eb58d3 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -21,7 +21,7 @@ common-net = { package = "veloren-common-net", path = "../common/net" } network = { package = "veloren-network", path = "../network", features = ["compression","quic"], default-features = false } byteorder = "1.3.2" -tokio = { version = "1.11", default-features = false, features = ["rt-multi-thread"] } +tokio = { version = "1.14", default-features = false, features = ["rt-multi-thread"] } quinn = "0.8" image = { version = "0.23.12", default-features = false, features = ["png"] } num = "0.4" diff --git a/network/Cargo.toml b/network/Cargo.toml index 5d1e15c308..3aa40f0cd0 100644 --- a/network/Cargo.toml +++ b/network/Cargo.toml @@ -22,7 +22,7 @@ bincode = "1.3.2" serde = { version = "1.0" } #sending crossbeam-channel = "0.5" -tokio = { version = "1.11", default-features = false, features = ["io-util", "macros", "rt", "net", "time"] } +tokio = { version = "1.14", default-features = false, features = ["io-util", "macros", "rt", "net", "time"] } tokio-stream = { version = "0.1.2", default-features = false } #tracing and metrics tracing = { version = "0.1", default-features = false, features = ["attributes"]} @@ -36,6 +36,7 @@ lazy_static = { version = "1.4", default-features = false } rand = { version = "0.8" } #quic support quinn = { version = "0.8", optional = true } +rustls = "0.20.1" #stream flags bitflags = "1.2.1" lz-fear = { version = "0.1.1", optional = true } @@ -47,7 +48,7 @@ hashbrown = { version = ">=0.9, <0.12" } [dev-dependencies] tracing-subscriber = { version = "0.2.25", default-features = false, features = ["env-filter", "fmt", "chrono", "ansi", "smallvec"] } -tokio = { version = "1.11", default-features = false, features = ["io-std", "fs", "rt-multi-thread"] } +tokio = { version = "1.14", default-features = false, features = ["io-std", "fs", "rt-multi-thread"] } futures-util = { version = "0.3.7", default-features = false, features = ["sink", "std"] } clap = { version = "2.33", default-features = false } shellexpand = "2.0.0" diff --git a/network/tests/helper.rs b/network/tests/helper.rs index 2bee092e51..b22df211b4 100644 --- a/network/tests/helper.rs +++ b/network/tests/helper.rs @@ -103,34 +103,28 @@ pub fn quic() -> (ListenAddr, ConnectAddr) { const LOCALHOST: &str = "localhost"; let port = UDP_PORTS.fetch_add(1, Ordering::Relaxed); - let transport_config = quinn::TransportConfig::default(); - let mut server_config = quinn::ServerConfig::default(); - server_config.transport = Arc::new(transport_config); - let mut server_config = quinn::ServerConfigBuilder::new(server_config); - trace!("generating self-signed certificate"); let cert = rcgen::generate_simple_self_signed(vec![LOCALHOST.into()]).unwrap(); let key = cert.serialize_private_key_der(); let cert = cert.serialize_der().unwrap(); - let key = quinn::PrivateKey::from_der(&key).expect("private key failed"); - let cert = quinn::Certificate::from_der(&cert).expect("cert failed"); - server_config - .certificate(quinn::CertificateChain::from_certs(vec![cert.clone()]), key) - .expect("set cert failed"); + let key = rustls::PrivateKey(key); + let cert = rustls::Certificate(cert); - let server_config = server_config.build(); + let mut root_store = rustls::RootCertStore::empty(); + root_store.add(&cert).expect("cannot add cert to rootstore"); - let mut client_config = quinn::ClientConfigBuilder::default(); - client_config - .add_certificate_authority(cert) - .expect("adding certificate failed"); - - let client_config = client_config.build(); + let server_config = quinn::ServerConfig::with_single_cert(vec![cert], key) + .expect("Server Config Cert/Key failed"); + let client_config = quinn::ClientConfig::with_root_certificates(root_store); + use std::net::{IpAddr, Ipv4Addr}; ( - ListenAddr::Quic(SocketAddr::from(([127, 0, 0, 1], port)), server_config), + ListenAddr::Quic( + SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), port), + server_config, + ), ConnectAddr::Quic( - SocketAddr::from(([127, 0, 0, 1], port)), + SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), port), client_config, LOCALHOST.to_owned(), ), diff --git a/server-cli/Cargo.toml b/server-cli/Cargo.toml index d0230f5309..ab919077ea 100644 --- a/server-cli/Cargo.toml +++ b/server-cli/Cargo.toml @@ -31,7 +31,7 @@ common-base = { package = "veloren-common-base", path = "../common/base" } common-net = { package = "veloren-common-net", path = "../common/net" } common-frontend = { package = "veloren-common-frontend", path = "../common/frontend" } -tokio = { version = "1.11", default-features = false, features = ["rt-multi-thread"] } +tokio = { version = "1.14", default-features = false, features = ["rt-multi-thread"] } num_cpus = "1.0" ansi-parser = "0.8" clap = "2.33" diff --git a/server/Cargo.toml b/server/Cargo.toml index 35b66f82ff..13a1a4a66c 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -34,7 +34,7 @@ num_cpus = "1.0" tracing = "0.1" vek = { version = "0.14.1", features = ["serde"] } futures-util = "0.3.7" -tokio = { version = "1.11", default-features = false, features = ["rt"] } +tokio = { version = "1.14", default-features = false, features = ["rt"] } prometheus-hyper = "0.1.2" quinn = "0.8" rustls = { version = "0.20", default-features = false } diff --git a/server/src/lib.rs b/server/src/lib.rs index e1566faa3b..8f60e18e5d 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -487,10 +487,7 @@ impl Server { } else { debug!("convert pem cert to der"); let certs = rustls_pemfile::certs(&mut cert_chain.as_slice())?; - certs - .into_iter() - .map(|cert| rustls::Certificate(cert)) - .collect() + certs.into_iter().map(rustls::Certificate).collect() }; let server_config = quinn::ServerConfig::with_single_cert(cert_chain, key)?; Ok(server_config) diff --git a/world/examples/world_block_statistics.rs b/world/examples/world_block_statistics.rs index a6c0138e8b..cccfd75782 100644 --- a/world/examples/world_block_statistics.rs +++ b/world/examples/world_block_statistics.rs @@ -236,7 +236,7 @@ fn palette(conn: Connection) -> Result<(), Box> { } } let mut f = File::create("palettes.ron")?; - let pretty = ron::ser::PrettyConfig::default().with_depth_limit(2); + let pretty = ron::ser::PrettyConfig::default().depth_limit(2); write!(f, "{}", ron::ser::to_string_pretty(&palettes, pretty)?)?; Ok(()) }