mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
EXPERIMENTAL QUIC server and client, DO NOT MERGE
This commit is contained in:
parent
c06d4d0156
commit
8d5b98bbf5
3
Cargo.lock
generated
3
Cargo.lock
generated
@ -5483,6 +5483,7 @@ dependencies = [
|
||||
"hashbrown",
|
||||
"image",
|
||||
"num 0.4.0",
|
||||
"quinn",
|
||||
"rayon",
|
||||
"ron",
|
||||
"rustyline",
|
||||
@ -5719,9 +5720,11 @@ dependencies = [
|
||||
"portpicker",
|
||||
"prometheus",
|
||||
"prometheus-hyper",
|
||||
"quinn",
|
||||
"rand 0.8.3",
|
||||
"rand_distr",
|
||||
"rayon",
|
||||
"rcgen",
|
||||
"refinery",
|
||||
"ron",
|
||||
"rusqlite",
|
||||
|
@ -20,6 +20,7 @@ common-systems = { package = "veloren-common-systems", path = "../common/systems
|
||||
common-net = { package = "veloren-common-net", path = "../common/net" }
|
||||
network = { package = "veloren-network", path = "../network", features = ["compression"], default-features = false }
|
||||
|
||||
quinn = "0.7.2"
|
||||
byteorder = "1.3.2"
|
||||
futures-util = "0.3.7"
|
||||
tokio = { version = "1", default-features = false, features = ["rt-multi-thread"] }
|
||||
|
@ -217,7 +217,44 @@ impl Client {
|
||||
// Try to connect to all IP's and return the first that works
|
||||
let mut participant = None;
|
||||
for addr in addrs {
|
||||
match network.connect(ConnectAddr::Tcp(addr)).await {
|
||||
let mut client_config = quinn::ClientConfigBuilder::default();
|
||||
client_config.protocols(&[b"veloren"]);
|
||||
let cert = vec![
|
||||
48, 130, 1, 73, 48, 129, 241, 160, 3, 2, 1, 2, 2, 1, 42, 48, 10, 6, 8, 42,
|
||||
134, 72, 206, 61, 4, 3, 2, 48, 33, 49, 31, 48, 29, 6, 3, 85, 4, 3, 12, 22,
|
||||
114, 99, 103, 101, 110, 32, 115, 101, 108, 102, 32, 115, 105, 103, 110,
|
||||
101, 100, 32, 99, 101, 114, 116, 48, 32, 23, 13, 55, 53, 48, 49, 48, 49,
|
||||
48, 48, 48, 48, 48, 48, 90, 24, 15, 52, 48, 57, 54, 48, 49, 48, 49, 48, 48,
|
||||
48, 48, 48, 48, 90, 48, 33, 49, 31, 48, 29, 6, 3, 85, 4, 3, 12, 22, 114,
|
||||
99, 103, 101, 110, 32, 115, 101, 108, 102, 32, 115, 105, 103, 110, 101,
|
||||
100, 32, 99, 101, 114, 116, 48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2,
|
||||
1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, 58, 203, 14, 179, 34,
|
||||
109, 217, 182, 42, 217, 92, 191, 224, 61, 95, 112, 166, 94, 36, 106, 71,
|
||||
88, 81, 167, 77, 103, 85, 92, 88, 166, 177, 96, 7, 153, 83, 222, 117, 3,
|
||||
213, 23, 55, 137, 55, 32, 81, 254, 142, 153, 246, 172, 153, 90, 172, 214,
|
||||
78, 234, 84, 104, 56, 71, 170, 102, 30, 125, 163, 24, 48, 22, 48, 20, 6, 3,
|
||||
85, 29, 17, 4, 13, 48, 11, 130, 9, 108, 111, 99, 97, 108, 104, 111, 115,
|
||||
116, 48, 10, 6, 8, 42, 134, 72, 206, 61, 4, 3, 2, 3, 71, 0, 48, 68, 2, 32,
|
||||
109, 43, 248, 126, 24, 88, 63, 107, 155, 121, 46, 160, 25, 138, 32, 80, 5,
|
||||
80, 161, 60, 157, 28, 241, 240, 177, 102, 164, 112, 115, 13, 147, 237, 2,
|
||||
32, 111, 239, 81, 7, 236, 11, 109, 67, 168, 37, 246, 2, 121, 36, 147, 25,
|
||||
245, 163, 17, 36, 78, 47, 185, 138, 10, 58, 162, 157, 188, 190, 47, 59,
|
||||
];
|
||||
let cert = quinn::Certificate::from_der(&cert).unwrap();
|
||||
client_config
|
||||
.add_certificate_authority(cert)
|
||||
.expect("adding certificate failed");
|
||||
|
||||
let client_config = client_config.build();
|
||||
|
||||
match network
|
||||
.connect(ConnectAddr::Quic(
|
||||
addr,
|
||||
client_config,
|
||||
"localhost".to_owned(),
|
||||
))
|
||||
.await
|
||||
{
|
||||
Ok(p) => {
|
||||
participant = Some(Ok(p));
|
||||
break;
|
||||
|
@ -25,6 +25,8 @@ network = { package = "veloren-network", path = "../network", features = ["metri
|
||||
specs = { git = "https://github.com/amethyst/specs.git", features = ["shred-derive"], rev = "5a9b71035007be0e3574f35184acac1cd4530496" }
|
||||
specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", rev = "b65fb220e94f5d3c9bc30074a076149763795556" }
|
||||
|
||||
rcgen = "0.8.10"
|
||||
quinn = "0.7.2"
|
||||
num_cpus = "1.0"
|
||||
tracing = "0.1"
|
||||
vek = { version = "0.14.1", features = ["serde"] }
|
||||
|
@ -388,6 +388,32 @@ impl Server {
|
||||
});
|
||||
runtime.block_on(network.listen(ListenAddr::Tcp(settings.gameserver_address)))?;
|
||||
runtime.block_on(network.listen(ListenAddr::Mpsc(14004)))?;
|
||||
|
||||
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);
|
||||
server_config.protocols(&[b"veloren"]);
|
||||
|
||||
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();
|
||||
|
||||
info!(?key, "KEY");
|
||||
info!(?cert, "CERT");
|
||||
|
||||
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 server_config = server_config.build();
|
||||
|
||||
runtime.block_on(
|
||||
network.listen(ListenAddr::Quic(settings.gameserver_address, server_config)),
|
||||
)?;
|
||||
let connection_handler = ConnectionHandler::new(network, &runtime);
|
||||
|
||||
// Initiate real-time world simulation
|
||||
|
Loading…
Reference in New Issue
Block a user