Fix: Auth
This commit is contained in:
parent
62cf03e37c
commit
fff7357756
@ -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);
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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(())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user