diff options
author | Daniel <kingdread@gmx.de> | 2024-08-03 10:06:08 +0000 |
---|---|---|
committer | Daniel <kingdread@gmx.de> | 2024-08-03 10:06:08 +0000 |
commit | 3f0eb33c666afb2924eef835904fe48ef4503d2d (patch) | |
tree | 215f268e6ab227f9cdc59da3f6abfe93df6fd495 | |
parent | 99a05ae1e0d613c7b5c381fce26d4e2da0b560f3 (diff) | |
parent | 7267b44e9d32deb027d0822b6dd92e9c65614156 (diff) | |
download | ezau-3f0eb33c666afb2924eef835904fe48ef4503d2d.tar.gz ezau-3f0eb33c666afb2924eef835904fe48ef4503d2d.tar.bz2 ezau-3f0eb33c666afb2924eef835904fe48ef4503d2d.zip |
Merge branch 'enable-dps-report-url-configuration' into 'master'
feat: add dps.report upload url configuration
See merge request dunj3/ezau!3
-rw-r--r-- | ezau-sample.toml | 7 | ||||
-rw-r--r-- | src/config.rs | 7 | ||||
-rw-r--r-- | src/main.rs | 9 |
3 files changed, 18 insertions, 5 deletions
diff --git a/ezau-sample.toml b/ezau-sample.toml index 9076233..512511c 100644 --- a/ezau-sample.toml +++ b/ezau-sample.toml @@ -3,6 +3,13 @@ # (mandatory) upload = false +# Where to upload the logs. +# By default, ezau will attempt to upload to https://dps.report/uploadContent, +# but depending on service availability you might want to use a different domain, +# like b.dps.report instead. +# (optional) +dps_report_upload_url = "https://dps.report/uploadContent" + # Whether logs with an unknown boss should be uploaded. # By default, ezau only uploads logs with bosses known to evtclib. # (optional) diff --git a/src/config.rs b/src/config.rs index 1c44aea..ad2ee22 100644 --- a/src/config.rs +++ b/src/config.rs @@ -9,6 +9,9 @@ use serde_with::{serde_as, OneOrMany}; pub struct Config { /// Flag indicating whether logs should be uploaded or not. pub upload: bool, + /// Where to upload the logs. + #[serde(default = "default_dps_report_upload_url")] + pub dps_report_upload_url: String, /// Flag indicating whether logs with an unknown boss should be uploaded. #[serde(default)] pub upload_unknown: bool, @@ -62,3 +65,7 @@ pub fn load<P: AsRef<Path>>(path: P) -> Result<Config> { fn default_zip() -> bool { true } + +fn default_dps_report_upload_url() -> String { + String::from("https://dps.report/uploadContent") +} diff --git a/src/main.rs b/src/main.rs index b86f281..6352bff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,7 +27,6 @@ mod logbag; #[cfg(feature = "im-matrix")] mod matrix; -const DPS_REPORT_API: &str = "https://dps.report/uploadContent"; const WATCH_DELAY_SECONDS: u64 = 2; const RETRY_DELAY: Duration = Duration::from_secs(5); @@ -83,7 +82,7 @@ fn inner_main(opts: &Opts) -> Result<()> { match &opts.subcmd { SubCommand::Watch(w) => watch(w, &config)?, SubCommand::Upload(u) => { - let permalink = upload_log(&u.path)?; + let permalink = upload_log(&u.path, &config.dps_report_upload_url)?; println!("{}", permalink); let log = load_log(&u.path)?; @@ -181,7 +180,7 @@ fn handle_file(config: &Config, filename: &Path) -> Result<()> { let mut try_counter = 0; let permalink = loop { - let result = upload_log(filename); + let result = upload_log(filename, &config.dps_report_upload_url); if let Ok(link) = result { break link; } @@ -238,7 +237,7 @@ fn load_log(path: &Path) -> Result<Log> { evtclib::process_file(path, Compression::Zip).map_err(Into::into) } -fn upload_log(file: &Path) -> Result<String> { +fn upload_log(file: &Path, url: &str) -> Result<String> { #[derive(Debug, Deserialize)] struct ApiResponse { permalink: String, @@ -248,7 +247,7 @@ fn upload_log(file: &Path) -> Result<String> { let form = reqwest::blocking::multipart::Form::new().file("file", file)?; let resp: ApiResponse = client - .post(DPS_REPORT_API) + .post(url) .query(&[("json", 1)]) .multipart(form) .send()? |