mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
Merge branch 'master' of github.com:LuoTianOrange/noita_entangled_worlds
This commit is contained in:
commit
67a8538a64
14 changed files with 147 additions and 43 deletions
|
@ -1,23 +1,12 @@
|
|||
//! Various common public types.
|
||||
|
||||
use std::{fmt::Display, time::Duration};
|
||||
use std::fmt::Display;
|
||||
|
||||
use bitcode::{Decode, Encode};
|
||||
|
||||
/// Per-peer settings. Peers that are connected to the same host, as well as the host itself, should have the same settings.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Settings {
|
||||
/// A single datagram will confirm at most this much messages. Default is 128.
|
||||
pub confirm_max_per_message: usize,
|
||||
/// How much time can elapse before another confirm is sent.
|
||||
/// Confirms are also sent when enough messages are awaiting confirm.
|
||||
/// Note that confirms also double as "heartbeats" and keep the connection alive, so this value should be much less than `connection_timeout`.
|
||||
/// Default: 1 second.
|
||||
pub confirm_max_period: Duration,
|
||||
/// Peers will be disconnected after this much time without any datagrams from them has passed.
|
||||
/// Default: 10 seconds.
|
||||
pub connection_timeout: Duration,
|
||||
}
|
||||
pub struct Settings {}
|
||||
|
||||
/// Tells how reliable a message is.
|
||||
#[derive(Encode, Decode, Clone, Copy, PartialEq, Debug)]
|
||||
|
@ -95,11 +84,7 @@ impl Display for PeerId {
|
|||
|
||||
impl Default for Settings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
confirm_max_per_message: 128,
|
||||
confirm_max_period: Duration::from_secs(1),
|
||||
connection_timeout: Duration::from_secs(10),
|
||||
}
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ use quinn::{
|
|||
pki_types::{CertificateDer, PrivatePkcs8KeyDer},
|
||||
},
|
||||
ClientConfig, ConnectError, Connecting, ConnectionError, Endpoint, Incoming, RecvStream,
|
||||
ServerConfig,
|
||||
ServerConfig, TransportConfig,
|
||||
};
|
||||
use thiserror::Error;
|
||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
|
@ -467,6 +467,10 @@ fn default_server_config() -> ServerConfig {
|
|||
let cert_der = CertificateDer::from(cert.cert);
|
||||
let priv_key = PrivatePkcs8KeyDer::from(cert.key_pair.serialize_der());
|
||||
|
||||
let config = ServerConfig::with_single_cert(vec![cert_der.clone()], priv_key.into()).unwrap();
|
||||
let mut config =
|
||||
ServerConfig::with_single_cert(vec![cert_der.clone()], priv_key.into()).unwrap();
|
||||
let mut transport_config = TransportConfig::default();
|
||||
transport_config.keep_alive_interval(Some(Duration::from_secs(10)));
|
||||
config.transport_config(Arc::new(transport_config));
|
||||
config
|
||||
}
|
||||
|
|
|
@ -159,8 +159,6 @@ mod test {
|
|||
async fn test_peer() {
|
||||
info!("Starting test_peer");
|
||||
let settings = Some(Settings {
|
||||
confirm_max_period: Duration::from_millis(100),
|
||||
connection_timeout: Duration::from_millis(1000),
|
||||
..Default::default()
|
||||
});
|
||||
let addr = "127.0.0.1:56001".parse().unwrap();
|
||||
|
@ -194,8 +192,6 @@ mod test {
|
|||
#[test_log::test(tokio::test)]
|
||||
async fn test_broadcast() {
|
||||
let settings = Some(Settings {
|
||||
confirm_max_period: Duration::from_millis(100),
|
||||
connection_timeout: Duration::from_millis(1000),
|
||||
..Default::default()
|
||||
});
|
||||
let addr = "127.0.0.1:56002".parse().unwrap();
|
||||
|
@ -233,8 +229,6 @@ mod test {
|
|||
#[test_log::test(tokio::test)]
|
||||
async fn test_host_has_conn() {
|
||||
let settings = Some(Settings {
|
||||
confirm_max_period: Duration::from_millis(100),
|
||||
connection_timeout: Duration::from_millis(1000),
|
||||
..Default::default()
|
||||
});
|
||||
let addr = "127.0.0.1:56003".parse().unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue