Skip to content

Commit caa07a9

Browse files
committed
Use release version in user agent
1 parent ae35cd0 commit caa07a9

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

crates/backend/src/backend.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,24 @@ pub fn start(launcher_dir: PathBuf, send: FrontendHandle, self_handle: BackendHa
3535
.build()
3636
.expect("Failed to initialize Tokio runtime");
3737

38+
let user_agent = if let Some(version) = option_env!("PANDORA_RELEASE_VERSION") {
39+
format!("PandoraLauncher/{version} (https://github.com/Moulberry/PandoraLauncher)")
40+
} else {
41+
"PandoraLauncher/dev (https://github.com/Moulberry/PandoraLauncher)".to_string()
42+
};
43+
3844
let http_client = reqwest::ClientBuilder::new()
3945
.connect_timeout(Duration::from_secs(15))
4046
.read_timeout(Duration::from_secs(15))
4147
.redirect(Policy::none())
4248
.use_rustls_tls()
43-
.user_agent("PandoraLauncher/0.1.0 (https://github.com/Moulberry/PandoraLauncher)")
49+
.user_agent(&user_agent)
4450
.build()
4551
.unwrap();
4652

4753
let redirecting_http_client = reqwest::ClientBuilder::new()
4854
.use_rustls_tls()
49-
.user_agent("PandoraLauncher/0.1.0 (https://github.com/Moulberry/PandoraLauncher)")
55+
.user_agent(&user_agent)
5056
.build()
5157
.unwrap();
5258

crates/frontend/src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@ pub fn start(
7777
backend_handle: BackendHandle,
7878
mut recv: FrontendReceiver,
7979
) {
80-
let http_client = std::sync::Arc::new(
81-
reqwest_client::ReqwestClient::user_agent(
82-
"PandoraLauncher/0.1.0 (https://github.com/Moulberry/PandoraLauncher)",
83-
)
84-
.unwrap(),
85-
);
80+
let user_agent = if let Some(version) = option_env!("PANDORA_RELEASE_VERSION") {
81+
format!("PandoraLauncher/{version} (https://github.com/Moulberry/PandoraLauncher)")
82+
} else {
83+
"PandoraLauncher/dev (https://github.com/Moulberry/PandoraLauncher)".to_string()
84+
};
85+
86+
let http_client = Arc::new(reqwest_client::ReqwestClient::user_agent(&user_agent).unwrap());
8687

8788
Application::new().with_http_client(http_client).with_assets(Assets).run(move |cx: &mut App| {
8889
let _ = cx.text_system().add_fonts(vec![

0 commit comments

Comments
 (0)