diff --git a/pumpkin-config/src/networking/auth.rs b/pumpkin-config/src/networking/auth.rs index 74f669eba..cdfe1e7e5 100644 --- a/pumpkin-config/src/networking/auth.rs +++ b/pumpkin-config/src/networking/auth.rs @@ -7,6 +7,8 @@ pub struct AuthenticationConfig { /// Whether to use Mojang authentication. pub enabled: bool, pub auth_url: Option, + pub connect_timeout: u32, + pub read_timeout: u32, pub prevent_proxy_connections: bool, pub prevent_proxy_connection_auth_url: Option, /// Player profile handling. @@ -24,6 +26,8 @@ impl Default for AuthenticationConfig { textures: Default::default(), auth_url: None, prevent_proxy_connection_auth_url: None, + connect_timeout: 5000, + read_timeout: 5000, } } } diff --git a/pumpkin/src/net/packet/login.rs b/pumpkin/src/net/packet/login.rs index e02074198..59f6bee69 100644 --- a/pumpkin/src/net/packet/login.rs +++ b/pumpkin/src/net/packet/login.rs @@ -187,9 +187,18 @@ impl Client { .await { Ok(new_profile) => *profile = new_profile, - Err(e) => { - self.kick(&TextComponent::text(e.to_string())).await; - return; + Err(error) => { + self.kick(&match error { + AuthError::FailedResponse => { + TextComponent::translate("multiplayer.disconnect.authservers_down", []) + } + AuthError::UnverifiedUsername => TextComponent::translate( + "multiplayer.disconnect.unverified_username", + [], + ), + e => TextComponent::text(e.to_string()), + }) + .await; } } } diff --git a/pumpkin/src/server/mod.rs b/pumpkin/src/server/mod.rs index bae6f9daa..b70cd7919 100644 --- a/pumpkin/src/server/mod.rs +++ b/pumpkin/src/server/mod.rs @@ -1,7 +1,8 @@ use connection_cache::{CachedBranding, CachedStatus}; use crossbeam::atomic::AtomicCell; +use hmac::digest::consts::U6; use key_store::KeyStore; -use pumpkin_config::BASIC_CONFIG; +use pumpkin_config::{ADVANCED_CONFIG, BASIC_CONFIG}; use pumpkin_data::entity::EntityType; use pumpkin_inventory::drag_handler::DragHandler; use pumpkin_inventory::{Container, OpenContainer}; @@ -88,7 +89,12 @@ impl Server { pub fn new() -> Self { let auth_client = BASIC_CONFIG.online_mode.then(|| { reqwest::Client::builder() - .timeout(Duration::from_millis(5000)) + .connect_timeout(Duration::from_millis( + ADVANCED_CONFIG.networking.authentication.connect_timeout as u64, + )) + .read_timeout(Duration::from_millis( + ADVANCED_CONFIG.networking.authentication.read_timeout as u64, + )) .build() .expect("Failed to to make reqwest client") });