Skip to content

Commit

Permalink
Fix: Auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Snowiiii committed Sep 28, 2024
1 parent 62cf03e commit fff7357
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
14 changes: 2 additions & 12 deletions pumpkin-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AdvancedConfiguration> =
LazyLock::new(AdvancedConfiguration::load);

Expand All @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
)
Expand All @@ -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
);
}
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 11 additions & 2 deletions pumpkin/src/client/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down

0 comments on commit fff7357

Please sign in to comment.