From f35f15214c8bd65cbc6801988769705d69326b17 Mon Sep 17 00:00:00 2001 From: TOwInOK <60252419+TOwInOK@users.noreply.github.com> Date: Mon, 27 May 2024 18:08:24 +0700 Subject: [PATCH] add machine-uid = "0.5.1" add uid to user-agent. (modrinth) #18 --- Cargo.toml | 1 + src/manager/mod.rs | 2 +- src/models/extensions/modrinth.rs | 11 +++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 35f4590..0ece4ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ futures-util = "0.3.30" indicatif = { version = "0.17.8", features = ["tokio"] } indicatif-log-bridge = "0.2.2" log = "0.4.21" +machine-uid = "0.5.1" md-5 = "0.10.6" once_cell = "1.19.0" pretty_env_logger = "0.5.0" diff --git a/src/manager/mod.rs b/src/manager/mod.rs index a5924eb..96ac043 100644 --- a/src/manager/mod.rs +++ b/src/manager/mod.rs @@ -29,7 +29,7 @@ use tr::load::Load; pub async fn run() -> Result<()> { let logger = pretty_env_logger::formatted_builder() - .filter_level(log::LevelFilter::Info) + .filter_level(log::LevelFilter::Trace) .build(); let (mpb, lock, settings) = init().await?; let mpb_cloned = mpb.as_ref().clone(); diff --git a/src/models/extensions/modrinth.rs b/src/models/extensions/modrinth.rs index b0bc2a3..85d3767 100644 --- a/src/models/extensions/modrinth.rs +++ b/src/models/extensions/modrinth.rs @@ -80,10 +80,13 @@ impl ModelExtensions for ModrinthData { } } }; - trace!("query: {:#?}", &query); - let client = reqwest::Client::builder() - .user_agent("TOwInOK/Minecraft-Dependency-Controller (TOwInOK@nothub.ru) TestPoligon") - .build()?; + trace!(target: "Modrinth", "query: {:#?}", &query); + let user_agent = format!( + "TOwInOK/Minecraft-Dependency-Manager (TOwInOK@nothub.ru) UID: {}", + machine_uid::get().unwrap() + ); + trace!(target: "Modrinth", "User-Agent: {}", &user_agent); + let client = reqwest::Client::builder().user_agent(user_agent).build()?; let modrinth_data: Vec = client.get(&link).query(&query).send().await?.json().await?;