From 7021c52c9b0b73eefdd9270268717168fa465202 Mon Sep 17 00:00:00 2001 From: strawberry Date: Sun, 7 Jan 2024 21:57:21 -0500 Subject: [PATCH] send a User-Agent on all requests amazing that this wasn't done in the first place. a lack of a UA is suspicious and some providers may block our requests just for the sake of no UA. Signed-off-by: strawberry --- DIFFERENCES.md | 3 ++- src/service/globals/mod.rs | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/DIFFERENCES.md b/DIFFERENCES.md index c28fb295..f9b05c7b 100644 --- a/DIFFERENCES.md +++ b/DIFFERENCES.md @@ -37,4 +37,5 @@ - Add debug admin command to force update user device lists (could potentially resolve some E2EE flukes) (`ForceDeviceListUpdates`) - Declare various missing Matrix versions and features at `/_matrix/client/versions` - Add support for serving server and client well-known files from conduwuit using `well_known_client` and `well_known_server` options -- Add non-standard sliding sync proxy health check (?) endpoint at `/client/server.json` that some clients such as Element Web query using the `well_known_client` or `well_known_server` config options \ No newline at end of file +- Add non-standard sliding sync proxy health check (?) endpoint at `/client/server.json` that some clients such as Element Web query using the `well_known_client` or `well_known_server` config options +- Send a User-Agent on all of our requests (`conduwuit/0.7.0-alpha+conduwuit-0.1.1`) which strangely was not done upstream since forever. Some providers consider no User-Agent suspicious and block said requests. diff --git a/src/service/globals/mod.rs b/src/service/globals/mod.rs index bf8b3dfb..89e85fd4 100644 --- a/src/service/globals/mod.rs +++ b/src/service/globals/mod.rs @@ -542,7 +542,12 @@ fn reqwest_client_builder(config: &Config) -> Result { let mut reqwest_client_builder = reqwest::Client::builder() .pool_max_idle_per_host(0) .connect_timeout(Duration::from_secs(60)) - .timeout(Duration::from_secs(60 * 5)); + .timeout(Duration::from_secs(60 * 5)) + .user_agent(concat!( + env!("CARGO_PKG_NAME"), + "/", + env!("CARGO_PKG_VERSION") + )); if let Some(proxy) = config.proxy.to_proxy()? { reqwest_client_builder = reqwest_client_builder.proxy(proxy);