Skip to content

Commit

Permalink
feat(mimic): Add Tor browser Firefox 128 mimic (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x676e67 authored Jan 5, 2025
1 parent f4895fb commit f69f660
Show file tree
Hide file tree
Showing 10 changed files with 175 additions and 85 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,25 @@ All notable changes to this project will be documented in this file.

## [unreleased]

### 🚀 Features

- *(mimic)* Optional mimic http2 (#262)
- *(mimic)* Add Tor browser `Firefox 128` mimic (#265)

### ⚙️ Miscellaneous Tasks

- Simplify http2 configuration

### Deps

- *(pool)* Replace `futures_channel::mpsc` with `tokio::sync::mpsc` in Hyper (#264)

## [1.3.2] - 2025-01-04

### ⚙️ Miscellaneous Tasks

- Rename and update access scope
- Fix typo

## [1.3.0] - 2025-01-04

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ An ergonomic, all-in-one `TLS`, `JA3`/`JA4`, and `HTTP2` fingerprint `HTTP` Clie
- Cookie Store
- HTTP Proxies
- WebSocket Upgrade
- HTTPS via [BoringSSL](https://github.com/cloudflare/boring)
- HTTPS via BoringSSL
- Preconfigured TLS and HTTP2 settings
- Perfectly mimic Chrome, Safari, and Firefox

Expand All @@ -42,9 +42,9 @@ use rquest::Impersonate;
#[tokio::main]
async fn main() -> Result<(), rquest::Error> {
// Build a client to mimic Chrome131
// Build a client to mimic Firefox133
let client = rquest::Client::builder()
.impersonate(Impersonate::Chrome131)
.impersonate(Impersonate::Firefox133)
.build()?;
// Use the API you're already familiar with
Expand All @@ -70,9 +70,9 @@ use rquest::{Impersonate, Client, Message};
#[tokio::main]
async fn main() -> Result<(), rquest::Error> {
// Build a client to mimic Chrome131
// Build a client to mimic Firefox133
let client = Client::builder()
.impersonate(Impersonate::Chrome131)
.impersonate(Impersonate::Firefox133)
.build()?;
// Use the API you're already familiar with
Expand Down
4 changes: 2 additions & 2 deletions examples/impersonate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use rquest::Impersonate;

#[tokio::main]
async fn main() -> Result<(), rquest::Error> {
// Build a client to mimic Firefox117
// Build a client to mimic Firefox128
let client = rquest::Client::builder()
.impersonate(Impersonate::Firefox117)
.impersonate(Impersonate::Firefox128)
.build()?;

let resp = client.get("https://tls.peet.ws/api/all").send().await?;
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
//!
//! #[tokio::main]
//! async fn main() -> Result<(), rquest::Error> {
//! // Build a client to mimic Chrome131
//! // Build a client to mimic Firefox133
//! let client = rquest::Client::builder()
//! .impersonate(Impersonate::Chrome131)
//! .impersonate(Impersonate::Firefox133)
//! .build()?;
//!
//! // Use the API you're already familiar with
Expand All @@ -54,9 +54,9 @@
//!
//! #[tokio::main]
//! async fn main() -> Result<(), rquest::Error> {
//! // Build a client to mimic Chrome131
//! // Build a client to mimic Firefox133
//! let websocket = Client::builder()
//! .impersonate(Impersonate::Chrome131)
//! .impersonate(Impersonate::Firefox133)
//! .build()?
//! .websocket("wss://echo.websocket.org")
//! .send()
Expand Down
46 changes: 23 additions & 23 deletions src/mimic/chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ macro_rules! http2_settings {
.max_concurrent_streams(1000)
.max_header_list_size(262144)
.header_table_size(65536)
.headers_priority(super::HEADER_PRIORITY)
.headers_pseudo_order(super::HEADERS_PSEUDO_ORDER)
.settings_order(super::SETTINGS_ORDER)
.headers_priority(HEADER_PRIORITY)
.headers_pseudo_order(HEADERS_PSEUDO_ORDER)
.settings_order(SETTINGS_ORDER)
.build()
}};
(2) => {{
Expand All @@ -84,9 +84,9 @@ macro_rules! http2_settings {
.max_header_list_size(262144)
.header_table_size(65536)
.enable_push(false)
.headers_priority(super::HEADER_PRIORITY)
.headers_pseudo_order(super::HEADERS_PSEUDO_ORDER)
.settings_order(super::SETTINGS_ORDER)
.headers_priority(HEADER_PRIORITY)
.headers_pseudo_order(HEADERS_PSEUDO_ORDER)
.settings_order(SETTINGS_ORDER)
.build()
}};
(3) => {{
Expand All @@ -96,9 +96,9 @@ macro_rules! http2_settings {
.max_header_list_size(262144)
.header_table_size(65536)
.enable_push(false)
.headers_priority(super::HEADER_PRIORITY)
.headers_pseudo_order(super::HEADERS_PSEUDO_ORDER)
.settings_order(super::SETTINGS_ORDER)
.headers_priority(HEADER_PRIORITY)
.headers_pseudo_order(HEADERS_PSEUDO_ORDER)
.settings_order(SETTINGS_ORDER)
.build()
}};
}
Expand Down Expand Up @@ -135,18 +135,18 @@ fn header_initializer_with_zstd_priority(sec_ch_ua: &'static str, ua: &'static s
}

mod tls {
use crate::{mimic::tls_imports::*, tls::AlpsProto};
use crate::mimic::tls_imports::*;

pub const CURVES: &[SslCurve] = &[SslCurve::X25519, SslCurve::SECP256R1, SslCurve::SECP384R1];
pub const CURVES_1: &[SslCurve] = &[SslCurve::X25519, SslCurve::SECP256R1, SslCurve::SECP384R1];

pub const NEW_CURVES_1: &[SslCurve] = &[
pub const CURVES_2: &[SslCurve] = &[
SslCurve::X25519_KYBER768_DRAFT00,
SslCurve::X25519,
SslCurve::SECP256R1,
SslCurve::SECP384R1,
];

pub const NEW_CURVES_2: &[SslCurve] = &[
pub const CURVES_3: &[SslCurve] = &[
SslCurve::X25519_MLKEM768,
SslCurve::X25519,
SslCurve::SECP256R1,
Expand Down Expand Up @@ -189,7 +189,7 @@ mod tls {

#[derive(TypedBuilder)]
pub struct ChromeTlsSettings {
#[builder(default = CURVES)]
#[builder(default = CURVES_1)]
curves: &'static [SslCurve],

#[builder(default = SIGALGS_LIST)]
Expand Down Expand Up @@ -388,7 +388,7 @@ mod_generator!(

mod_generator!(
v124,
tls_settings!(6, NEW_CURVES_1),
tls_settings!(6, CURVES_2),
http2_settings!(3),
header_initializer_with_zstd,
r#""Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99""#,
Expand All @@ -397,7 +397,7 @@ mod_generator!(

mod_generator!(
v126,
tls_settings!(6, NEW_CURVES_1),
tls_settings!(6, CURVES_2),
http2_settings!(3),
header_initializer_with_zstd,
r#""Chromium";v="126", "Google Chrome";v="126", "Not-A.Brand";v="99""#,
Expand All @@ -406,7 +406,7 @@ mod_generator!(

mod_generator!(
v127,
tls_settings!(6, NEW_CURVES_1),
tls_settings!(6, CURVES_2),
http2_settings!(3),
header_initializer_with_zstd,
r#""Not/A)Brand";v="8", "Chromium";v="127", "Google Chrome";v="127""#,
Expand All @@ -415,7 +415,7 @@ mod_generator!(

mod_generator!(
v128,
tls_settings!(6, NEW_CURVES_1),
tls_settings!(6, CURVES_2),
http2_settings!(3),
header_initializer,
r#""Chromium";v="128", "Google Chrome";v="128", "Not?A_Brand";v="99""#,
Expand All @@ -424,7 +424,7 @@ mod_generator!(

mod_generator!(
v129,
tls_settings!(6, NEW_CURVES_1),
tls_settings!(6, CURVES_2),
http2_settings!(3),
header_initializer_with_zstd_priority,
r#""Google Chrome";v="129", "Chromium";v="129", "Not_A Brand\";v="24""#,
Expand All @@ -433,7 +433,7 @@ mod_generator!(

mod_generator!(
v130,
tls_settings!(6, NEW_CURVES_1),
tls_settings!(6, CURVES_2),
http2_settings!(3),
header_initializer_with_zstd_priority,
r#""Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99""#,
Expand All @@ -442,7 +442,7 @@ mod_generator!(

mod_generator!(
v131,
tls_settings!(6, NEW_CURVES_2),
tls_settings!(6, CURVES_3),
http2_settings!(3),
header_initializer_with_zstd_priority,
r#""Google Chrome";v="131", "Chromium";v="131", "Not_A Brand\";v="24""#,
Expand All @@ -469,7 +469,7 @@ mod_generator!(

mod_generator!(
edge127,
tls_settings!(6, NEW_CURVES_1),
tls_settings!(6, CURVES_2),
http2_settings!(3),
header_initializer_with_zstd_priority,
r#""Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127""#,
Expand All @@ -478,7 +478,7 @@ mod_generator!(

mod_generator!(
edge131,
tls_settings!(6, NEW_CURVES_2),
tls_settings!(6, CURVES_3),
http2_settings!(3),
header_initializer_with_zstd_priority,
r#""Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24""#,
Expand Down
Loading

0 comments on commit f69f660

Please sign in to comment.