diff --git a/src/config/credentials.rs b/src/config/credentials.rs index 53c15a3..31d79e3 100644 --- a/src/config/credentials.rs +++ b/src/config/credentials.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later use { + crate::constants::USER_AGENT, anyhow::{anyhow, Result}, reqwest::{StatusCode, Url}, serde::{Deserialize, Serialize}, @@ -46,7 +47,9 @@ impl Credentials { } pub fn add(&mut self, server: Url) -> Result<()> { - let http_client = reqwest::blocking::Client::new(); + let http_client = reqwest::blocking::Client::builder() + .user_agent(USER_AGENT) + .build()?; #[derive(Deserialize)] struct LoginFlow { diff --git a/src/constants.rs b/src/constants.rs new file mode 100644 index 0000000..8fb4a1c --- /dev/null +++ b/src/constants.rs @@ -0,0 +1,4 @@ +// SPDX-FileCopyrightText: 2022 Matteo Settenvini +// SPDX-License-Identifier: AGPL-3.0-or-later + +pub const USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")); diff --git a/src/main.rs b/src/main.rs index 93b842e..5aee557 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later mod config; +mod constants; use { self::config::Config,