Skip to content

Commit 9b5d942

Browse files
authored
feat: randomize UA between windows and mac (#71)
1 parent 6f599b5 commit 9b5d942

5 files changed

Lines changed: 113 additions & 14 deletions

File tree

.github/workflows/cicd.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ jobs:
8989
uses: softprops/action-gh-release@v2.0.4
9090
if: startsWith(github.ref, 'refs/tags/')
9191
with:
92+
draft: true
9293
files: |
9394
target/release/bourso-cli-linux.tar.gz
9495
target/release/bourso-cli-darwin.tar.gz

Cargo.lock

Lines changed: 99 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bourso-cli"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
edition = "2021"
55
repository = "https://github.com/azerpas/bourso-api"
66

src/bourso_api/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bourso_api"
3-
version = "0.4.0"
3+
version = "0.5.1"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -20,6 +20,7 @@ tracing = { version = "0.1.41" }
2020
futures-util = { version = "0.3.31" }
2121
async-stream = { version = "0.3.6" }
2222
qrcode = { version = "0.14.1" }
23+
rand = { version = "0.9.2" }
2324

2425
[lints.rust]
2526
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }

src/bourso_api/src/client/mod.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,18 @@ impl BoursoWebClient {
131131
/// The headers as a `reqwest::header::HeaderMap`.
132132
#[cfg(not(tarpaulin_include))]
133133
fn get_headers(&self) -> reqwest::header::HeaderMap {
134+
use rand::prelude::IndexedRandom;
135+
134136
let mut headers = reqwest::header::HeaderMap::new();
135-
headers.insert(
136-
"user-agent",
137+
let uas = [
138+
// Chrome on Windows
139+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36",
140+
// Chrome on MacOS
137141
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36"
138-
.parse()
139-
.unwrap(),
140-
);
142+
];
143+
let ua = uas.choose(&mut rand::rng()).unwrap();
144+
145+
headers.insert("user-agent", ua.parse().unwrap());
141146

142147
headers
143148
}

0 commit comments

Comments
 (0)