Skip to content

Commit d242d4b

Browse files
committed
fix(client): use OkHttp 4.x emulation to match Reddit Android TLS fingerprint
1 parent 8dd1878 commit d242d4b

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

src/client.rs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use log::{error, info, trace, warn};
88
use percent_encoding::{percent_encode, CONTROLS};
99
use serde_json::Value;
1010
use wreq::redirect::Policy;
11-
use wreq::{Client as WreqClient, EmulationFactory};
12-
use wreq_util::{Emulation, EmulationOS, EmulationOption};
11+
use wreq::Client as WreqClient;
12+
use wreq_util::Emulation;
1313

1414
use std::sync::atomic::Ordering;
1515
use std::sync::atomic::{AtomicBool, AtomicU16};
@@ -61,22 +61,15 @@ const URL_PAIRS: [(&str, &str); 2] = [
6161
];
6262

6363
pub fn build_client() -> WreqClient {
64-
// Use a diverse set of browser profiles so different instances (and restarts)
65-
// produce different TLS/HTTP2 fingerprints, making bulk blocking harder.
64+
// Use OkHttp 4.x profiles to match Reddit's Android app TLS fingerprint,
65+
// keeping it consistent with the spoofed Android headers in MobileSpoofAuth.
6666
let emulations = [
67-
Emulation::Chrome135,
68-
Emulation::Chrome136,
69-
Emulation::Chrome137,
70-
Emulation::Firefox135,
71-
Emulation::Firefox136,
67+
Emulation::OkHttp4_9,
68+
Emulation::OkHttp4_10,
69+
Emulation::OkHttp4_12,
7270
];
73-
let emulation_os = [EmulationOS::Android, EmulationOS::Windows, EmulationOS::Linux];
7471

75-
let emulation = EmulationOption::builder()
76-
.emulation(*fastrand::choice(emulations.iter()).unwrap())
77-
.emulation_os(*fastrand::choice(emulation_os.iter()).unwrap())
78-
.build()
79-
.emulation();
72+
let emulation = *fastrand::choice(emulations.iter()).unwrap();
8073

8174
info!("Building wreq client with emulation {:?}", emulation);
8275

0 commit comments

Comments
 (0)