From fff7357756a4e8f7a4954e121146939602af78c3 Mon Sep 17 00:00:00 2001 From: Snowiiii Date: Sat, 28 Sep 2024 13:23:08 +0200 Subject: [PATCH] Fix: Auth --- pumpkin-config/src/lib.rs | 14 ++------------ pumpkin/src/client/authentication.rs | 13 +++++++++++-- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/pumpkin-config/src/lib.rs b/pumpkin-config/src/lib.rs index 0679bf5ed..a65caa444 100644 --- a/pumpkin-config/src/lib.rs +++ b/pumpkin-config/src/lib.rs @@ -27,9 +27,6 @@ mod rcon; use proxy::ProxyConfig; use resource_pack::ResourcePackConfig; -/// Current Config version of the Base Config -const CURRENT_BASE_VERSION: &str = "1.0.0"; - pub static ADVANCED_CONFIG: LazyLock = LazyLock::new(AdvancedConfiguration::load); @@ -53,8 +50,6 @@ pub struct AdvancedConfiguration { #[derive(Serialize, Deserialize)] pub struct BasicConfiguration { - /// A version identifier for the configuration format. - pub config_version: String, /// The address to bind the server to. pub server_address: SocketAddr, /// The seed for world generation. @@ -84,7 +79,6 @@ pub struct BasicConfiguration { impl Default for BasicConfiguration { fn default() -> Self { Self { - config_version: CURRENT_BASE_VERSION.to_string(), server_address: SocketAddr::new(Ipv4Addr::new(0, 0, 0, 0).into(), 25565), seed: "".to_string(), max_players: 100000, @@ -114,7 +108,7 @@ trait LoadConfiguration { toml::from_str(&file_content).unwrap_or_else(|err| { panic!( - "Couldn't parse config at {:?}. Reason: {}", + "Couldn't parse config at {:?}. Reason: {}. This is is proberbly caused by an Config update, Just delete the old Config and start Pumpkin again", path, err.message() ) @@ -124,7 +118,7 @@ trait LoadConfiguration { if let Err(err) = fs::write(path, toml::to_string(&content).unwrap()) { warn!( - "Couldn't write default config to {:?}. Reason: {}", + "Couldn't write default config to {:?}. Reason: {}. This is is proberbly caused by an Config update, Just delete the old Config and start Pumpkin again", path, err ); } @@ -157,10 +151,6 @@ impl LoadConfiguration for BasicConfiguration { } fn validate(&self) { - assert_eq!( - self.config_version, CURRENT_BASE_VERSION, - "Config version does not match used Config version. Please update your config" - ); assert!(self.view_distance >= 2, "View distance must be at least 2"); assert!( self.view_distance <= 32, diff --git a/pumpkin/src/client/authentication.rs b/pumpkin/src/client/authentication.rs index 03853578b..062c01b43 100644 --- a/pumpkin/src/client/authentication.rs +++ b/pumpkin/src/client/authentication.rs @@ -99,11 +99,20 @@ pub fn unpack_textures(property: &Property, config: &TextureConfig) -> Result<() pub fn is_texture_url_valid(url: Url, config: &TextureConfig) -> Result<(), TextureError> { let scheme = url.scheme(); - if !config.allowed_url_schemes.contains(&scheme.to_string()) { + if !config + .allowed_url_schemes + .iter() + .any(|allowed_scheme| scheme.ends_with(allowed_scheme)) + { return Err(TextureError::DisallowedUrlScheme(scheme.to_string())); } let domain = url.domain().unwrap_or(""); - if !config.allowed_url_domains.contains(&domain.to_string()) { + dbg!(domain); + if !config + .allowed_url_domains + .iter() + .any(|allowed_domain| domain.ends_with(allowed_domain)) + { return Err(TextureError::DisallowedUrlDomain(domain.to_string())); } Ok(())