diff --git a/src/cluster.rs b/src/cluster.rs index 4ab34d2..7fab1fa 100644 --- a/src/cluster.rs +++ b/src/cluster.rs @@ -1,4 +1,4 @@ -use crate::config::{ClusterByoc, Config}; +use crate::config::{Config}; use crate::utils::avro_data_to_file_list; use crate::PROTOCOL_VERSION; @@ -60,11 +60,7 @@ impl Cluster { pub async fn get_file_list(&self) -> Option> { // server: https://openbmclapi.bangbang93.com // path: /openbmclapi/files - let url = format!( - "{}://{}/openbmclapi/files", - self.config.cluster_byoc.to_string(), - self.config.center_url.clone() - ); + let url = self.config.join_center_url("/openbmclapi/files"); let password = self.config.cluster_secret.clone(); let username = self.config.cluster_id.clone(); let client = Client::builder().user_agent(self.ua.clone()).build().unwrap(); @@ -111,26 +107,17 @@ mod tests { } fn gen_config() -> Config { - let center_url = "openbmclapi.bangbang93.com".to_string(); // 读取 config.toml 获得 let raw_config = std::fs::read_to_string("config.toml").unwrap(); let test_conf: TestConfig = toml::from_str(raw_config.as_str()).unwrap(); - let cluster_byoc = ClusterByoc::https; - let no_demaon = false; - let disable_access_log = false; - let force_noopen = false; - let enable_nginx = false; Config::new( - center_url, + None, + "".to_string(), test_conf.cluster_port, test_conf.cluster_id, test_conf.cluster_secret, - cluster_byoc, - no_demaon, - disable_access_log, - force_noopen, - enable_nginx, + false, ) } @@ -138,6 +125,6 @@ mod tests { async fn test_get_file_list() { let config = gen_config(); let cluster = Cluster::new(config); - cluster.get_file_list().await; + cluster.get_file_list().await.unwrap(); } } diff --git a/src/config.rs b/src/config.rs index 28d1a2a..6beae3d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -39,6 +39,7 @@ impl Config { cluster_secret: String, no_demaon: bool, ) -> Self { + // https://openbmclapi.bangbang93.com Self { center_url, host_ip,