11use super :: properties;
2- use actix_web:: http:: uri;
32use std:: { env, fs, io, net, num, path} ;
43
54#[ derive( serde:: Deserialize ) ]
65struct ConfigFile {
76 listen_on : net:: SocketAddr ,
87 worlds_path : path:: PathBuf ,
98 users_file_path : path:: PathBuf ,
10- #[ serde( with = "http_serde::uri" ) ]
11- base_url : uri:: Uri ,
9+ base_url : url:: Url ,
1210 #[ serde( default = "default_min_password_len" ) ]
1311 min_password_length : u8 ,
1412 #[ serde( default = "default_max_password_len" ) ]
@@ -57,7 +55,7 @@ pub enum ConfigValidationError {
5755 #[ error( "Invalid users file path: {0}" ) ]
5856 UsersFilePath ( String ) ,
5957 #[ error( "Invalid base URL: {0}" ) ]
60- InvalidBaseUrl ( uri :: Uri ) ,
58+ InvalidBaseUrl ( url :: Url ) ,
6159 #[ error( "Invalid server.properties path: {}" , . 0 . display( ) ) ]
6260 PropertiesPath ( path:: PathBuf ) ,
6361 #[ error( "Unable to load server.properties file: {0}" ) ]
@@ -70,7 +68,7 @@ pub struct AppConfig {
7068 pub worlds_path : path:: PathBuf ,
7169 pub rcon_address : net:: SocketAddr ,
7270 pub users_file_path : path:: PathBuf ,
73- pub base_url : uri :: Uri ,
71+ pub base_url : url :: Url ,
7472 pub min_password_length : usize ,
7573 pub max_password_length : usize ,
7674 pub server_properties_path : path:: PathBuf ,
@@ -199,11 +197,11 @@ fn resolve_users_file_path(
199197 }
200198}
201199
202- fn check_base_url ( url : uri:: Uri ) -> Result < uri:: Uri , ConfigValidationError > {
203- if url. scheme ( ) . is_none ( ) {
204- Err ( ConfigValidationError :: InvalidBaseUrl ( url) )
205- } else {
200+ fn check_base_url ( url : url:: Url ) -> Result < url:: Url , ConfigValidationError > {
201+ if url. scheme ( ) . starts_with ( "http" ) {
206202 Ok ( url)
203+ } else {
204+ Err ( ConfigValidationError :: InvalidBaseUrl ( url) )
207205 }
208206}
209207
0 commit comments