Compare commits

...
Author SHA1 Message Date
François-X. T. c509161bb0 Fix build with updater feature 2026-01-07 21:29:34 -05:00
François-X. T. 000c0c3cc2 Include OS in theseus User-Agent 2026-01-04 18:56:45 -05:00
5 changed files with 18 additions and 13 deletions
+2 -2
View File
@@ -119,12 +119,12 @@ fn main() {
#[cfg(feature = "updater")]
{
use tauri_plugin_http::reqwest::header::{HeaderValue, USER_AGENT};
use theseus::LAUNCHER_USER_AGENT;
use theseus::launcher_user_agent;
builder = builder.plugin(
tauri_plugin_updater::Builder::new()
.header(
USER_AGENT,
HeaderValue::from_str(LAUNCHER_USER_AGENT).unwrap(),
HeaderValue::from_str(&launcher_user_agent()).unwrap(),
)
.unwrap()
.build(),
+2 -2
View File
@@ -8,7 +8,7 @@ use tauri_plugin_http::reqwest::ClientBuilder;
use tauri_plugin_updater::Error;
use tauri_plugin_updater::Update;
use theseus::{
LAUNCHER_USER_AGENT, LoadingBarType, emit_loading, init_loading,
LoadingBarType, emit_loading, init_loading, launcher_user_agent,
};
use tokio::time::Instant;
@@ -31,7 +31,7 @@ pub async fn get_update_size<R: Runtime>(
);
}
let mut request = ClientBuilder::new().user_agent(LAUNCHER_USER_AGENT);
let mut request = ClientBuilder::new().user_agent(launcher_user_agent());
if let Some(timeout) = update.timeout {
request = request.timeout(timeout);
}
+10 -5
View File
@@ -26,8 +26,13 @@ pub use event::{
pub use logger::start_logger;
pub use state::State;
pub const LAUNCHER_USER_AGENT: &str = concat!(
"modrinth/theseus/",
env!("CARGO_PKG_VERSION"),
" (support@modrinth.com)"
);
pub fn launcher_user_agent() -> String {
const LAUNCHER_BASE_USER_AGENT: &str =
concat!("modrinth/theseus/", env!("CARGO_PKG_VERSION"),);
format!(
"{} ({}; support@modrinth.com)",
LAUNCHER_BASE_USER_AGENT,
std::env::consts::OS
)
}
+1 -2
View File
@@ -1,5 +1,4 @@
use crate::ErrorKind;
use crate::LAUNCHER_USER_AGENT;
use crate::data::ModrinthCredentials;
use crate::event::FriendPayload;
use crate::event::emit::emit_friend;
@@ -85,7 +84,7 @@ impl FriendsSocket {
request.headers_mut().insert(
"User-Agent",
HeaderValue::from_str(LAUNCHER_USER_AGENT).unwrap(),
HeaderValue::from_str(&crate::launcher_user_agent()).unwrap(),
);
let res = connect_async(request).await;
+3 -2
View File
@@ -1,7 +1,6 @@
//! Functions for fetching information from the Internet
use super::io::{self, IOError};
use crate::ErrorKind;
use crate::LAUNCHER_USER_AGENT;
use crate::event::LoadingBarId;
use crate::event::emit::emit_loading;
use bytes::Bytes;
@@ -21,8 +20,10 @@ pub struct FetchSemaphore(pub Semaphore);
pub static REQWEST_CLIENT: LazyLock<reqwest::Client> = LazyLock::new(|| {
let mut headers = reqwest::header::HeaderMap::new();
let header =
reqwest::header::HeaderValue::from_str(LAUNCHER_USER_AGENT).unwrap();
reqwest::header::HeaderValue::from_str(&crate::launcher_user_agent())
.unwrap();
headers.insert(reqwest::header::USER_AGENT, header);
reqwest::Client::builder()
.tcp_keepalive(Some(time::Duration::from_secs(10)))