From 0aebe380d468013aa9c09220545e94ade8123e87 Mon Sep 17 00:00:00 2001 From: gngpp Date: Wed, 15 Jul 2026 08:24:06 +0800 Subject: [PATCH 01/38] pre-release --- Cargo.lock | 8 +- Cargo.toml | 5 + crates/wreq-util/.github/FUNDING.yml | 15 + .../.github/ISSUE_TEMPLATE/bug_report.md | 38 + .../.github/ISSUE_TEMPLATE/custom.md | 10 + .../.github/ISSUE_TEMPLATE/feature_request.md | 20 + crates/wreq-util/.github/dependabot.yml | 22 + crates/wreq-util/.github/workflows/ci.yml | 82 + .../.github/workflows/release-plz.yml | 52 + crates/wreq-util/.gitignore | 24 + crates/wreq-util/CHANGELOG.md | 74 + crates/wreq-util/Cargo.toml | 94 + crates/wreq-util/LICENSE | 201 ++ crates/wreq-util/README.md | 62 + crates/wreq-util/examples/emulate.rs | 39 + crates/wreq-util/examples/tower_delay.rs | 191 ++ crates/wreq-util/release-plz.toml | 2 + crates/wreq-util/rustfmt.toml | 5 + crates/wreq-util/src/emulate.rs | 369 +++ crates/wreq-util/src/emulate/compress.rs | 85 + crates/wreq-util/src/emulate/macros.rs | 370 +++ crates/wreq-util/src/emulate/profile.rs | 47 + .../wreq-util/src/emulate/profile/chrome.rs | 2028 +++++++++++++++++ .../src/emulate/profile/chrome/header.rs | 59 + .../src/emulate/profile/chrome/http2.rs | 65 + .../src/emulate/profile/chrome/tls.rs | 153 ++ .../wreq-util/src/emulate/profile/firefox.rs | 518 +++++ .../src/emulate/profile/firefox/header.rs | 21 + .../src/emulate/profile/firefox/http2.rs | 113 + .../src/emulate/profile/firefox/tls.rs | 253 ++ .../wreq-util/src/emulate/profile/okhttp.rs | 241 ++ crates/wreq-util/src/emulate/profile/opera.rs | 299 +++ .../src/emulate/profile/opera/header.rs | 30 + .../src/emulate/profile/opera/http2.rs | 50 + .../src/emulate/profile/opera/tls.rs | 97 + .../wreq-util/src/emulate/profile/safari.rs | 222 ++ .../src/emulate/profile/safari/header.rs | 59 + .../src/emulate/profile/safari/http2.rs | 116 + .../src/emulate/profile/safari/tls.rs | 177 ++ crates/wreq-util/src/lib.rs | 14 + crates/wreq-util/src/rand.rs | 24 + crates/wreq-util/src/tower.rs | 7 + crates/wreq-util/src/tower/delay.rs | 98 + crates/wreq-util/src/tower/delay/future.rs | 43 + crates/wreq-util/src/tower/delay/layer.rs | 201 ++ crates/wreq-util/src/tower/delay/service.rs | 190 ++ crates/wreq-util/tests/client.rs | 51 + crates/wreq-util/tests/emulate_chrome.rs | 270 +++ crates/wreq-util/tests/emulate_firefox.rs | 92 + crates/wreq-util/tests/emulate_okhttp.rs | 46 + crates/wreq-util/tests/emulate_opera.rs | 113 + crates/wreq-util/tests/emulate_safari.rs | 151 ++ crates/wreq-util/tests/support/mod.rs | 55 + crates/wreq-util/tests/support/server.rs | 232 ++ examples/emulate_request.rb | 2 +- lib/wreq_ruby/emulate.rb | 1 + src/emulate.rs | 1 + 57 files changed, 7900 insertions(+), 7 deletions(-) create mode 100644 crates/wreq-util/.github/FUNDING.yml create mode 100644 crates/wreq-util/.github/ISSUE_TEMPLATE/bug_report.md create mode 100644 crates/wreq-util/.github/ISSUE_TEMPLATE/custom.md create mode 100644 crates/wreq-util/.github/ISSUE_TEMPLATE/feature_request.md create mode 100644 crates/wreq-util/.github/dependabot.yml create mode 100644 crates/wreq-util/.github/workflows/ci.yml create mode 100644 crates/wreq-util/.github/workflows/release-plz.yml create mode 100644 crates/wreq-util/.gitignore create mode 100644 crates/wreq-util/CHANGELOG.md create mode 100644 crates/wreq-util/Cargo.toml create mode 100644 crates/wreq-util/LICENSE create mode 100644 crates/wreq-util/README.md create mode 100644 crates/wreq-util/examples/emulate.rs create mode 100644 crates/wreq-util/examples/tower_delay.rs create mode 100644 crates/wreq-util/release-plz.toml create mode 100644 crates/wreq-util/rustfmt.toml create mode 100644 crates/wreq-util/src/emulate.rs create mode 100644 crates/wreq-util/src/emulate/compress.rs create mode 100644 crates/wreq-util/src/emulate/macros.rs create mode 100644 crates/wreq-util/src/emulate/profile.rs create mode 100644 crates/wreq-util/src/emulate/profile/chrome.rs create mode 100644 crates/wreq-util/src/emulate/profile/chrome/header.rs create mode 100644 crates/wreq-util/src/emulate/profile/chrome/http2.rs create mode 100644 crates/wreq-util/src/emulate/profile/chrome/tls.rs create mode 100644 crates/wreq-util/src/emulate/profile/firefox.rs create mode 100644 crates/wreq-util/src/emulate/profile/firefox/header.rs create mode 100644 crates/wreq-util/src/emulate/profile/firefox/http2.rs create mode 100644 crates/wreq-util/src/emulate/profile/firefox/tls.rs create mode 100644 crates/wreq-util/src/emulate/profile/okhttp.rs create mode 100644 crates/wreq-util/src/emulate/profile/opera.rs create mode 100644 crates/wreq-util/src/emulate/profile/opera/header.rs create mode 100644 crates/wreq-util/src/emulate/profile/opera/http2.rs create mode 100644 crates/wreq-util/src/emulate/profile/opera/tls.rs create mode 100644 crates/wreq-util/src/emulate/profile/safari.rs create mode 100644 crates/wreq-util/src/emulate/profile/safari/header.rs create mode 100644 crates/wreq-util/src/emulate/profile/safari/http2.rs create mode 100644 crates/wreq-util/src/emulate/profile/safari/tls.rs create mode 100644 crates/wreq-util/src/lib.rs create mode 100644 crates/wreq-util/src/rand.rs create mode 100644 crates/wreq-util/src/tower.rs create mode 100644 crates/wreq-util/src/tower/delay.rs create mode 100644 crates/wreq-util/src/tower/delay/future.rs create mode 100644 crates/wreq-util/src/tower/delay/layer.rs create mode 100644 crates/wreq-util/src/tower/delay/service.rs create mode 100644 crates/wreq-util/tests/client.rs create mode 100644 crates/wreq-util/tests/emulate_chrome.rs create mode 100644 crates/wreq-util/tests/emulate_firefox.rs create mode 100644 crates/wreq-util/tests/emulate_okhttp.rs create mode 100644 crates/wreq-util/tests/emulate_opera.rs create mode 100644 crates/wreq-util/tests/emulate_safari.rs create mode 100644 crates/wreq-util/tests/support/mod.rs create mode 100644 crates/wreq-util/tests/support/server.rs diff --git a/Cargo.lock b/Cargo.lock index 6ebfec1..989bb37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -113,8 +113,7 @@ dependencies = [ [[package]] name = "btls" version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c5e60b8c8d282c86360cab651ded04ab0335a7b5390c8d34145cbeab8cacf5f" +source = "git+https://github.com/0x676e67/btls?branch=demo%2Fmerge-upstream-boring-20260616#397dfae69044c0c19ba3028e8b25f8481fbc0f00" dependencies = [ "bitflags", "btls-sys", @@ -126,8 +125,7 @@ dependencies = [ [[package]] name = "btls-sys" version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b1b8638a2e1c38a5ae4efa90ae57e643baec35a30d03fc5b399b893adc4954b" +source = "git+https://github.com/0x676e67/btls?branch=demo%2Fmerge-upstream-boring-20260616#397dfae69044c0c19ba3028e8b25f8481fbc0f00" dependencies = [ "bindgen", "cmake", @@ -1559,8 +1557,6 @@ dependencies = [ [[package]] name = "wreq-util" version = "3.0.0-rc.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d8d73c75be86fbde675988dbe5cb15f02567025c13f6ffab910361ad1ba6c89" dependencies = [ "brotli", "flate2", diff --git a/Cargo.toml b/Cargo.toml index 191d72b..ab3bfbb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,3 +52,8 @@ incremental = false lto = "fat" opt-level = 3 strip = true + +[patch.crates-io] +btls = { git = "https://github.com/0x676e67/btls", branch = "demo/merge-upstream-boring-20260616" } +btls-sys = { git = "https://github.com/0x676e67/btls", branch = "demo/merge-upstream-boring-20260616" } +wreq-util = { path = "crates/wreq-util" } \ No newline at end of file diff --git a/crates/wreq-util/.github/FUNDING.yml b/crates/wreq-util/.github/FUNDING.yml new file mode 100644 index 0000000..768ac2c --- /dev/null +++ b/crates/wreq-util/.github/FUNDING.yml @@ -0,0 +1,15 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +polar: # Replace with a single Polar username +buy_me_a_coffee: # Replace with a single Buy Me a Coffee username +thanks_dev: # Replace with a single thanks.dev username +custom: ['https://github.com/0x676e67/0x676e67/blob/main/SPONSOR.md'] diff --git a/crates/wreq-util/.github/ISSUE_TEMPLATE/bug_report.md b/crates/wreq-util/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..dd84ea7 --- /dev/null +++ b/crates/wreq-util/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/crates/wreq-util/.github/ISSUE_TEMPLATE/custom.md b/crates/wreq-util/.github/ISSUE_TEMPLATE/custom.md new file mode 100644 index 0000000..48d5f81 --- /dev/null +++ b/crates/wreq-util/.github/ISSUE_TEMPLATE/custom.md @@ -0,0 +1,10 @@ +--- +name: Custom issue template +about: Describe this issue template's purpose here. +title: '' +labels: '' +assignees: '' + +--- + + diff --git a/crates/wreq-util/.github/ISSUE_TEMPLATE/feature_request.md b/crates/wreq-util/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/crates/wreq-util/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/crates/wreq-util/.github/dependabot.yml b/crates/wreq-util/.github/dependabot.yml new file mode 100644 index 0000000..9ffca92 --- /dev/null +++ b/crates/wreq-util/.github/dependabot.yml @@ -0,0 +1,22 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "github-actions" + # Workflow files stored in the + # default location of `.github/workflows` + directory: "/" + schedule: + interval: "weekly" + - package-ecosystem: "cargo" + directory: "/" + schedule: + interval: "weekly" + # todo: if only this worked, see https://github.com/dependabot/dependabot-core/issues/4009 + # only tell us if there's a new 'breaking' change we could upgrade to + # versioning-strategy: increase-if-necessary + # disable regular version updates, security updates are unaffected + open-pull-requests-limit: 0 diff --git a/crates/wreq-util/.github/workflows/ci.yml b/crates/wreq-util/.github/workflows/ci.yml new file mode 100644 index 0000000..55422c8 --- /dev/null +++ b/crates/wreq-util/.github/workflows/ci.yml @@ -0,0 +1,82 @@ +name: CI + +on: + push: + tags: ["v*"] + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true + +permissions: + contents: write + packages: write + +jobs: + style: + name: Style + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - name: Style check + run: cargo fmt --all -- --check + - name: Clippy check + run: cargo clippy --all-targets --all-features + + docs: + name: Docs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - name: Build docs + run: cargo doc --document-private-items --all-features + + tests: + name: Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - uses: taiki-e/install-action@v2 + with: + tool: cargo-nextest + - name: Tests + run: | + set -euxo pipefail + cargo nextest run --workspace + + linux: + name: Linux + needs: [style, tests, docs] + runs-on: ubuntu-latest + environment: Linux + if: startsWith(github.ref, 'refs/tags/') + steps: + - uses: actions/checkout@v7 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - uses: katyo/publish-crates@v2 + with: + registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} + ignore-unpublished-changes: true + - name: Upload binaries to GitHub Release + uses: softprops/action-gh-release@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }} + generate_release_notes: true diff --git a/crates/wreq-util/.github/workflows/release-plz.yml b/crates/wreq-util/.github/workflows/release-plz.yml new file mode 100644 index 0000000..fe58090 --- /dev/null +++ b/crates/wreq-util/.github/workflows/release-plz.yml @@ -0,0 +1,52 @@ +name: Release-plz + +on: + push: + branches: + - main + +jobs: + release-plz-release: + name: Release-plz release + runs-on: ubuntu-latest + if: ${{ github.repository_owner == '0x676e67' }} + permissions: + contents: write + id-token: write + steps: + - &checkout + name: Checkout repository + uses: actions/checkout@v7 + with: + fetch-depth: 0 + persist-credentials: true + token: ${{ secrets.RELEASE_PLZ_TOKEN }} + - &install-rust + name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + - name: Run release-plz + uses: release-plz/action@v0.5 + with: + command: release + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }} + + release-plz-pr: + name: Release-plz PR + runs-on: ubuntu-latest + if: ${{ github.repository_owner == '0x676e67' }} + permissions: + pull-requests: write + contents: write + concurrency: + group: release-plz-${{ github.ref }} + cancel-in-progress: false + steps: + - *checkout + - *install-rust + - name: Run release-plz + uses: release-plz/action@v0.5 + with: + command: release-pr + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }} diff --git a/crates/wreq-util/.gitignore b/crates/wreq-util/.gitignore new file mode 100644 index 0000000..6a82881 --- /dev/null +++ b/crates/wreq-util/.gitignore @@ -0,0 +1,24 @@ +# Generated by Cargo +# will have compiled files and executables +debug +target +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +# Generated by cargo mutants +# Contains mutation testing data +**/mutants.out*/ + +# RustRover +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ +.vscode +.zed diff --git a/crates/wreq-util/CHANGELOG.md b/crates/wreq-util/CHANGELOG.md new file mode 100644 index 0000000..0d49056 --- /dev/null +++ b/crates/wreq-util/CHANGELOG.md @@ -0,0 +1,74 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [3.0.0-rc.14](https://github.com/0x676e67/wreq-util/compare/v3.0.0-rc.13...v3.0.0-rc.14) - 2026-07-04 + +### Fixed + +- *(emulate)* Fix chrome accept header `q` value ([#101](https://github.com/0x676e67/wreq-util/pull/101)) + +### Other + +- *(deps)* bump actions/checkout from 6 to 7 ([#100](https://github.com/0x676e67/wreq-util/pull/100)) + +## [3.0.0-rc.13](https://github.com/0x676e67/wreq-util/compare/v3.0.0-rc.12...v3.0.0-rc.13) - 2026-06-19 + +### Added + +- add Emulation::weighted_random for traffic-weighted profile selection ([#97](https://github.com/0x676e67/wreq-util/pull/97)) + +### Other + +- Add Chrome 149 to emulation profiles ([#99](https://github.com/0x676e67/wreq-util/pull/99)) + +## [3.0.0-rc.12](https://github.com/0x676e67/wreq-util/compare/v3.0.0-rc.11...v3.0.0-rc.12) - 2026-06-03 + +### Added + +- *(emulate)* Add Firefox 150-151 ([#93](https://github.com/0x676e67/wreq-util/pull/93)) +- *(emulate)* Add Chrome/Edge 148,Opera 131,Safari 26-2/4 ([#92](https://github.com/0x676e67/wreq-util/pull/92)) +- *(emulate)* export enum variants ([#87](https://github.com/0x676e67/wreq-util/pull/87)) +- *(emulation)* add Chrome and Edge 146-147 ([#86](https://github.com/0x676e67/wreq-util/pull/86)) +- *(emulation)* add Opera 120-130 and Firefox 148-149 support ([#82](https://github.com/0x676e67/wreq-util/pull/82)) + +### Fixed + +- *(emulate)* fix HTTP2 configuration for OkHttp ([#94](https://github.com/0x676e67/wreq-util/pull/94)) +- fix build +- fix chrome grease value and brand order ([#91](https://github.com/0x676e67/wreq-util/pull/91)) +- fix + +### Other + +- Update Cargo.toml +- Update Cargo.toml +- Update README.md +- fix docs build ([#95](https://github.com/0x676e67/wreq-util/pull/95)) +- Update wreq and wreq-util versions in README +- release-plz.yml +- *(deps)* bump softprops/action-gh-release from 2 to 3 ([#89](https://github.com/0x676e67/wreq-util/pull/89)) +- Add Discord chat badge to README +- Add rustfmt configuration settings +- Update issue submission instructions in README +- Update Cargo.toml +- Update copyright year and owner in LICENSE file +- Revise contributing section and add FAQ +- Update Apache-2.0 +- export +- Update Cargo.toml +- update deps +- update +- *(macros)* fmt code ([#85](https://github.com/0x676e67/wreq-util/pull/85)) +- *(macros)* fmt code +- Fix variable naming in emulate.rs +- *(emulation)* refine abstraction for emulation settings ([#84](https://github.com/0x676e67/wreq-util/pull/84)) +- fmt +- Change 'Overview' header to 'Features' +- *(mod)* use `emulate` when applying `emulation` ([#83](https://github.com/0x676e67/wreq-util/pull/83)) +- Update `Contributing` section in `README.md` ([#81](https://github.com/0x676e67/wreq-util/pull/81)) diff --git a/crates/wreq-util/Cargo.toml b/crates/wreq-util/Cargo.toml new file mode 100644 index 0000000..abb4367 --- /dev/null +++ b/crates/wreq-util/Cargo.toml @@ -0,0 +1,94 @@ +[package] +name = "wreq-util" +description = "Common utilities for wreq" +repository = "https://github.com/0x676e67/wreq-util" +documentation = "https://docs.rs/wreq-util" +keywords = ["http", "client", "emulation", "ja3", "ja4"] +authors = ["0x676e67 "] +version = "3.0.0-rc.14" +readme = "README.md" +license = "Apache-2.0" +edition = "2024" +rust-version = "1.85" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +targets = ["x86_64-unknown-linux-gnu"] + +[features] +default = ["emulation"] + +tokio-rt = ["wreq/tokio-rt"] +compio-rt = ["wreq/compio-rt"] + +emulation = ["dep:typed-builder", "dep:brotli", "dep:flate2", "dep:zstd"] +emulation-serde = ["dep:serde"] +emulation-compression = [] + +tower-delay = ["dep:tower", "dep:pin-project-lite", "tokio/time"] + +[dependencies] +wreq = { version = "6.0.0-rc", default-features = false } + +# Optional deps... + +serde = { version = "1.0.228", features = ["derive"], optional = true } +tokio = { version = "1.52.1", default-features = false, optional = true } +tower = { version = "0.5.2", default-features = false, optional = true } +typed-builder = { version = "0.23.2", optional = true } +pin-project-lite = { version = "0.2.17", optional = true } + +## Compression algorithms +brotli = { version = "8.0.2", optional = true } +flate2 = { version = "1.1.9", optional = true } +zstd = { version = "0.13.3", optional = true } + +[dev-dependencies] +wreq = "6.0.0-rc" +tokio = { version = "1.48.0", features = ["full"] } +hyper = { version = "1.10.1", default-features = false, features = [ + "http1", + "http2", + "server", +] } +hyper-util = { version = "0.1.20", features = [ + "http1", + "http2", + "server-auto", + "tokio", +] } +http = "1" + +[lib] +doctest = false + +[[test]] +name = "client" +path = "tests/client.rs" + +[[test]] +name = "emulate_chrome" +path = "tests/emulate_chrome.rs" + +[[test]] +name = "emulate_okhttp" +path = "tests/emulate_okhttp.rs" + +[[test]] +name = "emulate_firefox" +path = "tests/emulate_firefox.rs" + +[[test]] +name = "emulate_safari" +path = "tests/emulate_safari.rs" + +[[example]] +name = "emulate" +path = "examples/emulate.rs" +required-features = ["emulation"] + +[[example]] +name = "tower_delay" +path = "examples/tower_delay.rs" +required-features = ["tower-delay"] diff --git a/crates/wreq-util/LICENSE b/crates/wreq-util/LICENSE new file mode 100644 index 0000000..b94601a --- /dev/null +++ b/crates/wreq-util/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2026 0x676e67 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/crates/wreq-util/README.md b/crates/wreq-util/README.md new file mode 100644 index 0000000..7d32a28 --- /dev/null +++ b/crates/wreq-util/README.md @@ -0,0 +1,62 @@ +# wreq-util + +A collection of utilities to do common things with [wreq](https://github.com/0x676e67/wreq). + +[![Crates.io](https://img.shields.io/crates/v/wreq-util.svg?logo=rust)](https://crates.io/crates/wreq-util) +[![GitHub License](https://img.shields.io/github/license/0x676e67/wreq-util)](https://github.com/0x676e67/wreq-util/blob/main/LICENSE) +[![Discord chat][discord-badge]][discord-url] + +[discord-badge]: https://img.shields.io/discord/1486741856397164788.svg?logo=discord +[discord-url]: https://discord.gg/rfbvyFkgq3 + +See the [crate documentation](https://docs.rs/wreq-util/latest/wreq_util) for more details. + +## Features + +**wreq-util** offers a set of [tower](https://github.com/tower-rs/tower) middleware and utilities designed specifically for the [wreq](https://github.com/0x676e67/wreq) HTTP client: + +- **Emulation** various mainstream browsers (Chrome, Firefox, Safari, Opera, OkHttp) and their versions. +- **Delay/JitterDelay**: Add fixed or jittered delays to HTTP [request](https://docs.rs/http/latest/http/request/index.html) with customizable strategies and predicates. + +## Example + +The following example uses the [Tokio](https://tokio.rs) runtime with optional features enabled by adding this to your `Cargo.toml`: + +```toml +[dependencies] +tokio = { version = "1", features = ["full"] } +wreq = "6.0.0-rc" +wreq-util = "3.0.0-rc" +``` + +And then the code: + +```rust +use wreq::Client; +use wreq_util::Emulation; + +#[tokio::main] +async fn main() -> wreq::Result<()> { + // Build a client + let client = Client::builder() + .emulation(Emulation::Chrome147) + .build()?; + + // Use the API you're already familiar with + let resp = client.get("https://www.google.com").send().await?; + println!("{}", resp.text().await?); + Ok(()) +} +``` + +## License + +Licensed under either of Apache License, Version 2.0 ([LICENSE](./LICENSE) or http://www.apache.org/licenses/LICENSE-2.0). + +## Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the [Apache-2.0](./LICENSE) license, shall be licensed as above, without any additional terms or conditions. + +## FAQ + +**For all issues and feedback, please head over to the [wreq](https://github.com/0x676e67/wreq) repository.** diff --git a/crates/wreq-util/examples/emulate.rs b/crates/wreq-util/examples/emulate.rs new file mode 100644 index 0000000..062d175 --- /dev/null +++ b/crates/wreq-util/examples/emulate.rs @@ -0,0 +1,39 @@ +use wreq_util::{Emulation, Platform, Profile}; + +#[tokio::main] +async fn main() -> Result<(), wreq::Error> { + // Example 1: Basic emulation - Safari26 + let text = wreq::get("https://tls.browserleaks.com/") + .emulation(Emulation::Safari26) + .send() + .await? + .text() + .await?; + println!("{}\n", text); + + // Example 2: Advanced emulation with options - OkHttp5 + let text = wreq::get("https://tls.peet.ws/api/all") + .emulation( + Emulation::builder() + .profile(Profile::OkHttp5) + .platform(Platform::Windows) + .http2(false) + .build(), + ) + .send() + .await? + .text() + .await?; + println!("{}\n", text); + + // Example 3: Random device emulation + let text = wreq::get("https://tls.peet.ws/api/all") + .emulation(Emulation::random()) + .send() + .await? + .text() + .await?; + println!("{}", text); + + Ok(()) +} diff --git a/crates/wreq-util/examples/tower_delay.rs b/crates/wreq-util/examples/tower_delay.rs new file mode 100644 index 0000000..4a22c67 --- /dev/null +++ b/crates/wreq-util/examples/tower_delay.rs @@ -0,0 +1,191 @@ +use std::time::{Duration, Instant}; +use wreq::Client; +use wreq_util::tower::delay::{DelayLayer, JitterDelayLayer}; + +#[tokio::main] +async fn main() -> Result<(), wreq::Error> { + // Build a client with a 1 second delay between requests + let client = Client::builder() + .layer(DelayLayer::new(Duration::from_secs(1))) + .tls_cert_verification(false) + .build()?; + + let url = "https://httpbin.io/get"; + println!("Sending 3 requests to {} using DelayLayer(1s)", url); + + let mut prev_start = Instant::now(); + + for i in 1..=3 { + let start = Instant::now(); + let delta = start.duration_since(prev_start); + println!("Request #{}, start (+{:.3}s)", i, delta.as_secs_f64()); + + let _ = client.get(url).send().await?; + + println!( + "Request #{}, completed in {:.3}s", + i, + start.elapsed().as_secs_f64() + ); + + prev_start = start; + } + + // Example 1: Basic jittered delay for all requests + basic_jitter_delay().await?; + + println!("\n{}\n", "=".repeat(60)); + + // Example 2: Conditional jittered delay using `when` + conditional_jitter_delay().await?; + + println!("\n{}\n", "=".repeat(60)); + + // Example 3: Conditional fixed delay using `when` + conditional_fixed_delay().await?; + + Ok(()) +} + +/// Demonstrates basic jittered delay aplied to all requests. +async fn basic_jitter_delay() -> Result<(), wreq::Error> { + println!("=== Basic Jittered Delay ===\n"); + + // Build a client with jittered delay: base 1s ± 50% (range: 0.5s to 1.5s) + let client = Client::builder() + .layer(JitterDelayLayer::new(Duration::from_secs(1), 0.5)) + .tls_cert_verification(false) + .build()?; + + let url = "https://httpbin.io/get"; + println!( + "Sending 3 requests to {} using JitterDelayLayer(1s ± 50%)", + url + ); + println!("Expected delay range: [0.5s, 1.5s]\n"); + + let mut prev_start = Instant::now(); + + for i in 1..=3 { + let start = Instant::now(); + let delta = start.duration_since(prev_start); + + if i > 1 { + println!( + "Request #{}: delay since last = {:.3}s", + i, + delta.as_secs_f64() + ); + } else { + println!("Request #{}: starting...", i); + } + + let _ = client.get(url).send().await?; + + println!( + "Request #{}: completed in {:.3}s\n", + i, + start.elapsed().as_secs_f64() + ); + + prev_start = start; + } + + println!("Notice how the delays vary randomly within the [0.5s, 1.5s] range."); + + Ok(()) +} + +/// Demonstrates conditional jittered delay using `when` predicate. +async fn conditional_jitter_delay() -> Result<(), wreq::Error> { + println!("=== Conditional Jittered Delay (using `JitterDelayLayer::when`) ===\n"); + + let client = Client::builder() + .layer(JitterDelayLayer::new(Duration::from_millis(800), 0.3).when( + |req: &http::Request<_>| { + // Only apply delay to POST requests + req.method() == http::Method::POST + }, + )) + .tls_cert_verification(false) + .build()?; + + const BASE_URL: &str = "https://httpbin.io"; + + println!("POST requests will have jittered delay (800ms ± 30%)"); + println!("GET requests will pass through immediately\n"); + + // Send alternating GET and POST requests + for i in 1..=4 { + let start = Instant::now(); + + if i % 2 == 1 { + // GET request - no delay expected + let url = format!("{BASE_URL}/get"); + println!("Request #{}: GET {}", i, url); + let _ = client.get(&url).send().await?; + } else { + // POST request - delay expected + let url = format!("{BASE_URL}/post"); + println!("Request #{}: POST {}", i, url); + let _ = client.post(&url).send().await?; + } + + println!( + "Request #{}: completed in {:.3}s ({})\n", + i, + start.elapsed().as_secs_f64(), + if i % 2 == 1 { "no delay" } else { "with delay" } + ); + } + + println!("Notice: GET requests complete quickly, POST requests have ~800ms delay."); + + Ok(()) +} + +/// Demonstrates conditional fixed delay using `when` predicate. +async fn conditional_fixed_delay() -> Result<(), wreq::Error> { + println!("=== Conditional Fixed Delay (using `DelayLayer::when`) ===\n"); + + // Build a client that only delays requests to specific paths + let client = Client::builder() + .layer( + DelayLayer::new(Duration::from_secs(1)).when(|req: &http::Request<_>| { + // Only apply delay to /delay/* endpoints + req.uri().path().starts_with("/delay") + }), + ) + .tls_cert_verification(false) + .build()?; + + const BASE_URL: &str = "https://httpbin.io"; + + println!("Requests to /delay/* will have 1s fixed delay"); + println!("Other requests will pass through immediately\n"); + + // Test with different endpoints + let endpoints = ["/get", "/delay/0"]; + + for (i, endpoint) in endpoints.iter().enumerate() { + let url = format!("{BASE_URL}{endpoint}"); + let start = Instant::now(); + + println!("Request #{}: GET {}", i + 1, url); + let _ = client.get(&url).send().await?; + + let elapsed = start.elapsed().as_secs_f64(); + let has_delay = endpoint.starts_with("/delay"); + + println!( + "Request #{}: completed in {:.3}s ({})\n", + i + 1, + elapsed, + if has_delay { "with delay" } else { "no delay" } + ); + } + + println!("Notice: /get completes quickly, /delay/* has additional 1s delay."); + + Ok(()) +} diff --git a/crates/wreq-util/release-plz.toml b/crates/wreq-util/release-plz.toml new file mode 100644 index 0000000..395b352 --- /dev/null +++ b/crates/wreq-util/release-plz.toml @@ -0,0 +1,2 @@ +[workspace] +publish_features = ["tokio-rt"] \ No newline at end of file diff --git a/crates/wreq-util/rustfmt.toml b/crates/wreq-util/rustfmt.toml new file mode 100644 index 0000000..ae184a9 --- /dev/null +++ b/crates/wreq-util/rustfmt.toml @@ -0,0 +1,5 @@ +group_imports = "StdExternalCrate" +imports_granularity = "Crate" +reorder_imports = true +wrap_comments = true +comment_width = 100 diff --git a/crates/wreq-util/src/emulate.rs b/crates/wreq-util/src/emulate.rs new file mode 100644 index 0000000..33a1c58 --- /dev/null +++ b/crates/wreq-util/src/emulate.rs @@ -0,0 +1,369 @@ +#[macro_use] +mod macros; +pub mod compress; +pub mod profile; + +use profile::{chrome::*, firefox::*, okhttp::*, opera::*, safari::*}; +#[cfg(feature = "emulation-serde")] +use serde::{Deserialize, Serialize}; +use typed_builder::TypedBuilder; + +define_enum!( + /// Selects which client profile the request should look like. + /// + /// This controls the built-in TLS, HTTP/2, and header presets used for the + /// request. Variants cover browser-style profiles as well as other clients, + /// such as OkHttp. + dispatch, + Profile, Chrome100, + Emulation, + + // Chrome versions + Chrome100 => ("chrome_100", v100::emulation), + Chrome101 => ("chrome_101", v101::emulation), + Chrome104 => ("chrome_104", v104::emulation), + Chrome105 => ("chrome_105", v105::emulation), + Chrome106 => ("chrome_106", v106::emulation), + Chrome107 => ("chrome_107", v107::emulation), + Chrome108 => ("chrome_108", v108::emulation), + Chrome109 => ("chrome_109", v109::emulation), + Chrome110 => ("chrome_110", v110::emulation), + Chrome114 => ("chrome_114", v114::emulation), + Chrome116 => ("chrome_116", v116::emulation), + Chrome117 => ("chrome_117", v117::emulation), + Chrome118 => ("chrome_118", v118::emulation), + Chrome119 => ("chrome_119", v119::emulation), + Chrome120 => ("chrome_120", v120::emulation), + Chrome123 => ("chrome_123", v123::emulation), + Chrome124 => ("chrome_124", v124::emulation), + Chrome126 => ("chrome_126", v126::emulation), + Chrome127 => ("chrome_127", v127::emulation), + Chrome128 => ("chrome_128", v128::emulation), + Chrome129 => ("chrome_129", v129::emulation), + Chrome130 => ("chrome_130", v130::emulation), + Chrome131 => ("chrome_131", v131::emulation), + Chrome132 => ("chrome_132", v132::emulation), + Chrome133 => ("chrome_133", v133::emulation), + Chrome134 => ("chrome_134", v134::emulation), + Chrome135 => ("chrome_135", v135::emulation), + Chrome136 => ("chrome_136", v136::emulation), + Chrome137 => ("chrome_137", v137::emulation), + Chrome138 => ("chrome_138", v138::emulation), + Chrome139 => ("chrome_139", v139::emulation), + Chrome140 => ("chrome_140", v140::emulation), + Chrome141 => ("chrome_141", v141::emulation), + Chrome142 => ("chrome_142", v142::emulation), + Chrome143 => ("chrome_143", v143::emulation), + Chrome144 => ("chrome_144", v144::emulation), + Chrome145 => ("chrome_145", v145::emulation), + Chrome146 => ("chrome_146", v146::emulation), + Chrome147 => ("chrome_147", v147::emulation), + Chrome148 => ("chrome_148", v148::emulation), + Chrome149 => ("chrome_149", v149::emulation), + Chrome150 => ("chrome_150", v150::emulation), + + // Edge versions + Edge101 => ("edge_101", edge101::emulation), + Edge122 => ("edge_122", edge122::emulation), + Edge127 => ("edge_127", edge127::emulation), + Edge131 => ("edge_131", edge131::emulation), + Edge134 => ("edge_134", edge134::emulation), + Edge135 => ("edge_135", edge135::emulation), + Edge136 => ("edge_136", edge136::emulation), + Edge137 => ("edge_137", edge137::emulation), + Edge138 => ("edge_138", edge138::emulation), + Edge139 => ("edge_139", edge139::emulation), + Edge140 => ("edge_140", edge140::emulation), + Edge141 => ("edge_141", edge141::emulation), + Edge142 => ("edge_142", edge142::emulation), + Edge143 => ("edge_143", edge143::emulation), + Edge144 => ("edge_144", edge144::emulation), + Edge145 => ("edge_145", edge145::emulation), + Edge146 => ("edge_146", edge146::emulation), + Edge147 => ("edge_147", edge147::emulation), + Edge148 => ("edge_148", edge148::emulation), + + // Opera versions + Opera116 => ("opera_116", opera116::emulation), + Opera117 => ("opera_117", opera117::emulation), + Opera118 => ("opera_118", opera118::emulation), + Opera119 => ("opera_119", opera119::emulation), + Opera120 => ("opera_120", opera120::emulation), + Opera121 => ("opera_121", opera121::emulation), + Opera122 => ("opera_122", opera122::emulation), + Opera123 => ("opera_123", opera123::emulation), + Opera124 => ("opera_124", opera124::emulation), + Opera125 => ("opera_125", opera125::emulation), + Opera126 => ("opera_126", opera126::emulation), + Opera127 => ("opera_127", opera127::emulation), + Opera128 => ("opera_128", opera128::emulation), + Opera129 => ("opera_129", opera129::emulation), + Opera130 => ("opera_130", opera130::emulation), + Opera131 => ("opera_131", opera131::emulation), + + // Firefox versions + Firefox109 => ("firefox_109", ff109::emulation), + Firefox117 => ("firefox_117", ff117::emulation), + Firefox128 => ("firefox_128", ff128::emulation), + Firefox133 => ("firefox_133", ff133::emulation), + Firefox135 => ("firefox_135", ff135::emulation), + FirefoxPrivate135 => ("firefox_private_135", ff_private_135::emulation), + FirefoxAndroid135 => ("firefox_android_135", ff_android_135::emulation), + Firefox136 => ("firefox_136", ff136::emulation), + FirefoxPrivate136 => ("firefox_private_136", ff_private_136::emulation), + Firefox139 => ("firefox_139", ff139::emulation), + Firefox142 => ("firefox_142", ff142::emulation), + Firefox143 => ("firefox_143", ff143::emulation), + Firefox144 => ("firefox_144", ff144::emulation), + Firefox145 => ("firefox_145", ff145::emulation), + Firefox146 => ("firefox_146", ff146::emulation), + Firefox147 => ("firefox_147", ff147::emulation), + Firefox148 => ("firefox_148", ff148::emulation), + Firefox149 => ("firefox_149", ff149::emulation), + Firefox150 => ("firefox_150", ff150::emulation), + Firefox151 => ("firefox_151", ff151::emulation), + + // Safari versions + SafariIos17_2 => ("safari_ios_17.2", safari_ios_17_2::emulation), + SafariIos17_4_1 => ("safari_ios_17.4.1", safari_ios_17_4_1::emulation), + SafariIos16_5 => ("safari_ios_16.5", safari_ios_16_5::emulation), + Safari15_3 => ("safari_15.3", safari15_3::emulation), + Safari15_5 => ("safari_15.5", safari15_5::emulation), + Safari15_6_1 => ("safari_15.6.1", safari15_6_1::emulation), + Safari16 => ("safari_16", safari16::emulation), + Safari16_5 => ("safari_16.5", safari16_5::emulation), + Safari17_0 => ("safari_17.0", safari17_0::emulation), + Safari17_2_1 => ("safari_17.2.1", safari17_2_1::emulation), + Safari17_4_1 => ("safari_17.4.1", safari17_4_1::emulation), + Safari17_5 => ("safari_17.5", safari17_5::emulation), + Safari17_6 => ("safari_17.6", safari17_6::emulation), + Safari18 => ("safari_18", safari18::emulation), + SafariIPad18 => ("safari_ipad_18", safari_ipad_18::emulation), + Safari18_2 => ("safari_18.2", safari18_2::emulation), + SafariIos18_1_1 => ("safari_ios_18.1.1", safari_ios_18_1_1::emulation), + Safari18_3 => ("safari_18.3", safari18_3::emulation), + Safari18_3_1 => ("safari_18.3.1", safari18_3_1::emulation), + Safari18_5 => ("safari_18.5", safari18_5::emulation), + Safari26 => ("safari_26", safari26::emulation), + Safari26_1 => ("safari_26.1", safari26_1::emulation), + Safari26_2 => ("safari_26.2", safari26_2::emulation), + Safari26_3 => ("safari_26.3", safari26_3::emulation), + Safari26_4 => ("safari_26.4", safari26_4::emulation), + SafariIPad26 => ("safari_ipad_26", safari_ipad_26::emulation), + SafariIpad26_2 => ("safari_ipad_26.2", safari_ipad_26_2::emulation), + SafariIos26 => ("safari_ios_26", safari_ios_26::emulation), + SafariIos26_2 => ("safari_ios_26.2", safari_ios_26_2::emulation), + + // OkHttp versions + OkHttp3_9 => ("okhttp_3.9", okhttp3_9::emulation), + OkHttp3_11 => ("okhttp_3.11", okhttp3_11::emulation), + OkHttp3_13 => ("okhttp_3.13", okhttp3_13::emulation), + OkHttp3_14 => ("okhttp_3.14", okhttp3_14::emulation), + OkHttp4_9 => ("okhttp_4.9", okhttp4_9::emulation), + OkHttp4_10 => ("okhttp_4.10", okhttp4_10::emulation), + OkHttp4_12 => ("okhttp_4.12", okhttp4_12::emulation), + OkHttp5 => ("okhttp_5", okhttp5::emulation) + +); + +impl wreq::IntoEmulation for Profile { + #[inline] + fn into_emulation(self) -> wreq::Emulation { + Emulation::builder().profile(self).build().into_emulation() + } +} + +define_enum!( + /// Selects which platform the client should look like. + /// + /// This mainly affects platform-specific headers and user-agent details. + /// In most cases you can keep the default unless you need to match a + /// specific Windows, macOS, Linux, Android, or iOS profile. + plain, + Platform, MacOS, + Windows => "windows", + MacOS => "macos", + Linux => "linux", + Android => "android", + IOS => "ios" +); + +impl Platform { + #[inline] + const fn platform(&self) -> &'static str { + match self { + Platform::MacOS => "\"macOS\"", + Platform::Linux => "\"Linux\"", + Platform::Windows => "\"Windows\"", + Platform::Android => "\"Android\"", + Platform::IOS => "\"iOS\"", + } + } + + #[inline] + const fn is_mobile(&self) -> bool { + matches!(self, Platform::Android | Platform::IOS) + } +} + +/// Represents the configuration options for emulating a client profile and platform. +/// +/// The `Emulation` struct allows you to configure various aspects of profile and platform +/// emulation, including the profile, platform, and whether to enable certain features +/// like HTTP/2 or headers. +#[derive(Default, Clone, TypedBuilder)] +pub struct Emulation { + /// Whether to change the profile (browser/okhttp) information. + #[builder(default)] + profile: Profile, + + /// Whether to change the platform (Windows/macOS/Linux/Android/iOS) information. + #[builder(default)] + platform: Platform, + + /// Whether to enable HTTP/2. + #[builder(default = true)] + http2: bool, + + /// Whether to include default headers. + #[builder(default = true)] + headers: bool, +} + +impl Emulation { + /// Returns a random variant of the `Profile` enum. + /// + /// # Examples + /// + /// ``` + /// use wreq_util::Emulation; + /// + /// let random_emulation = Emulation::random(); + /// println!("{:?}", random_emulation); + /// ``` + pub fn random() -> Emulation { + let rand = crate::rand::fast_random(); + Emulation::builder() + .profile(Profile::VARIANTS[(rand as usize) % Profile::VARIANTS.len()]) + .platform(Platform::VARIANTS[((rand >> 32) as usize) % Platform::VARIANTS.len()]) + .build() + } + + /// Returns a market-share weighted random `Emulation`. + /// + /// Unlike [`Emulation::random`], selection is biased toward popular browser + /// families and their most recent versions, and each profile is only paired + /// with platforms it ships on. + /// + /// Browser family and version weights are derived from StatCounter Global + /// Stats data retrieved in June 2026: + /// + /// Browser market share: + /// + /// + /// Browser version market share: + /// + /// + /// StatCounter requests attribution for use of its data. See: + /// + /// + /// # Examples + /// + /// ``` + /// use wreq_util::Emulation; + /// + /// let random_emulation = Emulation::weighted_random(); + /// println!("{:?}", random_emulation); + /// ``` + pub fn weighted_random() -> Emulation { + use Platform::*; + use Profile::*; + + struct Class { + weight: u32, + platforms: &'static [Platform], + profiles: &'static [Profile], + } + + // Weights based on StatCounter June 2026 data. + // + // Each weight is the family's share percentage multiplied by 100 and + // rounded to an integer (e.g. Chrome 71.41% -> 7141, Edge 5.02% -> 502, + // Firefox 2.35% -> 235, Opera 1.73% -> 173). Only relative magnitudes + // matter, so the common x100 scale is arbitrary but keeps two decimals + // of precision without floats. + // + // Safari's 14.77% is split by platform using the browser-version data: + // iPhone 11.96% + iPad 0.44% = 12.40% mobile (-> 1240), leaving the + // remaining 2.37% for desktop/macOS (-> 237). + const CLASSES: &[Class] = &[ + Class { + weight: 7141, + platforms: &[Windows, MacOS, Linux, Android], + profiles: &[ + Chrome149, Chrome148, Chrome147, Chrome146, Chrome145, Chrome144, Chrome143, + ], + }, + Class { + weight: 1240, + platforms: &[IOS], + profiles: &[ + SafariIos26_2, + SafariIos26, + SafariIpad26_2, + SafariIPad26, + SafariIos18_1_1, + SafariIPad18, + ], + }, + Class { + weight: 502, + platforms: &[Windows, MacOS], + profiles: &[Edge148, Edge147, Edge146, Edge145, Edge144, Edge143], + }, + Class { + weight: 237, + platforms: &[MacOS], + profiles: &[ + Safari26_4, Safari26_3, Safari26_2, Safari26_1, Safari26, Safari18_5, + ], + }, + Class { + weight: 235, + platforms: &[Windows, MacOS, Linux], + profiles: &[ + Firefox151, Firefox150, Firefox149, Firefox148, Firefox147, Firefox146, + ], + }, + Class { + weight: 173, + platforms: &[Windows, MacOS, Linux, Android], + profiles: &[Opera131, Opera130, Opera129, Opera128, Opera127, Opera126], + }, + ]; + + let (r1, r2) = (crate::rand::fast_random(), crate::rand::fast_random()); + let total: u32 = CLASSES.iter().map(|c| c.weight).sum(); + let mut t = (r1 % total as u64) as u32; + let class = CLASSES + .iter() + .find(|c| { + t = t.checked_sub(c.weight).unwrap_or(u32::MAX); + t == u32::MAX + }) + .unwrap_or(&CLASSES[0]); + let n = class.profiles.len(); + let idx = ((r1 >> 32) as usize % n).min((r2 >> 32) as usize % n); + Emulation::builder() + .profile(class.profiles[idx]) + .platform(class.platforms[(r2 as usize) % class.platforms.len()]) + .build() + } +} + +impl wreq::IntoEmulation for Emulation { + #[inline] + fn into_emulation(self) -> wreq::Emulation { + self.profile.match_emulation(self) + } +} diff --git a/crates/wreq-util/src/emulate/compress.rs b/crates/wreq-util/src/emulate/compress.rs new file mode 100644 index 0000000..c3373c3 --- /dev/null +++ b/crates/wreq-util/src/emulate/compress.rs @@ -0,0 +1,85 @@ +//! Compression algorithms for TLS 1.3 certificate compression. + +use brotli::{CompressorWriter as BrotliEncoder, Decompressor as BrotliDecoder}; +use flate2::{Compression, read::ZlibDecoder, write::ZlibEncoder}; +use std::io::{self, Write}; +use wreq::tls::compress::{CertificateCompressionAlgorithm, CertificateCompressor, Codec}; +use zstd::stream::{Decoder as ZstdDecoder, Encoder as ZstdEncoder}; + +#[derive(Debug)] +pub struct BrotliCompressor; + +#[derive(Debug)] +pub struct ZlibCompressor; + +#[derive(Debug)] +pub struct ZstdCompressor; + +impl CertificateCompressor for BrotliCompressor { + fn compress(&self) -> Codec { + Codec::Pointer(|input, output| { + let mut writer = BrotliEncoder::new(output, input.len(), 11, 32); + writer.write_all(input)?; + writer.flush()?; + Ok(()) + }) + } + + fn decompress(&self) -> Codec { + Codec::Pointer(|input, output| { + let mut reader = BrotliDecoder::new(input, 4096); + io::copy(&mut reader, output)?; + Ok(()) + }) + } + + fn algorithm(&self) -> CertificateCompressionAlgorithm { + CertificateCompressionAlgorithm::BROTLI + } +} + +impl CertificateCompressor for ZlibCompressor { + fn compress(&self) -> Codec { + Codec::Pointer(|input, output| { + let mut encoder = ZlibEncoder::new(output, Compression::default()); + encoder.write_all(input)?; + encoder.finish()?; + Ok(()) + }) + } + + fn decompress(&self) -> Codec { + Codec::Pointer(|input, output| { + let mut reader = ZlibDecoder::new(input); + io::copy(&mut reader, output)?; + Ok(()) + }) + } + + fn algorithm(&self) -> CertificateCompressionAlgorithm { + CertificateCompressionAlgorithm::ZLIB + } +} + +impl CertificateCompressor for ZstdCompressor { + fn compress(&self) -> Codec { + Codec::Pointer(|input, output| { + let mut encoder = ZstdEncoder::new(output, 0)?; + encoder.write_all(input)?; + encoder.finish()?; + Ok(()) + }) + } + + fn decompress(&self) -> Codec { + Codec::Pointer(|input, output| { + let mut reader = ZstdDecoder::new(input)?; + io::copy(&mut reader, output)?; + Ok(()) + }) + } + + fn algorithm(&self) -> CertificateCompressionAlgorithm { + CertificateCompressionAlgorithm::ZSTD + } +} diff --git a/crates/wreq-util/src/emulate/macros.rs b/crates/wreq-util/src/emulate/macros.rs new file mode 100644 index 0000000..e763c89 --- /dev/null +++ b/crates/wreq-util/src/emulate/macros.rs @@ -0,0 +1,370 @@ +macro_rules! define_enum { + ( + $(#[$meta:meta])* + dispatch, + $name:ident, $default_variant:ident, + $const_target:ident, + $( + $variant:ident => ($rename:expr, $emulation_fn:path) + ),* $(,)? + ) => { + $(#[$meta])* + #[non_exhaustive] + #[derive(Clone, Copy, Hash, Debug, PartialEq, Eq)] + #[cfg_attr(feature = "emulation-serde", derive(Deserialize, Serialize))] + pub enum $name { + $( + #[cfg_attr(feature = "emulation-serde", serde(rename = $rename))] + $variant, + )* + } + + impl $name { + pub const VARIANTS: &[$name] = &[ + $( + $name::$variant, + )* + ]; + + pub fn match_emulation(self, opt: $const_target) -> wreq::Emulation { + match self { + $( + $name::$variant => $emulation_fn(opt), + )* + } + } + } + + impl Default for $name { + fn default() -> Self { + $name::$default_variant + } + } + + #[allow(non_upper_case_globals)] + impl $const_target { + $( + pub const $variant: $name = $name::$variant; + )* + } + }; + + ( + $(#[$meta:meta])* + plain, + $name:ident, $default_variant:ident, + $( + $variant:ident => $rename:expr + ),* $(,)? + ) => { + $(#[$meta])* + #[non_exhaustive] + #[derive(Clone, Copy, Hash, Debug, PartialEq, Eq)] + #[cfg_attr(feature = "emulation-serde", derive(Deserialize, Serialize))] + pub enum $name { + $( + #[cfg_attr(feature = "emulation-serde", serde(rename = $rename))] + $variant, + )* + } + + impl $name { + pub const VARIANTS: &[$name] = &[ + $( + $name::$variant, + )* + ]; + } + + impl Default for $name { + fn default() -> Self { + $name::$default_variant + } + } + }; +} + +macro_rules! header_chrome_sec_ch_ua { + ($headers:expr, $ua:expr, $platform:expr, $is_mobile:expr) => { + let mobile = if $is_mobile { "?1" } else { "?0" }; + $headers.insert("sec-ch-ua", HeaderValue::from_static($ua)); + $headers.insert("sec-ch-ua-mobile", HeaderValue::from_static(mobile)); + $headers.insert("sec-ch-ua-platform", HeaderValue::from_static($platform)); + }; +} + +macro_rules! header_chrome_sec_fetch { + ($headers:expr) => { + $headers.insert("sec-fetch-dest", HeaderValue::from_static("document")); + $headers.insert("sec-fetch-mode", HeaderValue::from_static("navigate")); + $headers.insert("sec-fetch-site", HeaderValue::from_static("none")); + }; +} + +macro_rules! header_chrome_ua { + ($headers:expr, $ua:expr) => { + $headers.insert(USER_AGENT, HeaderValue::from_static($ua)); + }; +} + +macro_rules! header_chrome_accept { + ($headers:expr) => { + $headers.insert(ACCEPT, HeaderValue::from_static("text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")); + #[cfg(feature = "emulation-compression")] + $headers.insert( + ACCEPT_ENCODING, + HeaderValue::from_static("gzip, deflate, br"), + ); + $headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.9")); + }; + (zstd, $headers:expr) => { + $headers.insert(ACCEPT, HeaderValue::from_static("text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")); + #[cfg(feature = "emulation-compression")] + $headers.insert( + ACCEPT_ENCODING, + HeaderValue::from_static("gzip, deflate, br, zstd"), + ); + $headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.9")); + } +} + +macro_rules! header_firefox_sec_fetch { + ($headers:expr) => { + $headers.insert("sec-fetch-dest", HeaderValue::from_static("document")); + $headers.insert("sec-fetch-mode", HeaderValue::from_static("navigate")); + $headers.insert("sec-fetch-site", HeaderValue::from_static("none")); + }; +} + +macro_rules! header_firefox_accept { + ($headers:expr) => { + $headers.insert( + ACCEPT, + HeaderValue::from_static( + "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", + ), + ); + #[cfg(feature = "emulation-compression")] + $headers.insert( + ACCEPT_ENCODING, + HeaderValue::from_static("gzip, deflate, br"), + ); + $headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.5")); + }; + (zstd, $headers:expr) => { + $headers.insert( + ACCEPT, + HeaderValue::from_static( + "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", + ), + ); + #[cfg(feature = "emulation-compression")] + $headers.insert( + ACCEPT_ENCODING, + HeaderValue::from_static("gzip, deflate, br, zstd"), + ); + $headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.5")); + }; +} + +macro_rules! header_firefox_ua { + ($headers:expr, $ua:expr) => { + $headers.insert( + HeaderName::from_static("te"), + HeaderValue::from_static("trailers"), + ); + $headers.insert(USER_AGENT, HeaderValue::from_static($ua)); + }; +} + +macro_rules! join { + ($sep:expr, $first:expr $(, $rest:expr)*) => { + concat!($first $(, $sep, $rest)*) + }; +} + +macro_rules! standard_mod_generator { + ($mod_name:ident, $tls_options:expr, $http2_options:expr, $headers:expr) => { + pub(crate) mod $mod_name { + use super::*; + + #[inline] + pub fn emulation(emulation: Emulation) -> wreq::Emulation { + build_emulation(emulation.http2, ($headers)(&emulation)) + } + + pub fn build_emulation( + http2: bool, + default_headers: Option, + ) -> wreq::Emulation { + build_standard_emulation( + stringify!($mod_name), + $tls_options, + http2.then(|| $http2_options), + default_headers, + ) + } + } + }; + ($mod_name:ident, $build_emulation:expr, $headers:expr) => { + pub(crate) mod $mod_name { + use super::*; + + #[inline] + pub fn emulation(emulation: Emulation) -> wreq::Emulation { + $build_emulation(emulation.http2, ($headers)(&emulation)) + } + } + }; +} + +macro_rules! fixed_headers { + ($emulation:expr, $header_initializer:ident, $ua:expr) => { + $emulation.headers.then(|| $header_initializer($ua)) + }; +} + +macro_rules! platform_headers { + ( + $emulation:expr, + $header_initializer:ident, + [($default_os:ident, $default_sec_ch_ua:tt, $default_ua:tt) $(, ($other_os:ident, $other_sec_ch_ua:tt, $other_ua:tt))*] + ) => {{ + #[allow(unreachable_patterns)] + $emulation.headers.then(|| { + match $emulation.platform { + $( + Platform::$other_os => $header_initializer( + $other_sec_ch_ua, + $other_ua, + $emulation.platform, + ), + )* + _ => $header_initializer( + $default_sec_ch_ua, + $default_ua, + Platform::$default_os, + ), + } + }) + }}; +} + +macro_rules! firefox_platform_headers { + ($emulation:expr, $header_initializer:ident, [($default_os:ident, $default_ua:tt) $(, ($other_os:ident, $other_ua:tt))*]) => {{ + #[allow(unreachable_patterns)] + $emulation.headers.then(|| { + match $emulation.platform { + $( + Platform::$other_os => $header_initializer($other_ua), + )* + _ => $header_initializer($default_ua), + } + }) + }}; +} + +macro_rules! mod_generator { + ( + $mod_name:ident, + $tls_options:expr, + $http2_options:expr, + $header_initializer:ident, + [($default_os:ident, $default_sec_ch_ua:tt, $default_ua:tt) $(, ($other_os:ident, $other_sec_ch_ua:tt, $other_ua:tt))*] + ) => { + standard_mod_generator!( + $mod_name, + $tls_options, + $http2_options, + |emulation: &Emulation| { + platform_headers!( + emulation, + $header_initializer, + [($default_os, $default_sec_ch_ua, $default_ua) $(, ($other_os, $other_sec_ch_ua, $other_ua))*] + ) + } + ); + }; + ( + $mod_name:ident, + $tls_options:expr, + $http2_options:expr, + $header_initializer:ident, + [($default_os:ident, $default_ua:tt) $(, ($other_os:ident, $other_ua:tt))*] + ) => { + standard_mod_generator!( + $mod_name, + $tls_options, + $http2_options, + |emulation: &Emulation| { + firefox_platform_headers!( + emulation, + $header_initializer, + [($default_os, $default_ua) $(, ($other_os, $other_ua))*] + ) + } + ); + }; + ( + $mod_name:ident, + $tls_options:expr, + $http2_options:expr, + $header_initializer:ident, + $ua:expr + ) => { + standard_mod_generator!( + $mod_name, + $tls_options, + $http2_options, + |emulation: &Emulation| fixed_headers!(emulation, $header_initializer, $ua) + ); + }; + ( + $mod_name:ident, + $build_emulation:expr, + $header_initializer:ident, + [($default_os:ident, $default_sec_ch_ua:tt, $default_ua:tt) $(, ($other_os:ident, $other_sec_ch_ua:tt, $other_ua:tt))*] + ) => { + standard_mod_generator!( + $mod_name, + $build_emulation, + |emulation: &Emulation| { + platform_headers!( + emulation, + $header_initializer, + [($default_os, $default_sec_ch_ua, $default_ua) $(, ($other_os, $other_sec_ch_ua, $other_ua))*] + ) + } + ); + }; + ( + $mod_name:ident, + $build_emulation:expr, + $header_initializer:ident, + [($default_os:ident, $default_ua:tt) $(, ($other_os:ident, $other_ua:tt))*] + ) => { + standard_mod_generator!( + $mod_name, + $build_emulation, + |emulation: &Emulation| { + firefox_platform_headers!( + emulation, + $header_initializer, + [($default_os, $default_ua) $(, ($other_os, $other_ua))*] + ) + } + ); + }; + ( + $mod_name:ident, + $build_emulation:expr, + $header_initializer:ident, + $ua:expr + ) => { + standard_mod_generator!( + $mod_name, + $build_emulation, + |emulation: &Emulation| fixed_headers!(emulation, $header_initializer, $ua) + ); + }; +} diff --git a/crates/wreq-util/src/emulate/profile.rs b/crates/wreq-util/src/emulate/profile.rs new file mode 100644 index 0000000..11a98cc --- /dev/null +++ b/crates/wreq-util/src/emulate/profile.rs @@ -0,0 +1,47 @@ +//! Emulation for different browsers. + +pub mod chrome; +pub mod firefox; +pub mod okhttp; +pub mod opera; +pub mod safari; + +use typed_builder::TypedBuilder; +#[cfg(feature = "emulation-compression")] +use wreq::header::ACCEPT_ENCODING; +use wreq::{ + Group, + header::{ACCEPT, ACCEPT_LANGUAGE, HeaderMap, HeaderName, HeaderValue, USER_AGENT}, + http2::{ + Http2Options, Priorities, Priority, PseudoId, PseudoOrder, SettingId, SettingsOrder, + StreamDependency, StreamId, + }, + tls::{ + AlpnProtocol, AlpsProtocol, ExtensionType, KeyShare, TlsOptions, TlsVersion, + compress::CertificateCompressor, + }, +}; + +use super::{ + Emulation, Platform, + compress::{BrotliCompressor, ZlibCompressor, ZstdCompressor}, +}; + +fn build_standard_emulation( + group: &'static str, + tls_options: TlsOptions, + http2_options: Option, + default_headers: Option, +) -> wreq::Emulation { + let mut builder = wreq::Emulation::builder().tls_options(tls_options); + + if let Some(http2_options) = http2_options { + builder = builder.http2_options(http2_options); + } + + if let Some(headers) = default_headers { + builder = builder.headers(headers); + } + + builder.build(Group::new(group)) +} diff --git a/crates/wreq-util/src/emulate/profile/chrome.rs b/crates/wreq-util/src/emulate/profile/chrome.rs new file mode 100644 index 0000000..b85424f --- /dev/null +++ b/crates/wreq-util/src/emulate/profile/chrome.rs @@ -0,0 +1,2028 @@ +#[macro_use] +mod http2; +#[macro_use] +mod tls; +mod header; + +use header::*; +use tls::*; + +use super::*; + +mod_generator!( + v100, + tls_options!(1), + http2_options!(1), + header_initializer, + [ + ( + MacOS, + r#""Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36" + ), + ( + Linux, + r#""Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100""#, + "Mozilla/5.0 (X11; U; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36" + ), + ( + Android, + r#""Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100""#, + "Mozilla/5.0 (X11; U; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36" + ), + ( + Windows, + r#""Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36" + ), + ( + IOS, + r#""Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 15_8 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/100.0.4896.85 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v101, + v100::build_emulation, + header_initializer, + [ + ( + MacOS, + r#""Not A;Brand";v="99", "Chromium";v="101", "Google Chrome";v="101""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36" + ), + ( + Linux, + r#""Not A;Brand";v="99", "Chromium";v="101", "Google Chrome";v="101""#, + "Mozilla/5.0 (X11; U; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36" + ), + ( + Android, + r#""Not A;Brand";v="99", "Chromium";v="101", "Google Chrome";v="101""#, + "Mozilla/5.0 (X11; U; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36" + ), + ( + Windows, + r#""Not A;Brand";v="99", "Chromium";v="101", "Google Chrome";v="101""#, + "Mozilla/5.0 (X11; U; Windows x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36" + ), + ( + IOS, + r#""Not A;Brand";v="99", "Chromium";v="101", "Google Chrome";v="101""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/101.0.4951.58 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + edge101, + v100::build_emulation, + header_initializer, + [ + ( + MacOS, + r#""Not A;Brand";v="99", "Chromium";v="101", "Microsoft Edge";v="101""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.47" + ), + ( + Android, + r#""Not A;Brand";v="99", "Chromium";v="101", "Microsoft Edge";v="101""#, + "Mozilla/5.0 (Linux; Android 10; ONEPLUS A6003) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.41 Safari/537.36 Edg/101.0.1210.31" + ), + ( + Windows, + r#""Not A;Brand";v="99", "Chromium";v="101", "Microsoft Edge";v="101""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.53" + ), + // This shouldn't exist, edge was never meant to be on linux, + // but I found some UAs in myip.ms (same for 122, 127 and 131) + ( + Linux, + r#""Not A;Brand";v="99", "Chromium";v="101", "Microsoft Edge";v="101""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.53" + ), + ( + IOS, + r#""Not A;Brand";v="99", "Chromium";v="101", "Microsoft Edge";v="101""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/101.0.4951.64 Mobile Safari/537.36 Edg/101.0.1210.53" + ) + ] +); + +mod_generator!( + v104, + v100::build_emulation, + header_initializer, + [ + ( + MacOS, + r#""Chromium";v="104", " Not A;Brand";v="99", "Google Chrome";v="104""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Chromium";v="104", " Not A;Brand";v="99", "Google Chrome";v="104""#, + "Mozilla/5.0 (X11; U; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Chromium";v="104", " Not A;Brand";v="99", "Google Chrome";v="104""#, + "Mozilla/5.0 (X11; U; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Chromium";v="104", " Not A;Brand";v="99", "Google Chrome";v="104""#, + "Mozilla/5.0 (X11; U; Windows x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Chromium";v="104", " Not A;Brand";v="99", "Google Chrome";v="104""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 16_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/104.0.5112.99 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v105, + tls_options!(2), + http2_options!(1), + header_initializer, + [ + ( + MacOS, + r#""Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105""#, + "Mozilla/5.0 (X11; U; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105""#, + "Mozilla/5.0 (X11; U; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105""#, + "Mozilla/5.0 (X11; U; Windows x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 16_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/105.0.5195.100 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v106, + tls_options!(3), + http2_options!(2), + header_initializer, + [ + ( + MacOS, + r#""Chromium";v="106", "Google Chrome";v="106", "Not;A=Brand";v="99""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Chromium";v="106", "Google Chrome";v="106", "Not;A=Brand";v="99""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Chromium";v="106", "Google Chrome";v="106", "Not;A=Brand";v="99""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Chromium";v="106", "Google Chrome";v="106", "Not;A=Brand";v="99""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Chromium";v="106", "Google Chrome";v="106", "Not;A=Brand";v="99""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 16_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/106.0.5249.92 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v107, + v106::build_emulation, + header_initializer, + [ + ( + MacOS, + r#""Google Chrome";v="107", "Chromium";v="107", "Not=A?Brand";v="24""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Google Chrome";v="107", "Chromium";v="107", "Not=A?Brand";v="24""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Google Chrome";v="107", "Chromium";v="107", "Not=A?Brand";v="24""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Google Chrome";v="107", "Chromium";v="107", "Not=A?Brand";v="24""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Google Chrome";v="107", "Chromium";v="107", "Not=A?Brand";v="24""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 15_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/107.0.5304.66 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v108, + v106::build_emulation, + header_initializer, + [ + ( + MacOS, + r#""Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 16_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/108.0.5359.112 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v109, + v106::build_emulation, + header_initializer, + [ + ( + MacOS, + r#""Not_A Brand";v="99", "Google Chrome";v="109", "Chromium";v="109""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Not_A Brand";v="99", "Google Chrome";v="109", "Chromium";v="109""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Not_A Brand";v="99", "Google Chrome";v="109", "Chromium";v="109""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Not_A Brand";v="99", "Google Chrome";v="109", "Chromium";v="109""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Not_A Brand";v="99", "Google Chrome";v="109", "Chromium";v="109""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/109.0.5414.112 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v110, + v100::build_emulation, + header_initializer, + [ + ( + MacOS, + r#""Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/110.0.5481.104 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v114, + v106::build_emulation, + header_initializer, + [ + ( + MacOS, + r#""Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36" + ) + ] +); + +mod_generator!( + v116, + tls_options!(4), + http2_options!(2), + header_initializer, + [ + ( + MacOS, + r#""Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/116.0.5845.103 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v117, + tls_options!(5), + http2_options!(3), + header_initializer, + [ + ( + MacOS, + r#""Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117""#, + "Mozilla/5.0 (iPad; CPU OS 16_0 like Mac OS X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36" + ) + ] +); + +mod_generator!( + v120, + v117::build_emulation, + header_initializer, + [ + ( + MacOS, + r#""Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/120.0.6099.119 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + edge122, + v117::build_emulation, + header_initializer, + [ + ( + MacOS, + r#""Chromium";v="122", "Not(A:Brand";v="24", "Microsoft Edge";v="122""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" + ), + ( + Android, + r#""Chromium";v="122", "Not(A:Brand";v="24", "Microsoft Edge";v="122""#, + "Mozilla/5.0 (Linux; Android 10; Pixel 3 XL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6268.219 Safari/537.36 Edg/122.0.2238.82" + ), + ( + Windows, + r#""Chromium";v="122", "Not(A:Brand";v="24", "Microsoft Edge";v="122""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" + ), + // This shouldn't exist, edge was never meant to be on linux + ( + Linux, + r#""Chromium";v="122", "Not(A:Brand";v="24", "Microsoft Edge";v="122""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" + ), + ( + IOS, + r#""Chromium";v="122", "Not(A:Brand";v="24", "Microsoft Edge";v="122""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" + ) + ] +); + +mod_generator!( + v123, + v117::build_emulation, + header_initializer_with_zstd, + [ + ( + MacOS, + r#""Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" + ) + ] +); + +mod_generator!( + v118, + tls_options!(4), + http2_options!(3), + header_initializer, + [ + ( + MacOS, + r#""Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/118.0.5993.92 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v119, + v118::build_emulation, + header_initializer, + [ + ( + MacOS, + r#""Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/119.0.6045.109 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v124, + tls_options!(6, CURVES_2), + http2_options!(3), + header_initializer_with_zstd, + [ + ( + MacOS, + r#""Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/124.0.6312.52 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v126, + v124::build_emulation, + header_initializer_with_zstd, + [ + ( + MacOS, + r#""Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/126.0.6478.153 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v127, + v124::build_emulation, + header_initializer_with_zstd, + [ + ( + MacOS, + r#""Not)A;Brand";v="99", "Google Chrome";v="127", "Chromium";v="127""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Not)A;Brand";v="99", "Google Chrome";v="127", "Chromium";v="127""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Not)A;Brand";v="99", "Google Chrome";v="127", "Chromium";v="127""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Not)A;Brand";v="99", "Google Chrome";v="127", "Chromium";v="127""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Not)A;Brand";v="99", "Google Chrome";v="127", "Chromium";v="127""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/127.0.6533.77 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + edge127, + v124::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0" + ), + ( + Android, + r#""Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127""#, + "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.6332.205 Safari/537.36 Edg/127.0.2322.67" + ), + ( + Windows, + r#""Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0" + ), + // This shouldn't exist, edge was never meant to be on linux + ( + Linux, + r#""Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0" + ), + ( + IOS, + r#""Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0" + ) + ] +); + +mod_generator!( + v128, + v124::build_emulation, + header_initializer, + [ + ( + MacOS, + r#""Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/128.0.6613.98 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v129, + v124::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/129.0.6668.46 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v130, + v124::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99""#, + "Mozilla/5.0 (iPad; CPU OS 18_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/130.0.6723.90 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v131, + tls_options!(6, CURVES_3), + http2_options!(3), + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24""#, + "Mozilla/5.0 (Linux: Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/131.0.6778.134 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + edge131, + v131::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0" + ), + ( + Android, + r#""Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24""#, + "Mozilla/5.0 (Linux; Android 10; HD1913) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.200 Mobile Safari/537.36 EdgA/131.0.2903.87" + ), + ( + Windows, + r#""Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0" + ), + // This shouldn't exist, edge was never meant to be on linux + ( + Linux, + r#""Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0" + ), + ( + IOS, + r#""Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0" + ) + ] +); + +mod_generator!( + v132, + tls_options!(7, CURVES_3), + http2_options!(3), + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Not A(Brand";v="8", "Chromium";v="132", "Google Chrome";v="132""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Not A(Brand";v="8", "Chromium";v="132", "Google Chrome";v="132""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Not A(Brand";v="8", "Chromium";v="132", "Google Chrome";v="132""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Not A(Brand";v="8", "Chromium";v="132", "Google Chrome";v="132""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Not A(Brand";v="8", "Chromium";v="132", "Google Chrome";v="132""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/132.0.6834.78 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v133, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/133.0.6943.33 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v134, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="134", "Not:A-Brand";v="24", "Google Chrome";v="134""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Chromium";v="134", "Not:A-Brand";v="24", "Google Chrome";v="134""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Chromium";v="134", "Not:A-Brand";v="24", "Google Chrome";v="134""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36" + ), + ( + Windows, + r#""Chromium";v="134", "Not:A-Brand";v="24", "Google Chrome";v="134""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Chromium";v="134", "Not:A-Brand";v="24", "Google Chrome";v="134""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/134.0.0.0 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + edge134, + v131::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="134", "Not:A-Brand";v="24", "Microsoft Edge";v="134"#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0" + ), + ( + Android, + r#""Chromium";v="134", "Not:A-Brand";v="24", "Microsoft Edge";v="134"#, + "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0" + ), + ( + Windows, + r#""Chromium";v="134", "Not:A-Brand";v="24", "Microsoft Edge";v="134"#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0" + ), + ( + Linux, + r#""Chromium";v="134", "Not:A-Brand";v="24", "Microsoft Edge";v="134"#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0" + ), + ( + IOS, + r#""Chromium";v="134", "Not:A-Brand";v="24", "Microsoft Edge";v="134"#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/134.0.0.0" + ) + ] +); + +mod_generator!( + edge135, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="135", "Not:A-Brand";v="24", "Microsoft Edge";v="135"#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0" + ), + ( + Android, + r#""Chromium";v="135", "Not:A-Brand";v="24", "Microsoft Edge";v="135"#, + "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0" + ), + ( + Windows, + r#""Chromium";v="135", "Not:A-Brand";v="24", "Microsoft Edge";v="135"#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0" + ), + ( + Linux, + r#""Chromium";v="135", "Not:A-Brand";v="24", "Microsoft Edge";v="135"#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0" + ), + ( + IOS, + r#""Chromium";v="135", "Not:A-Brand";v="24", "Microsoft Edge";v="135"#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/135.0.0.0" + ) + ] +); + +mod_generator!( + edge136, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="136", "Not:A-Brand";v="24", "Microsoft Edge";v="136"#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0" + ), + ( + Android, + r#""Chromium";v="136", "Not:A-Brand";v="24", "Microsoft Edge";v="136"#, + "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0" + ), + ( + Windows, + r#""Chromium";v="136", "Not:A-Brand";v="24", "Microsoft Edge";v="136"#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0" + ), + ( + Linux, + r#""Chromium";v="136", "Not:A-Brand";v="24", "Microsoft Edge";v="136"#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0" + ), + ( + IOS, + r#""Chromium";v="136", "Not:A-Brand";v="24", "Microsoft Edge";v="136"#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/136.0.0.0" + ) + ] +); + +mod_generator!( + edge137, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="137", "Not:A-Brand";v="24", "Microsoft Edge";v="137"#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0" + ), + ( + Android, + r#""Chromium";v="137", "Not:A-Brand";v="24", "Microsoft Edge";v="137"#, + "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0" + ), + ( + Windows, + r#""Chromium";v="137", "Not:A-Brand";v="24", "Microsoft Edge";v="137"#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0" + ), + ( + Linux, + r#""Chromium";v="137", "Not:A-Brand";v="24", "Microsoft Edge";v="137"#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0" + ), + ( + IOS, + r#""Chromium";v="137", "Not:A-Brand";v="24", "Microsoft Edge";v="137"#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/137.0.0.0" + ) + ] +); + +mod_generator!( + edge138, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="138", "Not=A?Brand";v="24", "Microsoft Edge";v="138"#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0" + ), + ( + Android, + r#""Chromium";v="138", "Not=A?Brand";v="24", "Microsoft Edge";v="138"#, + "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0" + ), + ( + Windows, + r#""Chromium";v="138", "Not=A?Brand";v="24", "Microsoft Edge";v="138"#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0" + ), + ( + Linux, + r#""Chromium";v="138", "Not=A?Brand";v="24", "Microsoft Edge";v="138"#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0" + ), + ( + IOS, + r#""Chromium";v="138", "Not=A?Brand";v="24", "Microsoft Edge";v="138"#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/138.0.0.0" + ) + ] +); + +mod_generator!( + edge139, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="139", "Not=A?Brand";v="24", "Microsoft Edge";v="139"#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0" + ), + ( + Android, + r#""Chromium";v="139", "Not=A?Brand";v="24", "Microsoft Edge";v="139"#, + "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0" + ), + ( + Windows, + r#""Chromium";v="139", "Not=A?Brand";v="24", "Microsoft Edge";v="139"#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0" + ), + ( + Linux, + r#""Chromium";v="139", "Not=A?Brand";v="24", "Microsoft Edge";v="139"#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0" + ), + ( + IOS, + r#""Chromium";v="139", "Not=A?Brand";v="24", "Microsoft Edge";v="139"#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/139.0.0.0" + ) + ] +); + +mod_generator!( + edge140, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0" + ), + ( + Android, + r#""Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"#, + "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0" + ), + ( + Windows, + r#""Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0" + ), + ( + Linux, + r#""Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0" + ), + ( + IOS, + r#""Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/140.0.0.0" + ) + ] +); + +mod_generator!( + edge141, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="141", "Not=A?Brand";v="24", "Microsoft Edge";v="141"#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0" + ), + ( + Android, + r#""Chromium";v="141", "Not=A?Brand";v="24", "Microsoft Edge";v="141"#, + "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0" + ), + ( + Windows, + r#""Chromium";v="141", "Not=A?Brand";v="24", "Microsoft Edge";v="141"#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0" + ), + ( + Linux, + r#""Chromium";v="141", "Not=A?Brand";v="24", "Microsoft Edge";v="141"#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0" + ), + ( + IOS, + r#""Chromium";v="141", "Not=A?Brand";v="24", "Microsoft Edge";v="141"#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/141.0.0.0" + ) + ] +); + +mod_generator!( + v135, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/135.0.0.0 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v136, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="136", "Google Chrome";v="136", "Not.A/Brand";v="99""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Chromium";v="136", "Google Chrome";v="136", "Not.A/Brand";v="99""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Chromium";v="136", "Google Chrome";v="136", "Not.A/Brand";v="99""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Chromium";v="136", "Google Chrome";v="136", "Not.A/Brand";v="99""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Chromium";v="136", "Google Chrome";v="136", "Not.A/Brand";v="99""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/136.0.0.0 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v137, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Google Chrome";v="137", "Chromium";v="137", "Not/A)Brand";v="24""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Google Chrome";v="137", "Chromium";v="137", "Not/A)Brand";v="24""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Google Chrome";v="137", "Chromium";v="137", "Not/A)Brand";v="24""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Google Chrome";v="137", "Chromium";v="137", "Not/A)Brand";v="24""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Google Chrome";v="137", "Chromium";v="137", "Not/A)Brand";v="24""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/137.0.0.0 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v138, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/138.0.0.0 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v139, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Not;A=Brand";v="99", "Google Chrome";v="139", "Chromium";v="139""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Not;A=Brand";v="99", "Google Chrome";v="139", "Chromium";v="139""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Not;A=Brand";v="99", "Google Chrome";v="139", "Chromium";v="139""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Not;A=Brand";v="99", "Google Chrome";v="139", "Chromium";v="139""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Not;A=Brand";v="99", "Google Chrome";v="139", "Chromium";v="139""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/139.0.0.0 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v140, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="140", "Not=A?Brand";v="24", "Google Chrome";v="140""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Chromium";v="140", "Not=A?Brand";v="24", "Google Chrome";v="140""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Chromium";v="140", "Not=A?Brand";v="24", "Google Chrome";v="140""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Chromium";v="140", "Not=A?Brand";v="24", "Google Chrome";v="140""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Chromium";v="140", "Not=A?Brand";v="24", "Google Chrome";v="140""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/140.0.0.0 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v141, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Google Chrome";v="141", "Not?A_Brand";v="8", "Chromium";v="141""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Google Chrome";v="141", "Not?A_Brand";v="8", "Chromium";v="141""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Google Chrome";v="141", "Not?A_Brand";v="8", "Chromium";v="141""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Google Chrome";v="141", "Not?A_Brand";v="8", "Chromium";v="141""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Google Chrome";v="141", "Not?A_Brand";v="8", "Chromium";v="141""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/141.0.0.0 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v142, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="142", "Google Chrome";v="142", "Not_A Brand";v="99""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Chromium";v="142", "Google Chrome";v="142", "Not_A Brand";v="99""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Chromium";v="142", "Google Chrome";v="142", "Not_A Brand";v="99""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Chromium";v="142", "Google Chrome";v="142", "Not_A Brand";v="99""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Chromium";v="142", "Google Chrome";v="142", "Not_A Brand";v="99""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/142.0.0.0 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + edge142, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="142", "Microsoft Edge";v="142", "Not_A Brand";v="99""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0" + ), + ( + Android, + r#""Chromium";v="142", "Microsoft Edge";v="142", "Not_A Brand";v="99""#, + "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Mobile Safari/537.36 Edg/142.0.0.0" + ), + ( + Windows, + r#""Chromium";v="142", "Microsoft Edge";v="142", "Not_A Brand";v="99""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0" + ), + ( + Linux, + r#""Chromium";v="142", "Microsoft Edge";v="142", "Not_A Brand";v="99""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0" + ), + ( + IOS, + r#""Chromium";v="142", "Microsoft Edge";v="142", "Not_A Brand";v="99""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0" + ) + ] +); + +mod_generator!( + v143, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Google Chrome";v="143", "Chromium";v="143", "Not A(Brand";v="24""#, + "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" + ), + ( + Linux, + r#""Google Chrome";v="143", "Chromium";v="143", "Not A(Brand";v="24""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Google Chrome";v="143", "Chromium";v="143", "Not A(Brand";v="24""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Google Chrome";v="143", "Chromium";v="143", "Not A(Brand";v="24""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Google Chrome";v="143", "Chromium";v="143", "Not A(Brand";v="24""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/143.0.0.0 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v144, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Not(A:Brand";v="8", "Chromium";v="144", "Google Chrome";v="144""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Not(A:Brand";v="8", "Chromium";v="144", "Google Chrome";v="144""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Not(A:Brand";v="8", "Chromium";v="144", "Google Chrome";v="144""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Not(A:Brand";v="8", "Chromium";v="144", "Google Chrome";v="144""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Not(A:Brand";v="8", "Chromium";v="144", "Google Chrome";v="144""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/144.0.0.0 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v145, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Not:A-Brand";v="99", "Google Chrome";v="145", "Chromium";v="145""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Not:A-Brand";v="99", "Google Chrome";v="145", "Chromium";v="145""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Not:A-Brand";v="99", "Google Chrome";v="145", "Chromium";v="145""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Not:A-Brand";v="99", "Google Chrome";v="145", "Chromium";v="145""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Not:A-Brand";v="99", "Google Chrome";v="145", "Chromium";v="145""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/145.0.0.0 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v146, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="146", "Not-A.Brand";v="24", "Google Chrome";v="146""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Chromium";v="146", "Not-A.Brand";v="24", "Google Chrome";v="146""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Chromium";v="146", "Not-A.Brand";v="24", "Google Chrome";v="146""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.7680.164 Mobile Safari/537.36" + ), + ( + Windows, + r#""Chromium";v="146", "Not-A.Brand";v="24", "Google Chrome";v="146""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Chromium";v="146", "Not-A.Brand";v="24", "Google Chrome";v="146""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/146.0.7680.164 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v147, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Google Chrome";v="147", "Not.A/Brand";v="8", "Chromium";v="147""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Google Chrome";v="147", "Not.A/Brand";v="8", "Chromium";v="147""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Google Chrome";v="147", "Not.A/Brand";v="8", "Chromium";v="147""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.7712.122 Mobile Safari/537.36" + ), + ( + Windows, + r#""Google Chrome";v="147", "Not.A/Brand";v="8", "Chromium";v="147""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Google Chrome";v="147", "Not.A/Brand";v="8", "Chromium";v="147""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/147.0.7712.122 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v148, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="148", "Google Chrome";v="148", "Not/A)Brand";v="99""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Chromium";v="148", "Google Chrome";v="148", "Not/A)Brand";v="99""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Chromium";v="148", "Google Chrome";v="148", "Not/A)Brand";v="99""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Chromium";v="148", "Google Chrome";v="148", "Not/A)Brand";v="99""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Chromium";v="148", "Google Chrome";v="148", "Not/A)Brand";v="99""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/148.0.0.0 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v149, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Google Chrome";v="149", "Chromium";v="149", "Not)A;Brand";v="24""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Google Chrome";v="149", "Chromium";v="149", "Not)A;Brand";v="24""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Google Chrome";v="149", "Chromium";v="149", "Not)A;Brand";v="24""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Google Chrome";v="149", "Chromium";v="149", "Not)A;Brand";v="24""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Google Chrome";v="149", "Chromium";v="149", "Not)A;Brand";v="24""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/149.0.0.0 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v150, + tls_options!(8, CURVES_3, NEW_SIGALGS_LIST), + http2_options!(3), + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Not;A=Brand";v="8", "Chromium";v="150", "Google Chrome";v="150""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Not;A=Brand";v="8", "Chromium";v="150", "Google Chrome";v="150""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Not;A=Brand";v="8", "Chromium";v="150", "Google Chrome";v="150""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Not;A=Brand";v="8", "Chromium";v="150", "Google Chrome";v="150""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Not;A=Brand";v="8", "Chromium";v="150", "Google Chrome";v="150""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/150.0.0.0 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + edge143, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="143", "Microsoft Edge";v="143", "Not_A Brand";v="99""#, + "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 Edg/143.0.0.0" + ), + ( + Android, + r#""Chromium";v="143", "Microsoft Edge";v="143", "Not_A Brand";v="99""#, + "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Mobile Safari/537.36 Edg/143.0.0.0" + ), + ( + Windows, + r#""Chromium";v="143", "Microsoft Edge";v="143", "Not_A Brand";v="99""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 Edg/143.0.0.0" + ), + ( + Linux, + r#""Chromium";v="143", "Microsoft Edge";v="143", "Not_A Brand";v="99""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 Edg/143.0.0.0" + ), + ( + IOS, + r#""Chromium";v="143", "Microsoft Edge";v="143", "Not_A Brand";v="99""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 Edg/143.0.0.0" + ) + ] +); + +mod_generator!( + edge144, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Not(A:Brand";v="8", "Chromium";v="144", "Microsoft Edge";v="144""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0" + ), + ( + Android, + r#""Not(A:Brand";v="8", "Chromium";v="144", "Microsoft Edge";v="144""#, + "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Mobile Safari/537.36 Edg/144.0.0.0" + ), + ( + Windows, + r#""Not(A:Brand";v="8", "Chromium";v="144", "Microsoft Edge";v="144""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0" + ), + ( + Linux, + r#""Not(A:Brand";v="8", "Chromium";v="144", "Microsoft Edge";v="144""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0" + ), + ( + IOS, + r#""Not(A:Brand";v="8", "Chromium";v="144", "Microsoft Edge";v="144""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0" + ) + ] +); + +mod_generator!( + edge145, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="145", "Not;A=Brand";v="24", "Microsoft Edge";v="145""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0" + ), + ( + Android, + r#""Chromium";v="145", "Not;A=Brand";v="24", "Microsoft Edge";v="145""#, + "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Mobile Safari/537.36 Edg/145.0.0.0" + ), + ( + Windows, + r#""Chromium";v="145", "Not;A=Brand";v="24", "Microsoft Edge";v="145""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0" + ), + ( + Linux, + r#""Chromium";v="145", "Not;A=Brand";v="24", "Microsoft Edge";v="145""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0" + ), + ( + IOS, + r#""Chromium";v="145", "Not;A=Brand";v="24", "Microsoft Edge";v="145""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0" + ) + ] +); + +mod_generator!( + edge146, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="146", "Not(A:Brand";v="24", "Microsoft Edge";v="146""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 Edg/146.0.3856.109" + ), + ( + Android, + r#""Chromium";v="146", "Not(A:Brand";v="24", "Microsoft Edge";v="146""#, + "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.7680.178 Mobile Safari/537.36 EdgA/146.0.3856.97" + ), + ( + Windows, + r#""Chromium";v="146", "Not(A:Brand";v="24", "Microsoft Edge";v="146""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 Edg/146.0.3856.109" + ), + ( + Linux, + r#""Chromium";v="146", "Not(A:Brand";v="24", "Microsoft Edge";v="146""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 Edg/146.0.3856.109" + ), + ( + IOS, + r#""Chromium";v="146", "Not(A:Brand";v="24", "Microsoft Edge";v="146""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 EdgiOS/146.0.3856.102 Mobile/15E148 Safari/605.1.15" + ) + ] +); + +mod_generator!( + edge147, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Microsoft Edge";v="147", "Not.A/Brand";v="8", "Chromium";v="147""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.3912.51" + ), + ( + Android, + r#""Microsoft Edge";v="147", "Not.A/Brand";v="8", "Chromium";v="147""#, + "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.7727.55 Mobile Safari/537.36 EdgA/147.0.3912.51" + ), + ( + Windows, + r#""Microsoft Edge";v="147", "Not.A/Brand";v="8", "Chromium";v="147""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.3912.51" + ), + ( + Linux, + r#""Microsoft Edge";v="147", "Not.A/Brand";v="8", "Chromium";v="147""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.3912.51" + ), + ( + IOS, + r#""Microsoft Edge";v="147", "Not.A/Brand";v="8", "Chromium";v="147""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 EdgiOS/147.0.3912.51 Mobile/15E148 Safari/605.1.15" + ) + ] +); + +mod_generator!( + edge148, + v132::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="148", "Microsoft Edge";v="148", "Not/A)Brand";v="99""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 Edg/148.0.0.0" + ), + ( + Android, + r#""Chromium";v="148", "Microsoft Edge";v="148", "Not/A)Brand";v="99""#, + "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Mobile Safari/537.36 EdgA/148.0.0.0" + ), + ( + Windows, + r#""Chromium";v="148", "Microsoft Edge";v="148", "Not/A)Brand";v="99""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 Edg/148.0.0.0" + ), + ( + Linux, + r#""Chromium";v="148", "Microsoft Edge";v="148", "Not/A)Brand";v="99""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 Edg/148.0.0.0" + ), + ( + IOS, + r#""Chromium";v="148", "Microsoft Edge";v="148", "Not/A)Brand";v="99""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 EdgiOS/148.0.0.0 Mobile/15E148 Safari/605.1.15" + ) + ] +); diff --git a/crates/wreq-util/src/emulate/profile/chrome/header.rs b/crates/wreq-util/src/emulate/profile/chrome/header.rs new file mode 100644 index 0000000..980b90a --- /dev/null +++ b/crates/wreq-util/src/emulate/profile/chrome/header.rs @@ -0,0 +1,59 @@ +use super::*; + +pub fn header_initializer( + sec_ch_ua: &'static str, + ua: &'static str, + emulation_os: Platform, +) -> HeaderMap { + let mut headers = HeaderMap::new(); + header_chrome_sec_ch_ua!( + headers, + sec_ch_ua, + emulation_os.platform(), + emulation_os.is_mobile() + ); + header_chrome_ua!(headers, ua); + header_chrome_sec_fetch!(headers); + header_chrome_accept!(headers); + headers +} + +pub fn header_initializer_with_zstd( + sec_ch_ua: &'static str, + ua: &'static str, + emulation_os: Platform, +) -> HeaderMap { + let mut headers = HeaderMap::new(); + header_chrome_sec_ch_ua!( + headers, + sec_ch_ua, + emulation_os.platform(), + emulation_os.is_mobile() + ); + header_chrome_ua!(headers, ua); + header_chrome_sec_fetch!(headers); + header_chrome_accept!(zstd, headers); + headers +} + +pub fn header_initializer_with_zstd_priority( + sec_ch_ua: &'static str, + ua: &'static str, + emulation_os: Platform, +) -> HeaderMap { + let mut headers = HeaderMap::new(); + header_chrome_sec_ch_ua!( + headers, + sec_ch_ua, + emulation_os.platform(), + emulation_os.is_mobile() + ); + header_chrome_ua!(headers, ua); + header_chrome_sec_fetch!(headers); + header_chrome_accept!(zstd, headers); + headers.insert( + HeaderName::from_static("priority"), + HeaderValue::from_static("u=0, i"), + ); + headers +} diff --git a/crates/wreq-util/src/emulate/profile/chrome/http2.rs b/crates/wreq-util/src/emulate/profile/chrome/http2.rs new file mode 100644 index 0000000..f2e17b7 --- /dev/null +++ b/crates/wreq-util/src/emulate/profile/chrome/http2.rs @@ -0,0 +1,65 @@ +macro_rules! headers_stream_dependency { + () => { + StreamDependency::new(StreamId::zero(), 219, true) + }; +} + +macro_rules! pseudo_order { + () => { + PseudoOrder::builder() + .extend([ + PseudoId::Method, + PseudoId::Authority, + PseudoId::Scheme, + PseudoId::Path, + ]) + .build() + }; +} + +macro_rules! settings_order { + () => { + SettingsOrder::builder() + .extend([ + SettingId::HeaderTableSize, + SettingId::EnablePush, + SettingId::MaxConcurrentStreams, + SettingId::InitialWindowSize, + SettingId::MaxFrameSize, + SettingId::MaxHeaderListSize, + SettingId::EnableConnectProtocol, + SettingId::NoRfc7540Priorities, + ]) + .build() + }; +} + +macro_rules! http2_options { + (@base $builder:expr) => { + $builder + .initial_window_size(6291456) + .initial_connection_window_size(15728640) + .max_header_list_size(262144) + .header_table_size(65536) + .headers_stream_dependency(headers_stream_dependency!()) + .headers_pseudo_order(pseudo_order!()) + .settings_order(settings_order!()) + }; + + (1) => { + http2_options!(@base Http2Options::builder()) + .max_concurrent_streams(1000) + .build() + }; + (2) => { + http2_options!(@base Http2Options::builder()) + .max_concurrent_streams(1000) + .enable_push(false) + .build() + }; + (3) => { + http2_options!(@base Http2Options::builder()) + .enable_push(false) + .build() + }; +} diff --git a/crates/wreq-util/src/emulate/profile/chrome/tls.rs b/crates/wreq-util/src/emulate/profile/chrome/tls.rs new file mode 100644 index 0000000..ebe0fd9 --- /dev/null +++ b/crates/wreq-util/src/emulate/profile/chrome/tls.rs @@ -0,0 +1,153 @@ +use super::*; + +macro_rules! tls_options { + (@build $builder:expr) => { + $builder.build().into() + }; + + (1) => { + tls_options!(@build ChromeTlsConfig::builder()) + }; + (2) => { + tls_options!(@build ChromeTlsConfig::builder().enable_ech_grease(true)) + }; + (3) => { + tls_options!(@build ChromeTlsConfig::builder().permute_extensions(true)) + }; + (4) => { + tls_options!(@build ChromeTlsConfig::builder() + .permute_extensions(true) + .enable_ech_grease(true)) + }; + (5) => { + tls_options!(@build ChromeTlsConfig::builder() + .permute_extensions(true) + .enable_ech_grease(true) + .pre_shared_key(true)) + }; + (6, $curves:expr) => { + tls_options!(@build ChromeTlsConfig::builder() + .permute_extensions(true) + .enable_ech_grease(true) + .pre_shared_key(true) + .curves($curves)) + }; + (7, $curves:expr) => { + tls_options!(@build ChromeTlsConfig::builder() + .permute_extensions(true) + .enable_ech_grease(true) + .pre_shared_key(true) + .curves($curves) + .alps_use_new_codepoint(true)) + }; + (8, $curves:expr, $sigalgs:expr) => { + tls_options!(@build ChromeTlsConfig::builder() + .permute_extensions(true) + .enable_ech_grease(true) + .pre_shared_key(true) + .curves($curves) + .sigalgs_list($sigalgs) + .alps_use_new_codepoint(true)) + }; +} + +pub const CURVES_1: &str = join!(":", "X25519", "P-256", "P-384"); +pub const CURVES_2: &str = join!(":", "X25519Kyber768Draft00", "X25519", "P-256", "P-384"); +pub const CURVES_3: &str = join!(":", "X25519MLKEM768", "X25519", "P-256", "P-384"); + +pub const CIPHER_LIST: &str = join!( + ":", + "TLS_AES_128_GCM_SHA256", + "TLS_AES_256_GCM_SHA384", + "TLS_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_256_GCM_SHA384", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_AES_256_CBC_SHA" +); + +pub const SIGALGS_LIST: &str = join!( + ":", + "ecdsa_secp256r1_sha256", + "rsa_pss_rsae_sha256", + "rsa_pkcs1_sha256", + "ecdsa_secp384r1_sha384", + "rsa_pss_rsae_sha384", + "rsa_pkcs1_sha384", + "rsa_pss_rsae_sha512", + "rsa_pkcs1_sha512" +); + +pub const NEW_SIGALGS_LIST: &str = join!( + ":", + "mldsa44", + "mldsa65", + "mldsa87", + "ecdsa_secp256r1_sha256", + "rsa_pss_rsae_sha256", + "rsa_pkcs1_sha256", + "ecdsa_secp384r1_sha384", + "rsa_pss_rsae_sha384", + "rsa_pkcs1_sha384", + "rsa_pss_rsae_sha512", + "rsa_pkcs1_sha512" +); + +pub const CERTIFICATE_COMPRESSORS: &[&'static dyn CertificateCompressor] = &[&BrotliCompressor]; + +#[derive(TypedBuilder)] +pub struct ChromeTlsConfig { + #[builder(default = CURVES_1)] + curves: &'static str, + + #[builder(default = SIGALGS_LIST)] + sigalgs_list: &'static str, + + #[builder(default = CIPHER_LIST)] + cipher_list: &'static str, + + #[builder(default = AlpsProtocol::HTTP2, setter(into))] + alps_protos: AlpsProtocol, + + #[builder(default = false)] + alps_use_new_codepoint: bool, + + #[builder(default = false, setter(into))] + enable_ech_grease: bool, + + #[builder(default = false, setter(into))] + permute_extensions: bool, + + #[builder(default = false, setter(into))] + pre_shared_key: bool, +} + +impl From for TlsOptions { + fn from(val: ChromeTlsConfig) -> Self { + TlsOptions::builder() + .grease_enabled(true) + .enable_ocsp_stapling(true) + .enable_signed_cert_timestamps(true) + .curves_list(val.curves) + .sigalgs_list(val.sigalgs_list) + .cipher_list(val.cipher_list) + .min_tls_version(TlsVersion::TLS_1_2) + .max_tls_version(TlsVersion::TLS_1_3) + .permute_extensions(val.permute_extensions) + .pre_shared_key(val.pre_shared_key) + .enable_ech_grease(val.enable_ech_grease) + .alps_protocols([val.alps_protos]) + .alps_use_new_codepoint(val.alps_use_new_codepoint) + .aes_hw_override(true) + .certificate_compressors(CERTIFICATE_COMPRESSORS) + .build() + } +} diff --git a/crates/wreq-util/src/emulate/profile/firefox.rs b/crates/wreq-util/src/emulate/profile/firefox.rs new file mode 100644 index 0000000..b4adb47 --- /dev/null +++ b/crates/wreq-util/src/emulate/profile/firefox.rs @@ -0,0 +1,518 @@ +#[macro_use] +mod http2; +#[macro_use] +mod tls; +mod header; + +use header::*; +use tls::*; + +use super::*; + +mod_generator!( + ff109, + tls_options!(2, CIPHER_LIST_1, CURVES_1), + http2_options!(2), + header_initializer, + [ + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/109.0" + ), + ( + MacOS, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_17; rv:109.0) Gecko/20000101 Firefox/109.0" + ), + ( + Android, + "Mozilla/5.0 (Android 13; Mobile; rv:109.0) Gecko/109.0 Firefox/109.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Linux i686; rv:109.0) Gecko/20100101 Firefox/109.0" + ), + ( + IOS, + "Mozilla/5.0 (iPad; CPU OS 13_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/109.0 Mobile/15E148 Safari/605.1.15" + ) + ] +); + +mod_generator!( + ff117, + ff109::build_emulation, + header_initializer, + [ + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:117.0) Gecko/20100101 Firefox/117.0" + ), + ( + MacOS, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_16_1; rv:117.0) Gecko/20010101 Firefox/117.0" + ), + ( + Android, + "Mozilla/5.0 (Android 13; Mobile; rv:117.0) Gecko/117.0 Firefox/117.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Linux i686; rv:117.0) Gecko/20100101 Firefox/117.0" + ), + ( + IOS, + "Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/117.0 Mobile/15E148 Safari/605.1.15" + ) + ] +); + +mod_generator!( + ff128, + tls_options!(3, CIPHER_LIST_2, CURVES_1, KEY_SHARES_1), + http2_options!(3), + header_initializer_with_zstd, + [ + ( + MacOs, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:128.0) Gecko/20100101 Firefox/128.0" + ), + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; rv:128.0) Gecko/20100101 Firefox/128.0" + ), + ( + Android, + "Mozilla/5.0 (Android 13; Mobile; rv:128.0) Gecko/128.0 Firefox/128.0" + ), + ( + IOS, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/128.0 Mobile/15E148 Safari/605.1.15" + ), + ( + Linux, + "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0" + ) + ] +); + +mod_generator!( + ff133, + tls_options!(1, CIPHER_LIST_1, CURVES_2, KEY_SHARES_2), + http2_options!(1), + header_initializer_with_zstd, + [ + ( + MacOs, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:133.0) Gecko/20100101 Firefox/133.0" + ), + ( + Android, + "Mozilla/5.0 (Android 13; Mobile; rv:133.0) Gecko/133.0 Firefox/133.0" + ), + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; rv:133.0) Gecko/20100101 Firefox/133.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0" + ), + ( + IOS, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_2_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/133.4 Mobile/15E148 Safari/605.1.15" + ) + ] +); + +mod_generator!( + ff135, + tls_options!(4, CIPHER_LIST_1, CURVES_2, KEY_SHARES_2), + http2_options!(1), + header_initializer_with_zstd, + [ + ( + MacOS, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0" + ), + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; rv:135.0) Gecko/20100101 Firefox/135.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0" + ) + ] +); + +mod_generator!( + ff_private_135, + tls_options!(6, CIPHER_LIST_1, CURVES_2, KEY_SHARES_2), + http2_options!(1), + header_initializer_with_zstd, + [ + ( + MacOS, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0" + ), + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; rv:135.0) Gecko/20100101 Firefox/135.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0" + ) + ] +); + +mod_generator!( + ff_android_135, + tls_options!(5, CIPHER_LIST_1, CURVES_1, KEY_SHARES_1), + http2_options!(4), + header_initializer_with_zstd, + [( + Android, + "Mozilla/5.0 (Android 13; Mobile; rv:135.0) Gecko/135.0 Firefox/135.0" + )] +); + +mod_generator!( + ff136, + ff135::build_emulation, + header_initializer_with_zstd, + [ + ( + MacOS, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:136.0) Gecko/20100101 Firefox/136.0" + ), + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; rv:136.0) Gecko/20100101 Firefox/136.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0" + ) + ] +); + +mod_generator!( + ff_private_136, + ff_private_135::build_emulation, + header_initializer_with_zstd, + [ + ( + MacOS, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:136.0) Gecko/20100101 Firefox/136.0" + ), + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; rv:136.0) Gecko/20100101 Firefox/136.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0" + ) + ] +); + +mod_generator!( + ff139, + ff135::build_emulation, + header_initializer_with_zstd, + [ + ( + MacOS, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0" + ), + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; rv:136.0) Gecko/20100101 Firefox/139.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/139.0" + ) + ] +); + +mod_generator!( + ff142, + ff135::build_emulation, + header_initializer_with_zstd, + [ + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0) Gecko/20100101 Firefox/142.0" + ), + ( + MacOS, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:142.0) Gecko/20100101 Firefox/142.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:142.0) Gecko/20100101 Firefox/142.0" + ), + ( + Android, + "Mozilla/5.0 (Android 13; Mobile; rv:142.0) Gecko/142.0 Firefox/142.0" + ), + ( + IOS, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/142.0 Mobile/15E148 Safari/605.1.15" + ) + ] +); + +mod_generator!( + ff143, + ff135::build_emulation, + header_initializer_with_zstd, + [ + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:143.0) Gecko/20100101 Firefox/143.0" + ), + ( + MacOS, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:143.0) Gecko/20100101 Firefox/143.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:143.0) Gecko/20100101 Firefox/143.0" + ), + ( + Android, + "Mozilla/5.0 (Android 13; Mobile; rv:143.0) Gecko/143.0 Firefox/143.0" + ), + ( + IOS, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/143.0 Mobile/15E148 Safari/605.1.15" + ) + ] +); + +mod_generator!( + ff144, + ff135::build_emulation, + header_initializer_with_zstd, + [ + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:144.0) Gecko/20100101 Firefox/144.0" + ), + ( + MacOS, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:144.0) Gecko/20100101 Firefox/144.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:144.0) Gecko/20100101 Firefox/144.0" + ), + ( + Android, + "Mozilla/5.0 (Android 13; Mobile; rv:144.0) Gecko/144.0 Firefox/144.0" + ), + ( + IOS, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/144.0 Mobile/15E148 Safari/605.1.15" + ) + ] +); + +mod_generator!( + ff145, + ff135::build_emulation, + header_initializer_with_zstd, + [ + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:145.0) Gecko/20100101 Firefox/145.0" + ), + ( + MacOS, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:145.0) Gecko/20100101 Firefox/145.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:145.0) Gecko/20100101 Firefox/145.0" + ), + ( + Android, + "Mozilla/5.0 (Android 13; Mobile; rv:145.0) Gecko/145.0 Firefox/145.0" + ), + ( + IOS, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/145.0 Mobile/15E148 Safari/605.1.15" + ) + ] +); + +mod_generator!( + ff146, + ff135::build_emulation, + header_initializer_with_zstd, + [ + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0" + ), + ( + MacOS, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:146.0) Gecko/20100101 Firefox/146.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:146.0) Gecko/20100101 Firefox/146.0" + ), + ( + Android, + "Mozilla/5.0 (Android 13; Mobile; rv:146.0) Gecko/146.0 Firefox/146.0" + ), + ( + IOS, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/146.0 Mobile/15E148 Safari/605.1.15" + ) + ] +); + +mod_generator!( + ff147, + ff135::build_emulation, + header_initializer_with_zstd, + [ + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:147.0) Gecko/20100101 Firefox/147.0" + ), + ( + MacOS, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:147.0) Gecko/20100101 Firefox/147.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:147.0) Gecko/20100101 Firefox/147.0" + ), + ( + Android, + "Mozilla/5.0 (Android 13; Mobile; rv:147.0) Gecko/147.0 Firefox/147.0" + ), + ( + IOS, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/147.0 Mobile/15E148 Safari/605.1.15" + ) + ] +); + +mod_generator!( + ff148, + ff135::build_emulation, + header_initializer_with_zstd, + [ + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:148.0) Gecko/20100101 Firefox/148.0" + ), + ( + MacOS, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:148.0) Gecko/20100101 Firefox/148.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:148.0) Gecko/20100101 Firefox/148.0" + ), + ( + Android, + "Mozilla/5.0 (Android 13; Mobile; rv:148.0) Gecko/148.0 Firefox/148.0" + ), + ( + IOS, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/148.0 Mobile/15E148 Safari/605.1.15" + ) + ] +); + +mod_generator!( + ff149, + ff135::build_emulation, + header_initializer_with_zstd, + [ + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:149.0) Gecko/20100101 Firefox/149.0" + ), + ( + MacOS, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:149.0) Gecko/20100101 Firefox/149.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:149.0) Gecko/20100101 Firefox/149.0" + ), + ( + Android, + "Mozilla/5.0 (Android 13; Mobile; rv:149.0) Gecko/149.0 Firefox/149.0" + ), + ( + IOS, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/149.0 Mobile/15E148 Safari/605.1.15" + ) + ] +); + +mod_generator!( + ff150, + ff135::build_emulation, + header_initializer_with_zstd, + [ + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:150.0) Gecko/20100101 Firefox/150.0" + ), + ( + MacOS, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:150.0) Gecko/20100101 Firefox/150.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0" + ), + ( + Android, + "Mozilla/5.0 (Android 13; Mobile; rv:150.0) Gecko/150.0 Firefox/150.0" + ), + ( + IOS, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/150.0 Mobile/15E148 Safari/605.1.15" + ) + ] +); + +mod_generator!( + ff151, + ff135::build_emulation, + header_initializer_with_zstd, + [ + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:151.0) Gecko/20100101 Firefox/151.0" + ), + ( + MacOS, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:151.0) Gecko/20100101 Firefox/151.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:151.0) Gecko/20100101 Firefox/151.0" + ), + ( + Android, + "Mozilla/5.0 (Android 13; Mobile; rv:151.0) Gecko/151.0 Firefox/151.0" + ), + ( + IOS, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/151.0 Mobile/15E148 Safari/605.1.15" + ) + ] +); diff --git a/crates/wreq-util/src/emulate/profile/firefox/header.rs b/crates/wreq-util/src/emulate/profile/firefox/header.rs new file mode 100644 index 0000000..443bf69 --- /dev/null +++ b/crates/wreq-util/src/emulate/profile/firefox/header.rs @@ -0,0 +1,21 @@ +use super::*; + +pub fn header_initializer(ua: &'static str) -> HeaderMap { + let mut headers = HeaderMap::new(); + header_firefox_ua!(headers, ua); + header_firefox_accept!(headers); + header_firefox_sec_fetch!(headers); + headers +} + +pub fn header_initializer_with_zstd(ua: &'static str) -> HeaderMap { + let mut headers = HeaderMap::new(); + header_firefox_ua!(headers, ua); + header_firefox_accept!(zstd, headers); + header_firefox_sec_fetch!(headers); + headers.insert( + HeaderName::from_static("priority"), + HeaderValue::from_static("u=0, i"), + ); + headers +} diff --git a/crates/wreq-util/src/emulate/profile/firefox/http2.rs b/crates/wreq-util/src/emulate/profile/firefox/http2.rs new file mode 100644 index 0000000..7077c90 --- /dev/null +++ b/crates/wreq-util/src/emulate/profile/firefox/http2.rs @@ -0,0 +1,113 @@ +macro_rules! headers_stream_dependency { + (1) => { + StreamDependency::new(StreamId::zero(), 21, false) + }; + (2) => { + StreamDependency::new(StreamId::from(13), 21, false) + }; +} + +macro_rules! pseudo_order { + () => { + PseudoOrder::builder() + .extend([ + PseudoId::Method, + PseudoId::Path, + PseudoId::Authority, + PseudoId::Scheme, + ]) + .build() + }; +} + +macro_rules! settings_order { + () => { + SettingsOrder::builder() + .extend([ + SettingId::HeaderTableSize, + SettingId::EnablePush, + SettingId::MaxConcurrentStreams, + SettingId::InitialWindowSize, + SettingId::MaxFrameSize, + SettingId::MaxHeaderListSize, + SettingId::EnableConnectProtocol, + SettingId::NoRfc7540Priorities, + ]) + .build() + }; +} + +macro_rules! http2_options { + (@base $builder:expr) => { + $builder + .initial_window_size(131072) + .max_frame_size(16384) + .initial_connection_window_size(12517377 + 65535) + .headers_pseudo_order(pseudo_order!()) + .settings_order(settings_order!()) + }; + + (1) => { + http2_options!(@base Http2Options::builder()) + .initial_stream_id(3) + .header_table_size(65536) + .enable_push(false) + .headers_stream_dependency(headers_stream_dependency!(1)) + .build() + }; + (2) => { + http2_options!(@base Http2Options::builder()) + .initial_stream_id(15) + .header_table_size(65536) + .headers_stream_dependency(headers_stream_dependency!(2)) + .priorities( + Priorities::builder() + .extend([ + Priority::new( + StreamId::from(3), + StreamDependency::new(StreamId::zero(), 200, false), + ), + Priority::new( + StreamId::from(5), + StreamDependency::new(StreamId::zero(), 100, false), + ), + Priority::new( + StreamId::from(7), + StreamDependency::new(StreamId::zero(), 0, false), + ), + Priority::new( + StreamId::from(9), + StreamDependency::new(StreamId::from(7), 0, false), + ), + Priority::new( + StreamId::from(11), + StreamDependency::new(StreamId::from(3), 0, false), + ), + Priority::new( + StreamId::from(13), + StreamDependency::new(StreamId::zero(), 240, false), + ), + ]) + .build(), + ) + .build() + }; + (3) => { + http2_options!(@base Http2Options::builder()) + .initial_stream_id(3) + .header_table_size(65536) + .enable_push(false) + .max_concurrent_streams(0) + .headers_stream_dependency(headers_stream_dependency!(1)) + .build() + }; + (4) => { + http2_options!(@base Http2Options::builder()) + .initial_stream_id(3) + .header_table_size(4096) + .enable_push(false) + .initial_window_size(32768) + .headers_stream_dependency(headers_stream_dependency!(1)) + .build() + }; +} diff --git a/crates/wreq-util/src/emulate/profile/firefox/tls.rs b/crates/wreq-util/src/emulate/profile/firefox/tls.rs new file mode 100644 index 0000000..5d73e36 --- /dev/null +++ b/crates/wreq-util/src/emulate/profile/firefox/tls.rs @@ -0,0 +1,253 @@ +use super::*; + +macro_rules! tls_options { + (@build $builder:expr) => { + $builder.build().into() + }; + + (@base $builder:expr, $cipher_list:expr, $curves:expr) => { + $builder + .cipher_list($cipher_list) + .curves_list($curves) + }; + + (1, $cipher_list:expr, $curves:expr, $key_shares:expr) => { + tls_options!(@build tls_options!(@base FirefoxTlsConfig::builder(), $cipher_list, $curves) + .enable_ech_grease(true) + .pre_shared_key(true) + .psk_skip_session_tickets(true) + .key_shares($key_shares) + .certificate_compressors(CERTIFICATE_COMPRESSORS)) + }; + (2, $cipher_list:expr, $curves:expr) => { + tls_options!(@build tls_options!(@base FirefoxTlsConfig::builder(), $cipher_list, $curves)) + }; + (3, $cipher_list:expr, $curves:expr, $key_shares:expr) => { + tls_options!(@build tls_options!(@base FirefoxTlsConfig::builder(), $cipher_list, $curves) + .session_ticket(false) + .enable_ech_grease(true) + .psk_dhe_ke(false) + .key_shares($key_shares)) + }; + (4, $cipher_list:expr, $curves:expr, $key_shares:expr) => { + tls_options!(@build tls_options!(@base FirefoxTlsConfig::builder(), $cipher_list, $curves) + .enable_ech_grease(true) + .enable_signed_cert_timestamps(true) + .session_ticket(true) + .pre_shared_key(true) + .psk_skip_session_tickets(true) + .key_shares($key_shares) + .certificate_compressors(CERTIFICATE_COMPRESSORS)) + }; + (5, $cipher_list:expr, $curves:expr, $key_shares:expr) => { + tls_options!(@build tls_options!(@base FirefoxTlsConfig::builder(), $cipher_list, $curves) + .enable_ech_grease(true) + .pre_shared_key(true) + .psk_skip_session_tickets(true) + .key_shares($key_shares) + .certificate_compressors(CERTIFICATE_COMPRESSORS)) + }; + (6, $cipher_list:expr, $curves:expr, $key_shares:expr) => { + tls_options!(@build tls_options!(@base FirefoxTlsConfig::builder(), $cipher_list, $curves) + .enable_ech_grease(true) + .enable_signed_cert_timestamps(true) + .session_ticket(false) + .psk_dhe_ke(false) + .key_shares($key_shares) + .certificate_compressors(CERTIFICATE_COMPRESSORS)) + }; +} + +pub const CURVES_1: &str = join!( + ":", + "X25519", + "P-256", + "P-384", + "P-521", + "ffdhe2048", + "ffdhe3072" +); + +pub const CURVES_2: &str = join!( + ":", + "X25519MLKEM768", + "X25519", + "P-256", + "P-384", + "P-521", + "ffdhe2048", + "ffdhe3072" +); + +pub const KEY_SHARES_1: &[KeyShare] = &[KeyShare::X25519, KeyShare::P256]; + +pub const KEY_SHARES_2: &[KeyShare] = + &[KeyShare::X25519_MLKEM768, KeyShare::X25519, KeyShare::P256]; + +pub const CIPHER_LIST_1: &str = join!( + ":", + "TLS_AES_128_GCM_SHA256", + "TLS_CHACHA20_POLY1305_SHA256", + "TLS_AES_256_GCM_SHA384", + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_256_GCM_SHA384", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_AES_256_CBC_SHA" +); + +pub const CIPHER_LIST_2: &str = join!( + ":", + "TLS_AES_128_GCM_SHA256", + "TLS_CHACHA20_POLY1305_SHA256", + "TLS_AES_256_GCM_SHA384", + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_256_GCM_SHA384", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_AES_256_CBC_SHA" +); + +pub const SIGALGS_LIST: &str = join!( + ":", + "ecdsa_secp256r1_sha256", + "ecdsa_secp384r1_sha384", + "ecdsa_secp521r1_sha512", + "rsa_pss_rsae_sha256", + "rsa_pss_rsae_sha384", + "rsa_pss_rsae_sha512", + "rsa_pkcs1_sha256", + "rsa_pkcs1_sha384", + "rsa_pkcs1_sha512", + "ecdsa_sha1", + "rsa_pkcs1_sha1" +); + +pub const CERTIFICATE_COMPRESSORS: &[&'static dyn CertificateCompressor] = + &[&ZlibCompressor, &BrotliCompressor, &ZstdCompressor]; + +pub const DELEGATED_CREDENTIALS: &str = join!( + ":", + "ecdsa_secp256r1_sha256", + "ecdsa_secp384r1_sha384", + "ecdsa_secp521r1_sha512", + "ecdsa_sha1" +); + +pub const RECORD_SIZE_LIMIT: u16 = 0x4001; + +pub const EXTENSION_PERMUTATION_INDICES: &[ExtensionType] = &[ + ExtensionType::SERVER_NAME, + ExtensionType::EXTENDED_MASTER_SECRET, + ExtensionType::RENEGOTIATE, + ExtensionType::SUPPORTED_GROUPS, + ExtensionType::EC_POINT_FORMATS, + ExtensionType::SESSION_TICKET, + ExtensionType::APPLICATION_LAYER_PROTOCOL_NEGOTIATION, + ExtensionType::STATUS_REQUEST, + ExtensionType::DELEGATED_CREDENTIAL, + ExtensionType::CERTIFICATE_TIMESTAMP, + ExtensionType::KEY_SHARE, + ExtensionType::SUPPORTED_VERSIONS, + ExtensionType::SIGNATURE_ALGORITHMS, + ExtensionType::PSK_KEY_EXCHANGE_MODES, + ExtensionType::RECORD_SIZE_LIMIT, + ExtensionType::CERT_COMPRESSION, + ExtensionType::ENCRYPTED_CLIENT_HELLO, +]; + +#[derive(TypedBuilder)] +pub struct FirefoxTlsConfig { + #[builder(default = SIGALGS_LIST)] + sigalgs_list: &'static str, + + #[builder(setter(into))] + cipher_list: &'static str, + + #[builder(setter(into))] + curves_list: &'static str, + + #[builder(default, setter(into))] + key_shares: Option<&'static [KeyShare]>, + + #[builder(default = true)] + session_ticket: bool, + + #[builder(default = false, setter(into))] + enable_ech_grease: bool, + + #[builder(default = false, setter(into))] + enable_signed_cert_timestamps: bool, + + #[builder(default = false, setter(into))] + pre_shared_key: bool, + + #[builder(default = false, setter(into))] + psk_skip_session_tickets: bool, + + #[builder(default = DELEGATED_CREDENTIALS, setter(into))] + delegated_credentials: &'static str, + + #[builder(default = RECORD_SIZE_LIMIT, setter(into))] + record_size_limit: u16, + + #[builder(default = true, setter(into))] + psk_dhe_ke: bool, + + #[builder(default, setter(into))] + certificate_compressors: Option<&'static [&'static dyn CertificateCompressor]>, + + #[builder(default = EXTENSION_PERMUTATION_INDICES, setter(into))] + extension_permutation: &'static [ExtensionType], +} + +impl From for TlsOptions { + fn from(val: FirefoxTlsConfig) -> Self { + let mut builder = TlsOptions::builder() + .curves_list(val.curves_list) + .sigalgs_list(val.sigalgs_list) + .cipher_list(val.cipher_list) + .session_ticket(val.session_ticket) + .delegated_credentials(val.delegated_credentials) + .record_size_limit(val.record_size_limit) + .enable_ocsp_stapling(true) + .enable_ech_grease(val.enable_ech_grease) + .enable_signed_cert_timestamps(val.enable_signed_cert_timestamps) + .alpn_protocols([AlpnProtocol::HTTP2, AlpnProtocol::HTTP1]) + .min_tls_version(TlsVersion::TLS_1_2) + .max_tls_version(TlsVersion::TLS_1_3) + .pre_shared_key(val.pre_shared_key) + .psk_skip_session_ticket(val.psk_skip_session_tickets) + .psk_dhe_ke(val.psk_dhe_ke) + .preserve_tls13_cipher_list(true) + .extension_permutation(val.extension_permutation) + .aes_hw_override(true) + .random_aes_hw_override(true); + + if let Some(key_shares) = val.key_shares { + builder = builder.key_shares(key_shares) + } + + if let Some(certificate_compressors) = val.certificate_compressors { + builder = builder.certificate_compressors(certificate_compressors) + } + + builder.build() + } +} diff --git a/crates/wreq-util/src/emulate/profile/okhttp.rs b/crates/wreq-util/src/emulate/profile/okhttp.rs new file mode 100644 index 0000000..11342ab --- /dev/null +++ b/crates/wreq-util/src/emulate/profile/okhttp.rs @@ -0,0 +1,241 @@ +use super::*; + +const CURVES: &str = join!(":", "X25519", "P-256", "P-384"); + +const SIGALGS_LIST: &str = join!( + ":", + "ecdsa_secp256r1_sha256", + "rsa_pss_rsae_sha256", + "rsa_pkcs1_sha256", + "ecdsa_secp384r1_sha384", + "rsa_pss_rsae_sha384", + "rsa_pkcs1_sha384", + "rsa_pss_rsae_sha512", + "rsa_pkcs1_sha512", + "rsa_pkcs1_sha1" +); + +const CIPHER_LIST: &str = join!( + ":", + "TLS_AES_128_GCM_SHA256", + "TLS_AES_256_GCM_SHA384", + "TLS_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_256_GCM_SHA384", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" +); + +#[derive(TypedBuilder)] +struct OkHttpTlsConfig { + #[builder(default = CURVES)] + curves: &'static str, + + #[builder(default = SIGALGS_LIST)] + sigalgs_list: &'static str, + + cipher_list: &'static str, +} + +impl From for TlsOptions { + fn from(val: OkHttpTlsConfig) -> Self { + TlsOptions::builder() + .enable_ocsp_stapling(true) + .curves_list(val.curves) + .sigalgs_list(val.sigalgs_list) + .cipher_list(val.cipher_list) + .min_tls_version(TlsVersion::TLS_1_2) + .max_tls_version(TlsVersion::TLS_1_3) + .aes_hw_override(true) + .build() + } +} + +macro_rules! mod_generator { + ($mod_name:ident, $cipher:expr, $ua:expr) => { + pub(crate) mod $mod_name { + use super::*; + + pub fn emulation(emulation: Emulation) -> wreq::Emulation { + build_emulation(stringify!($mod_name), emulation, $cipher, $ua) + } + } + }; +} + +fn build_emulation( + group: &'static str, + emulation: Emulation, + cipher_list: &'static str, + user_agent: &'static str, +) -> wreq::Emulation { + let tls_options = OkHttpTlsConfig::builder() + .cipher_list(cipher_list) + .build() + .into(); + + let http2_options = emulation.http2.then(|| { + let settings_order = SettingsOrder::builder() + .extend([ + SettingId::HeaderTableSize, + SettingId::EnablePush, + SettingId::MaxConcurrentStreams, + SettingId::InitialWindowSize, + SettingId::MaxFrameSize, + SettingId::MaxHeaderListSize, + SettingId::EnableConnectProtocol, + SettingId::NoRfc7540Priorities, + ]) + .build(); + + Http2Options::builder() + .initial_window_size(16777216) + .initial_connection_window_size(16777216) + .headers_pseudo_order( + PseudoOrder::builder() + .extend([ + PseudoId::Method, + PseudoId::Path, + PseudoId::Authority, + PseudoId::Scheme, + ]) + .build(), + ) + .settings_order(settings_order) + .build() + }); + + let headers = emulation.headers.then(|| { + let mut headers = HeaderMap::new(); + headers.insert(ACCEPT, HeaderValue::from_static("*/*")); + headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.9")); + headers.insert(USER_AGENT, HeaderValue::from_static(user_agent)); + #[cfg(feature = "emulation-compression")] + headers.insert(ACCEPT_ENCODING, HeaderValue::from_static("gzip")); + headers + }); + + build_standard_emulation(group, tls_options, http2_options, headers) +} + +mod_generator!( + okhttp3_9, + join!( + ":", + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_256_GCM_SHA384", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" + ), + "MaiMemo/4.4.50_639 okhttp/3.9 Android/5.0 Channel/WanDouJia Device/alps+M8+Emulator (armeabi-v7a) Screen/4.44 Resolution/480x800 DId/aa6cde19def3806806d5374c4e5fd617 RAM/0.94 ROM/4.91 Theme/Day" +); + +mod_generator!( + okhttp3_11, + join!( + ":", + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_256_GCM_SHA384", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" + ), + "NRC Audio/2.0.6 (nl.nrc.audio; build:36; Android 12; Sdk:31; Manufacturer:motorola; Model: moto g72) OkHttp/3.11.0" +); + +mod_generator!( + okhttp3_13, + join!( + ":", + "TLS_AES_128_GCM_SHA256", + "TLS_AES_256_GCM_SHA384", + "TLS_CHACHA20_POLY1305_SHA256", + "TLS_AES_128_CCM_SHA256", + "TLS_AES_256_CCM_8_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_256_GCM_SHA384", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" + ), + "GM-Android/6.112.2 (240590300; M:Google Pixel 7a; O:34; D:2b045e03986fa6dc) ObsoleteUrlFactory/1.0 OkHttp/3.13.0" +); + +mod_generator!( + okhttp3_14, + CIPHER_LIST, + "DS podcast/2.0.1 (be.standaard.audio; build:9; Android 11; Sdk:30; Manufacturer:samsung; Model: SM-A405FN) OkHttp/3.14.0" +); + +mod_generator!( + okhttp4_10, + CIPHER_LIST, + "GM-Android/6.112.2 (240590300; M:samsung SM-G781U1; O:33; D:edb34792871638d8) ObsoleteUrlFactory/1.0 OkHttp/4.10.0" +); + +mod_generator!( + okhttp4_9, + join!( + ":", + "TLS_AES_128_GCM_SHA256", + "TLS_AES_256_GCM_SHA384", + "TLS_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_256_GCM_SHA384", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_AES_256_CBC_SHA" + ), + "GM-Android/6.111.1 (240460200; M:motorola moto g power (2021); O:30; D:76ba9f6628d198c8) ObsoleteUrlFactory/1.0 OkHttp/4.9" +); + +mod_generator!(okhttp4_12, CIPHER_LIST, "okhttp/4.12.0"); + +mod_generator!( + okhttp5, + CIPHER_LIST, + "NRC Audio/2.0.6 (nl.nrc.audio; build:36; Android 14; Sdk:34; Manufacturer:OnePlus; Model: CPH2609) OkHttp/5.0.0-alpha2" +); diff --git a/crates/wreq-util/src/emulate/profile/opera.rs b/crates/wreq-util/src/emulate/profile/opera.rs new file mode 100644 index 0000000..c751d39 --- /dev/null +++ b/crates/wreq-util/src/emulate/profile/opera.rs @@ -0,0 +1,299 @@ +#[macro_use] +mod http2; +#[macro_use] +mod tls; +mod header; + +use header::*; +use tls::*; + +use super::*; + +mod_generator!( + opera116, + tls_options!(CURVES), + http2_options!(), + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Opera";v="116", "Chromium";v="131", "Not_A Brand";v="24""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 OPR/116.0.0.0" + ), + ( + Windows, + r#""Opera";v="116", "Chromium";v="131", "Not_A Brand";v="24""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 OPR/116.0.0.0" + ) + ] +); + +mod_generator!( + opera117, + opera116::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Not A(Brand";v="8", "Chromium";v="132", "Opera";v="117""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 OPR/117.0.0.0" + ), + ( + Windows, + r#""Not A(Brand";v="8", "Chromium";v="132", "Opera";v="117""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 OPR/117.0.0.0" + ) + ] +); + +mod_generator!( + opera118, + opera116::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Not(A:Brand";v="99", "Opera";v="118", "Chromium";v="133""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 OPR/118.0.0.0" + ), + ( + Windows, + r#""Not(A:Brand";v="99", "Opera";v="118", "Chromium";v="133""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 OPR/118.0.0.0" + ) + ] +); + +mod_generator!( + opera119, + opera116::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="134", "Not:A-Brand";v="24", "Opera";v="119""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 OPR/119.0.0.0" + ), + ( + Windows, + r#""Chromium";v="134", "Not:A-Brand";v="24", "Opera";v="119""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 OPR/119.0.0.0" + ) + ] +); + +mod_generator!( + opera120, + opera116::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="135", "Not:A-Brand";v="24", "Opera";v="120""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 OPR/120.0.0.0" + ), + ( + Windows, + r#""Chromium";v="135", "Not:A-Brand";v="24", "Opera";v="120""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 OPR/120.0.0.0" + ) + ] +); + +mod_generator!( + opera121, + opera116::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Opera";v="121", "Chromium";v="137", "Not/A)Brand";v="24""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 OPR/121.0.0.0" + ), + ( + Windows, + r#""Opera";v="121", "Chromium";v="137", "Not/A)Brand";v="24""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 OPR/121.0.0.0" + ) + ] +); + +mod_generator!( + opera122, + opera116::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="138", "Not=A?Brand";v="24", "Opera";v="122""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 OPR/122.0.0.0" + ), + ( + Windows, + r#""Chromium";v="138", "Not=A?Brand";v="24", "Opera";v="122""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 OPR/122.0.0.0" + ) + ] +); + +mod_generator!( + opera123, + opera116::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="139", "Not=A?Brand";v="24", "Opera";v="123""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 OPR/123.0.0.0" + ), + ( + Windows, + r#""Chromium";v="139", "Not=A?Brand";v="24", "Opera";v="123""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 OPR/123.0.0.0" + ) + ] +); + +mod_generator!( + opera124, + opera116::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="140", "Not=A?Brand";v="24", "Opera";v="124""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 OPR/124.0.0.0" + ), + ( + Windows, + r#""Chromium";v="140", "Not=A?Brand";v="24", "Opera";v="124""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 OPR/124.0.0.0" + ) + ] +); + +mod_generator!( + opera125, + opera116::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Opera";v="125", "Not?A_Brand";v="8", "Chromium";v="141""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 OPR/125.0.0.0" + ), + ( + Windows, + r#""Opera";v="125", "Not?A_Brand";v="8", "Chromium";v="141""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 OPR/125.0.0.0" + ) + ] +); + +mod_generator!( + opera126, + opera116::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Not:A-Brand";v="99", "Opera";v="126", "Chromium";v="142""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 OPR/126.0.0.0" + ), + ( + Windows, + r#""Not:A-Brand";v="99", "Opera";v="126", "Chromium";v="142""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 OPR/126.0.0.0" + ) + ] +); + +mod_generator!( + opera127, + opera116::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Not:A-Brand";v="99", "Opera";v="127", "Chromium";v="143""#, + "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 OPR/127.0.0.0" + ), + ( + Windows, + r#""Not:A-Brand";v="99", "Opera";v="127", "Chromium";v="143""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 OPR/127.0.0.0" + ) + ] +); + +mod_generator!( + opera128, + opera116::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Not:A-Brand";v="99", "Opera";v="128", "Chromium";v="144""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 OPR/128.0.0.0" + ), + ( + Windows, + r#""Not:A-Brand";v="99", "Opera";v="128", "Chromium";v="144""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 OPR/128.0.0.0" + ) + ] +); + +mod_generator!( + opera129, + opera116::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Not:A-Brand";v="99", "Opera";v="129", "Chromium";v="145""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 OPR/129.0.0.0" + ), + ( + Windows, + r#""Not:A-Brand";v="99", "Opera";v="129", "Chromium";v="145""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 OPR/129.0.0.0" + ) + ] +); + +mod_generator!( + opera130, + opera116::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Not:A-Brand";v="99", "Opera";v="130", "Chromium";v="146""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 OPR/130.0.0.0" + ), + ( + Windows, + r#""Not:A-Brand";v="99", "Opera";v="130", "Chromium";v="146""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 OPR/130.0.0.0" + ) + ] +); + +mod_generator!( + opera131, + opera116::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Opera";v="131", "Not.A/Brand";v="8", "Chromium";v="147""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 OPR/131.0.0.0" + ), + ( + Windows, + r#""Opera";v="131", "Not.A/Brand";v="8", "Chromium";v="147""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 OPR/131.0.0.0" + ) + ] +); diff --git a/crates/wreq-util/src/emulate/profile/opera/header.rs b/crates/wreq-util/src/emulate/profile/opera/header.rs new file mode 100644 index 0000000..91afa1e --- /dev/null +++ b/crates/wreq-util/src/emulate/profile/opera/header.rs @@ -0,0 +1,30 @@ +use super::*; + +#[inline] +pub fn header_initializer_with_zstd_priority( + sec_ch_ua: &'static str, + ua: &'static str, + emulation_os: Platform, +) -> HeaderMap { + let mut headers = HeaderMap::new(); + header_chrome_sec_ch_ua!( + headers, + sec_ch_ua, + emulation_os.platform(), + emulation_os.is_mobile() + ); + header_chrome_ua!(headers, ua); + + headers.insert(ACCEPT, HeaderValue::from_static("text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")); + #[cfg(feature = "emulation-compression")] + headers.insert( + ACCEPT_ENCODING, + HeaderValue::from_static("gzip, deflate, br, zstd"), + ); + headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.9")); + headers.insert( + HeaderName::from_static("priority"), + HeaderValue::from_static("u=0, i"), + ); + headers +} diff --git a/crates/wreq-util/src/emulate/profile/opera/http2.rs b/crates/wreq-util/src/emulate/profile/opera/http2.rs new file mode 100644 index 0000000..eb53e35 --- /dev/null +++ b/crates/wreq-util/src/emulate/profile/opera/http2.rs @@ -0,0 +1,50 @@ +macro_rules! headers_stream_dependency { + () => { + StreamDependency::new(StreamId::zero(), 219, true) + }; +} + +macro_rules! pseudo_order { + () => { + PseudoOrder::builder() + .extend([ + PseudoId::Method, + PseudoId::Authority, + PseudoId::Scheme, + PseudoId::Path, + ]) + .build() + }; +} + +macro_rules! settings_order { + () => { + SettingsOrder::builder() + .extend([ + SettingId::HeaderTableSize, + SettingId::EnablePush, + SettingId::MaxConcurrentStreams, + SettingId::InitialWindowSize, + SettingId::MaxFrameSize, + SettingId::MaxHeaderListSize, + SettingId::EnableConnectProtocol, + SettingId::NoRfc7540Priorities, + ]) + .build() + }; +} + +macro_rules! http2_options { + () => { + Http2Options::builder() + .initial_window_size(6291456) + .initial_connection_window_size(15728640) + .max_header_list_size(262144) + .header_table_size(65536) + .enable_push(false) + .headers_stream_dependency(headers_stream_dependency!()) + .headers_pseudo_order(pseudo_order!()) + .settings_order(settings_order!()) + .build() + }; +} diff --git a/crates/wreq-util/src/emulate/profile/opera/tls.rs b/crates/wreq-util/src/emulate/profile/opera/tls.rs new file mode 100644 index 0000000..434352c --- /dev/null +++ b/crates/wreq-util/src/emulate/profile/opera/tls.rs @@ -0,0 +1,97 @@ +use super::*; + +macro_rules! tls_options { + ($curves:expr) => { + OperaTlsConfig::builder() + .curves($curves) + .permute_extensions(true) + .pre_shared_key(true) + .enable_ech_grease(true) + .build() + .into() + }; +} + +pub const CURVES: &str = join!(":", "X25519MLKEM768", "X25519", "P-256", "P-384"); + +pub const CIPHER_LIST: &str = join!( + ":", + "TLS_AES_128_GCM_SHA256", + "TLS_AES_256_GCM_SHA384", + "TLS_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_256_GCM_SHA384", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_AES_256_CBC_SHA" +); + +pub const SIGALGS_LIST: &str = join!( + ":", + "ecdsa_secp256r1_sha256", + "rsa_pss_rsae_sha256", + "rsa_pkcs1_sha256", + "ecdsa_secp384r1_sha384", + "rsa_pss_rsae_sha384", + "rsa_pkcs1_sha384", + "rsa_pss_rsae_sha512", + "rsa_pkcs1_sha512" +); + +pub const CERTIFICATE_COMPRESSORS: &[&'static dyn CertificateCompressor] = &[&BrotliCompressor]; + +#[derive(TypedBuilder)] +pub struct OperaTlsConfig { + #[builder(default = CURVES)] + curves: &'static str, + + #[builder(default = SIGALGS_LIST)] + sigalgs_list: &'static str, + + #[builder(default = CIPHER_LIST)] + cipher_list: &'static str, + + #[builder(default = AlpsProtocol::HTTP2, setter(into))] + alps_protos: AlpsProtocol, + + #[builder(default = false)] + alps_use_new_codepoint: bool, + + #[builder(default = false, setter(into))] + enable_ech_grease: bool, + + #[builder(default = false, setter(into))] + permute_extensions: bool, + + #[builder(default = false, setter(into))] + pre_shared_key: bool, +} + +impl From for TlsOptions { + fn from(val: OperaTlsConfig) -> Self { + TlsOptions::builder() + .grease_enabled(true) + .enable_ocsp_stapling(true) + .enable_signed_cert_timestamps(true) + .curves_list(val.curves) + .sigalgs_list(val.sigalgs_list) + .cipher_list(val.cipher_list) + .min_tls_version(TlsVersion::TLS_1_2) + .max_tls_version(TlsVersion::TLS_1_3) + .permute_extensions(val.permute_extensions) + .pre_shared_key(val.pre_shared_key) + .enable_ech_grease(val.enable_ech_grease) + .alps_protocols([val.alps_protos]) + .alps_use_new_codepoint(val.alps_use_new_codepoint) + .aes_hw_override(true) + .certificate_compressors(CERTIFICATE_COMPRESSORS) + .build() + } +} diff --git a/crates/wreq-util/src/emulate/profile/safari.rs b/crates/wreq-util/src/emulate/profile/safari.rs new file mode 100644 index 0000000..69ac983 --- /dev/null +++ b/crates/wreq-util/src/emulate/profile/safari.rs @@ -0,0 +1,222 @@ +#[macro_use] +mod http2; +#[macro_use] +mod tls; +mod header; + +use header::*; +use tls::*; + +use super::*; + +mod_generator!( + safari15_3, + tls_options!(1, CIPHER_LIST_1), + http2_options!(4), + header_initializer_for_15, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15" +); + +mod_generator!( + safari15_5, + safari15_3::build_emulation, + header_initializer_for_15, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Safari/605.1.15" +); + +mod_generator!( + safari15_6_1, + tls_options!(1, CIPHER_LIST_2), + http2_options!(4), + header_initializer_for_15, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.1 Safari/605.1.15" +); + +mod_generator!( + safari16, + safari15_6_1::build_emulation, + header_initializer_for_16_17, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15" +); + +mod_generator!( + safari16_5, + safari15_6_1::build_emulation, + header_initializer_for_16_17, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Safari/605.1.15" +); + +mod_generator!( + safari17_4_1, + safari15_6_1::build_emulation, + header_initializer_for_16_17, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Safari/605.1.15" +); + +mod_generator!( + safari_ios_16_5, + tls_options!(1, CIPHER_LIST_2), + http2_options!(1), + header_initializer_for_16_17, + "Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Mobile/15E148 Safari/604.1" +); + +mod_generator!( + safari17_0, + tls_options!(1, CIPHER_LIST_2), + http2_options!(5), + header_initializer_for_16_17, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15" +); + +mod_generator!( + safari17_2_1, + safari17_0::build_emulation, + header_initializer_for_16_17, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15" +); + +mod_generator!( + safari17_5, + safari17_0::build_emulation, + header_initializer_for_16_17, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15" +); + +mod_generator!( + safari17_6, + safari17_0::build_emulation, + header_initializer_for_16_17, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Safari/605.1.15" +); + +mod_generator!( + safari_ios_17_2, + tls_options!(1, CIPHER_LIST_2), + http2_options!(2), + header_initializer_for_16_17, + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Mobile/15E148 Safari/604.1" +); + +mod_generator!( + safari_ios_17_4_1, + safari_ios_17_2::build_emulation, + header_initializer_for_16_17, + "Mozilla/5.0 (iPad; CPU OS 17_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Mobile/15E148 Safari/604.1" +); + +mod_generator!( + safari18, + tls_options!(1, CIPHER_LIST_2), + http2_options!(3), + header_initializer_for_18, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15" +); + +mod_generator!( + safari_ipad_18, + safari18::build_emulation, + header_initializer_for_18, + "Mozilla/5.0 (iPad; CPU OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1" +); + +mod_generator!( + safari_ios_18_1_1, + safari18::build_emulation, + header_initializer_for_18, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.1.1 Mobile/15E148 Safari/604.1" +); + +mod_generator!( + safari18_2, + tls_options!(2, CIPHER_LIST_2, SIGALGS_LIST_2), + http2_options!(3), + header_initializer_for_18, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.2 Safari/605.1.15" +); + +mod_generator!( + safari18_3, + safari18_2::build_emulation, + header_initializer_for_18, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3 Safari/605.1.15" +); + +mod_generator!( + safari18_3_1, + safari18_2::build_emulation, + header_initializer_for_18, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3.1 Safari/605.1.15" +); + +mod_generator!( + safari18_5, + tls_options!(2, CIPHER_LIST_2, SIGALGS_LIST_2), + http2_options!(6), + header_initializer_for_18, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Safari/605.1.15" +); + +mod_generator!( + safari26, + tls_options!(3, CIPHER_LIST_3, SIGALGS_LIST_2, CURVES_2), + http2_options!(6), + header_initializer_for_18, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15" +); + +mod_generator!( + safari_ipad_26, + safari26::build_emulation, + header_initializer_for_18, + "Mozilla/5.0 (iPad; CPU OS 18_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1" +); + +mod_generator!( + safari_ios_26, + safari26::build_emulation, + header_initializer_for_18, + "Mozilla/5.0 (iPhone; CPU iPhone OS 26_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1" +); + +mod_generator!( + safari26_1, + safari18_5::build_emulation, + header_initializer_for_18, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15" +); + +mod_generator!( + safari_ios_26_2, + safari26::build_emulation, + header_initializer_for_18, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.2 Mobile/15E148 Safari/604.1" +); + +mod_generator!( + safari26_2, + safari18_5::build_emulation, + header_initializer_for_18, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.2 Safari/605.1.15" +); + +mod_generator!( + safari26_3, + safari18_5::build_emulation, + header_initializer_for_18, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.3 Safari/605.1.15" +); + +mod_generator!( + safari26_4, + safari18_5::build_emulation, + header_initializer_for_18, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.4 Safari/605.1.15" +); + +mod_generator!( + safari_ipad_26_2, + safari26::build_emulation, + header_initializer_for_18, + "Mozilla/5.0 (iPad; CPU OS 18_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.2 Mobile/15E148 Safari/604.1" +); diff --git a/crates/wreq-util/src/emulate/profile/safari/header.rs b/crates/wreq-util/src/emulate/profile/safari/header.rs new file mode 100644 index 0000000..aef337c --- /dev/null +++ b/crates/wreq-util/src/emulate/profile/safari/header.rs @@ -0,0 +1,59 @@ +use super::*; + +#[inline] +pub fn header_initializer_for_15(ua: &'static str) -> HeaderMap { + let mut headers = HeaderMap::new(); + headers.insert(USER_AGENT, HeaderValue::from_static(ua)); + headers.insert( + ACCEPT, + HeaderValue::from_static("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"), + ); + headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.9")); + #[cfg(feature = "emulation-compression")] + headers.insert( + ACCEPT_ENCODING, + HeaderValue::from_static("gzip, deflate, br"), + ); + headers +} + +#[inline] +pub fn header_initializer_for_16_17(ua: &'static str) -> HeaderMap { + let mut headers = HeaderMap::new(); + headers.insert( + ACCEPT, + HeaderValue::from_static("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"), + ); + headers.insert("sec-fetch-site", HeaderValue::from_static("none")); + #[cfg(feature = "emulation-compression")] + headers.insert( + ACCEPT_ENCODING, + HeaderValue::from_static("gzip, deflate, br"), + ); + headers.insert("sec-fetch-mode", HeaderValue::from_static("navigate")); + headers.insert(USER_AGENT, HeaderValue::from_static(ua)); + headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.9")); + headers.insert("sec-fetch-dest", HeaderValue::from_static("document")); + headers +} + +#[inline] +pub fn header_initializer_for_18(ua: &'static str) -> HeaderMap { + let mut headers = HeaderMap::new(); + headers.insert("sec-fetch-dest", HeaderValue::from_static("document")); + headers.insert(USER_AGENT, HeaderValue::from_static(ua)); + headers.insert( + ACCEPT, + HeaderValue::from_static("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"), + ); + headers.insert("sec-fetch-site", HeaderValue::from_static("none")); + headers.insert("sec-fetch-mode", HeaderValue::from_static("navigate")); + headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.9")); + headers.insert("priority", HeaderValue::from_static("u=0, i")); + #[cfg(feature = "emulation-compression")] + headers.insert( + ACCEPT_ENCODING, + HeaderValue::from_static("gzip, deflate, br"), + ); + headers +} diff --git a/crates/wreq-util/src/emulate/profile/safari/http2.rs b/crates/wreq-util/src/emulate/profile/safari/http2.rs new file mode 100644 index 0000000..e900864 --- /dev/null +++ b/crates/wreq-util/src/emulate/profile/safari/http2.rs @@ -0,0 +1,116 @@ +macro_rules! headers_pseudo_order { + (1) => { + PseudoOrder::builder() + .extend([ + PseudoId::Method, + PseudoId::Scheme, + PseudoId::Path, + PseudoId::Authority, + ]) + .build() + }; + (2) => { + PseudoOrder::builder() + .extend([ + PseudoId::Method, + PseudoId::Scheme, + PseudoId::Authority, + PseudoId::Path, + ]) + .build() + }; +} + +macro_rules! settings_order { + (1) => { + SettingsOrder::builder() + .extend([ + SettingId::HeaderTableSize, + SettingId::EnablePush, + SettingId::InitialWindowSize, + SettingId::MaxConcurrentStreams, + SettingId::MaxFrameSize, + SettingId::MaxHeaderListSize, + SettingId::EnableConnectProtocol, + SettingId::NoRfc7540Priorities, + ]) + .build() + }; + (2) => { + SettingsOrder::builder() + .extend([ + SettingId::HeaderTableSize, + SettingId::EnablePush, + SettingId::MaxConcurrentStreams, + SettingId::InitialWindowSize, + SettingId::MaxFrameSize, + SettingId::MaxHeaderListSize, + SettingId::EnableConnectProtocol, + SettingId::NoRfc7540Priorities, + ]) + .build() + }; +} + +macro_rules! http2_options { + (@base $builder:expr) => { + $builder + .max_concurrent_streams(100) + }; + + (1) => { + http2_options!(@base Http2Options::builder()) + .initial_window_size(2097152) + .initial_connection_window_size(10551295) + .headers_pseudo_order(headers_pseudo_order!(1)) + .settings_order(settings_order!(1)) + .build() + }; + (2) => { + http2_options!(@base Http2Options::builder()) + .initial_window_size(2097152) + .initial_connection_window_size(10551295) + .enable_push(false) + .headers_pseudo_order(headers_pseudo_order!(1)) + .settings_order(settings_order!(1)) + .build() + }; + (3) => { + http2_options!(@base Http2Options::builder()) + .initial_window_size(2097152) + .initial_connection_window_size(10485760) + .enable_push(false) + .enable_connect_protocol(true) + .no_rfc7540_priorities(true) + .headers_pseudo_order(headers_pseudo_order!(2)) + .settings_order(settings_order!(2)) + .build() + }; + (4) => { + http2_options!(@base Http2Options::builder()) + .initial_window_size(4194304) + .initial_connection_window_size(10551295) + .headers_pseudo_order(headers_pseudo_order!(1)) + .settings_order(settings_order!(1)) + .build() + }; + (5) => { + http2_options!(@base Http2Options::builder()) + .initial_window_size(4194304) + .initial_connection_window_size(10551295) + .enable_push(false) + .headers_pseudo_order(headers_pseudo_order!(1)) + .settings_order(settings_order!(1)) + .build() + }; + (6) => { + http2_options!(@base Http2Options::builder()) + .initial_window_size(2097152) + .initial_connection_window_size(10485760) + .enable_push(false) + .no_rfc7540_priorities(true) + .headers_pseudo_order(headers_pseudo_order!(2)) + .settings_order(settings_order!(2)) + .build() + }; +} diff --git a/crates/wreq-util/src/emulate/profile/safari/tls.rs b/crates/wreq-util/src/emulate/profile/safari/tls.rs new file mode 100644 index 0000000..a412a8d --- /dev/null +++ b/crates/wreq-util/src/emulate/profile/safari/tls.rs @@ -0,0 +1,177 @@ +use super::*; + +macro_rules! tls_options { + (1, $cipher_list:expr) => { + SafariTlsConfig::builder() + .cipher_list($cipher_list) + .build() + .into() + }; + (2, $cipher_list:expr, $sigalgs_list:expr) => { + SafariTlsConfig::builder() + .cipher_list($cipher_list) + .sigalgs_list($sigalgs_list) + .build() + .into() + }; + (3, $cipher_list:expr, $sigalgs_list:expr, $curves:expr) => { + SafariTlsConfig::builder() + .curves($curves) + .cipher_list($cipher_list) + .sigalgs_list($sigalgs_list) + .preserve_tls13_cipher_list(true) + .min_tls_version(wreq::tls::TlsVersion::TLS_1_2) + .max_tls_version(wreq::tls::TlsVersion::TLS_1_3) + .build() + .into() + }; +} + +pub const CURVES_1: &str = join!(":", "X25519", "P-256", "P-384", "P-521"); + +pub const CURVES_2: &str = join!(":", "X25519MLKEM768", "X25519", "P-256", "P-384", "P-521"); + +pub const CIPHER_LIST_1: &str = join!( + ":", + "TLS_AES_128_GCM_SHA256", + "TLS_AES_256_GCM_SHA384", + "TLS_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", + "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_AES_256_GCM_SHA384", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_256_CBC_SHA256", + "TLS_RSA_WITH_AES_128_CBC_SHA256", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA", + "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" +); +pub const CIPHER_LIST_2: &str = join!( + ":", + "TLS_AES_128_GCM_SHA256", + "TLS_AES_256_GCM_SHA384", + "TLS_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_AES_256_GCM_SHA384", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA", + "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" +); +pub const CIPHER_LIST_3: &str = join!( + ":", + "TLS_AES_256_GCM_SHA384", + "TLS_CHACHA20_POLY1305_SHA256", + "TLS_AES_128_GCM_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_AES_256_GCM_SHA384", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA", + "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA" +); + +pub const SIGALGS_LIST_1: &str = join!( + ":", + "ecdsa_secp256r1_sha256", + "rsa_pss_rsae_sha256", + "rsa_pkcs1_sha256", + "ecdsa_secp384r1_sha384", + "ecdsa_sha1", + "rsa_pss_rsae_sha384", + "rsa_pss_rsae_sha384", + "rsa_pkcs1_sha384", + "rsa_pss_rsae_sha512", + "rsa_pkcs1_sha512", + "rsa_pkcs1_sha1" +); + +pub const SIGALGS_LIST_2: &str = join!( + ":", + "ecdsa_secp256r1_sha256", + "rsa_pss_rsae_sha256", + "rsa_pkcs1_sha256", + "ecdsa_secp384r1_sha384", + "rsa_pss_rsae_sha384", + "rsa_pss_rsae_sha384", + "rsa_pkcs1_sha384", + "rsa_pss_rsae_sha512", + "rsa_pkcs1_sha512", + "rsa_pkcs1_sha1" +); + +pub const CERTIFICATE_COMPRESSORS: &[&'static dyn CertificateCompressor] = &[&ZlibCompressor]; + +#[derive(TypedBuilder)] +pub struct SafariTlsConfig { + #[builder(default = TlsVersion::TLS_1_0)] + min_tls_version: TlsVersion, + + #[builder(default = TlsVersion::TLS_1_3)] + max_tls_version: TlsVersion, + + #[builder(default = CURVES_1)] + curves: &'static str, + + #[builder(default = SIGALGS_LIST_1)] + sigalgs_list: &'static str, + + cipher_list: &'static str, + + #[builder(default, setter(strip_option))] + preserve_tls13_cipher_list: Option, +} + +impl From for TlsOptions { + fn from(val: SafariTlsConfig) -> Self { + TlsOptions::builder() + .session_ticket(false) + .grease_enabled(true) + .enable_ocsp_stapling(true) + .enable_signed_cert_timestamps(true) + .preserve_tls13_cipher_list(val.preserve_tls13_cipher_list) + .curves_list(val.curves) + .sigalgs_list(val.sigalgs_list) + .cipher_list(val.cipher_list) + .min_tls_version(val.min_tls_version) + .max_tls_version(val.max_tls_version) + .certificate_compressors(CERTIFICATE_COMPRESSORS) + .build() + } +} diff --git a/crates/wreq-util/src/lib.rs b/crates/wreq-util/src/lib.rs new file mode 100644 index 0000000..03a68e6 --- /dev/null +++ b/crates/wreq-util/src/lib.rs @@ -0,0 +1,14 @@ +#![deny(unused)] +#![deny(unsafe_code)] +#![cfg_attr(docsrs, feature(doc_cfg))] +#![cfg_attr(test, deny(warnings))] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![doc = include_str!("../README.md")] + +#[cfg(feature = "emulation")] +pub mod emulate; +mod rand; +pub mod tower; + +#[cfg(feature = "emulation")] +pub use self::emulate::{Emulation, Platform, Profile}; diff --git a/crates/wreq-util/src/rand.rs b/crates/wreq-util/src/rand.rs new file mode 100644 index 0000000..2bc5f19 --- /dev/null +++ b/crates/wreq-util/src/rand.rs @@ -0,0 +1,24 @@ +use std::{ + cell::Cell, + collections::hash_map::RandomState, + hash::{BuildHasher, Hasher}, +}; + +// from: https://github.com/seanmonstar/reqwest/blob/5d5bf355744b181d31533501133ad9fbf99e8849/src/util.rs#L28 +pub(crate) fn fast_random() -> u64 { + thread_local! { + static KEY: RandomState = RandomState::new(); + static COUNTER: Cell = const { Cell::new(0) }; + } + + KEY.with(|key| { + COUNTER.with(|ctr| { + let n = ctr.get().wrapping_add(1); + ctr.set(n); + + let mut h = key.build_hasher(); + h.write_u64(n); + h.finish() + }) + }) +} diff --git a/crates/wreq-util/src/tower.rs b/crates/wreq-util/src/tower.rs new file mode 100644 index 0000000..fe20ba2 --- /dev/null +++ b/crates/wreq-util/src/tower.rs @@ -0,0 +1,7 @@ +//! Tower middleware helpers for `wreq`. +//! +//! Modules here are feature-gated. Enable the feature to make the tower middleware +//! available and to include its docs. + +#[cfg(feature = "tower-delay")] +pub mod delay; diff --git a/crates/wreq-util/src/tower/delay.rs b/crates/wreq-util/src/tower/delay.rs new file mode 100644 index 0000000..2bb0ff5 --- /dev/null +++ b/crates/wreq-util/src/tower/delay.rs @@ -0,0 +1,98 @@ +//! Request delay middleware. +//! +//! Adds configurable delays before HTTP requests — useful for rate limiting, +//! testing under slow network conditions, or just being polite to APIs. +//! +//! # Quick Start +//! +//! Fixed 1-second delay: +//! +//! ```no_run +//! use std::time::Duration; +//! use wreq::Client; +//! use wreq_util::middleware::delay::DelayLayer; +//! +//! let client = Client::builder() +//! .layer(DelayLayer::new(Duration::from_secs(1))) +//! .build()?; +//! # Ok::<(), wreq::Error>(()) +//! ``` +//! +//! Random jitter (0.8s ~ 1.2s): +//! +//! ```no_run +//! use std::time::Duration; +//! use wreq::Client; +//! use wreq_util::middleware::delay::JitterDelayLayer; +//! +//! let client = Client::builder() +//! .layer(JitterDelayLayer::new(Duration::from_secs(1), 0.2)) +//! .build()?; +//! # Ok::<(), wreq::Error>(()) +//! ``` +//! +//! # Conditional Delays +//! +//! Use `.when()` to apply delays only to matching requests: +//! +//! ```ignore +//! // Only delay POST requests +//! DelayLayer::new(Duration::from_secs(1)) +//! .when(|req: &http::Request<_>| req.method() == http::Method::POST) +//! +//! // Jitter on specific paths +//! JitterDelayLayer::new(Duration::from_millis(500), 0.3) +//! .when(|req: &http::Request<_>| req.uri().path().starts_with("/api")) +//! ``` +//! +//! # Notes +//! +//! - Delays are async and won't block the runtime +//! - Not a substitute for proper rate limiters — servers can still see timing patterns +//! - Keep delays short in hot paths + +mod future; +mod layer; +mod service; + +use std::time::Duration; + +pub use self::{ + future::ResponseFuture, + layer::{DelayLayer, DelayLayerWith, JitterDelayLayer, JitterDelayLayerWith}, + service::{Delay, DelayWith, JitterDelay, JitterDelayWith}, +}; + +/// Compute a randomized duration in `[base * (1 - pct), base * (1 + pct)]`. +fn jittered_duration(base: Duration, pct: f64) -> Duration { + let jitter = base.mul_f64(pct); + let low = base.saturating_sub(jitter); + let high = base.saturating_add(jitter); + + if low >= high { + return base; + } + + // Generate pseudo-random value using multiple entropy sources + let time_entropy = { + use std::time::SystemTime; + SystemTime::now() + .duration_since(SystemTime::UNIX_EPOCH) + .map(|d| d.as_nanos() as u64) + .unwrap_or(0) + }; + + // Use stack address as additional entropy source + let addr_entropy = (&time_entropy as *const u64 as u64).wrapping_mul(0x517cc1b727220a95); + + // Mix entropy sources with a simple but effective hash + let mixed = time_entropy + .wrapping_add(addr_entropy) + .wrapping_mul(0x9e3779b97f4a7c15); + + // Convert to fraction in [0, 1) + let frac = (mixed as f64) / (u64::MAX as f64); + + let span = (high - low).as_secs_f64(); + low + Duration::from_secs_f64(span * frac) +} diff --git a/crates/wreq-util/src/tower/delay/future.rs b/crates/wreq-util/src/tower/delay/future.rs new file mode 100644 index 0000000..944cb0b --- /dev/null +++ b/crates/wreq-util/src/tower/delay/future.rs @@ -0,0 +1,43 @@ +use std::{ + pin::Pin, + task::{Context, Poll, ready}, +}; + +use pin_project_lite::pin_project; +use tokio::time::Sleep; +use tower::BoxError; + +pin_project! { + /// Response future for [`Delay`]. + /// + /// [`Delay`]: super::Delay + #[derive(Debug)] + pub struct ResponseFuture { + #[pin] + response: S, + #[pin] + sleep: Sleep, + } +} + +impl ResponseFuture { + // Create a new [`ResponseFuture`] + #[inline] + pub(crate) fn new(response: S, sleep: Sleep) -> Self { + ResponseFuture { response, sleep } + } +} + +impl Future for ResponseFuture +where + F: Future>, + E: Into, +{ + type Output = Result; + + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + let this = self.project(); + ready!(this.sleep.poll(cx)); + this.response.poll(cx).map_err(Into::into) + } +} diff --git a/crates/wreq-util/src/tower/delay/layer.rs b/crates/wreq-util/src/tower/delay/layer.rs new file mode 100644 index 0000000..043e126 --- /dev/null +++ b/crates/wreq-util/src/tower/delay/layer.rs @@ -0,0 +1,201 @@ +use std::time::Duration; + +use tower::Layer; + +use super::service::{Delay, DelayWith, JitterDelay, JitterDelayWith}; + +/// A Tower [`Layer`] that introduces a fixed delay before each request. +#[derive(Clone, Debug)] +pub struct DelayLayer { + delay: Duration, +} + +/// Conditional delay [`Layer`], applies delay based on a predicate. +/// +/// Created via [`DelayLayer::when`]. +#[derive(Clone, Debug)] +pub struct DelayLayerWith

{ + delay: Duration, + predicate: P, +} + +/// A Tower [`Layer`] that introduces a jittered delay before each request. +/// +/// The actual delay for each request will be randomly chosen within the range +/// `[base - base*pct, base + base*pct]`. +/// +/// # Example +/// +/// ```no_run +/// use std::time::Duration; +/// use wreq::Client; +/// use wreq_util::middleware::delay::JitterDelayLayer; +/// +/// // Creates delays in range [0.8s, 1.2s] (1s ± 20%) +/// let client = Client::builder() +/// .layer(JitterDelayLayer::new(Duration::from_secs(1), 0.2)) +/// .build()?; +/// # Ok::<(), wreq::Error>(()) +/// ``` +#[derive(Clone, Debug)] +pub struct JitterDelayLayer { + base: Duration, + pct: f64, +} + +/// Conditional jitter delay [`Layer`], applies delay based on a predicate. +/// +/// Created via [`JitterDelayLayer::when`]. +#[derive(Clone, Debug)] +pub struct JitterDelayLayerWith

{ + base: Duration, + pct: f64, + predicate: P, +} + +// ===== impl DelayLayer ===== + +impl DelayLayer { + /// Create a new [`DelayLayer`] with the given delay duration. + #[inline] + pub const fn new(delay: Duration) -> Self { + DelayLayer { delay } + } + + /// Apply delay only to requests that satisfy a predicate. + /// + /// Requests that don't match the predicate will pass through without delay. + /// + /// # Example + /// + /// ```ignore + /// use std::time::Duration; + /// use http::Request; + /// use wreq_util::middleware::delay::DelayLayer; + /// + /// // Only delay POST requests + /// let layer = DelayLayer::new(Duration::from_secs(1)) + /// .when(|req: &Request<_>| req.method() == http::Method::POST); + /// ``` + pub fn when(self, predicate: P) -> DelayLayerWith

+ where + P: Fn(&Req) -> bool + Clone, + { + DelayLayerWith::new(self.delay, predicate) + } +} + +impl Layer for DelayLayer { + type Service = Delay; + + #[inline] + fn layer(&self, service: S) -> Self::Service { + Delay::new(service, self.delay) + } +} + +// ===== impl DelayLayerWith ===== + +impl

DelayLayerWith

{ + /// Creates a new [`DelayLayerWith`]. + #[inline] + pub fn new(delay: Duration, predicate: P) -> Self { + Self { delay, predicate } + } +} + +impl Layer for DelayLayerWith

+where + P: Clone, +{ + type Service = DelayWith; + + #[inline] + fn layer(&self, inner: S) -> Self::Service { + DelayWith::new(inner, self.delay, self.predicate.clone()) + } +} + +// ===== impl JitterDelayLayer ===== + +impl JitterDelayLayer { + /// Create a new [`JitterDelayLayer`] with the given base delay and jitter percentage. + /// + /// # Arguments + /// * `base` - The base delay duration + /// * `pct` - The jitter percentage (0.0 to 1.0), representing ±pct deviation + /// + /// # Example + /// + /// ``` + /// use std::time::Duration; + /// use wreq_util::middleware::delay::JitterDelayLayer; + /// + /// // Creates delays in range [800ms, 1200ms] + /// let layer = JitterDelayLayer::new(Duration::from_secs(1), 0.2); + /// ``` + #[inline] + pub fn new(base: Duration, pct: f64) -> Self { + Self { + base, + pct: pct.clamp(0.0, 1.0), + } + } + + /// Apply jitter delay only to requests that satisfy a predicate. + /// + /// Requests that don't match the predicate will pass through without delay. + /// + /// # Example + /// + /// ```ignore + /// use std::time::Duration; + /// use http::Request; + /// use wreq_util::middleware::delay::JitterDelayLayer; + /// + /// // Only delay requests to paths starting with "/slow" + /// let layer = JitterDelayLayer::new(Duration::from_secs(1), 0.2) + /// .when(|req: &Request<_>| req.uri().path().starts_with("/slow")); + /// ``` + pub fn when(self, predicate: P) -> JitterDelayLayerWith

+ where + P: Fn(&Req) -> bool + Clone, + { + JitterDelayLayerWith::new(self.base, self.pct, predicate) + } +} + +impl Layer for JitterDelayLayer { + type Service = JitterDelay; + + #[inline] + fn layer(&self, inner: S) -> Self::Service { + JitterDelay::new(inner, self.base, self.pct) + } +} + +// ===== impl JitterDelayLayerWith ===== + +impl

JitterDelayLayerWith

{ + /// Creates a new [`JitterDelayLayerWith`]. + #[inline] + pub fn new(base: Duration, pct: f64, predicate: P) -> Self { + Self { + base, + pct: pct.clamp(0.0, 1.0), + predicate, + } + } +} + +impl Layer for JitterDelayLayerWith

+where + P: Clone, +{ + type Service = JitterDelayWith; + + #[inline] + fn layer(&self, inner: S) -> Self::Service { + JitterDelayWith::new(inner, self.base, self.pct, self.predicate.clone()) + } +} diff --git a/crates/wreq-util/src/tower/delay/service.rs b/crates/wreq-util/src/tower/delay/service.rs new file mode 100644 index 0000000..741900e --- /dev/null +++ b/crates/wreq-util/src/tower/delay/service.rs @@ -0,0 +1,190 @@ +use std::{ + task::{Context, Poll}, + time::Duration, +}; + +use tower::{BoxError, Service}; + +use super::{future::ResponseFuture, jittered_duration}; + +/// A Tower [`Service`] that introduces a fixed delay before each request. +#[derive(Debug, Clone)] +pub struct Delay { + inner: S, + delay: Duration, +} + +/// A Tower [`Service`] that conditionally applies fixed delay based on a predicate. +/// +/// Requests that match the predicate will have the delay applied; +/// other requests pass through immediately. +#[derive(Clone, Debug)] +pub struct DelayWith { + inner: Delay, + predicate: P, +} + +/// A Tower [`Service`] that applies jittered delay to requests. +/// +/// This service wraps an inner service and introduces a random delay +/// (within a configured range) before each request. +#[derive(Clone, Debug)] +pub struct JitterDelay { + inner: S, + base: Duration, + pct: f64, +} + +/// A Tower [`Service`] that conditionally applies jittered delay based on a predicate. +/// +/// Requests that match the predicate will have a jittered delay applied; +/// other requests pass through immediately. +#[derive(Clone, Debug)] +pub struct JitterDelayWith { + inner: JitterDelay, + predicate: P, +} + +// ===== impl Delay ===== + +impl Delay { + /// Create a new [`Delay`] service wrapping the given inner service + #[inline] + pub fn new(inner: S, delay: Duration) -> Self { + Delay { inner, delay } + } +} + +impl Service for Delay +where + S: Service, + S::Error: Into, +{ + type Response = S::Response; + type Error = BoxError; + type Future = ResponseFuture; + + #[inline] + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + self.inner.poll_ready(cx).map_err(Into::into) + } + + fn call(&mut self, req: Request) -> Self::Future { + let response = self.inner.call(req); + let sleep = tokio::time::sleep(self.delay); + ResponseFuture::new(response, sleep) + } +} + +// ===== impl DelayWith ===== + +impl DelayWith { + /// Creates a new [`DelayWith`]. + #[inline] + pub fn new(inner: S, delay: Duration, predicate: P) -> Self { + Self { + inner: Delay::new(inner, delay), + predicate, + } + } +} + +impl Service for DelayWith +where + S: Service, + S::Error: Into, + P: Fn(&Req) -> bool, +{ + type Response = S::Response; + type Error = BoxError; + type Future = ResponseFuture; + + #[inline] + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + self.inner.poll_ready(cx).map_err(Into::into) + } + + fn call(&mut self, req: Req) -> Self::Future { + if !(self.predicate)(&req) { + self.inner.delay = Duration::ZERO; + } + self.inner.call(req) + } +} + +// ===== impl JitterDelay ===== + +impl JitterDelay { + /// Creates a new [`JitterDelay`]. + #[inline] + pub fn new(inner: S, base: Duration, pct: f64) -> Self { + Self { + inner, + base, + pct: pct.clamp(0.0, 1.0), + } + } +} + +impl Service for JitterDelay +where + S: Service, + S::Error: Into, +{ + type Response = S::Response; + type Error = BoxError; + type Future = ResponseFuture; + + #[inline] + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + self.inner.poll_ready(cx).map_err(Into::into) + } + + fn call(&mut self, req: Req) -> Self::Future { + let delay = jittered_duration(self.base, self.pct); + let sleep = tokio::time::sleep(delay); + let fut = self.inner.call(req); + ResponseFuture::new(fut, sleep) + } +} + +// ===== impl JitterDelayWith ===== + +impl JitterDelayWith { + /// Creates a new [`JitterDelayWith`]. + #[inline] + pub fn new(inner: S, base: Duration, pct: f64, predicate: P) -> Self { + Self { + inner: JitterDelay::new(inner, base, pct), + predicate, + } + } +} + +impl Service for JitterDelayWith +where + S: Service, + S::Error: Into, + P: Fn(&Req) -> bool, +{ + type Response = S::Response; + type Error = BoxError; + type Future = ResponseFuture; + + #[inline] + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + self.inner.poll_ready(cx).map_err(Into::into) + } + + fn call(&mut self, req: Req) -> Self::Future { + let delay = if (self.predicate)(&req) { + jittered_duration(self.inner.base, self.inner.pct) + } else { + Duration::ZERO + }; + + let sleep = tokio::time::sleep(delay); + let fut = self.inner.inner.call(req); + ResponseFuture::new(fut, sleep) + } +} diff --git a/crates/wreq-util/tests/client.rs b/crates/wreq-util/tests/client.rs new file mode 100644 index 0000000..5af9ea5 --- /dev/null +++ b/crates/wreq-util/tests/client.rs @@ -0,0 +1,51 @@ +#![cfg(not(target_arch = "wasm32"))] +mod support; + +use support::server; +use wreq::Client; +use wreq_util::{Emulation, Platform}; + +#[tokio::test] +async fn test_client_emulation_device() { + let server = server::http(move |req| async move { + for (name, value) in req.headers() { + if name == "user-agent" { + assert_eq!( + value, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36" + ); + } + if name == "sec-ch-ua" { + assert_eq!( + value, + r#""Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133""# + ); + } + if name == "sec-ch-ua-mobile" { + assert_eq!(value, "?0"); + } + if name == "sec-ch-ua-platform" { + assert_eq!(value, "\"Linux\""); + } + } + http::Response::default() + }); + + let url = format!("http://{}/ua", server.addr()); + let res = Client::builder() + .emulation( + Emulation::builder() + .profile(Emulation::Chrome133) + .platform(Platform::Linux) + .http2(true) + .build(), + ) + .build() + .expect("Unable to build client") + .get(&url) + .send() + .await + .expect("request"); + + assert_eq!(res.status(), wreq::StatusCode::OK); +} diff --git a/crates/wreq-util/tests/emulate_chrome.rs b/crates/wreq-util/tests/emulate_chrome.rs new file mode 100644 index 0000000..4484f63 --- /dev/null +++ b/crates/wreq-util/tests/emulate_chrome.rs @@ -0,0 +1,270 @@ +#[macro_use] +mod support; + +use wreq_util::Emulation; + +// Enabling certain extensions(ECH) will change the length during encryption. This is because TLS will +// automatically use padding to fill the data and add a padding extension. At this time, the ja4 +// fingerprint will change. + +test_emulation!( + test_chrome100, + Emulation::Chrome100, + ["t13d1516h2_8daaf6152771_e5627efa2ab1"], + "4f04edce68a7ecbe689edce7bf5f23f3" +); + +test_emulation!( + test_chrome101, + Emulation::Chrome101, + ["t13d1516h2_8daaf6152771_e5627efa2ab1"], + "4f04edce68a7ecbe689edce7bf5f23f3" +); + +test_emulation!( + test_edge101, + Emulation::Edge101, + ["t13d1516h2_8daaf6152771_e5627efa2ab1"], + "4f04edce68a7ecbe689edce7bf5f23f3" +); + +test_emulation!( + test_chrome104, + Emulation::Chrome104, + ["t13d1516h2_8daaf6152771_e5627efa2ab1"], + "4f04edce68a7ecbe689edce7bf5f23f3" +); + +test_emulation!( + test_chrome105, + Emulation::Chrome105, + [ + "t13d1516h2_8daaf6152771_02713d6af862", + "t13d1517h2_8daaf6152771_b1ff8ab2d16f" + ], + "4f04edce68a7ecbe689edce7bf5f23f3" +); + +test_emulation!( + test_chrome106, + Emulation::Chrome106, + ["t13d1516h2_8daaf6152771_e5627efa2ab1"], + "a345a694846ad9f6c97bcc3c75adbe26" +); + +test_emulation!( + test_chrome107, + Emulation::Chrome107, + ["t13d1516h2_8daaf6152771_e5627efa2ab1"], + "a345a694846ad9f6c97bcc3c75adbe26" +); + +test_emulation!( + test_chrome108, + Emulation::Chrome108, + ["t13d1516h2_8daaf6152771_e5627efa2ab1"], + "a345a694846ad9f6c97bcc3c75adbe26" +); + +test_emulation!( + test_chrome109, + Emulation::Chrome109, + ["t13d1516h2_8daaf6152771_e5627efa2ab1"], + "a345a694846ad9f6c97bcc3c75adbe26" +); + +test_emulation!( + test_chrome110, + Emulation::Chrome110, + ["t13d1516h2_8daaf6152771_e5627efa2ab1"], + "4f04edce68a7ecbe689edce7bf5f23f3" +); + +test_emulation!( + test_chrome114, + Emulation::Chrome114, + ["t13d1516h2_8daaf6152771_e5627efa2ab1"], + "a345a694846ad9f6c97bcc3c75adbe26" +); + +test_emulation!( + test_chrome116, + Emulation::Chrome116, + [ + "t13d1516h2_8daaf6152771_02713d6af862", + "t13d1517h2_8daaf6152771_b1ff8ab2d16f" + ], + "a345a694846ad9f6c97bcc3c75adbe26" +); + +test_emulation!( + test_chrome117, + Emulation::Chrome117, + [ + "t13d1516h2_8daaf6152771_02713d6af862", + "t13d1517h2_8daaf6152771_b1ff8ab2d16f" + ], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_chrome118, + Emulation::Chrome118, + [ + "t13d1516h2_8daaf6152771_02713d6af862", + "t13d1517h2_8daaf6152771_b1ff8ab2d16f" + ], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_chrome119, + Emulation::Chrome119, + [ + "t13d1516h2_8daaf6152771_02713d6af862", + "t13d1517h2_8daaf6152771_b1ff8ab2d16f" + ], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_chrome120, + Emulation::Chrome120, + [ + "t13d1516h2_8daaf6152771_02713d6af862", + "t13d1517h2_8daaf6152771_b1ff8ab2d16f" + ], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_edge122, + Emulation::Edge122, + [ + "t13d1516h2_8daaf6152771_02713d6af862", + "t13d1517h2_8daaf6152771_b1ff8ab2d16f" + ], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_chrome123, + Emulation::Chrome123, + [ + "t13d1516h2_8daaf6152771_02713d6af862", + "t13d1517h2_8daaf6152771_b1ff8ab2d16f" + ], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_chrome124, + Emulation::Chrome124, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_chrome126, + Emulation::Chrome126, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_chrome127, + Emulation::Chrome127, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_edge127, + Emulation::Edge127, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_chrome128, + Emulation::Chrome128, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_chrome129, + Emulation::Chrome129, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_chrome130, + Emulation::Chrome130, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_chrome131, + Emulation::Chrome131, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_edge131, + Emulation::Edge131, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_chrome132, + Emulation::Chrome132, + ["t13d1516h2_8daaf6152771_d8a2da3f94cd"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_chrome133, + Emulation::Chrome133, + ["t13d1516h2_8daaf6152771_d8a2da3f94cd"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_chrome134, + Emulation::Chrome134, + ["t13d1516h2_8daaf6152771_d8a2da3f94cd"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_edge134, + Emulation::Edge134, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_chrome135, + Emulation::Chrome135, + ["t13d1516h2_8daaf6152771_d8a2da3f94cd"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_chrome136, + Emulation::Chrome136, + ["t13d1516h2_8daaf6152771_d8a2da3f94cd"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_chrome137, + Emulation::Chrome137, + ["t13d1516h2_8daaf6152771_d8a2da3f94cd"], + "52d84b11737d980aef856699f885ca86" +); diff --git a/crates/wreq-util/tests/emulate_firefox.rs b/crates/wreq-util/tests/emulate_firefox.rs new file mode 100644 index 0000000..395bddf --- /dev/null +++ b/crates/wreq-util/tests/emulate_firefox.rs @@ -0,0 +1,92 @@ +#[macro_use] +mod support; + +use wreq_util::Emulation; + +// Enabling certain extensions(ECH) will change the length during encryption. This is because TLS will +// automatically use padding to fill the data and add a padding extension. At this time, the ja4 +// fingerprint will change. + +test_emulation!( + test_firefox_109, + Emulation::Firefox109, + ["t13d1715h2_5b57614c22b0_3d5424432f57"], + "73d042072ceabaedacfd45e84dff1020" +); + +test_emulation!( + test_firefox_117, + Emulation::Firefox117, + ["t13d1715h2_5b57614c22b0_3d5424432f57"], + "73d042072ceabaedacfd45e84dff1020" +); + +test_emulation!( + test_firefox_128, + Emulation::Firefox128, + ["t13d1513h2_8daaf6152771_748f4c70de1c"], + "1d8a6f51fd7253d04674593073fc18b0" +); + +test_emulation!( + test_firefox_133, + Emulation::Firefox133, + ["t13d1716h2_5b57614c22b0_eeeea6562960"], + "6ea73faa8fc5aac76bded7bd238f6433" +); + +test_emulation!( + test_firefox_135, + Emulation::Firefox135, + ["t13d1717h2_5b57614c22b0_3cbfd9057e0d"], + "6ea73faa8fc5aac76bded7bd238f6433" +); + +test_emulation!( + test_firefox_private_135, + Emulation::FirefoxPrivate135, + ["t13d1715h2_5b57614c22b0_a54fffd0eb61"], + "6ea73faa8fc5aac76bded7bd238f6433" +); + +test_emulation!( + test_firefox_android_135, + Emulation::FirefoxAndroid135, + ["t13d1716h2_5b57614c22b0_eeeea6562960"], + "41a06cadb1c6385e6d08c8d0dbbea818" +); + +test_emulation!( + test_firefox_136, + Emulation::Firefox136, + ["t13d1717h2_5b57614c22b0_3cbfd9057e0d"], + "6ea73faa8fc5aac76bded7bd238f6433" +); + +test_emulation!( + test_firefox_private_136, + Emulation::FirefoxPrivate136, + ["t13d1715h2_5b57614c22b0_a54fffd0eb61"], + "6ea73faa8fc5aac76bded7bd238f6433" +); + +test_emulation!( + test_firefox_139, + Emulation::Firefox139, + ["t13d1717h2_5b57614c22b0_3cbfd9057e0d"], + "6ea73faa8fc5aac76bded7bd238f6433" +); + +test_emulation!( + test_firefox_142, + Emulation::Firefox142, + ["t13d1717h2_5b57614c22b0_3cbfd9057e0d"], + "6ea73faa8fc5aac76bded7bd238f6433" +); + +test_emulation!( + test_firefox_143, + Emulation::Firefox143, + ["t13d1717h2_5b57614c22b0_3cbfd9057e0d"], + "6ea73faa8fc5aac76bded7bd238f6433" +); diff --git a/crates/wreq-util/tests/emulate_okhttp.rs b/crates/wreq-util/tests/emulate_okhttp.rs new file mode 100644 index 0000000..052e607 --- /dev/null +++ b/crates/wreq-util/tests/emulate_okhttp.rs @@ -0,0 +1,46 @@ +#[macro_use] +mod support; + +use wreq_util::Emulation; + +test_emulation!( + test_okhttp3_13, + Emulation::OkHttp3_13, + ["t13d1613h2_46e7e9700bed_eca864cca44a"], + "605a1154008045d7e3cb3c6fb062c0ce" +); + +test_emulation!( + test_okhttp3_14, + Emulation::OkHttp3_14, + ["t13d1613h2_46e7e9700bed_eca864cca44a"], + "605a1154008045d7e3cb3c6fb062c0ce" +); + +test_emulation!( + test_okhttp4_9, + Emulation::OkHttp4_9, + ["t13d1513h2_8daaf6152771_eca864cca44a"], + "605a1154008045d7e3cb3c6fb062c0ce" +); + +test_emulation!( + test_okhttp4_10, + Emulation::OkHttp4_10, + ["t13d1613h2_46e7e9700bed_eca864cca44a"], + "605a1154008045d7e3cb3c6fb062c0ce" +); + +test_emulation!( + test_okhttp4_12, + Emulation::OkHttp4_12, + ["t13d1613h2_46e7e9700bed_eca864cca44a"], + "605a1154008045d7e3cb3c6fb062c0ce" +); + +test_emulation!( + test_okhttp5, + Emulation::OkHttp5, + ["t13d1613h2_46e7e9700bed_eca864cca44a"], + "605a1154008045d7e3cb3c6fb062c0ce" +); diff --git a/crates/wreq-util/tests/emulate_opera.rs b/crates/wreq-util/tests/emulate_opera.rs new file mode 100644 index 0000000..3d8e3c2 --- /dev/null +++ b/crates/wreq-util/tests/emulate_opera.rs @@ -0,0 +1,113 @@ +#[macro_use] +mod support; + +use wreq_util::Emulation; + +// Enabling certain extensions will change the length during encryption. This is because TLS will +// automatically use padding to fill the data and add a padding extension. At this time, the ja4 +// fingerprint will change. + +test_emulation!( + test_opera116, + Emulation::Opera116, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_opera117, + Emulation::Opera117, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_opera118, + Emulation::Opera118, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_opera119, + Emulation::Opera119, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_opera120, + Emulation::Opera120, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_opera121, + Emulation::Opera121, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_opera122, + Emulation::Opera122, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_opera123, + Emulation::Opera123, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_opera124, + Emulation::Opera124, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_opera125, + Emulation::Opera125, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_opera126, + Emulation::Opera126, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_opera127, + Emulation::Opera127, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_opera128, + Emulation::Opera128, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_opera129, + Emulation::Opera129, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_opera130, + Emulation::Opera130, + ["t13d1516h2_8daaf6152771_02713d6af862"], + "52d84b11737d980aef856699f885ca86" +); diff --git a/crates/wreq-util/tests/emulate_safari.rs b/crates/wreq-util/tests/emulate_safari.rs new file mode 100644 index 0000000..f6e559d --- /dev/null +++ b/crates/wreq-util/tests/emulate_safari.rs @@ -0,0 +1,151 @@ +#[macro_use] +mod support; + +use wreq_util::Emulation; + +test_emulation!( + test_safari_15_3, + Emulation::Safari15_3, + ["t13d2614h2_2802a3db6c62_14788d8d241b"], + "dda308d35f4e5db7b52a61720ca1b122" +); + +test_emulation!( + test_safari_15_5, + Emulation::Safari15_5, + ["t13d2614h2_2802a3db6c62_14788d8d241b"], + "dda308d35f4e5db7b52a61720ca1b122" +); + +test_emulation!( + test_safari_15_6_1, + Emulation::Safari15_6_1, + ["t13d2014h2_a09f3c656075_14788d8d241b"], + "dda308d35f4e5db7b52a61720ca1b122" +); + +test_emulation!( + test_safari_16, + Emulation::Safari16, + ["t13d2014h2_a09f3c656075_14788d8d241b"], + "dda308d35f4e5db7b52a61720ca1b122" +); + +test_emulation!( + test_safari_16_5, + Emulation::Safari16_5, + ["t13d2014h2_a09f3c656075_14788d8d241b"], + "dda308d35f4e5db7b52a61720ca1b122" +); + +test_emulation!( + test_safari_ios_16_5, + Emulation::SafariIos16_5, + ["t13d2014h2_a09f3c656075_14788d8d241b"], + "d5fcbdc393757341115a861bf8d23265" +); + +test_emulation!( + test_safari_17, + Emulation::Safari17_0, + ["t13d2014h2_a09f3c656075_14788d8d241b"], + "959a7e813b79b909a1a0b00a38e8bba3" +); + +test_emulation!( + test_safari_17_2_1, + Emulation::Safari17_2_1, + ["t13d2014h2_a09f3c656075_14788d8d241b"], + "959a7e813b79b909a1a0b00a38e8bba3" +); + +test_emulation!( + test_safari_17_4_1, + Emulation::Safari17_4_1, + ["t13d2014h2_a09f3c656075_14788d8d241b"], + "dda308d35f4e5db7b52a61720ca1b122" +); + +test_emulation!( + test_safari_17_5, + Emulation::Safari17_5, + ["t13d2014h2_a09f3c656075_14788d8d241b"], + "959a7e813b79b909a1a0b00a38e8bba3" +); + +test_emulation!( + test_safari_ios_17_2, + Emulation::SafariIos17_2, + ["t13d2014h2_a09f3c656075_14788d8d241b"], + "ad8424af1cc590e09f7b0c499bf7fcdb" +); + +test_emulation!( + test_safari_ios_17_4_1, + Emulation::SafariIos17_4_1, + ["t13d2014h2_a09f3c656075_14788d8d241b"], + "ad8424af1cc590e09f7b0c499bf7fcdb" +); + +test_emulation!( + test_safari_18, + Emulation::Safari18, + ["t13d2014h2_a09f3c656075_14788d8d241b"], + "d4a2dcbfde511b5040ed5a5190a8d78b" +); + +test_emulation!( + test_safari_18_2, + Emulation::Safari18_2, + ["t13d2014h2_a09f3c656075_e42f34c56612"], + "d4a2dcbfde511b5040ed5a5190a8d78b" +); + +test_emulation!( + test_safari_18_3, + Emulation::Safari18_3, + ["t13d2014h2_a09f3c656075_e42f34c56612"], + "d4a2dcbfde511b5040ed5a5190a8d78b" +); + +test_emulation!( + test_safari_18_3_1, + Emulation::Safari18_3_1, + ["t13d2014h2_a09f3c656075_e42f34c56612"], + "d4a2dcbfde511b5040ed5a5190a8d78b" +); + +test_emulation!( + test_safari_ios_18_1_1, + Emulation::SafariIos18_1_1, + ["t13d2014h2_a09f3c656075_14788d8d241b"], + "d4a2dcbfde511b5040ed5a5190a8d78b" +); + +test_emulation!( + test_safari_ipad_18, + Emulation::SafariIPad18, + ["t13d2014h2_a09f3c656075_14788d8d241b"], + "d4a2dcbfde511b5040ed5a5190a8d78b" +); + +test_emulation!( + test_safari_18_5, + Emulation::Safari18_5, + ["t13d2014h2_a09f3c656075_e42f34c56612"], + "c52879e43202aeb92740be6e8c86ea96" +); + +test_emulation!( + test_safari_26, + Emulation::Safari26, + ["t13d2013h2_a09f3c656075_7f0f34a4126d"], + "c52879e43202aeb92740be6e8c86ea96" +); + +test_emulation!( + test_safari_26_1, + Emulation::Safari26_1, + ["t13d2014h2_a09f3c656075_e42f34c56612"], + "773906b0efdefa24a7f2b8eb6985bf37" +); diff --git a/crates/wreq-util/tests/support/mod.rs b/crates/wreq-util/tests/support/mod.rs new file mode 100644 index 0000000..96adad3 --- /dev/null +++ b/crates/wreq-util/tests/support/mod.rs @@ -0,0 +1,55 @@ +#![allow(dead_code)] +pub mod server; + +use std::{sync::LazyLock, time::Duration}; + +use tokio::sync::Semaphore; +use wreq::Client; + +// TODO: remove once done converting to new support server? +#[allow(unused)] +pub static DEFAULT_USER_AGENT: &str = + concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")); + +pub static TEST_SEMAPHORE: LazyLock = LazyLock::new(|| Semaphore::new(1)); + +pub static CLIENT: LazyLock = LazyLock::new(|| { + Client::builder() + .connect_timeout(Duration::from_secs(60)) + .build() + .unwrap() +}); + +#[allow(unused_macros)] +macro_rules! test_emulation { + ($test_name:ident, $emulation:expr, $ja4:expr, $akamai_hash:expr) => { + #[tokio::test] + async fn $test_name() { + let _permit = crate::support::TEST_SEMAPHORE.acquire().await.unwrap(); + + let resp = crate::support::CLIENT + .get("https://tls.browserleaks.com/") + .emulation($emulation) + .send() + .await + .unwrap(); + + assert_eq!(resp.status(), wreq::StatusCode::OK); + let content = resp.text().await.unwrap(); + + let conditional = $ja4.iter().any(|&ja4| content.contains(ja4)); + if !conditional { + println!("{}", content); + } + assert!(conditional); + + let conditional = content.contains($akamai_hash); + if !conditional { + println!("{}", content); + } + assert!(conditional); + + tokio::time::sleep(std::time::Duration::from_millis(1000)).await; + } + }; +} diff --git a/crates/wreq-util/tests/support/server.rs b/crates/wreq-util/tests/support/server.rs new file mode 100644 index 0000000..8b190fd --- /dev/null +++ b/crates/wreq-util/tests/support/server.rs @@ -0,0 +1,232 @@ +#![cfg(not(target_arch = "wasm32"))] +use std::{ + convert::Infallible, future::Future, net, sync::mpsc as std_mpsc, thread, time::Duration, +}; + +use tokio::{io::AsyncReadExt, net::TcpStream, runtime, sync::oneshot}; + +pub struct Server { + addr: net::SocketAddr, + panic_rx: std_mpsc::Receiver<()>, + events_rx: std_mpsc::Receiver, + shutdown_tx: Option>, +} + +#[non_exhaustive] +pub enum Event { + ConnectionClosed, +} + +impl Server { + pub fn addr(&self) -> net::SocketAddr { + self.addr + } + + #[allow(unused)] + pub fn events(&mut self) -> Vec { + let mut events = Vec::new(); + while let Ok(event) = self.events_rx.try_recv() { + events.push(event); + } + events + } +} + +impl Drop for Server { + fn drop(&mut self) { + if let Some(tx) = self.shutdown_tx.take() { + let _ = tx.send(()); + } + + if !::std::thread::panicking() { + self.panic_rx + .recv_timeout(Duration::from_secs(3)) + .expect("test server should not panic"); + } + } +} + +pub fn http(func: F) -> Server +where + F: Fn(http::Request) -> Fut + Clone + Send + 'static, + Fut: Future> + Send + 'static, +{ + http_with_config(func, |_builder| {}) +} + +type Builder = hyper_util::server::conn::auto::Builder; + +pub fn http_with_config(func: F1, apply_config: F2) -> Server +where + F1: Fn(http::Request) -> Fut + Clone + Send + 'static, + Fut: Future> + Send + 'static, + F2: FnOnce(&mut Builder) -> Bu + Send + 'static, +{ + // Spawn new runtime in thread to prevent reactor execution context conflict + let test_name = thread::current().name().unwrap_or("").to_string(); + thread::spawn(move || { + let rt = runtime::Builder::new_current_thread() + .enable_all() + .build() + .expect("new rt"); + let listener = rt.block_on(async move { + tokio::net::TcpListener::bind(&std::net::SocketAddr::from(([127, 0, 0, 1], 0))) + .await + .unwrap() + }); + let addr = listener.local_addr().unwrap(); + + let (shutdown_tx, mut shutdown_rx) = oneshot::channel(); + let (panic_tx, panic_rx) = std_mpsc::channel(); + let (events_tx, events_rx) = std_mpsc::channel(); + let tname = format!( + "test({})-support-server", + test_name, + ); + thread::Builder::new() + .name(tname) + .spawn(move || { + rt.block_on(async move { + let mut builder = + hyper_util::server::conn::auto::Builder::new(hyper_util::rt::TokioExecutor::new()); + apply_config(&mut builder); + + loop { + tokio::select! { + _ = &mut shutdown_rx => { + break; + } + accepted = listener.accept() => { + let (io, _) = accepted.expect("accepted"); + let func = func.clone(); + let svc = hyper::service::service_fn(move |req| { + let fut = func(req); + async move { Ok::<_, Infallible>(fut.await) } + }); + let builder = builder.clone(); + let events_tx = events_tx.clone(); + tokio::spawn(async move { + let _ = builder.serve_connection_with_upgrades(hyper_util::rt::TokioIo::new(io), svc).await; + let _ = events_tx.send(Event::ConnectionClosed); + }); + } + } + } + let _ = panic_tx.send(()); + }); + }) + .expect("thread spawn"); + Server { + addr, + panic_rx, + events_rx, + shutdown_tx: Some(shutdown_tx), + } + }) + .join() + .unwrap() +} + +#[allow(unused)] +pub fn low_level_with_response(do_response: F) -> Server +where + for<'c> F: Fn(&'c [u8], &'c mut TcpStream) -> Box + Send + 'c> + + Clone + + Send + + 'static, +{ + // Spawn new runtime in thread to prevent reactor execution context conflict + let test_name = thread::current().name().unwrap_or("").to_string(); + thread::spawn(move || { + let rt = runtime::Builder::new_current_thread() + .enable_all() + .build() + .expect("new rt"); + let listener = rt.block_on(async move { + tokio::net::TcpListener::bind(&std::net::SocketAddr::from(([127, 0, 0, 1], 0))) + .await + .unwrap() + }); + let addr = listener.local_addr().unwrap(); + + let (shutdown_tx, mut shutdown_rx) = oneshot::channel(); + let (panic_tx, panic_rx) = std_mpsc::channel(); + let (events_tx, events_rx) = std_mpsc::channel(); + let tname = format!("test({})-support-server", test_name,); + thread::Builder::new() + .name(tname) + .spawn(move || { + rt.block_on(async move { + loop { + tokio::select! { + _ = &mut shutdown_rx => { + break; + } + accepted = listener.accept() => { + let (io, _) = accepted.expect("accepted"); + let do_response = do_response.clone(); + let events_tx = events_tx.clone(); + tokio::spawn(async move { + low_level_server_client(io, do_response).await; + let _ = events_tx.send(Event::ConnectionClosed); + }); + } + } + } + let _ = panic_tx.send(()); + }); + }) + .expect("thread spawn"); + Server { + addr, + panic_rx, + events_rx, + shutdown_tx: Some(shutdown_tx), + } + }) + .join() + .unwrap() +} + +#[allow(unused)] +async fn low_level_server_client(mut client_socket: TcpStream, do_response: F) +where + for<'c> F: Fn(&'c [u8], &'c mut TcpStream) -> Box + Send + 'c>, +{ + loop { + let request = low_level_read_http_request(&mut client_socket) + .await + .expect("read_http_request failed"); + if request.is_empty() { + // connection closed by client + break; + } + + Box::into_pin(do_response(&request, &mut client_socket)).await; + } +} + +#[allow(unused)] +async fn low_level_read_http_request( + client_socket: &mut TcpStream, +) -> core::result::Result, std::io::Error> { + let mut buf = Vec::new(); + + // Read until the delimiter "\r\n\r\n" is found + loop { + let mut temp_buffer = [0; 1024]; + let n = client_socket.read(&mut temp_buffer).await?; + + if n == 0 { + break; + } + + buf.extend_from_slice(&temp_buffer[..n]); + + if let Some(pos) = buf.windows(4).position(|window| window == b"\r\n\r\n") { + return Ok(buf.drain(..pos + 4).collect()); + } + } + + Ok(buf) +} diff --git a/examples/emulate_request.rb b/examples/emulate_request.rb index 52ff307..0f3c1c0 100644 --- a/examples/emulate_request.rb +++ b/examples/emulate_request.rb @@ -11,7 +11,7 @@ # Set when creating the Wreq::Client instance. # All requests from this client will use the specified emulation unless overridden. client = Wreq::Client.new(emulation: Wreq::Emulation.new( - profile: Wreq::Profile::Chrome149, + profile: Wreq::Profile::Chrome150, platform: Wreq::Platform::MacOS, http2: true, headers: true diff --git a/lib/wreq_ruby/emulate.rb b/lib/wreq_ruby/emulate.rb index 66fb744..fcd9353 100644 --- a/lib/wreq_ruby/emulate.rb +++ b/lib/wreq_ruby/emulate.rb @@ -58,6 +58,7 @@ class Profile Chrome147 = nil Chrome148 = nil Chrome149 = nil + Chrome150 = nil Edge101 = nil Edge122 = nil diff --git a/src/emulate.rs b/src/emulate.rs index 788202e..661a4d2 100644 --- a/src/emulate.rs +++ b/src/emulate.rs @@ -50,6 +50,7 @@ define_ruby_enum!( Chrome147, Chrome148, Chrome149, + Chrome150, Edge101, Edge122, From 842842ea30e3aea34f3ccea5653dfc4ca23bf825 Mon Sep 17 00:00:00 2001 From: gngpp Date: Wed, 15 Jul 2026 08:24:31 +0800 Subject: [PATCH 02/38] v1.2.5 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 989bb37..0d097e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1535,7 +1535,7 @@ dependencies = [ [[package]] name = "wreq-ruby" -version = "1.2.4" +version = "1.2.5" dependencies = [ "arc-swap", "bytes", diff --git a/Cargo.toml b/Cargo.toml index ab3bfbb..827e789 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ homepage = "https://github.com/SearchApi/wreq-ruby" repository = "https://github.com/SearchApi/wreq-ruby" edition = "2024" rust-version = "1.85" -version = "1.2.4" +version = "1.2.5" [lib] crate-type = ["cdylib"] From 80d46af9c4c0bafd98e438e01784f7dc7f83aea8 Mon Sep 17 00:00:00 2001 From: gngpp Date: Fri, 24 Jul 2026 09:33:59 +0800 Subject: [PATCH 03/38] fix: correct header order and add missing headers in emulation profiles --- crates/wreq-util/src/emulate/macros.rs | 22 ++-- .../src/emulate/profile/chrome/header.rs | 21 +++- .../src/emulate/profile/firefox/header.rs | 16 +++ .../src/emulate/profile/opera/header.rs | 13 +-- crates/wreq-util/tests/client.rs | 104 +++++++++++++++++- 5 files changed, 155 insertions(+), 21 deletions(-) diff --git a/crates/wreq-util/src/emulate/macros.rs b/crates/wreq-util/src/emulate/macros.rs index e763c89..225c7f7 100644 --- a/crates/wreq-util/src/emulate/macros.rs +++ b/crates/wreq-util/src/emulate/macros.rs @@ -95,9 +95,10 @@ macro_rules! header_chrome_sec_ch_ua { macro_rules! header_chrome_sec_fetch { ($headers:expr) => { - $headers.insert("sec-fetch-dest", HeaderValue::from_static("document")); - $headers.insert("sec-fetch-mode", HeaderValue::from_static("navigate")); $headers.insert("sec-fetch-site", HeaderValue::from_static("none")); + $headers.insert("sec-fetch-mode", HeaderValue::from_static("navigate")); + $headers.insert("sec-fetch-user", HeaderValue::from_static("?1")); + $headers.insert("sec-fetch-dest", HeaderValue::from_static("document")); }; } @@ -110,6 +111,11 @@ macro_rules! header_chrome_ua { macro_rules! header_chrome_accept { ($headers:expr) => { $headers.insert(ACCEPT, HeaderValue::from_static("text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")); + }; +} + +macro_rules! header_chrome_accept_encoding { + ($headers:expr) => { #[cfg(feature = "emulation-compression")] $headers.insert( ACCEPT_ENCODING, @@ -118,14 +124,13 @@ macro_rules! header_chrome_accept { $headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.9")); }; (zstd, $headers:expr) => { - $headers.insert(ACCEPT, HeaderValue::from_static("text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")); #[cfg(feature = "emulation-compression")] $headers.insert( ACCEPT_ENCODING, HeaderValue::from_static("gzip, deflate, br, zstd"), ); $headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.9")); - } + }; } macro_rules! header_firefox_sec_fetch { @@ -133,6 +138,7 @@ macro_rules! header_firefox_sec_fetch { $headers.insert("sec-fetch-dest", HeaderValue::from_static("document")); $headers.insert("sec-fetch-mode", HeaderValue::from_static("navigate")); $headers.insert("sec-fetch-site", HeaderValue::from_static("none")); + $headers.insert("sec-fetch-user", HeaderValue::from_static("?1")); }; } @@ -144,12 +150,12 @@ macro_rules! header_firefox_accept { "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", ), ); + $headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.5")); #[cfg(feature = "emulation-compression")] $headers.insert( ACCEPT_ENCODING, HeaderValue::from_static("gzip, deflate, br"), ); - $headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.5")); }; (zstd, $headers:expr) => { $headers.insert( @@ -158,21 +164,17 @@ macro_rules! header_firefox_accept { "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", ), ); + $headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.5")); #[cfg(feature = "emulation-compression")] $headers.insert( ACCEPT_ENCODING, HeaderValue::from_static("gzip, deflate, br, zstd"), ); - $headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.5")); }; } macro_rules! header_firefox_ua { ($headers:expr, $ua:expr) => { - $headers.insert( - HeaderName::from_static("te"), - HeaderValue::from_static("trailers"), - ); $headers.insert(USER_AGENT, HeaderValue::from_static($ua)); }; } diff --git a/crates/wreq-util/src/emulate/profile/chrome/header.rs b/crates/wreq-util/src/emulate/profile/chrome/header.rs index 980b90a..6015b80 100644 --- a/crates/wreq-util/src/emulate/profile/chrome/header.rs +++ b/crates/wreq-util/src/emulate/profile/chrome/header.rs @@ -12,9 +12,14 @@ pub fn header_initializer( emulation_os.platform(), emulation_os.is_mobile() ); + headers.insert( + HeaderName::from_static("upgrade-insecure-requests"), + HeaderValue::from_static("1"), + ); header_chrome_ua!(headers, ua); - header_chrome_sec_fetch!(headers); header_chrome_accept!(headers); + header_chrome_sec_fetch!(headers); + header_chrome_accept_encoding!(headers); headers } @@ -30,9 +35,14 @@ pub fn header_initializer_with_zstd( emulation_os.platform(), emulation_os.is_mobile() ); + headers.insert( + HeaderName::from_static("upgrade-insecure-requests"), + HeaderValue::from_static("1"), + ); header_chrome_ua!(headers, ua); + header_chrome_accept!(headers); header_chrome_sec_fetch!(headers); - header_chrome_accept!(zstd, headers); + header_chrome_accept_encoding!(zstd, headers); headers } @@ -48,9 +58,14 @@ pub fn header_initializer_with_zstd_priority( emulation_os.platform(), emulation_os.is_mobile() ); + headers.insert( + HeaderName::from_static("upgrade-insecure-requests"), + HeaderValue::from_static("1"), + ); header_chrome_ua!(headers, ua); + header_chrome_accept!(headers); header_chrome_sec_fetch!(headers); - header_chrome_accept!(zstd, headers); + header_chrome_accept_encoding!(zstd, headers); headers.insert( HeaderName::from_static("priority"), HeaderValue::from_static("u=0, i"), diff --git a/crates/wreq-util/src/emulate/profile/firefox/header.rs b/crates/wreq-util/src/emulate/profile/firefox/header.rs index 443bf69..10223e0 100644 --- a/crates/wreq-util/src/emulate/profile/firefox/header.rs +++ b/crates/wreq-util/src/emulate/profile/firefox/header.rs @@ -4,7 +4,15 @@ pub fn header_initializer(ua: &'static str) -> HeaderMap { let mut headers = HeaderMap::new(); header_firefox_ua!(headers, ua); header_firefox_accept!(headers); + headers.insert( + HeaderName::from_static("upgrade-insecure-requests"), + HeaderValue::from_static("1"), + ); header_firefox_sec_fetch!(headers); + headers.insert( + HeaderName::from_static("te"), + HeaderValue::from_static("trailers"), + ); headers } @@ -12,10 +20,18 @@ pub fn header_initializer_with_zstd(ua: &'static str) -> HeaderMap { let mut headers = HeaderMap::new(); header_firefox_ua!(headers, ua); header_firefox_accept!(zstd, headers); + headers.insert( + HeaderName::from_static("upgrade-insecure-requests"), + HeaderValue::from_static("1"), + ); header_firefox_sec_fetch!(headers); headers.insert( HeaderName::from_static("priority"), HeaderValue::from_static("u=0, i"), ); + headers.insert( + HeaderName::from_static("te"), + HeaderValue::from_static("trailers"), + ); headers } diff --git a/crates/wreq-util/src/emulate/profile/opera/header.rs b/crates/wreq-util/src/emulate/profile/opera/header.rs index 91afa1e..6a7a77f 100644 --- a/crates/wreq-util/src/emulate/profile/opera/header.rs +++ b/crates/wreq-util/src/emulate/profile/opera/header.rs @@ -13,15 +13,14 @@ pub fn header_initializer_with_zstd_priority( emulation_os.platform(), emulation_os.is_mobile() ); - header_chrome_ua!(headers, ua); - - headers.insert(ACCEPT, HeaderValue::from_static("text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")); - #[cfg(feature = "emulation-compression")] headers.insert( - ACCEPT_ENCODING, - HeaderValue::from_static("gzip, deflate, br, zstd"), + HeaderName::from_static("upgrade-insecure-requests"), + HeaderValue::from_static("1"), ); - headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.9")); + header_chrome_ua!(headers, ua); + header_chrome_accept!(headers); + header_chrome_sec_fetch!(headers); + header_chrome_accept_encoding!(zstd, headers); headers.insert( HeaderName::from_static("priority"), HeaderValue::from_static("u=0, i"), diff --git a/crates/wreq-util/tests/client.rs b/crates/wreq-util/tests/client.rs index 5af9ea5..9dc9f06 100644 --- a/crates/wreq-util/tests/client.rs +++ b/crates/wreq-util/tests/client.rs @@ -1,9 +1,96 @@ #![cfg(not(target_arch = "wasm32"))] mod support; +use std::future::Future; + use support::server; +use tokio::{io::AsyncWriteExt, net::TcpStream}; use wreq::Client; -use wreq_util::{Emulation, Platform}; +use wreq_util::{Emulation, Platform, Profile}; + +const CHROMIUM_HEADER_ORDER: &[&str] = &[ + "sec-ch-ua", + "sec-ch-ua-mobile", + "sec-ch-ua-platform", + "upgrade-insecure-requests", + "user-agent", + "accept", + "sec-fetch-site", + "sec-fetch-mode", + "sec-fetch-user", + "sec-fetch-dest", + #[cfg(feature = "emulation-compression")] + "accept-encoding", + "accept-language", + "priority", +]; + +const FIREFOX_HEADER_ORDER: &[&str] = &[ + "user-agent", + "accept", + "accept-language", + #[cfg(feature = "emulation-compression")] + "accept-encoding", + "upgrade-insecure-requests", + "sec-fetch-dest", + "sec-fetch-mode", + "sec-fetch-site", + "sec-fetch-user", + "te", +]; + +fn check_header_order<'a>( + request: &'a [u8], + stream: &'a mut TcpStream, + expected: &'static [&'static str], +) -> Box + Send + 'a> { + Box::new(async move { + let request = std::str::from_utf8(request) + .expect("request should be valid UTF-8") + .to_ascii_lowercase(); + let mut previous = None; + + for name in expected { + let marker = format!("\r\n{name}:"); + let position = request + .find(&marker) + .unwrap_or_else(|| panic!("missing `{name}` header:\n{request}")); + + if let Some(previous) = previous { + assert!( + position > previous, + "`{name}` header is out of order:\n{request}" + ); + } + + previous = Some(position); + } + + assert!(request.contains("\r\nupgrade-insecure-requests: 1\r\n")); + assert!(request.contains("\r\nsec-fetch-user: ?1\r\n")); + + stream + .write_all(b"HTTP/1.1 200 OK\r\ncontent-length: 0\r\nconnection: close\r\n\r\n") + .await + .expect("response"); + }) +} + +async fn assert_emulation_headers(profile: Profile, expected: &'static [&'static str]) { + let server = server::low_level_with_response(move |request, stream| { + check_header_order(request, stream, expected) + }); + let response = Client::builder() + .emulation(profile) + .build() + .expect("client") + .get(format!("http://{}/headers", server.addr())) + .send() + .await + .expect("request"); + + assert_eq!(response.status(), wreq::StatusCode::OK); +} #[tokio::test] async fn test_client_emulation_device() { @@ -49,3 +136,18 @@ async fn test_client_emulation_device() { assert_eq!(res.status(), wreq::StatusCode::OK); } + +#[tokio::test] +async fn test_chrome_default_header_order() { + assert_emulation_headers(Emulation::Chrome133, CHROMIUM_HEADER_ORDER).await; +} + +#[tokio::test] +async fn test_firefox_default_header_order() { + assert_emulation_headers(Emulation::Firefox109, FIREFOX_HEADER_ORDER).await; +} + +#[tokio::test] +async fn test_opera_default_header_order() { + assert_emulation_headers(Emulation::Opera116, CHROMIUM_HEADER_ORDER).await; +} From a197e233293190ad14df565a2614f97b59c38860 Mon Sep 17 00:00:00 2001 From: gngpp Date: Fri, 24 Jul 2026 09:34:22 +0800 Subject: [PATCH 04/38] v1.2.6 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 84c221d..42150de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1540,7 +1540,7 @@ dependencies = [ [[package]] name = "wreq-ruby" -version = "1.2.5" +version = "1.2.6" dependencies = [ "arc-swap", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 91fdf9b..1adf974 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ homepage = "https://github.com/SearchApi/wreq-ruby" repository = "https://github.com/SearchApi/wreq-ruby" edition = "2024" rust-version = "1.85" -version = "1.2.5" +version = "1.2.6" [lib] crate-type = ["cdylib"] From a15a1d9da0915cd80d42416af3a51a8833ef316b Mon Sep 17 00:00:00 2001 From: gngpp Date: Fri, 24 Jul 2026 09:47:40 +0800 Subject: [PATCH 05/38] fix(ci): remove stale serde_magnus clean target --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 26940d5..b812658 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -83,7 +83,7 @@ jobs: env: RB_SYS_CARGO_PROFILE: release run: | - cargo clean -p rb-sys -p magnus -p serde_magnus -p wreq-ruby --release 2>/dev/null || true + cargo clean -p rb-sys -p magnus -p wreq-ruby --release 2>/dev/null || true bundle exec rake compile mkdir -p lib/wreq_ruby/3.3 cp lib/wreq_ruby/wreq_ruby.bundle lib/wreq_ruby/3.3/ @@ -97,7 +97,7 @@ jobs: env: RB_SYS_CARGO_PROFILE: release run: | - cargo clean -p rb-sys -p magnus -p serde_magnus -p wreq-ruby --release + cargo clean -p rb-sys -p magnus -p wreq-ruby --release bundle exec rake compile mkdir -p lib/wreq_ruby/3.4 cp lib/wreq_ruby/wreq_ruby.bundle lib/wreq_ruby/3.4/ @@ -111,7 +111,7 @@ jobs: env: RB_SYS_CARGO_PROFILE: release run: | - cargo clean -p rb-sys -p magnus -p serde_magnus -p wreq-ruby --release + cargo clean -p rb-sys -p magnus -p wreq-ruby --release bundle exec rake compile mkdir -p lib/wreq_ruby/4.0 cp lib/wreq_ruby/wreq_ruby.bundle lib/wreq_ruby/4.0/ From c2b30108c482105677613df0344137bd773780e5 Mon Sep 17 00:00:00 2001 From: gngpp Date: Sat, 25 Jul 2026 01:09:05 +0800 Subject: [PATCH 06/38] chore(wreq-util): sync upstream changes Sync with 0x676e67/wreq-util@501b142 while retaining the local Chrome 150 profile and header-order coverage. --- crates/wreq-util/README.md | 2 +- crates/wreq-util/examples/emulate.rs | 6 +++--- crates/wreq-util/src/emulate/macros.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/wreq-util/README.md b/crates/wreq-util/README.md index 7d32a28..740c801 100644 --- a/crates/wreq-util/README.md +++ b/crates/wreq-util/README.md @@ -43,7 +43,7 @@ async fn main() -> wreq::Result<()> { .build()?; // Use the API you're already familiar with - let resp = client.get("https://www.google.com").send().await?; + let resp = client.get("https://pingly.us.kg/api/all").send().await?; println!("{}", resp.text().await?); Ok(()) } diff --git a/crates/wreq-util/examples/emulate.rs b/crates/wreq-util/examples/emulate.rs index 062d175..1d9ace3 100644 --- a/crates/wreq-util/examples/emulate.rs +++ b/crates/wreq-util/examples/emulate.rs @@ -3,7 +3,7 @@ use wreq_util::{Emulation, Platform, Profile}; #[tokio::main] async fn main() -> Result<(), wreq::Error> { // Example 1: Basic emulation - Safari26 - let text = wreq::get("https://tls.browserleaks.com/") + let text = wreq::get("https://pingly.us.kg/api/all") .emulation(Emulation::Safari26) .send() .await? @@ -12,7 +12,7 @@ async fn main() -> Result<(), wreq::Error> { println!("{}\n", text); // Example 2: Advanced emulation with options - OkHttp5 - let text = wreq::get("https://tls.peet.ws/api/all") + let text = wreq::get("https://pingly.us.kg/api/all") .emulation( Emulation::builder() .profile(Profile::OkHttp5) @@ -27,7 +27,7 @@ async fn main() -> Result<(), wreq::Error> { println!("{}\n", text); // Example 3: Random device emulation - let text = wreq::get("https://tls.peet.ws/api/all") + let text = wreq::get("https://pingly.us.kg/api/all") .emulation(Emulation::random()) .send() .await? diff --git a/crates/wreq-util/src/emulate/macros.rs b/crates/wreq-util/src/emulate/macros.rs index 225c7f7..9fd9a74 100644 --- a/crates/wreq-util/src/emulate/macros.rs +++ b/crates/wreq-util/src/emulate/macros.rs @@ -110,7 +110,7 @@ macro_rules! header_chrome_ua { macro_rules! header_chrome_accept { ($headers:expr) => { - $headers.insert(ACCEPT, HeaderValue::from_static("text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")); + $headers.insert(ACCEPT, HeaderValue::from_static("text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7")); }; } From 11adf8bc24158d14e00175351ca1a9498c8624ea Mon Sep 17 00:00:00 2001 From: gngpp Date: Sat, 25 Jul 2026 01:42:42 +0800 Subject: [PATCH 07/38] v1.2.7 --- Cargo.lock | 223 ++++++++++++++++++++++++++++------------------------- Cargo.toml | 4 +- 2 files changed, 118 insertions(+), 109 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 42150de..7e7641b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,14 +80,14 @@ dependencies = [ "regex", "rustc-hash", "shlex 1.3.0", - "syn", + "syn 2.0.119", ] [[package]] name = "bitflags" -version = "2.13.0" +version = "2.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" +checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da" [[package]] name = "brotli" @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "btls" version = "0.5.6" -source = "git+https://github.com/0x676e67/btls?branch=demo%2Fmerge-upstream-boring-20260616#397dfae69044c0c19ba3028e8b25f8481fbc0f00" +source = "git+https://github.com/0x676e67/btls?branch=demo%2Fmerge-upstream-boring-20260616#3100f47f98d45765a55ce0b9f8d3a281109cb6fe" dependencies = [ "bitflags", "btls-sys", @@ -125,7 +125,7 @@ dependencies = [ [[package]] name = "btls-sys" version = "0.5.6" -source = "git+https://github.com/0x676e67/btls?branch=demo%2Fmerge-upstream-boring-20260616#397dfae69044c0c19ba3028e8b25f8481fbc0f00" +source = "git+https://github.com/0x676e67/btls?branch=demo%2Fmerge-upstream-boring-20260616#3100f47f98d45765a55ce0b9f8d3a281109cb6fe" dependencies = [ "bindgen", "cmake", @@ -141,9 +141,9 @@ checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" [[package]] name = "cc" -version = "1.2.66" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5d6cac793997bd970000024b2934968efe83b382de4fdcf4fcb46b6ee4ad996" +checksum = "5add81bb678e6cb321aff7fa0dc7689ad82b112dbc032cea19f91d6b8e3582b9" dependencies = [ "find-msvc-tools", "jobserver", @@ -246,9 +246,6 @@ name = "deranged" version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" -dependencies = [ - "powerfmt", -] [[package]] name = "displaydoc" @@ -258,7 +255,7 @@ checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -332,13 +329,13 @@ dependencies = [ [[package]] name = "foreign-types-macros" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" +checksum = "ea5190182e6915eb873ddbc16e23b711b6eb1f9c00a0d0a3a91b5f6228475225" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.3", ] [[package]] @@ -374,36 +371,36 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +checksum = "262590f4fe6afeb0bc83be1daa64e52657fe185690a958af7f3ad0e92085c5ae" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" +checksum = "2cd50c473c80f6d7c3670a752354b8e569b1a7cbfdc0419ec88e5edad85e0dc7" [[package]] name = "futures-sink" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" +checksum = "e34418ac499d6305c2fb5ad0ed2f6ac998c5f8ca209b4510f7f94242c647e307" [[package]] name = "futures-task" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" +checksum = "b231ed28831efb4a61a08580c4bc233ec56bc009f4cd8f52da2c3cb97df0c109" [[package]] name = "futures-util" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +checksum = "a77a90a256fce34da66415271e30f94ee91c57b04b8a2c042d9cf3220179deaa" dependencies = [ "futures-core", "futures-task", @@ -424,9 +421,9 @@ dependencies = [ [[package]] name = "glob" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" +checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" [[package]] name = "hashbrown" @@ -451,9 +448,9 @@ dependencies = [ [[package]] name = "http-body" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c" dependencies = [ "bytes", "http", @@ -461,9 +458,9 @@ dependencies = [ [[package]] name = "http-body-util" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +checksum = "e9f41fd6a08e4d4ec69df65976da761afd5ad5e58a9d4acb46bd1c953a9e3ff2" dependencies = [ "bytes", "futures-core", @@ -499,12 +496,13 @@ checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" [[package]] name = "icu_collections" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c" dependencies = [ "displaydoc", "potential_utf", + "utf8_iter", "yoke", "zerofrom", "zerovec", @@ -512,9 +510,9 @@ dependencies = [ [[package]] name = "icu_locale_core" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29" dependencies = [ "displaydoc", "litemap", @@ -525,9 +523,9 @@ dependencies = [ [[package]] name = "icu_normalizer" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4" dependencies = [ "icu_collections", "icu_normalizer_data", @@ -539,15 +537,15 @@ dependencies = [ [[package]] name = "icu_normalizer_data" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" +checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38" [[package]] name = "icu_properties" -version = "2.1.2" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de" dependencies = [ "icu_collections", "icu_locale_core", @@ -559,15 +557,15 @@ dependencies = [ [[package]] name = "icu_properties_data" -version = "2.1.2" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" +checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14" [[package]] name = "icu_provider" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421" dependencies = [ "displaydoc", "icu_locale_core", @@ -591,9 +589,9 @@ dependencies = [ [[package]] name = "idna_adapter" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" dependencies = [ "icu_normalizer", "icu_properties", @@ -650,9 +648,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.186" +version = "0.2.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" +checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" [[package]] name = "libloading" @@ -681,9 +679,9 @@ dependencies = [ [[package]] name = "lru" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a860605968fce16869fd239cf4237a82f3ac470723415db603b0e8b6c8d4fb9" +checksum = "0b6180140927ee907000b0aa540091f6ea512ead4447c92b8fc35bc72788a5a6" dependencies = [ "hashbrown", ] @@ -709,7 +707,7 @@ checksum = "47607461fd8e1513cb4f2076c197d8092d921a1ea75bd08af97398f593751892" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -742,9 +740,9 @@ dependencies = [ [[package]] name = "mio" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02bd0af71c67b473010cbbc60715ee815645a4dc942899111f494b4b737d6fda" +checksum = "30d65c71f1ce40ab09135ce117d742b9f8a19ff91a41a8b57ed50bc2de59c427" dependencies = [ "libc", "wasi", @@ -763,9 +761,9 @@ dependencies = [ [[package]] name = "num-conv" -version = "0.1.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" [[package]] name = "openssl-macros" @@ -775,7 +773,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -836,18 +834,18 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "proc-macro2" -version = "1.0.106" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.46" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" dependencies = [ "proc-macro2", ] @@ -879,7 +877,7 @@ dependencies = [ "quote", "regex", "shell-words", - "syn", + "syn 2.0.119", ] [[package]] @@ -899,9 +897,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0e75113e14dc5acb068cd0786884f214f1312650a3d36d269f5c4f3cdee8a2" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" dependencies = [ "aho-corasick", "memchr", @@ -911,9 +909,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.15" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f388202e4b80542a0921078cc23b6333bcf1409c1e3f86404cae4766a6131db" +checksum = "8fcfdb36bda0c880c5931cdc7a2bcdc8ba4556847b9d912bca70bc94708711ad" dependencies = [ "aho-corasick", "memchr", @@ -934,9 +932,9 @@ checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" [[package]] name = "rustls-pki-types" -version = "1.15.0" +version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "764899a24af3980067ee14bc143654f297b22eaebfe3c7b6b211920a5a59b046" +checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" [[package]] name = "rustversion" @@ -958,9 +956,9 @@ checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc" [[package]] name = "serde" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" dependencies = [ "serde_core", "serde_derive", @@ -968,22 +966,22 @@ dependencies = [ [[package]] name = "serde_core" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.3", ] [[package]] @@ -1011,9 +1009,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.150" +version = "1.0.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" +checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" dependencies = [ "indexmap", "itoa", @@ -1064,9 +1062,9 @@ dependencies = [ [[package]] name = "simd-adler32" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214" +checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" [[package]] name = "slab" @@ -1082,9 +1080,9 @@ checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" [[package]] name = "socket2" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52d1cfed4120b4d927bf7c0f86d2087a4a7d6027c906d9f9d525a80573b9be51" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" dependencies = [ "libc", "windows-sys", @@ -1098,9 +1096,20 @@ checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "syn" -version = "2.0.118" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" +checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3" dependencies = [ "proc-macro2", "quote", @@ -1124,7 +1133,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -1165,17 +1174,16 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] name = "time" -version = "0.3.45" +version = "0.3.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9e442fc33d7fdb45aa9bfeb312c095964abdf596f7567261062b2a7107aaabd" +checksum = "3e1d5e639ff6bab73cb6885cc7e7b1de96c3f32c68ec55f3952614bec1092244" dependencies = [ "deranged", - "itoa", "num-conv", "powerfmt", "serde_core", @@ -1185,15 +1193,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.7" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b36ee98fd31ec7426d599183e8fe26932a8dc1fb76ddb6214d05493377d34ca" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" [[package]] name = "time-macros" -version = "0.2.25" +version = "0.2.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e552d1249bf61ac2a52db88179fd0673def1e1ad8243a00d9ec9ed71fee3dd" +checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85" dependencies = [ "num-conv", "time-core", @@ -1211,9 +1219,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.52.3" +version = "1.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe" +checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed" dependencies = [ "bytes", "libc", @@ -1238,13 +1246,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" +checksum = "6328af13490e73a9b4694030fafd93f8c8c6a9dede33e821c3fc63eddf8042ba" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -1261,13 +1269,14 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.18" +version = "0.7.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" +checksum = "494815d09bf52b5548659851081238f0ca39ff638363907596da739561c62c52" dependencies = [ "bytes", "futures-core", "futures-sink", + "libc", "pin-project-lite", "tokio", ] @@ -1342,7 +1351,7 @@ checksum = "076a02dc54dd46795c2e9c8282ed40bcfb1e22747e955de9389a1de28190fb26" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -1392,9 +1401,9 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "webpki-root-certs" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d46a5a140e6f7afeccd8eae97eff335163939eac8b929834875168b29b3d267" +checksum = "b96554aa2acc8ccdb7e1c9a58a7a68dd5d13bccc69cd124cb09406db612a1c9b" dependencies = [ "rustls-pki-types", ] @@ -1540,7 +1549,7 @@ dependencies = [ [[package]] name = "wreq-ruby" -version = "1.2.6" +version = "1.2.7" dependencies = [ "arc-swap", "bytes", @@ -1597,7 +1606,7 @@ checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", "synstructure", ] @@ -1618,7 +1627,7 @@ checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", "synstructure", ] @@ -1652,14 +1661,14 @@ checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] name = "zmij" -version = "1.0.21" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" [[package]] name = "zstd" diff --git a/Cargo.toml b/Cargo.toml index d98ae36..79606b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,8 +5,8 @@ authors = ["SearchApi "] homepage = "https://github.com/SearchApi/wreq-ruby" repository = "https://github.com/SearchApi/wreq-ruby" edition = "2024" -version = "1.2.6" -rust-version = "1.97" +version = "1.2.7" +rust-version = "1.95" [lib] crate-type = ["cdylib"] From 784fe4ca515bdfa46dfdd4a045685e7031811176 Mon Sep 17 00:00:00 2001 From: gngpp Date: Sat, 25 Jul 2026 16:18:17 +0800 Subject: [PATCH 08/38] v1.2.8 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7e7641b..26a2855 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1549,7 +1549,7 @@ dependencies = [ [[package]] name = "wreq-ruby" -version = "1.2.7" +version = "1.2.8" dependencies = [ "arc-swap", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 79606b2..475b552 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = ["SearchApi "] homepage = "https://github.com/SearchApi/wreq-ruby" repository = "https://github.com/SearchApi/wreq-ruby" edition = "2024" -version = "1.2.7" +version = "1.2.8" rust-version = "1.95" [lib] From 9047284d226c31e768d4e18060d510f30371a4ef Mon Sep 17 00:00:00 2001 From: gngpp Date: Sun, 26 Jul 2026 13:14:39 +0800 Subject: [PATCH 09/38] sync btls upstream --- .gitignore | 1 + Cargo.lock | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 8b30577..3827505 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ /pkg/ /tmp/ /target/ +/btls-extension-order-validation/ *.bundle *.so Gemfile.lock diff --git a/Cargo.lock b/Cargo.lock index 26a2855..66f060e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "btls" version = "0.5.6" -source = "git+https://github.com/0x676e67/btls?branch=demo%2Fmerge-upstream-boring-20260616#3100f47f98d45765a55ce0b9f8d3a281109cb6fe" +source = "git+https://github.com/0x676e67/btls?branch=demo%2Fmerge-upstream-boring-20260616#67bc8c3547acabe5aa97f8e4529813926f2f7d4d" dependencies = [ "bitflags", "btls-sys", @@ -125,7 +125,7 @@ dependencies = [ [[package]] name = "btls-sys" version = "0.5.6" -source = "git+https://github.com/0x676e67/btls?branch=demo%2Fmerge-upstream-boring-20260616#3100f47f98d45765a55ce0b9f8d3a281109cb6fe" +source = "git+https://github.com/0x676e67/btls?branch=demo%2Fmerge-upstream-boring-20260616#67bc8c3547acabe5aa97f8e4529813926f2f7d4d" dependencies = [ "bindgen", "cmake", @@ -260,9 +260,9 @@ dependencies = [ [[package]] name = "either" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e" +checksum = "9e5e8f6c15a24b9a3ee5efec809ccd006d3b30e8b3bb63c39af737c7f87daa1d" [[package]] name = "encoding_rs" From 1f4178cdffab02d09e66eeeec2ddaad326e0cf6b Mon Sep 17 00:00:00 2001 From: 0x676e67 Date: Sun, 26 Jul 2026 13:16:05 +0800 Subject: [PATCH 10/38] build(deps): update tokio dependency version to 1.53.1 (#148) --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 475b552..30164df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ name = "wreq_ruby" [dependencies] magnus = { version = "0.8.2", features = ["bytes"] } rb-sys = { version = "0.9.128", default-features = false } -tokio = { version = "1.52.3", features = ["full"] } +tokio = { version = "1.53.1", features = ["full"] } wreq = { version = "6.0.0-rc", features = [ "query", "form", @@ -64,4 +64,4 @@ strip = true [patch.crates-io] btls = { git = "https://github.com/0x676e67/btls", branch = "demo/merge-upstream-boring-20260616" } btls-sys = { git = "https://github.com/0x676e67/btls", branch = "demo/merge-upstream-boring-20260616" } -wreq-util = { path = "crates/wreq-util" } \ No newline at end of file +wreq-util = { path = "crates/wreq-util" } From 909d92514f8ff286fa95f808bedf357edc9f5e5b Mon Sep 17 00:00:00 2001 From: gngpp Date: Sun, 26 Jul 2026 14:12:18 +0800 Subject: [PATCH 11/38] v1.2.9 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 66f060e..801b4f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1549,7 +1549,7 @@ dependencies = [ [[package]] name = "wreq-ruby" -version = "1.2.8" +version = "1.2.9" dependencies = [ "arc-swap", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 30164df..7b80d66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = ["SearchApi "] homepage = "https://github.com/SearchApi/wreq-ruby" repository = "https://github.com/SearchApi/wreq-ruby" edition = "2024" -version = "1.2.8" +version = "1.2.9" rust-version = "1.95" [lib] From 1a022133f0d3f4d6de2669ea7116e1e0812d1a18 Mon Sep 17 00:00:00 2001 From: gngpp Date: Tue, 4 Aug 2026 13:17:15 +0800 Subject: [PATCH 12/38] feat(emulate): add Chrome 151 profile --- README.md | 2 +- crates/wreq-util/CHANGELOG.md | 4 +++ crates/wreq-util/src/emulate.rs | 1 + .../wreq-util/src/emulate/profile/chrome.rs | 33 +++++++++++++++++ crates/wreq-util/tests/client.rs | 36 ++++++++----------- crates/wreq-util/tests/emulate_chrome.rs | 7 ++++ lib/wreq_ruby/emulate.rb | 1 + src/emulate.rs | 1 + test/emulation_test.rb | 7 ++++ 9 files changed, 70 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 422d8fb..adf881b 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ Most browser device models share identical TLS and HTTP/2 configurations, differ | **Browser** | **Versions** | | ----------- | ------------ | - | **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135`, `Chrome136`, `Chrome137`, `Chrome138`, `Chrome139`, `Chrome140`, `Chrome141`, `Chrome142`, `Chrome143`, `Chrome144`, `Chrome145`, `Chrome146`, `Chrome147`, `Chrome148`, `Chrome149` | + | **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135`, `Chrome136`, `Chrome137`, `Chrome138`, `Chrome139`, `Chrome140`, `Chrome141`, `Chrome142`, `Chrome143`, `Chrome144`, `Chrome145`, `Chrome146`, `Chrome147`, `Chrome148`, `Chrome149`, `Chrome150`, `Chrome151` | | **Edge** | `Edge101`, `Edge122`, `Edge127`, `Edge131`, `Edge134`, `Edge135`, `Edge136`, `Edge137`, `Edge138`, `Edge139`, `Edge140`, `Edge141`, `Edge142`, `Edge143`, `Edge144`, `Edge145`, `Edge146`, `Edge147`, `Edge148` | | **Firefox** | `Firefox109`, `Firefox117`, `Firefox128`, `Firefox133`, `Firefox135`, `FirefoxPrivate135`, `FirefoxAndroid135`, `Firefox136`, `FirefoxPrivate136`, `Firefox139`, `Firefox142`, `Firefox143`, `Firefox144`, `Firefox145`, `Firefox146`, `Firefox147`, `Firefox148`, `Firefox149`, `Firefox150`, `Firefox151` | | **Safari** | `Safari15_3`, `Safari15_5`, `Safari15_6_1`, `Safari16`, `Safari16_5`, `Safari17_0`, `Safari17_2_1`, `Safari17_4_1`, `Safari17_5`, `Safari17_6`, `Safari18`, `Safari18_2`, `Safari18_3`, `Safari18_3_1`, `Safari18_5`, `Safari26`, `Safari26_1`, `Safari26_2`, `SafariIos16_5`, `SafariIos17_2`, `SafariIos17_4_1`, `SafariIos18_1_1`, `SafariIos26`, `SafariIos26_2`, `SafariIPad18`, `SafariIPad26`, `SafariIpad26_2` | diff --git a/crates/wreq-util/CHANGELOG.md b/crates/wreq-util/CHANGELOG.md index 0d49056..dd6e58e 100644 --- a/crates/wreq-util/CHANGELOG.md +++ b/crates/wreq-util/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- *(emulate)* Add Chrome 151 profile. + ## [3.0.0-rc.14](https://github.com/0x676e67/wreq-util/compare/v3.0.0-rc.13...v3.0.0-rc.14) - 2026-07-04 ### Fixed diff --git a/crates/wreq-util/src/emulate.rs b/crates/wreq-util/src/emulate.rs index 33a1c58..4ce4ee7 100644 --- a/crates/wreq-util/src/emulate.rs +++ b/crates/wreq-util/src/emulate.rs @@ -61,6 +61,7 @@ define_enum!( Chrome148 => ("chrome_148", v148::emulation), Chrome149 => ("chrome_149", v149::emulation), Chrome150 => ("chrome_150", v150::emulation), + Chrome151 => ("chrome_151", v151::emulation), // Edge versions Edge101 => ("edge_101", edge101::emulation), diff --git a/crates/wreq-util/src/emulate/profile/chrome.rs b/crates/wreq-util/src/emulate/profile/chrome.rs index b85424f..0f8a2b5 100644 --- a/crates/wreq-util/src/emulate/profile/chrome.rs +++ b/crates/wreq-util/src/emulate/profile/chrome.rs @@ -1829,6 +1829,39 @@ mod_generator!( ] ); +mod_generator!( + v151, + v150::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Not=A?Brand";v="99", "Google Chrome";v="151", "Chromium";v="151""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Not=A?Brand";v="99", "Google Chrome";v="151", "Chromium";v="151""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Not=A?Brand";v="99", "Google Chrome";v="151", "Chromium";v="151""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Not=A?Brand";v="99", "Google Chrome";v="151", "Chromium";v="151""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Not=A?Brand";v="99", "Google Chrome";v="151", "Chromium";v="151""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/151.0.7922.43 Mobile/15E148 Safari/604.1" + ) + ] +); + mod_generator!( edge143, v132::build_emulation, diff --git a/crates/wreq-util/tests/client.rs b/crates/wreq-util/tests/client.rs index 9dc9f06..3881397 100644 --- a/crates/wreq-util/tests/client.rs +++ b/crates/wreq-util/tests/client.rs @@ -95,26 +95,20 @@ async fn assert_emulation_headers(profile: Profile, expected: &'static [&'static #[tokio::test] async fn test_client_emulation_device() { let server = server::http(move |req| async move { - for (name, value) in req.headers() { - if name == "user-agent" { - assert_eq!( - value, - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36" - ); - } - if name == "sec-ch-ua" { - assert_eq!( - value, - r#""Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133""# - ); - } - if name == "sec-ch-ua-mobile" { - assert_eq!(value, "?0"); - } - if name == "sec-ch-ua-platform" { - assert_eq!(value, "\"Linux\""); - } - } + let header = |name| req.headers().get(name).and_then(|value| value.to_str().ok()); + + assert_eq!( + header("user-agent"), + Some( + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36" + ) + ); + assert_eq!( + header("sec-ch-ua"), + Some(r#""Not=A?Brand";v="99", "Google Chrome";v="151", "Chromium";v="151""#) + ); + assert_eq!(header("sec-ch-ua-mobile"), Some("?0")); + assert_eq!(header("sec-ch-ua-platform"), Some("\"Linux\"")); http::Response::default() }); @@ -122,7 +116,7 @@ async fn test_client_emulation_device() { let res = Client::builder() .emulation( Emulation::builder() - .profile(Emulation::Chrome133) + .profile(Emulation::Chrome151) .platform(Platform::Linux) .http2(true) .build(), diff --git a/crates/wreq-util/tests/emulate_chrome.rs b/crates/wreq-util/tests/emulate_chrome.rs index 4484f63..9c44439 100644 --- a/crates/wreq-util/tests/emulate_chrome.rs +++ b/crates/wreq-util/tests/emulate_chrome.rs @@ -268,3 +268,10 @@ test_emulation!( ["t13d1516h2_8daaf6152771_d8a2da3f94cd"], "52d84b11737d980aef856699f885ca86" ); + +test_emulation!( + test_chrome151, + Emulation::Chrome151, + ["t13d1516h2_8daaf6152771_806a8c22fdea"], + "52d84b11737d980aef856699f885ca86" +); diff --git a/lib/wreq_ruby/emulate.rb b/lib/wreq_ruby/emulate.rb index 61cf54f..b7e76fb 100644 --- a/lib/wreq_ruby/emulate.rb +++ b/lib/wreq_ruby/emulate.rb @@ -62,6 +62,7 @@ class Profile Chrome148 = nil Chrome149 = nil Chrome150 = nil + Chrome151 = nil Edge101 = nil Edge122 = nil diff --git a/src/emulate.rs b/src/emulate.rs index ccd6fa8..5085ec7 100644 --- a/src/emulate.rs +++ b/src/emulate.rs @@ -87,6 +87,7 @@ define_ruby_enum!( Chrome148, Chrome149, Chrome150, + Chrome151, Edge101, Edge122, diff --git a/test/emulation_test.rb b/test/emulation_test.rb index 322edb7..eba774a 100644 --- a/test/emulation_test.rb +++ b/test/emulation_test.rb @@ -11,6 +11,13 @@ def test_all_emulation_device_constants_are_non_nil end end + def test_chrome151_profile_is_available + profile = Wreq::Profile::Chrome151 + + assert_equal "Chrome151", profile.to_s + assert_instance_of Wreq::Emulation, Wreq::Emulation.new(profile: profile) + end + def test_all_emulation_os_constants_are_non_nil Wreq::Platform.constants.each do |name| const = Wreq::Platform.const_get(name) From 446858fb8e80c85791edccaf6030d2e6fa006f43 Mon Sep 17 00:00:00 2001 From: gngpp Date: Tue, 4 Aug 2026 13:18:42 +0800 Subject: [PATCH 13/38] v1.2.10 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 801b4f9..a7ab7da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1549,7 +1549,7 @@ dependencies = [ [[package]] name = "wreq-ruby" -version = "1.2.9" +version = "1.2.10" dependencies = [ "arc-swap", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 7b80d66..7684533 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = ["SearchApi "] homepage = "https://github.com/SearchApi/wreq-ruby" repository = "https://github.com/SearchApi/wreq-ruby" edition = "2024" -version = "1.2.9" +version = "1.2.10" rust-version = "1.95" [lib] From 268ae55a5c8ffa93670785f2be585495edf9a868 Mon Sep 17 00:00:00 2001 From: gngpp Date: Thu, 6 Aug 2026 07:46:30 +0800 Subject: [PATCH 14/38] build(deps): bump wreq --- Cargo.lock | 3 +-- Cargo.toml | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a7ab7da..b0e3ab3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1477,8 +1477,7 @@ dependencies = [ [[package]] name = "wreq" version = "6.0.0-rc.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f0eba5f5814a94e5f1a99156f187133464e525b66bdbc69a9627d46530af2e1" +source = "git+https://github.com/0x676e67/wreq?rev=5159279f43e5e61e24643f7639c8f5a74f9ec380#5159279f43e5e61e24643f7639c8f5a74f9ec380" dependencies = [ "btls", "btls-sys", diff --git a/Cargo.toml b/Cargo.toml index 7684533..cd26024 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,4 +64,5 @@ strip = true [patch.crates-io] btls = { git = "https://github.com/0x676e67/btls", branch = "demo/merge-upstream-boring-20260616" } btls-sys = { git = "https://github.com/0x676e67/btls", branch = "demo/merge-upstream-boring-20260616" } +wreq = { git = "https://github.com/0x676e67/wreq", rev = "5159279f43e5e61e24643f7639c8f5a74f9ec380" } wreq-util = { path = "crates/wreq-util" } From bb27f5d680570ebcbf898bda052fbead20f345f1 Mon Sep 17 00:00:00 2001 From: gngpp Date: Thu, 6 Aug 2026 07:46:49 +0800 Subject: [PATCH 15/38] v1.2.11 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b0e3ab3..cf566ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1548,7 +1548,7 @@ dependencies = [ [[package]] name = "wreq-ruby" -version = "1.2.10" +version = "1.2.11" dependencies = [ "arc-swap", "bytes", diff --git a/Cargo.toml b/Cargo.toml index cd26024..0751cc6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = ["SearchApi "] homepage = "https://github.com/SearchApi/wreq-ruby" repository = "https://github.com/SearchApi/wreq-ruby" edition = "2024" -version = "1.2.10" +version = "1.2.11" rust-version = "1.95" [lib] From cc1a92051d6f22b4632ef755227a9e4477f5a6f7 Mon Sep 17 00:00:00 2001 From: gngpp Date: Sat, 15 Aug 2026 16:04:40 +0800 Subject: [PATCH 16/38] update headers stream dependency --- crates/wreq-util/src/emulate/profile/chrome/http2.rs | 2 +- crates/wreq-util/src/emulate/profile/firefox/http2.rs | 4 ++-- crates/wreq-util/src/emulate/profile/opera/http2.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/wreq-util/src/emulate/profile/chrome/http2.rs b/crates/wreq-util/src/emulate/profile/chrome/http2.rs index f2e17b7..841c8a4 100644 --- a/crates/wreq-util/src/emulate/profile/chrome/http2.rs +++ b/crates/wreq-util/src/emulate/profile/chrome/http2.rs @@ -1,6 +1,6 @@ macro_rules! headers_stream_dependency { () => { - StreamDependency::new(StreamId::zero(), 219, true) + StreamDependency::new(StreamId::zero(), 255, true) }; } diff --git a/crates/wreq-util/src/emulate/profile/firefox/http2.rs b/crates/wreq-util/src/emulate/profile/firefox/http2.rs index 7077c90..b7f18f7 100644 --- a/crates/wreq-util/src/emulate/profile/firefox/http2.rs +++ b/crates/wreq-util/src/emulate/profile/firefox/http2.rs @@ -1,9 +1,9 @@ macro_rules! headers_stream_dependency { (1) => { - StreamDependency::new(StreamId::zero(), 21, false) + StreamDependency::new(StreamId::zero(), 41, false) }; (2) => { - StreamDependency::new(StreamId::from(13), 21, false) + StreamDependency::new(StreamId::from(13), 41, false) }; } diff --git a/crates/wreq-util/src/emulate/profile/opera/http2.rs b/crates/wreq-util/src/emulate/profile/opera/http2.rs index eb53e35..070d50a 100644 --- a/crates/wreq-util/src/emulate/profile/opera/http2.rs +++ b/crates/wreq-util/src/emulate/profile/opera/http2.rs @@ -1,6 +1,6 @@ macro_rules! headers_stream_dependency { () => { - StreamDependency::new(StreamId::zero(), 219, true) + StreamDependency::new(StreamId::zero(), 255, true) }; } From 65e55aba0da620add52be372f24343c4ce01ac71 Mon Sep 17 00:00:00 2001 From: gngpp Date: Sat, 15 Aug 2026 16:08:00 +0800 Subject: [PATCH 17/38] v1.2.12 --- Cargo.lock | 7 +++---- Cargo.toml | 5 +++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7dd3f09..3220343 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -465,8 +465,7 @@ dependencies = [ [[package]] name = "http2" version = "0.5.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d3114be2f413b2e491e686b93a28cda30c355cffc8d091a57f8be4b1342896" +source = "git+https://github.com/0x676e67/http2?rev=b413a92b2e1fe7e2ea1b7be78e75b872386fdfa0#b413a92b2e1fe7e2ea1b7be78e75b872386fdfa0" dependencies = [ "atomic-waker", "bytes", @@ -1421,7 +1420,7 @@ dependencies = [ [[package]] name = "wreq" version = "6.0.0-rc.29" -source = "git+https://github.com/0x676e67/wreq?rev=5159279f43e5e61e24643f7639c8f5a74f9ec380#5159279f43e5e61e24643f7639c8f5a74f9ec380" +source = "git+https://github.com/0x676e67/wreq?rev=12ccf64bb00e79db6eabd4bc3ccf82871d3eb5a5#12ccf64bb00e79db6eabd4bc3ccf82871d3eb5a5" dependencies = [ "btls", "btls-sys", @@ -1490,7 +1489,7 @@ dependencies = [ [[package]] name = "wreq-ruby" -version = "1.2.11" +version = "1.2.12" dependencies = [ "arc-swap", "bytes", diff --git a/Cargo.toml b/Cargo.toml index e344215..af184a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = ["SearchApi "] homepage = "https://github.com/SearchApi/wreq-ruby" repository = "https://github.com/SearchApi/wreq-ruby" edition = "2024" -version = "1.2.11" +version = "1.2.12" rust-version = "1.95" [lib] @@ -64,7 +64,8 @@ opt-level = 3 strip = true [patch.crates-io] +http2 = { git = "https://github.com/0x676e67/http2", rev = "b413a92b2e1fe7e2ea1b7be78e75b872386fdfa0" } btls = { git = "https://github.com/0x676e67/btls", branch = "demo/merge-upstream-boring-20260616" } btls-sys = { git = "https://github.com/0x676e67/btls", branch = "demo/merge-upstream-boring-20260616" } -wreq = { git = "https://github.com/0x676e67/wreq", rev = "5159279f43e5e61e24643f7639c8f5a74f9ec380" } +wreq = { git = "https://github.com/0x676e67/wreq", rev = "12ccf64bb00e79db6eabd4bc3ccf82871d3eb5a5" } wreq-util = { path = "crates/wreq-util" } From 2ac0d2ab271ae59a974db6d1a76a1372d9439920 Mon Sep 17 00:00:00 2001 From: gngpp Date: Mon, 17 Aug 2026 07:46:53 +0800 Subject: [PATCH 18/38] v1.2.13 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3220343..e9913d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1489,7 +1489,7 @@ dependencies = [ [[package]] name = "wreq-ruby" -version = "1.2.12" +version = "1.2.13" dependencies = [ "arc-swap", "bytes", diff --git a/Cargo.toml b/Cargo.toml index af184a1..3b5a64d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = ["SearchApi "] homepage = "https://github.com/SearchApi/wreq-ruby" repository = "https://github.com/SearchApi/wreq-ruby" edition = "2024" -version = "1.2.12" +version = "1.2.13" rust-version = "1.95" [lib] From 6074b453b19928d1b8002c2869ddc734cbb15187 Mon Sep 17 00:00:00 2001 From: gngpp Date: Wed, 9 Sep 2026 13:34:42 +0800 Subject: [PATCH 19/38] feat(emulate): add Chrome 152 and 153 profiles --- Cargo.lock | 34 +++++----- Cargo.toml | 10 +-- README.md | 2 +- crates/wreq-util/CHANGELOG.md | 2 + crates/wreq-util/Cargo.toml | 16 +++-- crates/wreq-util/src/emulate.rs | 2 + crates/wreq-util/src/emulate/macros.rs | 7 ++ .../wreq-util/src/emulate/profile/chrome.rs | 67 +++++++++++++++++++ .../src/emulate/profile/chrome/header.rs | 28 ++++++++ .../src/emulate/profile/chrome/tls.rs | 36 +++++++++- crates/wreq-util/tests/emulate_chrome.rs | 20 ++++++ lib/wreq_ruby/emulate.rb | 2 + src/emulate.rs | 2 + test/emulation_test.rb | 10 +++ wreq.gemspec | 2 +- 15 files changed, 210 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e9913d4..6c260f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "btls" version = "0.5.6" -source = "git+https://github.com/0x676e67/btls?branch=demo%2Fmerge-upstream-boring-20260616#2c1026a045e31454e841f96c6dfb594d5a4e4752" +source = "git+https://github.com/0x676e67/btls?rev=de7ab84fdb58641a2bdfdf9d8ebd7db1dcf4b29b#de7ab84fdb58641a2bdfdf9d8ebd7db1dcf4b29b" dependencies = [ "bitflags", "btls-sys", @@ -125,7 +125,7 @@ dependencies = [ [[package]] name = "btls-sys" version = "0.5.6" -source = "git+https://github.com/0x676e67/btls?branch=demo%2Fmerge-upstream-boring-20260616#2c1026a045e31454e841f96c6dfb594d5a4e4752" +source = "git+https://github.com/0x676e67/btls?rev=de7ab84fdb58641a2bdfdf9d8ebd7db1dcf4b29b#de7ab84fdb58641a2bdfdf9d8ebd7db1dcf4b29b" dependencies = [ "bindgen", "cmake", @@ -166,6 +166,15 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +[[package]] +name = "chromium-roots" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "229b200495e6cf4d4b599a1884c30f5af57898604e6c0bd94a217295c0d1df69" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "clang-sys" version = "1.9.1" @@ -1270,9 +1279,9 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.6.11" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" +checksum = "08a05a66a4fdd61cbbe0a1d755ffe0ca6aba159dd4820936a0ff8a8278245b9c" dependencies = [ "async-compression", "bitflags", @@ -1281,6 +1290,7 @@ dependencies = [ "http", "http-body", "http-body-util", + "percent-encoding", "pin-project-lite", "tokio", "tokio-util", @@ -1371,15 +1381,6 @@ version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" -[[package]] -name = "webpki-root-certs" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b96554aa2acc8ccdb7e1c9a58a7a68dd5d13bccc69cd124cb09406db612a1c9b" -dependencies = [ - "rustls-pki-types", -] - [[package]] name = "winapi" version = "0.3.9" @@ -1419,12 +1420,13 @@ dependencies = [ [[package]] name = "wreq" -version = "6.0.0-rc.29" -source = "git+https://github.com/0x676e67/wreq?rev=12ccf64bb00e79db6eabd4bc3ccf82871d3eb5a5#12ccf64bb00e79db6eabd4bc3ccf82871d3eb5a5" +version = "0.16.1" +source = "git+https://github.com/0x676e67/wreq?rev=abd421d16dd48b3c2d7fb812f185eec3c6ec3132#abd421d16dd48b3c2d7fb812f185eec3c6ec3132" dependencies = [ "btls", "btls-sys", "bytes", + "chromium-roots", "cookie", "encoding_rs", "futures-util", @@ -1451,7 +1453,6 @@ dependencies = [ "tower", "tower-http", "url", - "webpki-root-certs", "wreq-proto", "wreq-rt", ] @@ -1516,6 +1517,7 @@ name = "wreq-util" version = "3.0.0-rc.14" dependencies = [ "brotli", + "chromium-roots", "flate2", "typed-builder", "wreq", diff --git a/Cargo.toml b/Cargo.toml index 3b5a64d..3a7bae4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ homepage = "https://github.com/SearchApi/wreq-ruby" repository = "https://github.com/SearchApi/wreq-ruby" edition = "2024" version = "1.2.13" -rust-version = "1.95" +rust-version = "1.98" [lib] crate-type = ["cdylib"] @@ -17,7 +17,7 @@ name = "wreq_ruby" magnus = { version = "0.8.2", features = ["bytes"] } rb-sys = { version = "0.9.128", default-features = false } tokio = { version = "1.53.1", features = ["full"] } -wreq = { version = "6.0.0-rc", features = [ +wreq = { version = "0.16.1", features = [ "query", "form", "json", @@ -65,7 +65,7 @@ strip = true [patch.crates-io] http2 = { git = "https://github.com/0x676e67/http2", rev = "b413a92b2e1fe7e2ea1b7be78e75b872386fdfa0" } -btls = { git = "https://github.com/0x676e67/btls", branch = "demo/merge-upstream-boring-20260616" } -btls-sys = { git = "https://github.com/0x676e67/btls", branch = "demo/merge-upstream-boring-20260616" } -wreq = { git = "https://github.com/0x676e67/wreq", rev = "12ccf64bb00e79db6eabd4bc3ccf82871d3eb5a5" } +btls = { git = "https://github.com/0x676e67/btls", rev = "de7ab84fdb58641a2bdfdf9d8ebd7db1dcf4b29b" } +btls-sys = { git = "https://github.com/0x676e67/btls", rev = "de7ab84fdb58641a2bdfdf9d8ebd7db1dcf4b29b" } +wreq = { git = "https://github.com/0x676e67/wreq", rev = "abd421d16dd48b3c2d7fb812f185eec3c6ec3132" } wreq-util = { path = "crates/wreq-util" } diff --git a/README.md b/README.md index adf881b..1396011 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ Most browser device models share identical TLS and HTTP/2 configurations, differ | **Browser** | **Versions** | | ----------- | ------------ | - | **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135`, `Chrome136`, `Chrome137`, `Chrome138`, `Chrome139`, `Chrome140`, `Chrome141`, `Chrome142`, `Chrome143`, `Chrome144`, `Chrome145`, `Chrome146`, `Chrome147`, `Chrome148`, `Chrome149`, `Chrome150`, `Chrome151` | + | **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135`, `Chrome136`, `Chrome137`, `Chrome138`, `Chrome139`, `Chrome140`, `Chrome141`, `Chrome142`, `Chrome143`, `Chrome144`, `Chrome145`, `Chrome146`, `Chrome147`, `Chrome148`, `Chrome149`, `Chrome150`, `Chrome151`, `Chrome152`, `Chrome153` | | **Edge** | `Edge101`, `Edge122`, `Edge127`, `Edge131`, `Edge134`, `Edge135`, `Edge136`, `Edge137`, `Edge138`, `Edge139`, `Edge140`, `Edge141`, `Edge142`, `Edge143`, `Edge144`, `Edge145`, `Edge146`, `Edge147`, `Edge148` | | **Firefox** | `Firefox109`, `Firefox117`, `Firefox128`, `Firefox133`, `Firefox135`, `FirefoxPrivate135`, `FirefoxAndroid135`, `Firefox136`, `FirefoxPrivate136`, `Firefox139`, `Firefox142`, `Firefox143`, `Firefox144`, `Firefox145`, `Firefox146`, `Firefox147`, `Firefox148`, `Firefox149`, `Firefox150`, `Firefox151` | | **Safari** | `Safari15_3`, `Safari15_5`, `Safari15_6_1`, `Safari16`, `Safari16_5`, `Safari17_0`, `Safari17_2_1`, `Safari17_4_1`, `Safari17_5`, `Safari17_6`, `Safari18`, `Safari18_2`, `Safari18_3`, `Safari18_3_1`, `Safari18_5`, `Safari26`, `Safari26_1`, `Safari26_2`, `SafariIos16_5`, `SafariIos17_2`, `SafariIos17_4_1`, `SafariIos18_1_1`, `SafariIos26`, `SafariIos26_2`, `SafariIPad18`, `SafariIPad26`, `SafariIpad26_2` | diff --git a/crates/wreq-util/CHANGELOG.md b/crates/wreq-util/CHANGELOG.md index dd6e58e..dd95cc1 100644 --- a/crates/wreq-util/CHANGELOG.md +++ b/crates/wreq-util/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - *(emulate)* Add Chrome 151 profile. +- *(emulate)* Add Chrome 152 profile. +- *(emulate)* Add Chrome 153 profile. ## [3.0.0-rc.14](https://github.com/0x676e67/wreq-util/compare/v3.0.0-rc.13...v3.0.0-rc.14) - 2026-07-04 diff --git a/crates/wreq-util/Cargo.toml b/crates/wreq-util/Cargo.toml index abb4367..0b7b2f7 100644 --- a/crates/wreq-util/Cargo.toml +++ b/crates/wreq-util/Cargo.toml @@ -9,7 +9,7 @@ version = "3.0.0-rc.14" readme = "README.md" license = "Apache-2.0" edition = "2024" -rust-version = "1.85" +rust-version = "1.98" [package.metadata.docs.rs] all-features = true @@ -22,14 +22,21 @@ default = ["emulation"] tokio-rt = ["wreq/tokio-rt"] compio-rt = ["wreq/compio-rt"] -emulation = ["dep:typed-builder", "dep:brotli", "dep:flate2", "dep:zstd"] +emulation = [ + "dep:typed-builder", + "dep:brotli", + "dep:flate2", + "dep:zstd", + "dep:chromium-roots", + "wreq/chromium-roots", +] emulation-serde = ["dep:serde"] emulation-compression = [] tower-delay = ["dep:tower", "dep:pin-project-lite", "tokio/time"] [dependencies] -wreq = { version = "6.0.0-rc", default-features = false } +wreq = { version = "0.16.1", default-features = false } # Optional deps... @@ -38,6 +45,7 @@ tokio = { version = "1.52.1", default-features = false, optional = true } tower = { version = "0.5.2", default-features = false, optional = true } typed-builder = { version = "0.23.2", optional = true } pin-project-lite = { version = "0.2.17", optional = true } +chromium-roots = { version = "0.1.1", optional = true } ## Compression algorithms brotli = { version = "8.0.2", optional = true } @@ -45,7 +53,7 @@ flate2 = { version = "1.1.9", optional = true } zstd = { version = "0.13.3", optional = true } [dev-dependencies] -wreq = "6.0.0-rc" +wreq = "0.16.1" tokio = { version = "1.48.0", features = ["full"] } hyper = { version = "1.10.1", default-features = false, features = [ "http1", diff --git a/crates/wreq-util/src/emulate.rs b/crates/wreq-util/src/emulate.rs index 4ce4ee7..a36ebaf 100644 --- a/crates/wreq-util/src/emulate.rs +++ b/crates/wreq-util/src/emulate.rs @@ -62,6 +62,8 @@ define_enum!( Chrome149 => ("chrome_149", v149::emulation), Chrome150 => ("chrome_150", v150::emulation), Chrome151 => ("chrome_151", v151::emulation), + Chrome152 => ("chrome_152", v152::emulation), + Chrome153 => ("chrome_153", v153::emulation), // Edge versions Edge101 => ("edge_101", edge101::emulation), diff --git a/crates/wreq-util/src/emulate/macros.rs b/crates/wreq-util/src/emulate/macros.rs index 9fd9a74..0a8ca27 100644 --- a/crates/wreq-util/src/emulate/macros.rs +++ b/crates/wreq-util/src/emulate/macros.rs @@ -131,6 +131,13 @@ macro_rules! header_chrome_accept_encoding { ); $headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.9")); }; + (zstd_only, $headers:expr) => { + #[cfg(feature = "emulation-compression")] + $headers.insert( + ACCEPT_ENCODING, + HeaderValue::from_static("gzip, deflate, br, zstd"), + ); + }; } macro_rules! header_firefox_sec_fetch { diff --git a/crates/wreq-util/src/emulate/profile/chrome.rs b/crates/wreq-util/src/emulate/profile/chrome.rs index 0f8a2b5..65a4091 100644 --- a/crates/wreq-util/src/emulate/profile/chrome.rs +++ b/crates/wreq-util/src/emulate/profile/chrome.rs @@ -1862,6 +1862,73 @@ mod_generator!( ] ); +mod_generator!( + v152, + tls_options!(9, CURVES_3), + http2_options!(3), + header_initializer_chrome152, + [ + ( + MacOS, + r#""Chromium";v="152", "Not?A_Brand";v="24", "Google Chrome";v="152""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Chromium";v="152", "Not?A_Brand";v="24", "Google Chrome";v="152""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Chromium";v="152", "Not?A_Brand";v="24", "Google Chrome";v="152""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Chromium";v="152", "Not?A_Brand";v="24", "Google Chrome";v="152""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Chromium";v="152", "Not?A_Brand";v="24", "Google Chrome";v="152""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/152.0.0.0 Mobile/15E148 Safari/604.1" + ) + ] +); + +mod_generator!( + v153, + v152::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Google Chrome";v="153", "Not_A Brand";v="8", "Chromium";v="153""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Google Chrome";v="153", "Not_A Brand";v="8", "Chromium";v="153""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Google Chrome";v="153", "Not_A Brand";v="8", "Chromium";v="153""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Google Chrome";v="153", "Not_A Brand";v="8", "Chromium";v="153""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Google Chrome";v="153", "Not_A Brand";v="8", "Chromium";v="153""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/153.0.8010.24 Mobile/15E148 Safari/604.1" + ) + ] +); + mod_generator!( edge143, v132::build_emulation, diff --git a/crates/wreq-util/src/emulate/profile/chrome/header.rs b/crates/wreq-util/src/emulate/profile/chrome/header.rs index 6015b80..4304c75 100644 --- a/crates/wreq-util/src/emulate/profile/chrome/header.rs +++ b/crates/wreq-util/src/emulate/profile/chrome/header.rs @@ -72,3 +72,31 @@ pub fn header_initializer_with_zstd_priority( ); headers } + +pub fn header_initializer_chrome152( + sec_ch_ua: &'static str, + ua: &'static str, + emulation_os: Platform, +) -> HeaderMap { + let mut headers = HeaderMap::new(); + header_chrome_sec_ch_ua!( + headers, + sec_ch_ua, + emulation_os.platform(), + emulation_os.is_mobile() + ); + headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.9")); + headers.insert( + HeaderName::from_static("upgrade-insecure-requests"), + HeaderValue::from_static("1"), + ); + header_chrome_ua!(headers, ua); + header_chrome_accept!(headers); + header_chrome_sec_fetch!(headers); + header_chrome_accept_encoding!(zstd_only, headers); + headers.insert( + HeaderName::from_static("priority"), + HeaderValue::from_static("u=0, i"), + ); + headers +} diff --git a/crates/wreq-util/src/emulate/profile/chrome/tls.rs b/crates/wreq-util/src/emulate/profile/chrome/tls.rs index ebe0fd9..0a0004b 100644 --- a/crates/wreq-util/src/emulate/profile/chrome/tls.rs +++ b/crates/wreq-util/src/emulate/profile/chrome/tls.rs @@ -49,6 +49,17 @@ macro_rules! tls_options { .sigalgs_list($sigalgs) .alps_use_new_codepoint(true)) }; + (9, $curves:expr) => { + tls_options!(@build ChromeTlsConfig::builder() + .permute_extensions(true) + .enable_ech_grease(true) + .pre_shared_key(true) + .curves($curves) + .sigalgs_list(NEW_SIGALGS_LIST) + .trust_anchors(CHROME_TRUST_ANCHORS) + .grease_sigalgs_enabled(true) + .alps_use_new_codepoint(true)) + }; } pub const CURVES_1: &str = join!(":", "X25519", "P-256", "P-384"); @@ -101,6 +112,9 @@ pub const NEW_SIGALGS_LIST: &str = join!( "rsa_pkcs1_sha512" ); +// Encoded IDs and wreq's Chromium root store come from the same root set. +pub(super) const CHROME_TRUST_ANCHORS: &[u8] = &chromium_roots::encoded_trust_anchor_ids(); + pub const CERTIFICATE_COMPRESSORS: &[&'static dyn CertificateCompressor] = &[&BrotliCompressor]; #[derive(TypedBuilder)] @@ -128,11 +142,17 @@ pub struct ChromeTlsConfig { #[builder(default = false, setter(into))] pre_shared_key: bool, + + #[builder(default, setter(strip_option))] + trust_anchors: Option<&'static [u8]>, + + #[builder(default, setter(strip_option))] + grease_sigalgs_enabled: Option, } impl From for TlsOptions { fn from(val: ChromeTlsConfig) -> Self { - TlsOptions::builder() + let builder = TlsOptions::builder() .grease_enabled(true) .enable_ocsp_stapling(true) .enable_signed_cert_timestamps(true) @@ -147,7 +167,17 @@ impl From for TlsOptions { .alps_protocols([val.alps_protos]) .alps_use_new_codepoint(val.alps_use_new_codepoint) .aes_hw_override(true) - .certificate_compressors(CERTIFICATE_COMPRESSORS) - .build() + .certificate_compressors(CERTIFICATE_COMPRESSORS); + let builder = if let Some(trust_anchors) = val.trust_anchors { + builder.trust_anchors(trust_anchors) + } else { + builder + }; + let builder = if let Some(enabled) = val.grease_sigalgs_enabled { + builder.grease_sigalgs_enabled(enabled) + } else { + builder + }; + builder.build() } } diff --git a/crates/wreq-util/tests/emulate_chrome.rs b/crates/wreq-util/tests/emulate_chrome.rs index 9c44439..7aee038 100644 --- a/crates/wreq-util/tests/emulate_chrome.rs +++ b/crates/wreq-util/tests/emulate_chrome.rs @@ -275,3 +275,23 @@ test_emulation!( ["t13d1516h2_8daaf6152771_806a8c22fdea"], "52d84b11737d980aef856699f885ca86" ); + +test_emulation!( + test_chrome152, + Emulation::Chrome152, + [ + "t13d1517h2_8daaf6152771_cb7bf5808d99", + "t13d1518h2_8daaf6152771_e2d80978ab2e" + ], + "52d84b11737d980aef856699f885ca86" +); + +test_emulation!( + test_chrome153, + Emulation::Chrome153, + [ + "t13d1517h2_8daaf6152771_cb7bf5808d99", + "t13d1518h2_8daaf6152771_e2d80978ab2e" + ], + "52d84b11737d980aef856699f885ca86" +); diff --git a/lib/wreq_ruby/emulate.rb b/lib/wreq_ruby/emulate.rb index b7e76fb..854fd38 100644 --- a/lib/wreq_ruby/emulate.rb +++ b/lib/wreq_ruby/emulate.rb @@ -63,6 +63,8 @@ class Profile Chrome149 = nil Chrome150 = nil Chrome151 = nil + Chrome152 = nil + Chrome153 = nil Edge101 = nil Edge122 = nil diff --git a/src/emulate.rs b/src/emulate.rs index 5085ec7..621446c 100644 --- a/src/emulate.rs +++ b/src/emulate.rs @@ -88,6 +88,8 @@ define_ruby_enum!( Chrome149, Chrome150, Chrome151, + Chrome152, + Chrome153, Edge101, Edge122, diff --git a/test/emulation_test.rb b/test/emulation_test.rb index eba774a..d97681b 100644 --- a/test/emulation_test.rb +++ b/test/emulation_test.rb @@ -18,6 +18,16 @@ def test_chrome151_profile_is_available assert_instance_of Wreq::Emulation, Wreq::Emulation.new(profile: profile) end + def test_new_chrome_profiles_are_available + { + Wreq::Profile::Chrome152 => "Chrome152", + Wreq::Profile::Chrome153 => "Chrome153" + }.each do |profile, name| + assert_equal name, profile.to_s + assert_instance_of Wreq::Emulation, Wreq::Emulation.new(profile: profile) + end + end + def test_all_emulation_os_constants_are_non_nil Wreq::Platform.constants.each do |name| const = Wreq::Platform.const_get(name) diff --git a/wreq.gemspec b/wreq.gemspec index 8fd8fb3..f4de445 100644 --- a/wreq.gemspec +++ b/wreq.gemspec @@ -56,7 +56,7 @@ Gem::Specification.new do |spec| # Exclude non-Ruby files from RDoc to prevent parsing errors spec.rdoc_options = ["--exclude", "Cargo\\..*", "--exclude", "\\.rs$"] - spec.requirements = ["Rust >= 1.97"] + spec.requirements = ["Rust >= 1.98"] # use a Ruby version which: # - supports Rubygems with the ability of compilation of Rust gem # - not end of life From 7098fb46427c857b00c18015b22bab800ff7027f Mon Sep 17 00:00:00 2001 From: gngpp Date: Wed, 9 Sep 2026 13:38:16 +0800 Subject: [PATCH 20/38] v1.2.14 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c260f0..c1c1fc9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1490,7 +1490,7 @@ dependencies = [ [[package]] name = "wreq-ruby" -version = "1.2.13" +version = "1.2.14" dependencies = [ "arc-swap", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 3a7bae4..a6f70b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = ["SearchApi "] homepage = "https://github.com/SearchApi/wreq-ruby" repository = "https://github.com/SearchApi/wreq-ruby" edition = "2024" -version = "1.2.13" +version = "1.2.14" rust-version = "1.98" [lib] From 6279973d758aca94c1a38f15056ab54599362f68 Mon Sep 17 00:00:00 2001 From: gngpp Date: Mon, 14 Sep 2026 21:58:21 +0800 Subject: [PATCH 21/38] feat(emulate): add Firefox 152 profile --- README.md | 2 +- crates/wreq-util/CHANGELOG.md | 5 +++ crates/wreq-util/src/emulate.rs | 1 + .../wreq-util/src/emulate/profile/firefox.rs | 33 +++++++++++++++++-- .../src/emulate/profile/firefox/tls.rs | 20 +++++++++++ crates/wreq-util/tests/emulate_firefox.rs | 21 ++++++++++++ lib/wreq_ruby/emulate.rb | 1 + src/emulate.rs | 1 + test/emulation_test.rb | 5 +-- 9 files changed, 84 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1396011..152b055 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ Most browser device models share identical TLS and HTTP/2 configurations, differ | ----------- | ------------ | | **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135`, `Chrome136`, `Chrome137`, `Chrome138`, `Chrome139`, `Chrome140`, `Chrome141`, `Chrome142`, `Chrome143`, `Chrome144`, `Chrome145`, `Chrome146`, `Chrome147`, `Chrome148`, `Chrome149`, `Chrome150`, `Chrome151`, `Chrome152`, `Chrome153` | | **Edge** | `Edge101`, `Edge122`, `Edge127`, `Edge131`, `Edge134`, `Edge135`, `Edge136`, `Edge137`, `Edge138`, `Edge139`, `Edge140`, `Edge141`, `Edge142`, `Edge143`, `Edge144`, `Edge145`, `Edge146`, `Edge147`, `Edge148` | - | **Firefox** | `Firefox109`, `Firefox117`, `Firefox128`, `Firefox133`, `Firefox135`, `FirefoxPrivate135`, `FirefoxAndroid135`, `Firefox136`, `FirefoxPrivate136`, `Firefox139`, `Firefox142`, `Firefox143`, `Firefox144`, `Firefox145`, `Firefox146`, `Firefox147`, `Firefox148`, `Firefox149`, `Firefox150`, `Firefox151` | + | **Firefox** | `Firefox109`, `Firefox117`, `Firefox128`, `Firefox133`, `Firefox135`, `FirefoxPrivate135`, `FirefoxAndroid135`, `Firefox136`, `FirefoxPrivate136`, `Firefox139`, `Firefox142`, `Firefox143`, `Firefox144`, `Firefox145`, `Firefox146`, `Firefox147`, `Firefox148`, `Firefox149`, `Firefox150`, `Firefox151`, `Firefox152` | | **Safari** | `Safari15_3`, `Safari15_5`, `Safari15_6_1`, `Safari16`, `Safari16_5`, `Safari17_0`, `Safari17_2_1`, `Safari17_4_1`, `Safari17_5`, `Safari17_6`, `Safari18`, `Safari18_2`, `Safari18_3`, `Safari18_3_1`, `Safari18_5`, `Safari26`, `Safari26_1`, `Safari26_2`, `SafariIos16_5`, `SafariIos17_2`, `SafariIos17_4_1`, `SafariIos18_1_1`, `SafariIos26`, `SafariIos26_2`, `SafariIPad18`, `SafariIPad26`, `SafariIpad26_2` | | **OkHttp** | `Opera116`, `Opera117`, `Opera118`, `Opera119`, `Opera120`, `Opera121`, `Opera122`, `Opera123`, `Opera124`, `Opera125`, `Opera126`, `Opera127`, `Opera128`, `Opera129`, `Opera130` | | **Opera** | `Opera116`, `Opera117`, `Opera118`, `Opera119` | diff --git a/crates/wreq-util/CHANGELOG.md b/crates/wreq-util/CHANGELOG.md index dd95cc1..1060fe3 100644 --- a/crates/wreq-util/CHANGELOG.md +++ b/crates/wreq-util/CHANGELOG.md @@ -12,6 +12,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - *(emulate)* Add Chrome 151 profile. - *(emulate)* Add Chrome 152 profile. - *(emulate)* Add Chrome 153 profile. +- *(emulate)* Add Firefox 152 profile. + +### Fixed + +- *(emulate)* Fix Firefox 150 and 151 cipher suite lists. ## [3.0.0-rc.14](https://github.com/0x676e67/wreq-util/compare/v3.0.0-rc.13...v3.0.0-rc.14) - 2026-07-04 diff --git a/crates/wreq-util/src/emulate.rs b/crates/wreq-util/src/emulate.rs index a36ebaf..cd76ca6 100644 --- a/crates/wreq-util/src/emulate.rs +++ b/crates/wreq-util/src/emulate.rs @@ -125,6 +125,7 @@ define_enum!( Firefox149 => ("firefox_149", ff149::emulation), Firefox150 => ("firefox_150", ff150::emulation), Firefox151 => ("firefox_151", ff151::emulation), + Firefox152 => ("firefox_152", ff152::emulation), // Safari versions SafariIos17_2 => ("safari_ios_17.2", safari_ios_17_2::emulation), diff --git a/crates/wreq-util/src/emulate/profile/firefox.rs b/crates/wreq-util/src/emulate/profile/firefox.rs index b4adb47..6924fb4 100644 --- a/crates/wreq-util/src/emulate/profile/firefox.rs +++ b/crates/wreq-util/src/emulate/profile/firefox.rs @@ -463,7 +463,8 @@ mod_generator!( mod_generator!( ff150, - ff135::build_emulation, + tls_options!(4, CIPHER_LIST_3, CURVES_2, KEY_SHARES_2), + http2_options!(1), header_initializer_with_zstd, [ ( @@ -491,7 +492,7 @@ mod_generator!( mod_generator!( ff151, - ff135::build_emulation, + ff150::build_emulation, header_initializer_with_zstd, [ ( @@ -516,3 +517,31 @@ mod_generator!( ) ] ); + +mod_generator!( + ff152, + ff150::build_emulation, + header_initializer_with_zstd, + [ + ( + Windows, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:152.0) Gecko/20100101 Firefox/152.0" + ), + ( + MacOS, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:152.0) Gecko/20100101 Firefox/152.0" + ), + ( + Linux, + "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:152.0) Gecko/20100101 Firefox/152.0" + ), + ( + Android, + "Mozilla/5.0 (Android 13; Mobile; rv:152.0) Gecko/152.0 Firefox/152.0" + ), + ( + IOS, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/152.0 Mobile/15E148 Safari/605.1.15" + ) + ] +); diff --git a/crates/wreq-util/src/emulate/profile/firefox/tls.rs b/crates/wreq-util/src/emulate/profile/firefox/tls.rs index 5d73e36..0c4e9c4 100644 --- a/crates/wreq-util/src/emulate/profile/firefox/tls.rs +++ b/crates/wreq-util/src/emulate/profile/firefox/tls.rs @@ -124,6 +124,26 @@ pub const CIPHER_LIST_2: &str = join!( "TLS_RSA_WITH_AES_256_CBC_SHA" ); +pub const CIPHER_LIST_3: &str = join!( + ":", + "TLS_AES_128_GCM_SHA256", + "TLS_CHACHA20_POLY1305_SHA256", + "TLS_AES_256_GCM_SHA384", + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_256_GCM_SHA384", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_AES_256_CBC_SHA" +); + pub const SIGALGS_LIST: &str = join!( ":", "ecdsa_secp256r1_sha256", diff --git a/crates/wreq-util/tests/emulate_firefox.rs b/crates/wreq-util/tests/emulate_firefox.rs index 395bddf..fb0dd15 100644 --- a/crates/wreq-util/tests/emulate_firefox.rs +++ b/crates/wreq-util/tests/emulate_firefox.rs @@ -90,3 +90,24 @@ test_emulation!( ["t13d1717h2_5b57614c22b0_3cbfd9057e0d"], "6ea73faa8fc5aac76bded7bd238f6433" ); + +test_emulation!( + test_firefox_150, + Emulation::Firefox150, + ["t13d1617h2_86a278354501_3cbfd9057e0d"], + "6ea73faa8fc5aac76bded7bd238f6433" +); + +test_emulation!( + test_firefox_151, + Emulation::Firefox151, + ["t13d1617h2_86a278354501_3cbfd9057e0d"], + "6ea73faa8fc5aac76bded7bd238f6433" +); + +test_emulation!( + test_firefox_152, + Emulation::Firefox152, + ["t13d1617h2_86a278354501_3cbfd9057e0d"], + "6ea73faa8fc5aac76bded7bd238f6433" +); diff --git a/lib/wreq_ruby/emulate.rb b/lib/wreq_ruby/emulate.rb index 854fd38..11363fa 100644 --- a/lib/wreq_ruby/emulate.rb +++ b/lib/wreq_ruby/emulate.rb @@ -106,6 +106,7 @@ class Profile Firefox149 = nil Firefox150 = nil Firefox151 = nil + Firefox152 = nil SafariIos17_2 = nil SafariIos17_4_1 = nil diff --git a/src/emulate.rs b/src/emulate.rs index 621446c..4189cdf 100644 --- a/src/emulate.rs +++ b/src/emulate.rs @@ -131,6 +131,7 @@ define_ruby_enum!( Firefox149, Firefox150, Firefox151, + Firefox152, SafariIos17_2, SafariIos17_4_1, diff --git a/test/emulation_test.rb b/test/emulation_test.rb index d97681b..3fc4dcc 100644 --- a/test/emulation_test.rb +++ b/test/emulation_test.rb @@ -18,10 +18,11 @@ def test_chrome151_profile_is_available assert_instance_of Wreq::Emulation, Wreq::Emulation.new(profile: profile) end - def test_new_chrome_profiles_are_available + def test_new_browser_profiles_are_available { Wreq::Profile::Chrome152 => "Chrome152", - Wreq::Profile::Chrome153 => "Chrome153" + Wreq::Profile::Chrome153 => "Chrome153", + Wreq::Profile::Firefox152 => "Firefox152" }.each do |profile, name| assert_equal name, profile.to_s assert_instance_of Wreq::Emulation, Wreq::Emulation.new(profile: profile) From b168cf3fb804d100f8ad91bdf2ce80feac592043 Mon Sep 17 00:00:00 2001 From: gngpp Date: Mon, 14 Sep 2026 22:03:22 +0800 Subject: [PATCH 22/38] chore(release): prepare v1.2.15 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c1c1fc9..9b3f38e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1490,7 +1490,7 @@ dependencies = [ [[package]] name = "wreq-ruby" -version = "1.2.14" +version = "1.2.15" dependencies = [ "arc-swap", "bytes", diff --git a/Cargo.toml b/Cargo.toml index a6f70b0..040af6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = ["SearchApi "] homepage = "https://github.com/SearchApi/wreq-ruby" repository = "https://github.com/SearchApi/wreq-ruby" edition = "2024" -version = "1.2.14" +version = "1.2.15" rust-version = "1.98" [lib] From 8aceb643891bfe827578ba96d4da59e306224008 Mon Sep 17 00:00:00 2001 From: Luam Souza Date: Fri, 18 Sep 2026 21:05:14 -0300 Subject: [PATCH 23/38] fix(emulate): correct Firefox 147+ Accept-Language q-value (#178) Firefox 147 changed how Accept-Language q-values are generated: the list used to divide 1.0 across its entries, giving q=0.5 for a two-entry list, and now decrements by 0.1 per entry, giving q=0.9. See Bugzilla 2000765 (target milestone 147 Branch), landed in mozilla-firefox 0e050ae5116d. The Firefox 147 through 152 profiles still emitted the pre-147 value. Profiles below 147 are unchanged. --- crates/wreq-util/src/emulate/macros.rs | 29 ++++------ .../wreq-util/src/emulate/profile/firefox.rs | 12 ++-- .../src/emulate/profile/firefox/header.rs | 22 +++++++ crates/wreq-util/tests/emulate_firefox.rs | 58 +++++++++++++++++++ 4 files changed, 98 insertions(+), 23 deletions(-) diff --git a/crates/wreq-util/src/emulate/macros.rs b/crates/wreq-util/src/emulate/macros.rs index 0a8ca27..f045273 100644 --- a/crates/wreq-util/src/emulate/macros.rs +++ b/crates/wreq-util/src/emulate/macros.rs @@ -151,32 +151,27 @@ macro_rules! header_firefox_sec_fetch { macro_rules! header_firefox_accept { ($headers:expr) => { - $headers.insert( - ACCEPT, - HeaderValue::from_static( - "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", - ), - ); - $headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.5")); - #[cfg(feature = "emulation-compression")] - $headers.insert( - ACCEPT_ENCODING, - HeaderValue::from_static("gzip, deflate, br"), - ); + header_firefox_accept!(@build $headers, "en-US,en;q=0.5", "gzip, deflate, br"); }; (zstd, $headers:expr) => { + header_firefox_accept!(@build $headers, "en-US,en;q=0.5", "gzip, deflate, br, zstd"); + }; + // Firefox 147 changed the generated q-value from dividing 1.0 across the list to + // decrementing by 0.1 per entry, so a two-entry list became q=0.9 (Bugzilla 2000765, + // landed in 0e050ae5116d). + (zstd_q09, $headers:expr) => { + header_firefox_accept!(@build $headers, "en-US,en;q=0.9", "gzip, deflate, br, zstd"); + }; + (@build $headers:expr, $accept_language:expr, $accept_encoding:expr) => { $headers.insert( ACCEPT, HeaderValue::from_static( "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", ), ); - $headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.5")); + $headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static($accept_language)); #[cfg(feature = "emulation-compression")] - $headers.insert( - ACCEPT_ENCODING, - HeaderValue::from_static("gzip, deflate, br, zstd"), - ); + $headers.insert(ACCEPT_ENCODING, HeaderValue::from_static($accept_encoding)); }; } diff --git a/crates/wreq-util/src/emulate/profile/firefox.rs b/crates/wreq-util/src/emulate/profile/firefox.rs index 6924fb4..74cf164 100644 --- a/crates/wreq-util/src/emulate/profile/firefox.rs +++ b/crates/wreq-util/src/emulate/profile/firefox.rs @@ -380,7 +380,7 @@ mod_generator!( mod_generator!( ff147, ff135::build_emulation, - header_initializer_with_zstd, + header_initializer_with_zstd_q09, [ ( Windows, @@ -408,7 +408,7 @@ mod_generator!( mod_generator!( ff148, ff135::build_emulation, - header_initializer_with_zstd, + header_initializer_with_zstd_q09, [ ( Windows, @@ -436,7 +436,7 @@ mod_generator!( mod_generator!( ff149, ff135::build_emulation, - header_initializer_with_zstd, + header_initializer_with_zstd_q09, [ ( Windows, @@ -465,7 +465,7 @@ mod_generator!( ff150, tls_options!(4, CIPHER_LIST_3, CURVES_2, KEY_SHARES_2), http2_options!(1), - header_initializer_with_zstd, + header_initializer_with_zstd_q09, [ ( Windows, @@ -493,7 +493,7 @@ mod_generator!( mod_generator!( ff151, ff150::build_emulation, - header_initializer_with_zstd, + header_initializer_with_zstd_q09, [ ( Windows, @@ -521,7 +521,7 @@ mod_generator!( mod_generator!( ff152, ff150::build_emulation, - header_initializer_with_zstd, + header_initializer_with_zstd_q09, [ ( Windows, diff --git a/crates/wreq-util/src/emulate/profile/firefox/header.rs b/crates/wreq-util/src/emulate/profile/firefox/header.rs index 10223e0..2627180 100644 --- a/crates/wreq-util/src/emulate/profile/firefox/header.rs +++ b/crates/wreq-util/src/emulate/profile/firefox/header.rs @@ -35,3 +35,25 @@ pub fn header_initializer_with_zstd(ua: &'static str) -> HeaderMap { ); headers } + +/// Firefox 147 and later. Identical to [`header_initializer_with_zstd`] apart from the +/// `Accept-Language` q-value, which Firefox changed in 147 (Bugzilla 2000765). +pub fn header_initializer_with_zstd_q09(ua: &'static str) -> HeaderMap { + let mut headers = HeaderMap::new(); + header_firefox_ua!(headers, ua); + header_firefox_accept!(zstd_q09, headers); + headers.insert( + HeaderName::from_static("upgrade-insecure-requests"), + HeaderValue::from_static("1"), + ); + header_firefox_sec_fetch!(headers); + headers.insert( + HeaderName::from_static("priority"), + HeaderValue::from_static("u=0, i"), + ); + headers.insert( + HeaderName::from_static("te"), + HeaderValue::from_static("trailers"), + ); + headers +} diff --git a/crates/wreq-util/tests/emulate_firefox.rs b/crates/wreq-util/tests/emulate_firefox.rs index fb0dd15..29cf391 100644 --- a/crates/wreq-util/tests/emulate_firefox.rs +++ b/crates/wreq-util/tests/emulate_firefox.rs @@ -111,3 +111,61 @@ test_emulation!( ["t13d1617h2_86a278354501_3cbfd9057e0d"], "6ea73faa8fc5aac76bded7bd238f6433" ); + +/// Firefox 147 changed the generated `Accept-Language` q-value: the list used to divide 1.0 +/// across its entries, giving `q=0.5` for two, and now decrements by 0.1 per entry, giving +/// `q=0.9`. See Bugzilla 2000765, landed in mozilla-firefox 0e050ae5116d. +/// +/// Every profile is listed rather than a range, so adding one is a deliberate choice about +/// which side of 147 it falls on. +#[test] +fn firefox_accept_language_matches_the_profile_version() { + use wreq::IntoEmulation; + use wreq_util::{Platform, Profile}; + + const PRE_147: &[(&str, Profile)] = &[ + ("Firefox109", Emulation::Firefox109), + ("Firefox117", Emulation::Firefox117), + ("Firefox128", Emulation::Firefox128), + ("Firefox133", Emulation::Firefox133), + ("Firefox135", Emulation::Firefox135), + ("FirefoxPrivate135", Emulation::FirefoxPrivate135), + ("FirefoxAndroid135", Emulation::FirefoxAndroid135), + ("Firefox136", Emulation::Firefox136), + ("FirefoxPrivate136", Emulation::FirefoxPrivate136), + ("Firefox139", Emulation::Firefox139), + ("Firefox142", Emulation::Firefox142), + ("Firefox143", Emulation::Firefox143), + ("Firefox144", Emulation::Firefox144), + ("Firefox145", Emulation::Firefox145), + ("Firefox146", Emulation::Firefox146), + ]; + const POST_147: &[(&str, Profile)] = &[ + ("Firefox147", Emulation::Firefox147), + ("Firefox148", Emulation::Firefox148), + ("Firefox149", Emulation::Firefox149), + ("Firefox150", Emulation::Firefox150), + ("Firefox151", Emulation::Firefox151), + ("Firefox152", Emulation::Firefox152), + ]; + + fn accept_language(profile: Profile) -> String { + Emulation::builder() + .profile(profile) + .platform(Platform::Linux) + .build() + .into_emulation() + .headers + .get("accept-language") + .and_then(|value| value.to_str().ok()) + .unwrap_or_default() + .to_owned() + } + + for (name, profile) in PRE_147 { + assert_eq!("en-US,en;q=0.5", accept_language(*profile), "{name}"); + } + for (name, profile) in POST_147 { + assert_eq!("en-US,en;q=0.9", accept_language(*profile), "{name}"); + } +} From c0974c1baee403aaf13c3e473134f78b8d95ebd2 Mon Sep 17 00:00:00 2001 From: gngpp Date: Mon, 21 Sep 2026 10:45:26 +0800 Subject: [PATCH 24/38] feat(emulate): add Chrome 154 profile --- README.md | 2 +- crates/wreq-util/CHANGELOG.md | 1 + crates/wreq-util/src/emulate.rs | 1 + .../wreq-util/src/emulate/profile/chrome.rs | 33 +++++++++++++++++++ crates/wreq-util/tests/emulate_chrome.rs | 10 ++++++ lib/wreq_ruby/emulate.rb | 1 + src/emulate.rs | 1 + test/emulation_test.rb | 1 + 8 files changed, 49 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 152b055..ebf0633 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ Most browser device models share identical TLS and HTTP/2 configurations, differ | **Browser** | **Versions** | | ----------- | ------------ | - | **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135`, `Chrome136`, `Chrome137`, `Chrome138`, `Chrome139`, `Chrome140`, `Chrome141`, `Chrome142`, `Chrome143`, `Chrome144`, `Chrome145`, `Chrome146`, `Chrome147`, `Chrome148`, `Chrome149`, `Chrome150`, `Chrome151`, `Chrome152`, `Chrome153` | + | **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135`, `Chrome136`, `Chrome137`, `Chrome138`, `Chrome139`, `Chrome140`, `Chrome141`, `Chrome142`, `Chrome143`, `Chrome144`, `Chrome145`, `Chrome146`, `Chrome147`, `Chrome148`, `Chrome149`, `Chrome150`, `Chrome151`, `Chrome152`, `Chrome153`, `Chrome154` | | **Edge** | `Edge101`, `Edge122`, `Edge127`, `Edge131`, `Edge134`, `Edge135`, `Edge136`, `Edge137`, `Edge138`, `Edge139`, `Edge140`, `Edge141`, `Edge142`, `Edge143`, `Edge144`, `Edge145`, `Edge146`, `Edge147`, `Edge148` | | **Firefox** | `Firefox109`, `Firefox117`, `Firefox128`, `Firefox133`, `Firefox135`, `FirefoxPrivate135`, `FirefoxAndroid135`, `Firefox136`, `FirefoxPrivate136`, `Firefox139`, `Firefox142`, `Firefox143`, `Firefox144`, `Firefox145`, `Firefox146`, `Firefox147`, `Firefox148`, `Firefox149`, `Firefox150`, `Firefox151`, `Firefox152` | | **Safari** | `Safari15_3`, `Safari15_5`, `Safari15_6_1`, `Safari16`, `Safari16_5`, `Safari17_0`, `Safari17_2_1`, `Safari17_4_1`, `Safari17_5`, `Safari17_6`, `Safari18`, `Safari18_2`, `Safari18_3`, `Safari18_3_1`, `Safari18_5`, `Safari26`, `Safari26_1`, `Safari26_2`, `SafariIos16_5`, `SafariIos17_2`, `SafariIos17_4_1`, `SafariIos18_1_1`, `SafariIos26`, `SafariIos26_2`, `SafariIPad18`, `SafariIPad26`, `SafariIpad26_2` | diff --git a/crates/wreq-util/CHANGELOG.md b/crates/wreq-util/CHANGELOG.md index 1060fe3..3f3802c 100644 --- a/crates/wreq-util/CHANGELOG.md +++ b/crates/wreq-util/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - *(emulate)* Add Chrome 151 profile. - *(emulate)* Add Chrome 152 profile. - *(emulate)* Add Chrome 153 profile. +- *(emulate)* Add Chrome 154 profile. - *(emulate)* Add Firefox 152 profile. ### Fixed diff --git a/crates/wreq-util/src/emulate.rs b/crates/wreq-util/src/emulate.rs index cd76ca6..256c2e2 100644 --- a/crates/wreq-util/src/emulate.rs +++ b/crates/wreq-util/src/emulate.rs @@ -64,6 +64,7 @@ define_enum!( Chrome151 => ("chrome_151", v151::emulation), Chrome152 => ("chrome_152", v152::emulation), Chrome153 => ("chrome_153", v153::emulation), + Chrome154 => ("chrome_154", v154::emulation), // Edge versions Edge101 => ("edge_101", edge101::emulation), diff --git a/crates/wreq-util/src/emulate/profile/chrome.rs b/crates/wreq-util/src/emulate/profile/chrome.rs index 65a4091..1958855 100644 --- a/crates/wreq-util/src/emulate/profile/chrome.rs +++ b/crates/wreq-util/src/emulate/profile/chrome.rs @@ -1929,6 +1929,39 @@ mod_generator!( ] ); +mod_generator!( + v154, + v152::build_emulation, + header_initializer_with_zstd_priority, + [ + ( + MacOS, + r#""Chromium";v="154", "Google Chrome";v="154", "Not A(Brand";v="99""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Chromium";v="154", "Google Chrome";v="154", "Not A(Brand";v="99""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Chromium";v="154", "Google Chrome";v="154", "Not A(Brand";v="99""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Chromium";v="154", "Google Chrome";v="154", "Not A(Brand";v="99""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Chromium";v="154", "Google Chrome";v="154", "Not A(Brand";v="99""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/154.0.8037.41 Mobile/15E148 Safari/604.1" + ) + ] +); + mod_generator!( edge143, v132::build_emulation, diff --git a/crates/wreq-util/tests/emulate_chrome.rs b/crates/wreq-util/tests/emulate_chrome.rs index 7aee038..8e05b74 100644 --- a/crates/wreq-util/tests/emulate_chrome.rs +++ b/crates/wreq-util/tests/emulate_chrome.rs @@ -295,3 +295,13 @@ test_emulation!( ], "52d84b11737d980aef856699f885ca86" ); + +test_emulation!( + test_chrome154, + Emulation::Chrome154, + [ + "t13d1517h2_8daaf6152771_cb7bf5808d99", + "t13d1518h2_8daaf6152771_e2d80978ab2e" + ], + "52d84b11737d980aef856699f885ca86" +); diff --git a/lib/wreq_ruby/emulate.rb b/lib/wreq_ruby/emulate.rb index 11363fa..dcf3479 100644 --- a/lib/wreq_ruby/emulate.rb +++ b/lib/wreq_ruby/emulate.rb @@ -65,6 +65,7 @@ class Profile Chrome151 = nil Chrome152 = nil Chrome153 = nil + Chrome154 = nil Edge101 = nil Edge122 = nil diff --git a/src/emulate.rs b/src/emulate.rs index 4189cdf..1ff51bc 100644 --- a/src/emulate.rs +++ b/src/emulate.rs @@ -90,6 +90,7 @@ define_ruby_enum!( Chrome151, Chrome152, Chrome153, + Chrome154, Edge101, Edge122, diff --git a/test/emulation_test.rb b/test/emulation_test.rb index 3fc4dcc..efeaddf 100644 --- a/test/emulation_test.rb +++ b/test/emulation_test.rb @@ -22,6 +22,7 @@ def test_new_browser_profiles_are_available { Wreq::Profile::Chrome152 => "Chrome152", Wreq::Profile::Chrome153 => "Chrome153", + Wreq::Profile::Chrome154 => "Chrome154", Wreq::Profile::Firefox152 => "Firefox152" }.each do |profile, name| assert_equal name, profile.to_s From 67f38734850001c3b1aad6783376fcbd37f7365e Mon Sep 17 00:00:00 2001 From: gngpp Date: Mon, 21 Sep 2026 10:45:26 +0800 Subject: [PATCH 25/38] chore(release): prepare v1.2.16 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b3f38e..6408bcf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1490,7 +1490,7 @@ dependencies = [ [[package]] name = "wreq-ruby" -version = "1.2.15" +version = "1.2.16" dependencies = [ "arc-swap", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 040af6c..7c5315a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = ["SearchApi "] homepage = "https://github.com/SearchApi/wreq-ruby" repository = "https://github.com/SearchApi/wreq-ruby" edition = "2024" -version = "1.2.15" +version = "1.2.16" rust-version = "1.98" [lib] From f86e9a69557904ac33cd35e0a1755877f1592b7e Mon Sep 17 00:00:00 2001 From: gngpp Date: Thu, 24 Sep 2026 11:32:41 +0800 Subject: [PATCH 26/38] fix(emulate): preserve version-specific Chrome trust anchor configuration --- crates/wreq-util/CHANGELOG.md | 2 + crates/wreq-util/src/emulate.rs | 5 + .../wreq-util/src/emulate/profile/chrome.rs | 3 +- .../src/emulate/profile/chrome/tls.rs | 107 +++++++++++++++++- lib/wreq_ruby/emulate.rb | 12 ++ src/emulate.rs | 11 +- test/emulation_test.rb | 76 +++++++++++++ 7 files changed, 210 insertions(+), 6 deletions(-) diff --git a/crates/wreq-util/CHANGELOG.md b/crates/wreq-util/CHANGELOG.md index 3f3802c..4575699 100644 --- a/crates/wreq-util/CHANGELOG.md +++ b/crates/wreq-util/CHANGELOG.md @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Match Trust Anchor ID ordering by Chrome version: randomized per native configuration for 152/153, and sorted by raw ID bytes for 154. + - *(emulate)* Fix Firefox 150 and 151 cipher suite lists. ## [3.0.0-rc.14](https://github.com/0x676e67/wreq-util/compare/v3.0.0-rc.13...v3.0.0-rc.14) - 2026-07-04 diff --git a/crates/wreq-util/src/emulate.rs b/crates/wreq-util/src/emulate.rs index 256c2e2..2230710 100644 --- a/crates/wreq-util/src/emulate.rs +++ b/crates/wreq-util/src/emulate.rs @@ -216,6 +216,11 @@ impl Platform { /// The `Emulation` struct allows you to configure various aspects of profile and platform /// emulation, including the profile, platform, and whether to enable certain features /// like HTTP/2 or headers. +/// +/// Conversion through [`wreq::IntoEmulation`] creates a native configuration, +/// including a randomized Trust Anchor ID order for Chrome 152/153 profiles. +/// Client-level emulation retains that order for subsequent connections. +/// Chrome 154 sorts the IDs by their raw bytes instead. #[derive(Default, Clone, TypedBuilder)] pub struct Emulation { /// Whether to change the profile (browser/okhttp) information. diff --git a/crates/wreq-util/src/emulate/profile/chrome.rs b/crates/wreq-util/src/emulate/profile/chrome.rs index 1958855..c888292 100644 --- a/crates/wreq-util/src/emulate/profile/chrome.rs +++ b/crates/wreq-util/src/emulate/profile/chrome.rs @@ -1931,7 +1931,8 @@ mod_generator!( mod_generator!( v154, - v152::build_emulation, + tls_options!(9, CURVES_3, sorted_trust_anchors()), + http2_options!(3), header_initializer_with_zstd_priority, [ ( diff --git a/crates/wreq-util/src/emulate/profile/chrome/tls.rs b/crates/wreq-util/src/emulate/profile/chrome/tls.rs index 0a0004b..bdc8f69 100644 --- a/crates/wreq-util/src/emulate/profile/chrome/tls.rs +++ b/crates/wreq-util/src/emulate/profile/chrome/tls.rs @@ -50,13 +50,16 @@ macro_rules! tls_options { .alps_use_new_codepoint(true)) }; (9, $curves:expr) => { + tls_options!(9, $curves, shuffled_trust_anchors(crate::rand::fast_random)) + }; + (9, $curves:expr, $trust_anchors:expr) => { tls_options!(@build ChromeTlsConfig::builder() .permute_extensions(true) .enable_ech_grease(true) .pre_shared_key(true) .curves($curves) .sigalgs_list(NEW_SIGALGS_LIST) - .trust_anchors(CHROME_TRUST_ANCHORS) + .trust_anchors($trust_anchors) .grease_sigalgs_enabled(true) .alps_use_new_codepoint(true)) }; @@ -115,6 +118,44 @@ pub const NEW_SIGALGS_LIST: &str = join!( // Encoded IDs and wreq's Chromium root store come from the same root set. pub(super) const CHROME_TRUST_ANCHORS: &[u8] = &chromium_roots::encoded_trust_anchor_ids(); +// Chrome 152/153 iterate a salted flat_hash_set held by SSLClientContext, rather than +// the root store's source order. Generate an order once per native configuration; +// connections using that client configuration retain the order. +// https://chromium.googlesource.com/chromium/src/+/f7b831a4e249fbd98eae4b391c69f70300a849d1/net/ssl/ssl_config_service.cc +pub(super) fn shuffled_trust_anchors(mut random: impl FnMut() -> u64) -> Vec { + let mut ids = chromium_roots::trust_anchor_ids(); + for index in (1..ids.len()).rev() { + let bound = (index + 1) as u64; + let limit = u64::MAX - u64::MAX % bound; + let mut value = random(); + while value >= limit { + value = random(); + } + ids.swap(index, (value % bound) as usize); + } + + encode_trust_anchors(&ids) +} + +// Chrome 154 sorts the raw IDs before adding their length prefixes. +// https://chromium.googlesource.com/chromium/src/+/731082f0a26ce4b3976c3d82943092f5d13daf13/net/cert/x509_util.cc +pub(super) fn sorted_trust_anchors() -> Vec { + let mut ids = chromium_roots::trust_anchor_ids(); + ids.sort_unstable(); + encode_trust_anchors(&ids) +} + +fn encode_trust_anchors(ids: &[&[u8]]) -> Vec { + let mut encoded = Vec::with_capacity(CHROME_TRUST_ANCHORS.len()); + for id in ids { + // encoded_trust_anchor_ids() validates these same IDs at compile time: + // each length is nonzero and fits in one byte. + encoded.push(id.len() as u8); + encoded.extend_from_slice(id); + } + encoded +} + pub const CERTIFICATE_COMPRESSORS: &[&'static dyn CertificateCompressor] = &[&BrotliCompressor]; #[derive(TypedBuilder)] @@ -144,7 +185,7 @@ pub struct ChromeTlsConfig { pre_shared_key: bool, #[builder(default, setter(strip_option))] - trust_anchors: Option<&'static [u8]>, + trust_anchors: Option>, #[builder(default, setter(strip_option))] grease_sigalgs_enabled: Option, @@ -181,3 +222,65 @@ impl From for TlsOptions { builder.build() } } + +#[cfg(test)] +mod tests { + use super::*; + use wreq::IntoEmulation; + + #[test] + fn chrome_profiles_retain_trust_anchor_order_when_cloned() { + for profile in [ + crate::Profile::Chrome152, + crate::Profile::Chrome153, + crate::Profile::Chrome154, + ] { + let native = profile.into_emulation(); + let cloned = native.clone(); + let ids = native.tls_options.unwrap().trust_anchors.unwrap(); + assert_eq!(ids.len(), CHROME_TRUST_ANCHORS.len()); + assert_eq!(ids, cloned.tls_options.unwrap().trust_anchors.unwrap()); + let decoded = decode_ids(&ids); + let mut expected = chromium_roots::trust_anchor_ids(); + expected.sort_unstable(); + if profile == crate::Profile::Chrome154 { + assert_eq!(decoded, expected); + } + let mut actual = decoded; + actual.sort_unstable(); + assert_eq!(actual, expected); + } + assert!( + crate::Profile::Chrome151 + .into_emulation() + .tls_options + .unwrap() + .trust_anchors + .is_none() + ); + } + + #[test] + fn trust_anchor_shuffle_preserves_ids_without_pinning_the_first() { + // Choosing index zero at every step rotates the entire list left. + // Rejecting u64::MAX also covers the unbiased sampling boundary. + let mut samples = std::iter::once(u64::MAX).chain(std::iter::repeat(0)); + let encoded = shuffled_trust_anchors(|| samples.next().unwrap()); + let decoded = decode_ids(&encoded); + let mut expected = chromium_roots::trust_anchor_ids(); + expected.rotate_left(1); + assert_eq!(decoded, expected); + assert_eq!(encoded.len(), CHROME_TRUST_ANCHORS.len()); + } + + fn decode_ids(mut remaining: &[u8]) -> Vec<&[u8]> { + let mut decoded = Vec::new(); + while let Some((&length, rest)) = remaining.split_first() { + assert_ne!(length, 0); + let (id, rest) = rest.split_at(usize::from(length)); + decoded.push(id); + remaining = rest; + } + decoded + } +} diff --git a/lib/wreq_ruby/emulate.rb b/lib/wreq_ruby/emulate.rb index dcf3479..88792cc 100644 --- a/lib/wreq_ruby/emulate.rb +++ b/lib/wreq_ruby/emulate.rb @@ -264,6 +264,14 @@ def hash # for HTTP/2 and automatic default headers. The actual implementation is # provided by Rust. # + # Construction generates the native configuration once. For Chrome 152/153, + # the TLS trust_anchors extension's ID order is randomized at construction; + # Chrome 154 sorts those IDs by their raw bytes instead. Reusing this object + # across clients or requests retains that order. Creating a new object generates + # a new configuration, including a fresh shuffle for Chrome 152/153. + # This does not freeze other per-handshake randomness or force a new handshake + # when a request reuses an existing connection. + # # `profile:` defaults to the library's default profile when omitted. # `platform:` defaults to the library's default platform when omitted. # @@ -289,6 +297,10 @@ class Emulation # Native fields and methods are set by the extension. # This stub is for documentation only. unless singleton_methods(false).include?(:new) + # Generates a reusable native configuration. Chrome 152/153 Trust Anchor ID + # order is chosen here and retained when this object is reused; Chrome 154 + # uses raw-byte sorted order. See {Emulation} for connection semantics. + # # @param profile [Wreq::Profile, nil] Fingerprint profile to emulate # @param platform [Wreq::Platform, nil] Operating system platform to emulate # @param http2 [Boolean, nil] Whether HTTP/2 emulation is enabled; defaults diff --git a/src/emulate.rs b/src/emulate.rs index 1ff51bc..996f29f 100644 --- a/src/emulate.rs +++ b/src/emulate.rs @@ -1,5 +1,6 @@ use ::serde::Deserialize; use magnus::{Error, Module, Object, RModule, Ruby, Value, function, method, typed_data::Obj}; +use wreq::IntoEmulation; use crate::options::{NativeOption, Options}; @@ -206,10 +207,13 @@ define_ruby_enum!( IOS => "ios", ); -/// A struct to represent the `EmulationOption` class. +/// Materialized emulation configuration owned by the Ruby object. +/// +/// Clients and requests clone this value rather than regenerating profile settings, +/// preserving configuration-level randomness for the lifetime of the object. #[derive(Clone)] #[magnus::wrap(class = "Wreq::Emulation", free_immediately, size)] -pub struct Emulation(pub wreq_util::Emulation); +pub struct Emulation(pub wreq::Emulation); // ===== impl Emulation ===== @@ -246,7 +250,8 @@ impl Emulation { ) .http2(params.http2.unwrap_or(true)) .headers(params.headers.unwrap_or(true)) - .build(); + .build() + .into_emulation(); Ok(Self(emulation)) } diff --git a/test/emulation_test.rb b/test/emulation_test.rb index efeaddf..e6965a2 100644 --- a/test/emulation_test.rb +++ b/test/emulation_test.rb @@ -1,8 +1,28 @@ # frozen_string_literal: true require "test_helper" +require "socket" +require "stringio" +require "timeout" class EmulationTest < Minitest::Test + def test_reused_emulation_retains_trust_anchors_across_clients_and_requests + [Wreq::Profile::Chrome152, Wreq::Profile::Chrome153, Wreq::Profile::Chrome154].each do |profile| + emulation = Wreq::Emulation.new(profile: profile) + client = Wreq::Client.new(emulation: emulation, no_proxy: true) + expected = capture_trust_anchors { |url| client.get(url, timeout: 5) } + refute_empty expected, profile.to_s + + request_client = Wreq::Client.new(no_proxy: true) + 2.times do + actual = capture_trust_anchors do |url| + request_client.get(url, emulation: emulation, timeout: 5) + end + assert_equal expected, actual, "#{profile}: reusing an object must retain its configuration" + end + end + end + def test_all_emulation_device_constants_are_non_nil Wreq::Profile.constants.each do |name| const = Wreq::Profile.const_get(name) @@ -37,4 +57,60 @@ def test_all_emulation_os_constants_are_non_nil "#{name} should be Platform, got #{const.inspect}" end end + + private + + # Each listener forces a new connection. Stop after ClientHello so this test + # inspects the extension bytes without depending on certificates or the network. + def capture_trust_anchors + server = TCPServer.new("127.0.0.1", 0) + thread = Thread.new do + socket = nil + Timeout.timeout(5) do + socket = server.accept + handshake = +"".b + loop do + header = read_tls_bytes(socket, 5) + raise "expected a TLS handshake record" unless header.getbyte(0) == 22 + handshake << read_tls_bytes(socket, header.byteslice(3, 2).unpack1("n")) + next if handshake.bytesize < 4 + length = handshake.byteslice(1, 3).bytes.reduce(0) { |n, byte| (n << 8) | byte } + break if handshake.bytesize >= length + 4 + end + trust_anchors_from_client_hello(handshake) + end + ensure + socket&.close + end + thread.report_on_exception = false + + assert_raises(Wreq::ConnectionError) { yield "https://127.0.0.1:#{server.addr[1]}/" } + thread.value + ensure + server&.close + thread&.kill if thread&.alive? + thread&.join + end + + def read_tls_bytes(io, length) + bytes = io.read(length) + raise EOFError, "truncated ClientHello" unless bytes&.bytesize == length + bytes + end + + def trust_anchors_from_client_hello(handshake) + io = StringIO.new(handshake) + raise "expected ClientHello" unless read_tls_bytes(io, 1).unpack1("C") == 1 + read_tls_bytes(io, 3 + 2 + 32) # Handshake length, legacy version and random. + read_tls_bytes(io, read_tls_bytes(io, 1).unpack1("C")) # Session ID. + read_tls_bytes(io, read_tls_bytes(io, 2).unpack1("n")) # Cipher suites. + read_tls_bytes(io, read_tls_bytes(io, 1).unpack1("C")) # Compression methods. + extensions = StringIO.new(read_tls_bytes(io, read_tls_bytes(io, 2).unpack1("n"))) + until extensions.eof? + type, length = read_tls_bytes(extensions, 4).unpack("nn") + data = read_tls_bytes(extensions, length) + return data if type == 51764 + end + raise "missing trust_anchors extension" + end end From a0f10899c3d5821facecdf63c1f12cb019536a58 Mon Sep 17 00:00:00 2001 From: gngpp Date: Thu, 24 Sep 2026 11:34:46 +0800 Subject: [PATCH 27/38] chore(release): prepare v1.3.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6408bcf..6445aba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1490,7 +1490,7 @@ dependencies = [ [[package]] name = "wreq-ruby" -version = "1.2.16" +version = "1.3.0" dependencies = [ "arc-swap", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 7c5315a..7e09e02 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = ["SearchApi "] homepage = "https://github.com/SearchApi/wreq-ruby" repository = "https://github.com/SearchApi/wreq-ruby" edition = "2024" -version = "1.2.16" +version = "1.3.0" rust-version = "1.98" [lib] From e8a12b8b07a3e6c6e0b8de1aa1c5b90e3975685a Mon Sep 17 00:00:00 2001 From: gngpp Date: Fri, 9 Oct 2026 02:33:18 +0800 Subject: [PATCH 28/38] feat(emulate): add Chrome 155 profile --- README.md | 2 +- crates/wreq-util/CHANGELOG.md | 1 + crates/wreq-util/src/emulate.rs | 3 +- .../wreq-util/src/emulate/profile/chrome.rs | 36 +++++++++++++++++++ .../src/emulate/profile/chrome/header.rs | 14 ++++++++ .../src/emulate/profile/chrome/tls.rs | 6 +++- crates/wreq-util/tests/emulate_chrome.rs | 10 ++++++ lib/wreq_ruby/emulate.rb | 7 ++-- src/emulate.rs | 1 + test/emulation_test.rb | 3 +- 10 files changed, 76 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ebf0633..c9b31b8 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ Most browser device models share identical TLS and HTTP/2 configurations, differ | **Browser** | **Versions** | | ----------- | ------------ | - | **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135`, `Chrome136`, `Chrome137`, `Chrome138`, `Chrome139`, `Chrome140`, `Chrome141`, `Chrome142`, `Chrome143`, `Chrome144`, `Chrome145`, `Chrome146`, `Chrome147`, `Chrome148`, `Chrome149`, `Chrome150`, `Chrome151`, `Chrome152`, `Chrome153`, `Chrome154` | + | **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135`, `Chrome136`, `Chrome137`, `Chrome138`, `Chrome139`, `Chrome140`, `Chrome141`, `Chrome142`, `Chrome143`, `Chrome144`, `Chrome145`, `Chrome146`, `Chrome147`, `Chrome148`, `Chrome149`, `Chrome150`, `Chrome151`, `Chrome152`, `Chrome153`, `Chrome154`, `Chrome155` | | **Edge** | `Edge101`, `Edge122`, `Edge127`, `Edge131`, `Edge134`, `Edge135`, `Edge136`, `Edge137`, `Edge138`, `Edge139`, `Edge140`, `Edge141`, `Edge142`, `Edge143`, `Edge144`, `Edge145`, `Edge146`, `Edge147`, `Edge148` | | **Firefox** | `Firefox109`, `Firefox117`, `Firefox128`, `Firefox133`, `Firefox135`, `FirefoxPrivate135`, `FirefoxAndroid135`, `Firefox136`, `FirefoxPrivate136`, `Firefox139`, `Firefox142`, `Firefox143`, `Firefox144`, `Firefox145`, `Firefox146`, `Firefox147`, `Firefox148`, `Firefox149`, `Firefox150`, `Firefox151`, `Firefox152` | | **Safari** | `Safari15_3`, `Safari15_5`, `Safari15_6_1`, `Safari16`, `Safari16_5`, `Safari17_0`, `Safari17_2_1`, `Safari17_4_1`, `Safari17_5`, `Safari17_6`, `Safari18`, `Safari18_2`, `Safari18_3`, `Safari18_3_1`, `Safari18_5`, `Safari26`, `Safari26_1`, `Safari26_2`, `SafariIos16_5`, `SafariIos17_2`, `SafariIos17_4_1`, `SafariIos18_1_1`, `SafariIos26`, `SafariIos26_2`, `SafariIPad18`, `SafariIPad26`, `SafariIpad26_2` | diff --git a/crates/wreq-util/CHANGELOG.md b/crates/wreq-util/CHANGELOG.md index 4575699..6b00b8c 100644 --- a/crates/wreq-util/CHANGELOG.md +++ b/crates/wreq-util/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - *(emulate)* Add Chrome 152 profile. - *(emulate)* Add Chrome 153 profile. - *(emulate)* Add Chrome 154 profile. +- *(emulate)* Add Chrome 155 profile, including the JPEG XL navigation Accept header. - *(emulate)* Add Firefox 152 profile. ### Fixed diff --git a/crates/wreq-util/src/emulate.rs b/crates/wreq-util/src/emulate.rs index 2230710..9801a78 100644 --- a/crates/wreq-util/src/emulate.rs +++ b/crates/wreq-util/src/emulate.rs @@ -65,6 +65,7 @@ define_enum!( Chrome152 => ("chrome_152", v152::emulation), Chrome153 => ("chrome_153", v153::emulation), Chrome154 => ("chrome_154", v154::emulation), + Chrome155 => ("chrome_155", v155::emulation), // Edge versions Edge101 => ("edge_101", edge101::emulation), @@ -220,7 +221,7 @@ impl Platform { /// Conversion through [`wreq::IntoEmulation`] creates a native configuration, /// including a randomized Trust Anchor ID order for Chrome 152/153 profiles. /// Client-level emulation retains that order for subsequent connections. -/// Chrome 154 sorts the IDs by their raw bytes instead. +/// Chrome 154/155 sort the IDs by their raw bytes instead. #[derive(Default, Clone, TypedBuilder)] pub struct Emulation { /// Whether to change the profile (browser/okhttp) information. diff --git a/crates/wreq-util/src/emulate/profile/chrome.rs b/crates/wreq-util/src/emulate/profile/chrome.rs index c888292..7954c8b 100644 --- a/crates/wreq-util/src/emulate/profile/chrome.rs +++ b/crates/wreq-util/src/emulate/profile/chrome.rs @@ -1963,6 +1963,42 @@ mod_generator!( ] ); +// Chrome 155 retains Chrome 154's TLS/HTTP2 configuration. Its UA-CH permutation +// and GREASE brand are seeded by major version 155. +// https://chromium.googlesource.com/chromium/src/+/cfaadc5a132d78e1828635aa8405a499f3e14864/components/embedder_support/user_agent_utils.cc +mod_generator!( + v155, + v154::build_emulation, + header_initializer_chrome155, + [ + ( + MacOS, + r#""Google Chrome";v="155", "Chromium";v="155", "Not(A:Brand";v="24""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Google Chrome";v="155", "Chromium";v="155", "Not(A:Brand";v="24""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Google Chrome";v="155", "Chromium";v="155", "Not(A:Brand";v="24""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Google Chrome";v="155", "Chromium";v="155", "Not(A:Brand";v="24""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Google Chrome";v="155", "Chromium";v="155", "Not(A:Brand";v="24""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/155.0.8059.37 Mobile/15E148 Safari/604.1" + ) + ] +); + mod_generator!( edge143, v132::build_emulation, diff --git a/crates/wreq-util/src/emulate/profile/chrome/header.rs b/crates/wreq-util/src/emulate/profile/chrome/header.rs index 4304c75..2926948 100644 --- a/crates/wreq-util/src/emulate/profile/chrome/header.rs +++ b/crates/wreq-util/src/emulate/profile/chrome/header.rs @@ -73,6 +73,20 @@ pub fn header_initializer_with_zstd_priority( headers } +pub fn header_initializer_chrome155( + sec_ch_ua: &'static str, + ua: &'static str, + emulation_os: Platform, +) -> HeaderMap { + let mut headers = header_initializer_with_zstd_priority(sec_ch_ua, ua, emulation_os); + // Chrome 155 enables JPEG XL in Blink; the iOS profile keeps its WebKit headers. + // https://chromium.googlesource.com/chromium/src/+/cfaadc5a132d78e1828635aa8405a499f3e14864/content/common/content_constants_internal.h + if !matches!(emulation_os, Platform::IOS) { + headers.insert(ACCEPT, HeaderValue::from_static("text/html,application/xhtml+xml,application/xml;q=0.9,image/jxl,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7")); + } + headers +} + pub fn header_initializer_chrome152( sec_ch_ua: &'static str, ua: &'static str, diff --git a/crates/wreq-util/src/emulate/profile/chrome/tls.rs b/crates/wreq-util/src/emulate/profile/chrome/tls.rs index bdc8f69..cf870fa 100644 --- a/crates/wreq-util/src/emulate/profile/chrome/tls.rs +++ b/crates/wreq-util/src/emulate/profile/chrome/tls.rs @@ -234,6 +234,7 @@ mod tests { crate::Profile::Chrome152, crate::Profile::Chrome153, crate::Profile::Chrome154, + crate::Profile::Chrome155, ] { let native = profile.into_emulation(); let cloned = native.clone(); @@ -243,7 +244,10 @@ mod tests { let decoded = decode_ids(&ids); let mut expected = chromium_roots::trust_anchor_ids(); expected.sort_unstable(); - if profile == crate::Profile::Chrome154 { + if matches!( + profile, + crate::Profile::Chrome154 | crate::Profile::Chrome155 + ) { assert_eq!(decoded, expected); } let mut actual = decoded; diff --git a/crates/wreq-util/tests/emulate_chrome.rs b/crates/wreq-util/tests/emulate_chrome.rs index 8e05b74..85f4ad8 100644 --- a/crates/wreq-util/tests/emulate_chrome.rs +++ b/crates/wreq-util/tests/emulate_chrome.rs @@ -305,3 +305,13 @@ test_emulation!( ], "52d84b11737d980aef856699f885ca86" ); + +test_emulation!( + test_chrome155, + Emulation::Chrome155, + [ + "t13d1517h2_8daaf6152771_cb7bf5808d99", + "t13d1518h2_8daaf6152771_e2d80978ab2e" + ], + "52d84b11737d980aef856699f885ca86" +); diff --git a/lib/wreq_ruby/emulate.rb b/lib/wreq_ruby/emulate.rb index 88792cc..ce10c27 100644 --- a/lib/wreq_ruby/emulate.rb +++ b/lib/wreq_ruby/emulate.rb @@ -66,6 +66,7 @@ class Profile Chrome152 = nil Chrome153 = nil Chrome154 = nil + Chrome155 = nil Edge101 = nil Edge122 = nil @@ -266,7 +267,7 @@ def hash # # Construction generates the native configuration once. For Chrome 152/153, # the TLS trust_anchors extension's ID order is randomized at construction; - # Chrome 154 sorts those IDs by their raw bytes instead. Reusing this object + # Chrome 154/155 sort those IDs by their raw bytes instead. Reusing this object # across clients or requests retains that order. Creating a new object generates # a new configuration, including a fresh shuffle for Chrome 152/153. # This does not freeze other per-handshake randomness or force a new handshake @@ -298,8 +299,8 @@ class Emulation # This stub is for documentation only. unless singleton_methods(false).include?(:new) # Generates a reusable native configuration. Chrome 152/153 Trust Anchor ID - # order is chosen here and retained when this object is reused; Chrome 154 - # uses raw-byte sorted order. See {Emulation} for connection semantics. + # order is chosen here and retained when this object is reused; Chrome 154/155 + # use raw-byte sorted order. See {Emulation} for connection semantics. # # @param profile [Wreq::Profile, nil] Fingerprint profile to emulate # @param platform [Wreq::Platform, nil] Operating system platform to emulate diff --git a/src/emulate.rs b/src/emulate.rs index 996f29f..9c94102 100644 --- a/src/emulate.rs +++ b/src/emulate.rs @@ -92,6 +92,7 @@ define_ruby_enum!( Chrome152, Chrome153, Chrome154, + Chrome155, Edge101, Edge122, diff --git a/test/emulation_test.rb b/test/emulation_test.rb index e6965a2..be6d2ef 100644 --- a/test/emulation_test.rb +++ b/test/emulation_test.rb @@ -7,7 +7,7 @@ class EmulationTest < Minitest::Test def test_reused_emulation_retains_trust_anchors_across_clients_and_requests - [Wreq::Profile::Chrome152, Wreq::Profile::Chrome153, Wreq::Profile::Chrome154].each do |profile| + [Wreq::Profile::Chrome152, Wreq::Profile::Chrome153, Wreq::Profile::Chrome154, Wreq::Profile::Chrome155].each do |profile| emulation = Wreq::Emulation.new(profile: profile) client = Wreq::Client.new(emulation: emulation, no_proxy: true) expected = capture_trust_anchors { |url| client.get(url, timeout: 5) } @@ -43,6 +43,7 @@ def test_new_browser_profiles_are_available Wreq::Profile::Chrome152 => "Chrome152", Wreq::Profile::Chrome153 => "Chrome153", Wreq::Profile::Chrome154 => "Chrome154", + Wreq::Profile::Chrome155 => "Chrome155", Wreq::Profile::Firefox152 => "Firefox152" }.each do |profile, name| assert_equal name, profile.to_s From 480666e05dbdccbfba494c89e559eaae7c7e6afd Mon Sep 17 00:00:00 2001 From: gngpp Date: Fri, 9 Oct 2026 02:34:13 +0800 Subject: [PATCH 29/38] chore(release): prepare v1.3.1 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6445aba..9e64fa1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1490,7 +1490,7 @@ dependencies = [ [[package]] name = "wreq-ruby" -version = "1.3.0" +version = "1.3.1" dependencies = [ "arc-swap", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 7e09e02..4e51f90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = ["SearchApi "] homepage = "https://github.com/SearchApi/wreq-ruby" repository = "https://github.com/SearchApi/wreq-ruby" edition = "2024" -version = "1.3.0" +version = "1.3.1" rust-version = "1.98" [lib] From 2009a6c4bc8021e98028a97b1b009b4a05cfd8b7 Mon Sep 17 00:00:00 2001 From: gngpp Date: Tue, 27 Oct 2026 15:48:16 +0800 Subject: [PATCH 30/38] feat(emulate): add Chrome 156 profile --- README.md | 2 +- crates/wreq-util/CHANGELOG.md | 1 + crates/wreq-util/src/emulate.rs | 3 +- .../wreq-util/src/emulate/profile/chrome.rs | 35 +++++++++++++++++++ .../src/emulate/profile/chrome/tls.rs | 3 +- crates/wreq-util/tests/emulate_chrome.rs | 10 ++++++ lib/wreq_ruby/emulate.rb | 5 +-- src/emulate.rs | 1 + test/emulation_test.rb | 3 +- 9 files changed, 57 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c9b31b8..1c6698a 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ Most browser device models share identical TLS and HTTP/2 configurations, differ | **Browser** | **Versions** | | ----------- | ------------ | - | **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135`, `Chrome136`, `Chrome137`, `Chrome138`, `Chrome139`, `Chrome140`, `Chrome141`, `Chrome142`, `Chrome143`, `Chrome144`, `Chrome145`, `Chrome146`, `Chrome147`, `Chrome148`, `Chrome149`, `Chrome150`, `Chrome151`, `Chrome152`, `Chrome153`, `Chrome154`, `Chrome155` | + | **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135`, `Chrome136`, `Chrome137`, `Chrome138`, `Chrome139`, `Chrome140`, `Chrome141`, `Chrome142`, `Chrome143`, `Chrome144`, `Chrome145`, `Chrome146`, `Chrome147`, `Chrome148`, `Chrome149`, `Chrome150`, `Chrome151`, `Chrome152`, `Chrome153`, `Chrome154`, `Chrome155`, `Chrome156` | | **Edge** | `Edge101`, `Edge122`, `Edge127`, `Edge131`, `Edge134`, `Edge135`, `Edge136`, `Edge137`, `Edge138`, `Edge139`, `Edge140`, `Edge141`, `Edge142`, `Edge143`, `Edge144`, `Edge145`, `Edge146`, `Edge147`, `Edge148` | | **Firefox** | `Firefox109`, `Firefox117`, `Firefox128`, `Firefox133`, `Firefox135`, `FirefoxPrivate135`, `FirefoxAndroid135`, `Firefox136`, `FirefoxPrivate136`, `Firefox139`, `Firefox142`, `Firefox143`, `Firefox144`, `Firefox145`, `Firefox146`, `Firefox147`, `Firefox148`, `Firefox149`, `Firefox150`, `Firefox151`, `Firefox152` | | **Safari** | `Safari15_3`, `Safari15_5`, `Safari15_6_1`, `Safari16`, `Safari16_5`, `Safari17_0`, `Safari17_2_1`, `Safari17_4_1`, `Safari17_5`, `Safari17_6`, `Safari18`, `Safari18_2`, `Safari18_3`, `Safari18_3_1`, `Safari18_5`, `Safari26`, `Safari26_1`, `Safari26_2`, `SafariIos16_5`, `SafariIos17_2`, `SafariIos17_4_1`, `SafariIos18_1_1`, `SafariIos26`, `SafariIos26_2`, `SafariIPad18`, `SafariIPad26`, `SafariIpad26_2` | diff --git a/crates/wreq-util/CHANGELOG.md b/crates/wreq-util/CHANGELOG.md index 6b00b8c..f91f599 100644 --- a/crates/wreq-util/CHANGELOG.md +++ b/crates/wreq-util/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - *(emulate)* Add Chrome 153 profile. - *(emulate)* Add Chrome 154 profile. - *(emulate)* Add Chrome 155 profile, including the JPEG XL navigation Accept header. +- *(emulate)* Add Chrome 156 profile. - *(emulate)* Add Firefox 152 profile. ### Fixed diff --git a/crates/wreq-util/src/emulate.rs b/crates/wreq-util/src/emulate.rs index 9801a78..914908d 100644 --- a/crates/wreq-util/src/emulate.rs +++ b/crates/wreq-util/src/emulate.rs @@ -66,6 +66,7 @@ define_enum!( Chrome153 => ("chrome_153", v153::emulation), Chrome154 => ("chrome_154", v154::emulation), Chrome155 => ("chrome_155", v155::emulation), + Chrome156 => ("chrome_156", v156::emulation), // Edge versions Edge101 => ("edge_101", edge101::emulation), @@ -221,7 +222,7 @@ impl Platform { /// Conversion through [`wreq::IntoEmulation`] creates a native configuration, /// including a randomized Trust Anchor ID order for Chrome 152/153 profiles. /// Client-level emulation retains that order for subsequent connections. -/// Chrome 154/155 sort the IDs by their raw bytes instead. +/// Chrome 154–156 sort the IDs by their raw bytes instead. #[derive(Default, Clone, TypedBuilder)] pub struct Emulation { /// Whether to change the profile (browser/okhttp) information. diff --git a/crates/wreq-util/src/emulate/profile/chrome.rs b/crates/wreq-util/src/emulate/profile/chrome.rs index 7954c8b..6f2f974 100644 --- a/crates/wreq-util/src/emulate/profile/chrome.rs +++ b/crates/wreq-util/src/emulate/profile/chrome.rs @@ -1999,6 +1999,41 @@ mod_generator!( ] ); +// Chrome 156 retains Chrome 155's TLS/HTTP2 and Accept configuration. +// https://chromium.googlesource.com/chromium/src/+/29eb03535d5f2f4f899b95f22a92413ffde5284e/components/embedder_support/user_agent_utils.cc +mod_generator!( + v156, + v154::build_emulation, + header_initializer_chrome155, + [ + ( + MacOS, + r#""Not:A-Brand";v="8", "Chromium";v="156", "Google Chrome";v="156""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/156.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Not:A-Brand";v="8", "Chromium";v="156", "Google Chrome";v="156""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/156.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Not:A-Brand";v="8", "Chromium";v="156", "Google Chrome";v="156""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/156.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Not:A-Brand";v="8", "Chromium";v="156", "Google Chrome";v="156""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/156.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Not:A-Brand";v="8", "Chromium";v="156", "Google Chrome";v="156""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/156.0.8078.54 Mobile/15E148 Safari/604.1" + ) + ] +); + mod_generator!( edge143, v132::build_emulation, diff --git a/crates/wreq-util/src/emulate/profile/chrome/tls.rs b/crates/wreq-util/src/emulate/profile/chrome/tls.rs index cf870fa..2fa80d0 100644 --- a/crates/wreq-util/src/emulate/profile/chrome/tls.rs +++ b/crates/wreq-util/src/emulate/profile/chrome/tls.rs @@ -235,6 +235,7 @@ mod tests { crate::Profile::Chrome153, crate::Profile::Chrome154, crate::Profile::Chrome155, + crate::Profile::Chrome156, ] { let native = profile.into_emulation(); let cloned = native.clone(); @@ -246,7 +247,7 @@ mod tests { expected.sort_unstable(); if matches!( profile, - crate::Profile::Chrome154 | crate::Profile::Chrome155 + crate::Profile::Chrome154 | crate::Profile::Chrome155 | crate::Profile::Chrome156 ) { assert_eq!(decoded, expected); } diff --git a/crates/wreq-util/tests/emulate_chrome.rs b/crates/wreq-util/tests/emulate_chrome.rs index 85f4ad8..2e2bc72 100644 --- a/crates/wreq-util/tests/emulate_chrome.rs +++ b/crates/wreq-util/tests/emulate_chrome.rs @@ -315,3 +315,13 @@ test_emulation!( ], "52d84b11737d980aef856699f885ca86" ); + +test_emulation!( + test_chrome156, + Emulation::Chrome156, + [ + "t13d1517h2_8daaf6152771_cb7bf5808d99", + "t13d1518h2_8daaf6152771_e2d80978ab2e" + ], + "52d84b11737d980aef856699f885ca86" +); diff --git a/lib/wreq_ruby/emulate.rb b/lib/wreq_ruby/emulate.rb index ce10c27..7255e85 100644 --- a/lib/wreq_ruby/emulate.rb +++ b/lib/wreq_ruby/emulate.rb @@ -67,6 +67,7 @@ class Profile Chrome153 = nil Chrome154 = nil Chrome155 = nil + Chrome156 = nil Edge101 = nil Edge122 = nil @@ -267,7 +268,7 @@ def hash # # Construction generates the native configuration once. For Chrome 152/153, # the TLS trust_anchors extension's ID order is randomized at construction; - # Chrome 154/155 sort those IDs by their raw bytes instead. Reusing this object + # Chrome 154–156 sort those IDs by their raw bytes instead. Reusing this object # across clients or requests retains that order. Creating a new object generates # a new configuration, including a fresh shuffle for Chrome 152/153. # This does not freeze other per-handshake randomness or force a new handshake @@ -299,7 +300,7 @@ class Emulation # This stub is for documentation only. unless singleton_methods(false).include?(:new) # Generates a reusable native configuration. Chrome 152/153 Trust Anchor ID - # order is chosen here and retained when this object is reused; Chrome 154/155 + # order is chosen here and retained when this object is reused; Chrome 154–156 # use raw-byte sorted order. See {Emulation} for connection semantics. # # @param profile [Wreq::Profile, nil] Fingerprint profile to emulate diff --git a/src/emulate.rs b/src/emulate.rs index 9c94102..a611f7f 100644 --- a/src/emulate.rs +++ b/src/emulate.rs @@ -93,6 +93,7 @@ define_ruby_enum!( Chrome153, Chrome154, Chrome155, + Chrome156, Edge101, Edge122, diff --git a/test/emulation_test.rb b/test/emulation_test.rb index be6d2ef..91e4e9e 100644 --- a/test/emulation_test.rb +++ b/test/emulation_test.rb @@ -7,7 +7,7 @@ class EmulationTest < Minitest::Test def test_reused_emulation_retains_trust_anchors_across_clients_and_requests - [Wreq::Profile::Chrome152, Wreq::Profile::Chrome153, Wreq::Profile::Chrome154, Wreq::Profile::Chrome155].each do |profile| + [Wreq::Profile::Chrome152, Wreq::Profile::Chrome153, Wreq::Profile::Chrome154, Wreq::Profile::Chrome155, Wreq::Profile::Chrome156].each do |profile| emulation = Wreq::Emulation.new(profile: profile) client = Wreq::Client.new(emulation: emulation, no_proxy: true) expected = capture_trust_anchors { |url| client.get(url, timeout: 5) } @@ -44,6 +44,7 @@ def test_new_browser_profiles_are_available Wreq::Profile::Chrome153 => "Chrome153", Wreq::Profile::Chrome154 => "Chrome154", Wreq::Profile::Chrome155 => "Chrome155", + Wreq::Profile::Chrome156 => "Chrome156", Wreq::Profile::Firefox152 => "Firefox152" }.each do |profile, name| assert_equal name, profile.to_s From ccd227f9dbb62003df78cac2be74238225de839f Mon Sep 17 00:00:00 2001 From: gngpp Date: Tue, 3 Nov 2026 18:08:03 +0800 Subject: [PATCH 31/38] fix(tests): compare fingerprint JSON fields exactly --- crates/wreq-util/Cargo.toml | 1 + crates/wreq-util/tests/emulate_safari.rs | 2 +- crates/wreq-util/tests/support/mod.rs | 27 +++++++++++++----------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/crates/wreq-util/Cargo.toml b/crates/wreq-util/Cargo.toml index 0b7b2f7..e66c7fb 100644 --- a/crates/wreq-util/Cargo.toml +++ b/crates/wreq-util/Cargo.toml @@ -54,6 +54,7 @@ zstd = { version = "0.13.3", optional = true } [dev-dependencies] wreq = "0.16.1" +serde_json = "1.0.151" tokio = { version = "1.48.0", features = ["full"] } hyper = { version = "1.10.1", default-features = false, features = [ "http1", diff --git a/crates/wreq-util/tests/emulate_safari.rs b/crates/wreq-util/tests/emulate_safari.rs index f6e559d..4e4c667 100644 --- a/crates/wreq-util/tests/emulate_safari.rs +++ b/crates/wreq-util/tests/emulate_safari.rs @@ -147,5 +147,5 @@ test_emulation!( test_safari_26_1, Emulation::Safari26_1, ["t13d2014h2_a09f3c656075_e42f34c56612"], - "773906b0efdefa24a7f2b8eb6985bf37" + "c52879e43202aeb92740be6e8c86ea96" ); diff --git a/crates/wreq-util/tests/support/mod.rs b/crates/wreq-util/tests/support/mod.rs index 96adad3..c57ae63 100644 --- a/crates/wreq-util/tests/support/mod.rs +++ b/crates/wreq-util/tests/support/mod.rs @@ -36,18 +36,21 @@ macro_rules! test_emulation { assert_eq!(resp.status(), wreq::StatusCode::OK); let content = resp.text().await.unwrap(); - - let conditional = $ja4.iter().any(|&ja4| content.contains(ja4)); - if !conditional { - println!("{}", content); - } - assert!(conditional); - - let conditional = content.contains($akamai_hash); - if !conditional { - println!("{}", content); - } - assert!(conditional); + let fingerprint: serde_json::Value = serde_json::from_str(&content) + .unwrap_or_else(|error| panic!("invalid fingerprint JSON: {error}\n{content}")); + + let actual_ja4 = fingerprint["ja4"].as_str(); + assert!( + actual_ja4.is_some_and(|value| $ja4.contains(&value)), + "JA4 fingerprint mismatch: expected {:?}, got {actual_ja4:?}\n{content}", + $ja4 + ); + + assert_eq!( + fingerprint["akamai_hash"].as_str(), + Some($akamai_hash), + "HTTP/2 fingerprint mismatch:\n{content}" + ); tokio::time::sleep(std::time::Duration::from_millis(1000)).await; } From 461dd1c8af73b2c5753a3b09cfbdd6891a978c1b Mon Sep 17 00:00:00 2001 From: gngpp Date: Tue, 3 Nov 2026 20:09:25 +0800 Subject: [PATCH 32/38] chore(release): prepare v1.3.2 --- Cargo.lock | 47 +++++++++++-------- Cargo.toml | 16 ++++--- crates/wreq-util/Cargo.toml | 2 +- crates/wreq-util/src/emulate/profile.rs | 4 +- .../src/emulate/profile/chrome/tls.rs | 16 +++++-- .../src/emulate/profile/firefox/tls.rs | 23 ++++----- .../wreq-util/src/emulate/profile/okhttp.rs | 19 +++----- .../src/emulate/profile/opera/tls.rs | 16 +++++-- .../src/emulate/profile/safari/tls.rs | 29 ++++++------ lib/wreq.rb | 18 +++---- lib/wreq_ruby/client.rb | 24 +++++----- 11 files changed, 114 insertions(+), 100 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e64fa1..63bbfe3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,12 +32,6 @@ dependencies = [ "alloc-no-stdlib", ] -[[package]] -name = "allocator-api2" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" - [[package]] name = "arc-swap" version = "1.9.2" @@ -83,6 +77,23 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "bindgen" +version = "0.73.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "787ef8ef523575546b106a58213d6e6b06198a05c2f757258c68a74273670cfa" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex 2.0.1", + "syn 2.0.119", +] + [[package]] name = "bitflags" version = "2.13.1" @@ -113,7 +124,7 @@ dependencies = [ [[package]] name = "btls" version = "0.5.6" -source = "git+https://github.com/0x676e67/btls?rev=de7ab84fdb58641a2bdfdf9d8ebd7db1dcf4b29b#de7ab84fdb58641a2bdfdf9d8ebd7db1dcf4b29b" +source = "git+https://github.com/0x676e67/btls?rev=5ec1c113a03626a5877b34dd6d2ea8d440897a91#5ec1c113a03626a5877b34dd6d2ea8d440897a91" dependencies = [ "bitflags", "btls-sys", @@ -125,9 +136,9 @@ dependencies = [ [[package]] name = "btls-sys" version = "0.5.6" -source = "git+https://github.com/0x676e67/btls?rev=de7ab84fdb58641a2bdfdf9d8ebd7db1dcf4b29b#de7ab84fdb58641a2bdfdf9d8ebd7db1dcf4b29b" +source = "git+https://github.com/0x676e67/btls?rev=5ec1c113a03626a5877b34dd6d2ea8d440897a91#5ec1c113a03626a5877b34dd6d2ea8d440897a91" dependencies = [ - "bindgen", + "bindgen 0.73.2", "cmake", "fs_extra", "fslock", @@ -433,8 +444,6 @@ version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" dependencies = [ - "allocator-api2", - "equivalent", "foldhash", ] @@ -474,7 +483,7 @@ dependencies = [ [[package]] name = "http2" version = "0.5.20" -source = "git+https://github.com/0x676e67/http2?rev=b413a92b2e1fe7e2ea1b7be78e75b872386fdfa0#b413a92b2e1fe7e2ea1b7be78e75b872386fdfa0" +source = "git+https://github.com/0x676e67/http2?rev=29b3bdfc7560d6f84119c103311afa147488b6f0#29b3bdfc7560d6f84119c103311afa147488b6f0" dependencies = [ "atomic-waker", "bytes", @@ -681,9 +690,9 @@ dependencies = [ [[package]] name = "lru" -version = "0.18.2" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d2f2f9b4ba7e6b24d95e7e899329d35be83bcded72c8540cdd5368932d1d90a" +checksum = "4a9f71e3591c7ec44d3e563e87bf14ddc2bada8519dca046e5b0e560cd004e2d" dependencies = [ "hashbrown", ] @@ -873,7 +882,7 @@ version = "0.9.128" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce04b2c55eff3a21aaa623fcc655d94373238e72cac6b3e1a3641ff31649f99a" dependencies = [ - "bindgen", + "bindgen 0.72.1", "lazy_static", "proc-macro2", "quote", @@ -1218,10 +1227,10 @@ dependencies = [ [[package]] name = "tokio-btls" version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e1fd638ec35427faf3b8f412e0fdd6fae76591d79dba40f38fa667d22bc44dd" +source = "git+https://github.com/0x676e67/btls?rev=5ec1c113a03626a5877b34dd6d2ea8d440897a91#5ec1c113a03626a5877b34dd6d2ea8d440897a91" dependencies = [ "btls", + "btls-sys", "tokio", ] @@ -1421,7 +1430,7 @@ dependencies = [ [[package]] name = "wreq" version = "0.16.1" -source = "git+https://github.com/0x676e67/wreq?rev=abd421d16dd48b3c2d7fb812f185eec3c6ec3132#abd421d16dd48b3c2d7fb812f185eec3c6ec3132" +source = "git+https://github.com/0x676e67/wreq?rev=74fc1469b5c54b3fb93037e48f136b569d0fe418#74fc1469b5c54b3fb93037e48f136b569d0fe418" dependencies = [ "btls", "btls-sys", @@ -1490,7 +1499,7 @@ dependencies = [ [[package]] name = "wreq-ruby" -version = "1.3.1" +version = "1.3.2" dependencies = [ "arc-swap", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 4e51f90..bf9d963 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = ["SearchApi "] homepage = "https://github.com/SearchApi/wreq-ruby" repository = "https://github.com/SearchApi/wreq-ruby" edition = "2024" -version = "1.3.1" +version = "1.3.2" rust-version = "1.98" [lib] @@ -17,7 +17,10 @@ name = "wreq_ruby" magnus = { version = "0.8.2", features = ["bytes"] } rb-sys = { version = "0.9.128", default-features = false } tokio = { version = "1.53.1", features = ["full"] } -wreq = { version = "0.16.1", features = [ +# Keep the existing trust store independent of wreq's default feature selection. +wreq = { version = "0.16.1", default-features = false, features = [ + "tokio-rt", + "chromium-roots", "query", "form", "json", @@ -64,8 +67,9 @@ opt-level = 3 strip = true [patch.crates-io] -http2 = { git = "https://github.com/0x676e67/http2", rev = "b413a92b2e1fe7e2ea1b7be78e75b872386fdfa0" } -btls = { git = "https://github.com/0x676e67/btls", rev = "de7ab84fdb58641a2bdfdf9d8ebd7db1dcf4b29b" } -btls-sys = { git = "https://github.com/0x676e67/btls", rev = "de7ab84fdb58641a2bdfdf9d8ebd7db1dcf4b29b" } -wreq = { git = "https://github.com/0x676e67/wreq", rev = "abd421d16dd48b3c2d7fb812f185eec3c6ec3132" } +http2 = { git = "https://github.com/0x676e67/http2", rev = "29b3bdfc7560d6f84119c103311afa147488b6f0" } +btls = { git = "https://github.com/0x676e67/btls", rev = "5ec1c113a03626a5877b34dd6d2ea8d440897a91" } +btls-sys = { git = "https://github.com/0x676e67/btls", rev = "5ec1c113a03626a5877b34dd6d2ea8d440897a91" } +tokio-btls = { git = "https://github.com/0x676e67/btls", rev = "5ec1c113a03626a5877b34dd6d2ea8d440897a91" } +wreq = { git = "https://github.com/0x676e67/wreq", rev = "74fc1469b5c54b3fb93037e48f136b569d0fe418" } wreq-util = { path = "crates/wreq-util" } diff --git a/crates/wreq-util/Cargo.toml b/crates/wreq-util/Cargo.toml index e66c7fb..5c0b011 100644 --- a/crates/wreq-util/Cargo.toml +++ b/crates/wreq-util/Cargo.toml @@ -17,7 +17,7 @@ rustdoc-args = ["--cfg", "docsrs"] targets = ["x86_64-unknown-linux-gnu"] [features] -default = ["emulation"] +default = ["emulation", "tokio-rt"] tokio-rt = ["wreq/tokio-rt"] compio-rt = ["wreq/compio-rt"] diff --git a/crates/wreq-util/src/emulate/profile.rs b/crates/wreq-util/src/emulate/profile.rs index 11a98cc..6d604ed 100644 --- a/crates/wreq-util/src/emulate/profile.rs +++ b/crates/wreq-util/src/emulate/profile.rs @@ -17,8 +17,8 @@ use wreq::{ StreamDependency, StreamId, }, tls::{ - AlpnProtocol, AlpsProtocol, ExtensionType, KeyShare, TlsOptions, TlsVersion, - compress::CertificateCompressor, + AlpnProtocol, AlpsProtocol, EchGrease, EchGreaseAead, ExtensionType, KeyShare, Tls13Cipher, + TlsOptions, TlsVersion, compress::CertificateCompressor, }, }; diff --git a/crates/wreq-util/src/emulate/profile/chrome/tls.rs b/crates/wreq-util/src/emulate/profile/chrome/tls.rs index 2fa80d0..0cd610a 100644 --- a/crates/wreq-util/src/emulate/profile/chrome/tls.rs +++ b/crates/wreq-util/src/emulate/profile/chrome/tls.rs @@ -71,9 +71,6 @@ pub const CURVES_3: &str = join!(":", "X25519MLKEM768", "X25519", "P-256", "P-38 pub const CIPHER_LIST: &str = join!( ":", - "TLS_AES_128_GCM_SHA256", - "TLS_AES_256_GCM_SHA384", - "TLS_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", @@ -88,6 +85,12 @@ pub const CIPHER_LIST: &str = join!( "TLS_RSA_WITH_AES_256_CBC_SHA" ); +pub const TLS13_CIPHER_LIST: &[Tls13Cipher] = &[ + Tls13Cipher::AES_128_GCM_SHA256, + Tls13Cipher::AES_256_GCM_SHA384, + Tls13Cipher::CHACHA20_POLY1305_SHA256, +]; + pub const SIGALGS_LIST: &str = join!( ":", "ecdsa_secp256r1_sha256", @@ -200,14 +203,17 @@ impl From for TlsOptions { .curves_list(val.curves) .sigalgs_list(val.sigalgs_list) .cipher_list(val.cipher_list) + .tls13_cipher_list(TLS13_CIPHER_LIST) .min_tls_version(TlsVersion::TLS_1_2) .max_tls_version(TlsVersion::TLS_1_3) .permute_extensions(val.permute_extensions) .pre_shared_key(val.pre_shared_key) - .enable_ech_grease(val.enable_ech_grease) + .ech_grease( + val.enable_ech_grease + .then_some(EchGrease::Aead(EchGreaseAead::AES_128_GCM)), + ) .alps_protocols([val.alps_protos]) .alps_use_new_codepoint(val.alps_use_new_codepoint) - .aes_hw_override(true) .certificate_compressors(CERTIFICATE_COMPRESSORS); let builder = if let Some(trust_anchors) = val.trust_anchors { builder.trust_anchors(trust_anchors) diff --git a/crates/wreq-util/src/emulate/profile/firefox/tls.rs b/crates/wreq-util/src/emulate/profile/firefox/tls.rs index 0c4e9c4..fb610b3 100644 --- a/crates/wreq-util/src/emulate/profile/firefox/tls.rs +++ b/crates/wreq-util/src/emulate/profile/firefox/tls.rs @@ -86,9 +86,6 @@ pub const KEY_SHARES_2: &[KeyShare] = pub const CIPHER_LIST_1: &str = join!( ":", - "TLS_AES_128_GCM_SHA256", - "TLS_CHACHA20_POLY1305_SHA256", - "TLS_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", @@ -107,9 +104,6 @@ pub const CIPHER_LIST_1: &str = join!( pub const CIPHER_LIST_2: &str = join!( ":", - "TLS_AES_128_GCM_SHA256", - "TLS_CHACHA20_POLY1305_SHA256", - "TLS_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", @@ -126,9 +120,6 @@ pub const CIPHER_LIST_2: &str = join!( pub const CIPHER_LIST_3: &str = join!( ":", - "TLS_AES_128_GCM_SHA256", - "TLS_CHACHA20_POLY1305_SHA256", - "TLS_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", @@ -159,6 +150,12 @@ pub const SIGALGS_LIST: &str = join!( "rsa_pkcs1_sha1" ); +pub const TLS13_CIPHER_LIST: &[Tls13Cipher] = &[ + Tls13Cipher::AES_128_GCM_SHA256, + Tls13Cipher::CHACHA20_POLY1305_SHA256, + Tls13Cipher::AES_256_GCM_SHA384, +]; + pub const CERTIFICATE_COMPRESSORS: &[&'static dyn CertificateCompressor] = &[&ZlibCompressor, &BrotliCompressor, &ZstdCompressor]; @@ -243,11 +240,12 @@ impl From for TlsOptions { .curves_list(val.curves_list) .sigalgs_list(val.sigalgs_list) .cipher_list(val.cipher_list) + .tls13_cipher_list(TLS13_CIPHER_LIST) .session_ticket(val.session_ticket) .delegated_credentials(val.delegated_credentials) .record_size_limit(val.record_size_limit) .enable_ocsp_stapling(true) - .enable_ech_grease(val.enable_ech_grease) + .ech_grease(val.enable_ech_grease.then_some(EchGrease::NssPre3127)) .enable_signed_cert_timestamps(val.enable_signed_cert_timestamps) .alpn_protocols([AlpnProtocol::HTTP2, AlpnProtocol::HTTP1]) .min_tls_version(TlsVersion::TLS_1_2) @@ -255,10 +253,7 @@ impl From for TlsOptions { .pre_shared_key(val.pre_shared_key) .psk_skip_session_ticket(val.psk_skip_session_tickets) .psk_dhe_ke(val.psk_dhe_ke) - .preserve_tls13_cipher_list(true) - .extension_permutation(val.extension_permutation) - .aes_hw_override(true) - .random_aes_hw_override(true); + .extension_permutation(val.extension_permutation); if let Some(key_shares) = val.key_shares { builder = builder.key_shares(key_shares) diff --git a/crates/wreq-util/src/emulate/profile/okhttp.rs b/crates/wreq-util/src/emulate/profile/okhttp.rs index 11342ab..5eaf2a6 100644 --- a/crates/wreq-util/src/emulate/profile/okhttp.rs +++ b/crates/wreq-util/src/emulate/profile/okhttp.rs @@ -17,9 +17,6 @@ const SIGALGS_LIST: &str = join!( const CIPHER_LIST: &str = join!( ":", - "TLS_AES_128_GCM_SHA256", - "TLS_AES_256_GCM_SHA384", - "TLS_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", @@ -35,6 +32,12 @@ const CIPHER_LIST: &str = join!( "TLS_RSA_WITH_3DES_EDE_CBC_SHA" ); +const TLS13_CIPHER_LIST: &[Tls13Cipher] = &[ + Tls13Cipher::AES_128_GCM_SHA256, + Tls13Cipher::AES_256_GCM_SHA384, + Tls13Cipher::CHACHA20_POLY1305_SHA256, +]; + #[derive(TypedBuilder)] struct OkHttpTlsConfig { #[builder(default = CURVES)] @@ -53,9 +56,9 @@ impl From for TlsOptions { .curves_list(val.curves) .sigalgs_list(val.sigalgs_list) .cipher_list(val.cipher_list) + .tls13_cipher_list(TLS13_CIPHER_LIST) .min_tls_version(TlsVersion::TLS_1_2) .max_tls_version(TlsVersion::TLS_1_3) - .aes_hw_override(true) .build() } } @@ -175,11 +178,6 @@ mod_generator!( okhttp3_13, join!( ":", - "TLS_AES_128_GCM_SHA256", - "TLS_AES_256_GCM_SHA384", - "TLS_CHACHA20_POLY1305_SHA256", - "TLS_AES_128_CCM_SHA256", - "TLS_AES_256_CCM_8_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", @@ -213,9 +211,6 @@ mod_generator!( okhttp4_9, join!( ":", - "TLS_AES_128_GCM_SHA256", - "TLS_AES_256_GCM_SHA384", - "TLS_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", diff --git a/crates/wreq-util/src/emulate/profile/opera/tls.rs b/crates/wreq-util/src/emulate/profile/opera/tls.rs index 434352c..b1cbf4d 100644 --- a/crates/wreq-util/src/emulate/profile/opera/tls.rs +++ b/crates/wreq-util/src/emulate/profile/opera/tls.rs @@ -16,9 +16,6 @@ pub const CURVES: &str = join!(":", "X25519MLKEM768", "X25519", "P-256", "P-384" pub const CIPHER_LIST: &str = join!( ":", - "TLS_AES_128_GCM_SHA256", - "TLS_AES_256_GCM_SHA384", - "TLS_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", @@ -33,6 +30,12 @@ pub const CIPHER_LIST: &str = join!( "TLS_RSA_WITH_AES_256_CBC_SHA" ); +pub const TLS13_CIPHER_LIST: &[Tls13Cipher] = &[ + Tls13Cipher::AES_128_GCM_SHA256, + Tls13Cipher::AES_256_GCM_SHA384, + Tls13Cipher::CHACHA20_POLY1305_SHA256, +]; + pub const SIGALGS_LIST: &str = join!( ":", "ecdsa_secp256r1_sha256", @@ -83,14 +86,17 @@ impl From for TlsOptions { .curves_list(val.curves) .sigalgs_list(val.sigalgs_list) .cipher_list(val.cipher_list) + .tls13_cipher_list(TLS13_CIPHER_LIST) .min_tls_version(TlsVersion::TLS_1_2) .max_tls_version(TlsVersion::TLS_1_3) .permute_extensions(val.permute_extensions) .pre_shared_key(val.pre_shared_key) - .enable_ech_grease(val.enable_ech_grease) + .ech_grease( + val.enable_ech_grease + .then_some(EchGrease::Aead(EchGreaseAead::AES_128_GCM)), + ) .alps_protocols([val.alps_protos]) .alps_use_new_codepoint(val.alps_use_new_codepoint) - .aes_hw_override(true) .certificate_compressors(CERTIFICATE_COMPRESSORS) .build() } diff --git a/crates/wreq-util/src/emulate/profile/safari/tls.rs b/crates/wreq-util/src/emulate/profile/safari/tls.rs index a412a8d..a495a14 100644 --- a/crates/wreq-util/src/emulate/profile/safari/tls.rs +++ b/crates/wreq-util/src/emulate/profile/safari/tls.rs @@ -19,7 +19,7 @@ macro_rules! tls_options { .curves($curves) .cipher_list($cipher_list) .sigalgs_list($sigalgs_list) - .preserve_tls13_cipher_list(true) + .tls13_cipher_list(TLS13_CIPHER_LIST) .min_tls_version(wreq::tls::TlsVersion::TLS_1_2) .max_tls_version(wreq::tls::TlsVersion::TLS_1_3) .build() @@ -33,9 +33,6 @@ pub const CURVES_2: &str = join!(":", "X25519MLKEM768", "X25519", "P-256", "P-38 pub const CIPHER_LIST_1: &str = join!( ":", - "TLS_AES_128_GCM_SHA256", - "TLS_AES_256_GCM_SHA384", - "TLS_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", @@ -62,9 +59,6 @@ pub const CIPHER_LIST_1: &str = join!( ); pub const CIPHER_LIST_2: &str = join!( ":", - "TLS_AES_128_GCM_SHA256", - "TLS_AES_256_GCM_SHA384", - "TLS_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", @@ -85,9 +79,6 @@ pub const CIPHER_LIST_2: &str = join!( ); pub const CIPHER_LIST_3: &str = join!( ":", - "TLS_AES_256_GCM_SHA384", - "TLS_CHACHA20_POLY1305_SHA256", - "TLS_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", @@ -107,6 +98,12 @@ pub const CIPHER_LIST_3: &str = join!( "TLS_RSA_WITH_3DES_EDE_CBC_SHA" ); +pub const TLS13_CIPHER_LIST: &[Tls13Cipher] = &[ + Tls13Cipher::AES_256_GCM_SHA384, + Tls13Cipher::CHACHA20_POLY1305_SHA256, + Tls13Cipher::AES_128_GCM_SHA256, +]; + pub const SIGALGS_LIST_1: &str = join!( ":", "ecdsa_secp256r1_sha256", @@ -155,23 +152,25 @@ pub struct SafariTlsConfig { cipher_list: &'static str, #[builder(default, setter(strip_option))] - preserve_tls13_cipher_list: Option, + tls13_cipher_list: Option<&'static [Tls13Cipher]>, } impl From for TlsOptions { fn from(val: SafariTlsConfig) -> Self { - TlsOptions::builder() + let mut builder = TlsOptions::builder() .session_ticket(false) .grease_enabled(true) .enable_ocsp_stapling(true) .enable_signed_cert_timestamps(true) - .preserve_tls13_cipher_list(val.preserve_tls13_cipher_list) .curves_list(val.curves) .sigalgs_list(val.sigalgs_list) .cipher_list(val.cipher_list) .min_tls_version(val.min_tls_version) .max_tls_version(val.max_tls_version) - .certificate_compressors(CERTIFICATE_COMPRESSORS) - .build() + .certificate_compressors(CERTIFICATE_COMPRESSORS); + if let Some(ciphers) = val.tls13_cipher_list { + builder = builder.tls13_cipher_list(ciphers); + } + builder.build() } } diff --git a/lib/wreq.rb b/lib/wreq.rb index 3d8de6f..23e7cc1 100644 --- a/lib/wreq.rb +++ b/lib/wreq.rb @@ -76,7 +76,7 @@ module Wreq # @param deflate [Boolean, nil] Enable deflate compression # @param zstd [Boolean, nil] Enable Zstandard compression # @param timeout [Integer, nil] Total request timeout (seconds) - # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds) + # @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds) # @param proxy [String, nil] Proxy server URI # @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail. # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError. @@ -110,7 +110,7 @@ def self.request(method, url, **options) # @param deflate [Boolean, nil] Enable deflate compression # @param zstd [Boolean, nil] Enable Zstandard compression # @param timeout [Integer, nil] Total request timeout (seconds) - # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds) + # @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds) # @param proxy [String, nil] Proxy server URI # @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail. # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError. @@ -144,7 +144,7 @@ def self.get(url, **options) # @param deflate [Boolean, nil] Enable deflate compression # @param zstd [Boolean, nil] Enable Zstandard compression # @param timeout [Integer, nil] Total request timeout (seconds) - # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds) + # @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds) # @param proxy [String, nil] Proxy server URI # @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail. # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError. @@ -178,7 +178,7 @@ def self.head(url, **options) # @param deflate [Boolean, nil] Enable deflate compression # @param zstd [Boolean, nil] Enable Zstandard compression # @param timeout [Integer, nil] Total request timeout (seconds) - # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds) + # @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds) # @param proxy [String, nil] Proxy server URI # @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail. # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError. @@ -212,7 +212,7 @@ def self.post(url, **options) # @param deflate [Boolean, nil] Enable deflate compression # @param zstd [Boolean, nil] Enable Zstandard compression # @param timeout [Integer, nil] Total request timeout (seconds) - # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds) + # @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds) # @param proxy [String, nil] Proxy server URI # @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail. # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError. @@ -246,7 +246,7 @@ def self.put(url, **options) # @param deflate [Boolean, nil] Enable deflate compression # @param zstd [Boolean, nil] Enable Zstandard compression # @param timeout [Integer, nil] Total request timeout (seconds) - # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds) + # @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds) # @param proxy [String, nil] Proxy server URI # @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail. # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError. @@ -280,7 +280,7 @@ def self.delete(url, **options) # @param deflate [Boolean, nil] Enable deflate compression # @param zstd [Boolean, nil] Enable Zstandard compression # @param timeout [Integer, nil] Total request timeout (seconds) - # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds) + # @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds) # @param proxy [String, nil] Proxy server URI # @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail. # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError. @@ -314,7 +314,7 @@ def self.options(url, **options) # @param deflate [Boolean, nil] Enable deflate compression # @param zstd [Boolean, nil] Enable Zstandard compression # @param timeout [Integer, nil] Total request timeout (seconds) - # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds) + # @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds) # @param proxy [String, nil] Proxy server URI # @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail. # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError. @@ -348,7 +348,7 @@ def self.trace(url, **options) # @param deflate [Boolean, nil] Enable deflate compression # @param zstd [Boolean, nil] Enable Zstandard compression # @param timeout [Integer, nil] Total request timeout (seconds) - # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds) + # @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds) # @param proxy [String, nil] Proxy server URI # @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail. # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError. diff --git a/lib/wreq_ruby/client.rb b/lib/wreq_ruby/client.rb index 9e62269..592e1d2 100644 --- a/lib/wreq_ruby/client.rb +++ b/lib/wreq_ruby/client.rb @@ -84,8 +84,8 @@ class Client # from the overall timeout. # # @param read_timeout [Integer, nil] Maximum time in seconds to wait - # between reading chunks of data from the server. Applies to each - # read operation, not the entire response. + # for response headers or each body chunk. Time spent by the caller + # between body reads is excluded. Defaults to no read timeout. # # @param tcp_keepalive [Integer, nil] Time in seconds that a connection # must be idle before TCP keepalive probes are sent. Helps detect @@ -196,7 +196,7 @@ class Client # client = Wreq::Client.new( # timeout: 30, # 30 seconds total # connect_timeout: 5, # 5 seconds to connect - # read_timeout: 10 # 10 seconds between reads + # read_timeout: 10 # 10 seconds for headers or each body read # ) # # @example Client with redirect handling @@ -280,7 +280,7 @@ def self.new(**options) # @param deflate [Boolean, nil] Enable deflate compression # @param zstd [Boolean, nil] Enable Zstandard compression # @param timeout [Integer, nil] Total request timeout (seconds) - # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds) + # @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds) # @param proxy [String, nil] Proxy server URI # @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail. # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError. @@ -316,7 +316,7 @@ def request(method, url, **options) # @param deflate [Boolean, nil] Enable deflate compression # @param zstd [Boolean, nil] Enable Zstandard compression # @param timeout [Integer, nil] Total request timeout (seconds) - # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds) + # @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds) # @param proxy [String, nil] Proxy server URI # @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail. # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError. @@ -350,7 +350,7 @@ def get(url, **options) # @param deflate [Boolean, nil] Enable deflate compression # @param zstd [Boolean, nil] Enable Zstandard compression # @param timeout [Integer, nil] Total request timeout (seconds) - # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds) + # @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds) # @param proxy [String, nil] Proxy server URI # @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail. # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError. @@ -384,7 +384,7 @@ def head(url, **options) # @param deflate [Boolean, nil] Enable deflate compression # @param zstd [Boolean, nil] Enable Zstandard compression # @param timeout [Integer, nil] Total request timeout (seconds) - # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds) + # @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds) # @param proxy [String, nil] Proxy server URI # @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail. # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError. @@ -418,7 +418,7 @@ def post(url, **options) # @param deflate [Boolean, nil] Enable deflate compression # @param zstd [Boolean, nil] Enable Zstandard compression # @param timeout [Integer, nil] Total request timeout (seconds) - # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds) + # @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds) # @param proxy [String, nil] Proxy server URI # @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail. # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError. @@ -452,7 +452,7 @@ def put(url, **options) # @param deflate [Boolean, nil] Enable deflate compression # @param zstd [Boolean, nil] Enable Zstandard compression # @param timeout [Integer, nil] Total request timeout (seconds) - # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds) + # @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds) # @param proxy [String, nil] Proxy server URI # @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail. # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError. @@ -486,7 +486,7 @@ def delete(url, **options) # @param deflate [Boolean, nil] Enable deflate compression # @param zstd [Boolean, nil] Enable Zstandard compression # @param timeout [Integer, nil] Total request timeout (seconds) - # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds) + # @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds) # @param proxy [String, nil] Proxy server URI # @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail. # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError. @@ -520,7 +520,7 @@ def options(url, **options) # @param deflate [Boolean, nil] Enable deflate compression # @param zstd [Boolean, nil] Enable Zstandard compression # @param timeout [Integer, nil] Total request timeout (seconds) - # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds) + # @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds) # @param proxy [String, nil] Proxy server URI # @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail. # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError. @@ -554,7 +554,7 @@ def trace(url, **options) # @param deflate [Boolean, nil] Enable deflate compression # @param zstd [Boolean, nil] Enable Zstandard compression # @param timeout [Integer, nil] Total request timeout (seconds) - # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds) + # @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds) # @param proxy [String, nil] Proxy server URI # @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail. # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError. From 223f5c5f100ad67aac8b9156fe384fe8d5266729 Mon Sep 17 00:00:00 2001 From: gngpp Date: Tue, 10 Nov 2026 14:56:13 +0800 Subject: [PATCH 33/38] feat(emulate): add Chrome 157 profile --- README.md | 2 +- crates/wreq-util/src/emulate.rs | 1 + .../wreq-util/src/emulate/profile/chrome.rs | 36 +++++++++++++++++++ .../src/emulate/profile/chrome/tls.rs | 6 +++- crates/wreq-util/tests/emulate_chrome.rs | 10 ++++++ lib/wreq_ruby/emulate.rb | 3 +- src/emulate.rs | 1 + test/emulation_test.rb | 3 +- 8 files changed, 58 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1c6698a..fd5479a 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ Most browser device models share identical TLS and HTTP/2 configurations, differ | **Browser** | **Versions** | | ----------- | ------------ | - | **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135`, `Chrome136`, `Chrome137`, `Chrome138`, `Chrome139`, `Chrome140`, `Chrome141`, `Chrome142`, `Chrome143`, `Chrome144`, `Chrome145`, `Chrome146`, `Chrome147`, `Chrome148`, `Chrome149`, `Chrome150`, `Chrome151`, `Chrome152`, `Chrome153`, `Chrome154`, `Chrome155`, `Chrome156` | + | **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135`, `Chrome136`, `Chrome137`, `Chrome138`, `Chrome139`, `Chrome140`, `Chrome141`, `Chrome142`, `Chrome143`, `Chrome144`, `Chrome145`, `Chrome146`, `Chrome147`, `Chrome148`, `Chrome149`, `Chrome150`, `Chrome151`, `Chrome152`, `Chrome153`, `Chrome154`, `Chrome155`, `Chrome156`, `Chrome157` | | **Edge** | `Edge101`, `Edge122`, `Edge127`, `Edge131`, `Edge134`, `Edge135`, `Edge136`, `Edge137`, `Edge138`, `Edge139`, `Edge140`, `Edge141`, `Edge142`, `Edge143`, `Edge144`, `Edge145`, `Edge146`, `Edge147`, `Edge148` | | **Firefox** | `Firefox109`, `Firefox117`, `Firefox128`, `Firefox133`, `Firefox135`, `FirefoxPrivate135`, `FirefoxAndroid135`, `Firefox136`, `FirefoxPrivate136`, `Firefox139`, `Firefox142`, `Firefox143`, `Firefox144`, `Firefox145`, `Firefox146`, `Firefox147`, `Firefox148`, `Firefox149`, `Firefox150`, `Firefox151`, `Firefox152` | | **Safari** | `Safari15_3`, `Safari15_5`, `Safari15_6_1`, `Safari16`, `Safari16_5`, `Safari17_0`, `Safari17_2_1`, `Safari17_4_1`, `Safari17_5`, `Safari17_6`, `Safari18`, `Safari18_2`, `Safari18_3`, `Safari18_3_1`, `Safari18_5`, `Safari26`, `Safari26_1`, `Safari26_2`, `SafariIos16_5`, `SafariIos17_2`, `SafariIos17_4_1`, `SafariIos18_1_1`, `SafariIos26`, `SafariIos26_2`, `SafariIPad18`, `SafariIPad26`, `SafariIpad26_2` | diff --git a/crates/wreq-util/src/emulate.rs b/crates/wreq-util/src/emulate.rs index 914908d..ba4d792 100644 --- a/crates/wreq-util/src/emulate.rs +++ b/crates/wreq-util/src/emulate.rs @@ -67,6 +67,7 @@ define_enum!( Chrome154 => ("chrome_154", v154::emulation), Chrome155 => ("chrome_155", v155::emulation), Chrome156 => ("chrome_156", v156::emulation), + Chrome157 => ("chrome_157", v157::emulation), // Edge versions Edge101 => ("edge_101", edge101::emulation), diff --git a/crates/wreq-util/src/emulate/profile/chrome.rs b/crates/wreq-util/src/emulate/profile/chrome.rs index 6f2f974..f9815f4 100644 --- a/crates/wreq-util/src/emulate/profile/chrome.rs +++ b/crates/wreq-util/src/emulate/profile/chrome.rs @@ -2034,6 +2034,42 @@ mod_generator!( ] ); +// Chrome 157 retains Chrome 156's TLS/HTTP2 and Accept configuration. +// Its UA-CH order and GREASE brand are seeded by major version 157. +// https://chromium.googlesource.com/chromium/src/+/653674df293788cf4932c40d914e9e15b41a2d31/components/embedder_support/user_agent_utils.cc +mod_generator!( + v157, + v154::build_emulation, + header_initializer_chrome155, + [ + ( + MacOS, + r#""Not-A.Brand";v="99", "Google Chrome";v="157", "Chromium";v="157""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Not-A.Brand";v="99", "Google Chrome";v="157", "Chromium";v="157""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Not-A.Brand";v="99", "Google Chrome";v="157", "Chromium";v="157""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Not-A.Brand";v="99", "Google Chrome";v="157", "Chromium";v="157""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Not-A.Brand";v="99", "Google Chrome";v="157", "Chromium";v="157""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/157.0.8103.37 Mobile/15E148 Safari/604.1" + ) + ] +); + mod_generator!( edge143, v132::build_emulation, diff --git a/crates/wreq-util/src/emulate/profile/chrome/tls.rs b/crates/wreq-util/src/emulate/profile/chrome/tls.rs index 0cd610a..f189eb3 100644 --- a/crates/wreq-util/src/emulate/profile/chrome/tls.rs +++ b/crates/wreq-util/src/emulate/profile/chrome/tls.rs @@ -242,6 +242,7 @@ mod tests { crate::Profile::Chrome154, crate::Profile::Chrome155, crate::Profile::Chrome156, + crate::Profile::Chrome157, ] { let native = profile.into_emulation(); let cloned = native.clone(); @@ -253,7 +254,10 @@ mod tests { expected.sort_unstable(); if matches!( profile, - crate::Profile::Chrome154 | crate::Profile::Chrome155 | crate::Profile::Chrome156 + crate::Profile::Chrome154 + | crate::Profile::Chrome155 + | crate::Profile::Chrome156 + | crate::Profile::Chrome157 ) { assert_eq!(decoded, expected); } diff --git a/crates/wreq-util/tests/emulate_chrome.rs b/crates/wreq-util/tests/emulate_chrome.rs index 2e2bc72..0bcc518 100644 --- a/crates/wreq-util/tests/emulate_chrome.rs +++ b/crates/wreq-util/tests/emulate_chrome.rs @@ -325,3 +325,13 @@ test_emulation!( ], "52d84b11737d980aef856699f885ca86" ); + +test_emulation!( + test_chrome157, + Emulation::Chrome157, + [ + "t13d1517h2_8daaf6152771_cb7bf5808d99", + "t13d1518h2_8daaf6152771_e2d80978ab2e" + ], + "52d84b11737d980aef856699f885ca86" +); diff --git a/lib/wreq_ruby/emulate.rb b/lib/wreq_ruby/emulate.rb index 7255e85..7dc4dcd 100644 --- a/lib/wreq_ruby/emulate.rb +++ b/lib/wreq_ruby/emulate.rb @@ -68,6 +68,7 @@ class Profile Chrome154 = nil Chrome155 = nil Chrome156 = nil + Chrome157 = nil Edge101 = nil Edge122 = nil @@ -268,7 +269,7 @@ def hash # # Construction generates the native configuration once. For Chrome 152/153, # the TLS trust_anchors extension's ID order is randomized at construction; - # Chrome 154–156 sort those IDs by their raw bytes instead. Reusing this object + # Chrome 154 and later sort those IDs by their raw bytes instead. Reusing this object # across clients or requests retains that order. Creating a new object generates # a new configuration, including a fresh shuffle for Chrome 152/153. # This does not freeze other per-handshake randomness or force a new handshake diff --git a/src/emulate.rs b/src/emulate.rs index a611f7f..7efb010 100644 --- a/src/emulate.rs +++ b/src/emulate.rs @@ -94,6 +94,7 @@ define_ruby_enum!( Chrome154, Chrome155, Chrome156, + Chrome157, Edge101, Edge122, diff --git a/test/emulation_test.rb b/test/emulation_test.rb index 91e4e9e..3dbe07b 100644 --- a/test/emulation_test.rb +++ b/test/emulation_test.rb @@ -7,7 +7,7 @@ class EmulationTest < Minitest::Test def test_reused_emulation_retains_trust_anchors_across_clients_and_requests - [Wreq::Profile::Chrome152, Wreq::Profile::Chrome153, Wreq::Profile::Chrome154, Wreq::Profile::Chrome155, Wreq::Profile::Chrome156].each do |profile| + [Wreq::Profile::Chrome152, Wreq::Profile::Chrome153, Wreq::Profile::Chrome154, Wreq::Profile::Chrome155, Wreq::Profile::Chrome156, Wreq::Profile::Chrome157].each do |profile| emulation = Wreq::Emulation.new(profile: profile) client = Wreq::Client.new(emulation: emulation, no_proxy: true) expected = capture_trust_anchors { |url| client.get(url, timeout: 5) } @@ -45,6 +45,7 @@ def test_new_browser_profiles_are_available Wreq::Profile::Chrome154 => "Chrome154", Wreq::Profile::Chrome155 => "Chrome155", Wreq::Profile::Chrome156 => "Chrome156", + Wreq::Profile::Chrome157 => "Chrome157", Wreq::Profile::Firefox152 => "Firefox152" }.each do |profile, name| assert_equal name, profile.to_s From 13936228d6cee0910614097eaafc1f5b4ba52f67 Mon Sep 17 00:00:00 2001 From: gngpp Date: Tue, 10 Nov 2026 16:08:25 +0800 Subject: [PATCH 34/38] feat(client): enable HTTP/3 with updated wreq --- Cargo.lock | 509 ++++++++++++++++-- Cargo.toml | 12 +- crates/wreq-util/Cargo.toml | 1 + crates/wreq-util/README.md | 6 +- crates/wreq-util/examples/emulate.rs | 10 +- crates/wreq-util/examples/tower_delay.rs | 8 +- crates/wreq-util/src/emulate/macros.rs | 1 - crates/wreq-util/src/emulate/profile.rs | 12 +- .../src/emulate/profile/chrome/http2.rs | 6 +- .../src/emulate/profile/chrome/tls.rs | 45 +- .../src/emulate/profile/firefox/http2.rs | 22 +- .../wreq-util/src/emulate/profile/okhttp.rs | 5 +- .../src/emulate/profile/opera/http2.rs | 6 +- crates/wreq-util/src/tower/delay.rs | 8 +- crates/wreq-util/src/tower/delay/layer.rs | 10 +- crates/wreq-util/tests/client.rs | 10 +- crates/wreq-util/tests/emulate_firefox.rs | 47 +- crates/wreq-util/tests/support/mod.rs | 2 +- lib/wreq_ruby/client.rb | 40 +- lib/wreq_ruby/emulate.rb | 3 + lib/wreq_ruby/http.rb | 11 +- src/client.rs | 12 +- test/option_validation_test.rb | 17 +- 23 files changed, 628 insertions(+), 175 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 63bbfe3..f59208c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -144,6 +144,12 @@ dependencies = [ "fslock", ] +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + [[package]] name = "bytes" version = "1.12.1" @@ -177,6 +183,23 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +[[package]] +name = "cfg_aliases" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" + +[[package]] +name = "chacha20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" +dependencies = [ + "cfg-if", + "cpufeatures", + "rand_core", +] + [[package]] name = "chromium-roots" version = "0.1.1" @@ -236,6 +259,15 @@ dependencies = [ "version_check", ] +[[package]] +name = "cpufeatures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" +dependencies = [ + "libc", +] + [[package]] name = "crc32fast" version = "1.5.0" @@ -251,6 +283,32 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" +[[package]] +name = "derive-deftly" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "724949bdda5310709ca2f97bf69c2b01e3362f44fef1fb47913445db4c1debb5" +dependencies = [ + "derive-deftly-macros", +] + +[[package]] +name = "derive-deftly-macros" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17933e749f2502cfcd1c27519292fbbea22e8fc64ce680e863f855e8cd8cce23" +dependencies = [ + "indexmap", + "itertools", + "proc-macro-crate", + "proc-macro2", + "quote", + "strum", + "syn 2.0.119", + "unicode-ident", + "void", +] + [[package]] name = "displaydoc" version = "0.2.7" @@ -262,6 +320,18 @@ dependencies = [ "syn 3.0.3", ] +[[package]] +name = "educe" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e451fac8dd8dece16234604bf1efce6e90fddd8ab6ad4d66eec0eca5160959dd" +dependencies = [ + "enum-ordinalize", + "proc-macro2", + "quote", + "syn 3.0.3", +] + [[package]] name = "either" version = "1.17.0" @@ -277,6 +347,26 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "enum-ordinalize" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89dd01549b09589510cf0647475075d12071456586d70f5c75c98ae2a5537677" +dependencies = [ + "enum-ordinalize-derive", +] + +[[package]] +name = "enum-ordinalize-derive" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a65863d15a4ce2888bd2f0f543cc963d3879c3a022c8ee43f6141d479a3ac815" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -293,6 +383,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + [[package]] name = "find-msvc-tools" version = "0.1.11" @@ -397,6 +493,12 @@ version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + [[package]] name = "futures-sink" version = "0.3.34" @@ -416,7 +518,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" dependencies = [ "futures-core", + "futures-io", "futures-task", + "memchr", "pin-project-lite", "slab", ] @@ -428,8 +532,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", + "js-sys", "libc", "r-efi", + "rand_core", + "wasm-bindgen", ] [[package]] @@ -447,6 +554,12 @@ dependencies = [ "foldhash", ] +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "http" version = "1.5.0" @@ -483,7 +596,7 @@ dependencies = [ [[package]] name = "http2" version = "0.5.20" -source = "git+https://github.com/0x676e67/http2?rev=29b3bdfc7560d6f84119c103311afa147488b6f0#29b3bdfc7560d6f84119c103311afa147488b6f0" +source = "git+https://github.com/0x676e67/http2?rev=ce505e52ce9c25fb055412cb39b1caaa7a1f70a8#ce505e52ce9c25fb055412cb39b1caaa7a1f70a8" dependencies = [ "atomic-waker", "bytes", @@ -498,6 +611,40 @@ dependencies = [ "tokio-util", ] +[[package]] +name = "http3" +version = "0.2.0" +source = "git+https://github.com/0x676e67/http3?rev=5bd394f3dfb8bc63591627a229c34c02caadc3af#5bd394f3dfb8bc63591627a229c34c02caadc3af" +dependencies = [ + "bytes", + "fastrand", + "futures-util", + "http", + "pin-project-lite", + "smallvec", + "tokio", +] + +[[package]] +name = "http3-datagram" +version = "0.2.0" +source = "git+https://github.com/0x676e67/http3?rev=5bd394f3dfb8bc63591627a229c34c02caadc3af#5bd394f3dfb8bc63591627a229c34c02caadc3af" +dependencies = [ + "bytes", + "http3", +] + +[[package]] +name = "http3-quic" +version = "0.2.0" +source = "git+https://github.com/0x676e67/http3?rev=5bd394f3dfb8bc63591627a229c34c02caadc3af#5bd394f3dfb8bc63591627a229c34c02caadc3af" +dependencies = [ + "bytes", + "futures-util", + "http3", + "quic", +] + [[package]] name = "httparse" version = "1.10.1" @@ -651,6 +798,17 @@ dependencies = [ "libc", ] +[[package]] +name = "js-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -697,6 +855,12 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "lru-slab" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f" + [[package]] name = "magnus" version = "0.8.2" @@ -760,6 +924,30 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "netty" +version = "0.2.5" +source = "git+https://github.com/0x676e67/netty?rev=0e1e53c0d9e500b253361cf6997559c44d7717b5#0e1e53c0d9e500b253361cf6997559c44d7717b5" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "http-body-util", + "http2", + "http3", + "http3-datagram", + "httparse", + "pin-project-lite", + "smallvec", + "tokio", + "tokio-socks", + "tokio-util", + "tower-service", + "want", +] + [[package]] name = "nom" version = "7.1.3" @@ -776,6 +964,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + [[package]] name = "openssl-macros" version = "0.1.1" @@ -843,6 +1037,15 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" +[[package]] +name = "proc-macro-crate" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" +dependencies = [ + "toml_edit", +] + [[package]] name = "proc-macro2" version = "1.0.107" @@ -852,6 +1055,62 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quic" +version = "0.12.2" +source = "git+https://github.com/0x676e67/quic?rev=b3d74044e874c5e785f462e3032faaf021cb6958#b3d74044e874c5e785f462e3032faaf021cb6958" +dependencies = [ + "bytes", + "cfg_aliases", + "futures-io", + "libc", + "pin-project-lite", + "quic-proto", + "quinn-udp", + "rustc-hash", + "socket2", + "thiserror 2.0.21", + "tokio", + "tracing", + "web-time", + "windows-sys", +] + +[[package]] +name = "quic-proto" +version = "0.12.2" +source = "git+https://github.com/0x676e67/quic?rev=b3d74044e874c5e785f462e3032faaf021cb6958#b3d74044e874c5e785f462e3032faaf021cb6958" +dependencies = [ + "btls", + "bytes", + "getrandom", + "lru", + "lru-slab", + "rand", + "rand_pcg", + "rustc-hash", + "rustls-pki-types", + "slab", + "thiserror 2.0.21", + "tinyvec", + "tracing", + "web-time", + "zeroize", +] + +[[package]] +name = "quinn-udp" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47091c86514c2e11452cb228dee77037334b99d92a23e4c69aa5982261f39247" +dependencies = [ + "cfg_aliases", + "libc", + "socket2", + "tracing", + "windows-sys", +] + [[package]] name = "quote" version = "1.0.47" @@ -867,6 +1126,32 @@ version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" +[[package]] +name = "rand" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af" +dependencies = [ + "chacha20", + "getrandom", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + +[[package]] +name = "rand_pcg" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caa0f4137e1c0a72f4c651489402276c8e8e1cf081f3b0ba156d2cbeef09e86a" +dependencies = [ + "rand_core", +] + [[package]] name = "rb-sys" version = "0.9.128" @@ -946,6 +1231,10 @@ name = "rustls-pki-types" version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" +dependencies = [ + "web-time", + "zeroize", +] [[package]] name = "rustversion" @@ -1105,6 +1394,27 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" +[[package]] +name = "strum" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9628de9b8791db39ceda2b119bbe13134770b56c138ec1d3af810d045c04f9bd" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab85eea0270ee17587ed4156089e10b9e6880ee688791d45a905f5b1ca36f664" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "syn" version = "2.0.119" @@ -1153,7 +1463,16 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl 2.0.21", ] [[package]] @@ -1167,6 +1486,17 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", +] + [[package]] name = "time" version = "0.3.55" @@ -1207,6 +1537,12 @@ dependencies = [ "zerovec", ] +[[package]] +name = "tinyvec" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" + [[package]] name = "tokio" version = "1.53.1" @@ -1253,8 +1589,7 @@ checksum = "a7e2948f60dbe26b35f2c7fb74ac2854c1fddded0fe9d7548fcc674a246f7615" dependencies = [ "either", "futures-util", - "thiserror", - "tokio", + "thiserror 1.0.69", ] [[package]] @@ -1271,6 +1606,36 @@ dependencies = [ "tokio", ] +[[package]] +name = "toml_datetime" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +version = "0.25.19+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd43688c4858d7264ae1cf9a9f874a67c3feb74a883b1cd7bebd6a4ea8307218" +dependencies = [ + "indexmap", + "toml_datetime", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.1.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" +dependencies = [ + "winnow", +] + [[package]] name = "tower" version = "0.5.3" @@ -1319,6 +1684,25 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + [[package]] name = "try-lock" version = "0.2.5" @@ -1375,6 +1759,12 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + [[package]] name = "want" version = "0.3.1" @@ -1390,6 +1780,60 @@ version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" +[[package]] +name = "wasm-bindgen" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" +dependencies = [ + "cfg-if", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.3", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "winapi" version = "0.3.9" @@ -1427,29 +1871,42 @@ dependencies = [ "windows-link", ] +[[package]] +name = "winnow" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef" +dependencies = [ + "memchr", +] + [[package]] name = "wreq" version = "0.16.1" -source = "git+https://github.com/0x676e67/wreq?rev=74fc1469b5c54b3fb93037e48f136b569d0fe418#74fc1469b5c54b3fb93037e48f136b569d0fe418" +source = "git+https://github.com/0x676e67/wreq?rev=10029bb86ff88d8ed88b8e10518fe6e1f7ff322c#10029bb86ff88d8ed88b8e10518fe6e1f7ff322c" dependencies = [ "btls", "btls-sys", "bytes", "chromium-roots", "cookie", + "derive-deftly", + "educe", "encoding_rs", "futures-util", "http", "http-body", "http-body-util", "http2", - "httparse", + "http3-quic", "ipnet", "libc", "lru", "mime", + "netty", "percent-encoding", "pin-project-lite", + "quic", "serde", "serde_html_form", "serde_json", @@ -1457,44 +1914,10 @@ dependencies = [ "sync_wrapper", "tokio", "tokio-btls", - "tokio-socks", "tokio-util", "tower", "tower-http", "url", - "wreq-proto", - "wreq-rt", -] - -[[package]] -name = "wreq-proto" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a43942f024bb303f1042c9aa3c87fa1d9149f507c65db6e5220a11ccdb207387" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "http", - "http-body", - "http2", - "httparse", - "pin-project-lite", - "smallvec", - "tokio", - "tokio-util", - "want", -] - -[[package]] -name = "wreq-rt" -version = "0.2.2-rc.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e9bce67a3fa3dd3f1503f066d86661c9caf399a763d3bd184da7afaf886c8b" -dependencies = [ - "pin-project-lite", - "tokio", - "wreq-proto", ] [[package]] @@ -1583,6 +2006,12 @@ dependencies = [ "synstructure", ] +[[package]] +name = "zeroize" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" + [[package]] name = "zerotrie" version = "0.2.5" diff --git a/Cargo.toml b/Cargo.toml index bf9d963..e3d1cd1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,8 @@ tokio = { version = "1.53.1", features = ["full"] } # Keep the existing trust store independent of wreq's default feature selection. wreq = { version = "0.16.1", default-features = false, features = [ "tokio-rt", + "http2", + "http3", "chromium-roots", "query", "form", @@ -67,9 +69,15 @@ opt-level = 3 strip = true [patch.crates-io] -http2 = { git = "https://github.com/0x676e67/http2", rev = "29b3bdfc7560d6f84119c103311afa147488b6f0" } +# Keep transport patches aligned with wreq's demo/brave-galileo-ac7w3r branch. +http2 = { git = "https://github.com/0x676e67/http2", rev = "ce505e52ce9c25fb055412cb39b1caaa7a1f70a8" } +http3 = { git = "https://github.com/0x676e67/http3", rev = "5bd394f3dfb8bc63591627a229c34c02caadc3af" } +http3-datagram = { git = "https://github.com/0x676e67/http3", rev = "5bd394f3dfb8bc63591627a229c34c02caadc3af" } +http3-quic = { git = "https://github.com/0x676e67/http3", rev = "5bd394f3dfb8bc63591627a229c34c02caadc3af" } +quic = { git = "https://github.com/0x676e67/quic", rev = "b3d74044e874c5e785f462e3032faaf021cb6958" } +netty = { git = "https://github.com/0x676e67/netty", rev = "0e1e53c0d9e500b253361cf6997559c44d7717b5" } btls = { git = "https://github.com/0x676e67/btls", rev = "5ec1c113a03626a5877b34dd6d2ea8d440897a91" } btls-sys = { git = "https://github.com/0x676e67/btls", rev = "5ec1c113a03626a5877b34dd6d2ea8d440897a91" } tokio-btls = { git = "https://github.com/0x676e67/btls", rev = "5ec1c113a03626a5877b34dd6d2ea8d440897a91" } -wreq = { git = "https://github.com/0x676e67/wreq", rev = "74fc1469b5c54b3fb93037e48f136b569d0fe418" } +wreq = { git = "https://github.com/0x676e67/wreq", rev = "10029bb86ff88d8ed88b8e10518fe6e1f7ff322c" } wreq-util = { path = "crates/wreq-util" } diff --git a/crates/wreq-util/Cargo.toml b/crates/wreq-util/Cargo.toml index 5c0b011..b2436c6 100644 --- a/crates/wreq-util/Cargo.toml +++ b/crates/wreq-util/Cargo.toml @@ -23,6 +23,7 @@ tokio-rt = ["wreq/tokio-rt"] compio-rt = ["wreq/compio-rt"] emulation = [ + "wreq/http2", "dep:typed-builder", "dep:brotli", "dep:flate2", diff --git a/crates/wreq-util/README.md b/crates/wreq-util/README.md index 740c801..6afb1db 100644 --- a/crates/wreq-util/README.md +++ b/crates/wreq-util/README.md @@ -20,12 +20,14 @@ See the [crate documentation](https://docs.rs/wreq-util/latest/wreq_util) for mo ## Example +This vendored copy uses the development wreq revision pinned in the [root Cargo.toml](../../Cargo.toml). Building it independently requires the same Git patches. + The following example uses the [Tokio](https://tokio.rs) runtime with optional features enabled by adding this to your `Cargo.toml`: ```toml [dependencies] tokio = { version = "1", features = ["full"] } -wreq = "6.0.0-rc" +wreq = "0.16.1" wreq-util = "3.0.0-rc" ``` @@ -38,7 +40,7 @@ use wreq_util::Emulation; #[tokio::main] async fn main() -> wreq::Result<()> { // Build a client - let client = Client::builder() + let client = Client::builder_tokio() .emulation(Emulation::Chrome147) .build()?; diff --git a/crates/wreq-util/examples/emulate.rs b/crates/wreq-util/examples/emulate.rs index 1d9ace3..7ff9094 100644 --- a/crates/wreq-util/examples/emulate.rs +++ b/crates/wreq-util/examples/emulate.rs @@ -2,8 +2,10 @@ use wreq_util::{Emulation, Platform, Profile}; #[tokio::main] async fn main() -> Result<(), wreq::Error> { + let client = wreq::Client::builder_tokio().build()?; // Example 1: Basic emulation - Safari26 - let text = wreq::get("https://pingly.us.kg/api/all") + let text = client + .get("https://pingly.us.kg/api/all") .emulation(Emulation::Safari26) .send() .await? @@ -12,7 +14,8 @@ async fn main() -> Result<(), wreq::Error> { println!("{}\n", text); // Example 2: Advanced emulation with options - OkHttp5 - let text = wreq::get("https://pingly.us.kg/api/all") + let text = client + .get("https://pingly.us.kg/api/all") .emulation( Emulation::builder() .profile(Profile::OkHttp5) @@ -27,7 +30,8 @@ async fn main() -> Result<(), wreq::Error> { println!("{}\n", text); // Example 3: Random device emulation - let text = wreq::get("https://pingly.us.kg/api/all") + let text = client + .get("https://pingly.us.kg/api/all") .emulation(Emulation::random()) .send() .await? diff --git a/crates/wreq-util/examples/tower_delay.rs b/crates/wreq-util/examples/tower_delay.rs index 4a22c67..4fe67fd 100644 --- a/crates/wreq-util/examples/tower_delay.rs +++ b/crates/wreq-util/examples/tower_delay.rs @@ -5,7 +5,7 @@ use wreq_util::tower::delay::{DelayLayer, JitterDelayLayer}; #[tokio::main] async fn main() -> Result<(), wreq::Error> { // Build a client with a 1 second delay between requests - let client = Client::builder() + let client = Client::builder_tokio() .layer(DelayLayer::new(Duration::from_secs(1))) .tls_cert_verification(false) .build()?; @@ -52,7 +52,7 @@ async fn basic_jitter_delay() -> Result<(), wreq::Error> { println!("=== Basic Jittered Delay ===\n"); // Build a client with jittered delay: base 1s ± 50% (range: 0.5s to 1.5s) - let client = Client::builder() + let client = Client::builder_tokio() .layer(JitterDelayLayer::new(Duration::from_secs(1), 0.5)) .tls_cert_verification(false) .build()?; @@ -100,7 +100,7 @@ async fn basic_jitter_delay() -> Result<(), wreq::Error> { async fn conditional_jitter_delay() -> Result<(), wreq::Error> { println!("=== Conditional Jittered Delay (using `JitterDelayLayer::when`) ===\n"); - let client = Client::builder() + let client = Client::builder_tokio() .layer(JitterDelayLayer::new(Duration::from_millis(800), 0.3).when( |req: &http::Request<_>| { // Only apply delay to POST requests @@ -149,7 +149,7 @@ async fn conditional_fixed_delay() -> Result<(), wreq::Error> { println!("=== Conditional Fixed Delay (using `DelayLayer::when`) ===\n"); // Build a client that only delays requests to specific paths - let client = Client::builder() + let client = Client::builder_tokio() .layer( DelayLayer::new(Duration::from_secs(1)).when(|req: &http::Request<_>| { // Only apply delay to /delay/* endpoints diff --git a/crates/wreq-util/src/emulate/macros.rs b/crates/wreq-util/src/emulate/macros.rs index f045273..56f4102 100644 --- a/crates/wreq-util/src/emulate/macros.rs +++ b/crates/wreq-util/src/emulate/macros.rs @@ -202,7 +202,6 @@ macro_rules! standard_mod_generator { default_headers: Option, ) -> wreq::Emulation { build_standard_emulation( - stringify!($mod_name), $tls_options, http2.then(|| $http2_options), default_headers, diff --git a/crates/wreq-util/src/emulate/profile.rs b/crates/wreq-util/src/emulate/profile.rs index 6d604ed..b0da064 100644 --- a/crates/wreq-util/src/emulate/profile.rs +++ b/crates/wreq-util/src/emulate/profile.rs @@ -10,11 +10,10 @@ use typed_builder::TypedBuilder; #[cfg(feature = "emulation-compression")] use wreq::header::ACCEPT_ENCODING; use wreq::{ - Group, header::{ACCEPT, ACCEPT_LANGUAGE, HeaderMap, HeaderName, HeaderValue, USER_AGENT}, http2::{ - Http2Options, Priorities, Priority, PseudoId, PseudoOrder, SettingId, SettingsOrder, - StreamDependency, StreamId, + HeadersDependency, HeadersPriority, Http2Options, Priorities, Priority, PseudoId, + PseudoOrder, SettingId, SettingsOrder, StreamDependency, StreamId, }, tls::{ AlpnProtocol, AlpsProtocol, EchGrease, EchGreaseAead, ExtensionType, KeyShare, Tls13Cipher, @@ -28,20 +27,19 @@ use super::{ }; fn build_standard_emulation( - group: &'static str, tls_options: TlsOptions, http2_options: Option, default_headers: Option, ) -> wreq::Emulation { - let mut builder = wreq::Emulation::builder().tls_options(tls_options); + let mut builder = wreq::Emulation::builder().config(tls_options); if let Some(http2_options) = http2_options { - builder = builder.http2_options(http2_options); + builder = builder.config(http2_options); } if let Some(headers) = default_headers { builder = builder.headers(headers); } - builder.build(Group::new(group)) + builder.build() } diff --git a/crates/wreq-util/src/emulate/profile/chrome/http2.rs b/crates/wreq-util/src/emulate/profile/chrome/http2.rs index 841c8a4..a47190a 100644 --- a/crates/wreq-util/src/emulate/profile/chrome/http2.rs +++ b/crates/wreq-util/src/emulate/profile/chrome/http2.rs @@ -1,6 +1,6 @@ -macro_rules! headers_stream_dependency { +macro_rules! headers_priority { () => { - StreamDependency::new(StreamId::zero(), 255, true) + HeadersPriority::new(HeadersDependency::Root, 255, true) }; } @@ -41,7 +41,7 @@ macro_rules! http2_options { .initial_connection_window_size(15728640) .max_header_list_size(262144) .header_table_size(65536) - .headers_stream_dependency(headers_stream_dependency!()) + .headers_priority(headers_priority!()) .headers_pseudo_order(pseudo_order!()) .settings_order(settings_order!()) }; diff --git a/crates/wreq-util/src/emulate/profile/chrome/tls.rs b/crates/wreq-util/src/emulate/profile/chrome/tls.rs index f189eb3..ffabd41 100644 --- a/crates/wreq-util/src/emulate/profile/chrome/tls.rs +++ b/crates/wreq-util/src/emulate/profile/chrome/tls.rs @@ -232,47 +232,14 @@ impl From for TlsOptions { #[cfg(test)] mod tests { use super::*; - use wreq::IntoEmulation; #[test] - fn chrome_profiles_retain_trust_anchor_order_when_cloned() { - for profile in [ - crate::Profile::Chrome152, - crate::Profile::Chrome153, - crate::Profile::Chrome154, - crate::Profile::Chrome155, - crate::Profile::Chrome156, - crate::Profile::Chrome157, - ] { - let native = profile.into_emulation(); - let cloned = native.clone(); - let ids = native.tls_options.unwrap().trust_anchors.unwrap(); - assert_eq!(ids.len(), CHROME_TRUST_ANCHORS.len()); - assert_eq!(ids, cloned.tls_options.unwrap().trust_anchors.unwrap()); - let decoded = decode_ids(&ids); - let mut expected = chromium_roots::trust_anchor_ids(); - expected.sort_unstable(); - if matches!( - profile, - crate::Profile::Chrome154 - | crate::Profile::Chrome155 - | crate::Profile::Chrome156 - | crate::Profile::Chrome157 - ) { - assert_eq!(decoded, expected); - } - let mut actual = decoded; - actual.sort_unstable(); - assert_eq!(actual, expected); - } - assert!( - crate::Profile::Chrome151 - .into_emulation() - .tls_options - .unwrap() - .trust_anchors - .is_none() - ); + fn sorted_trust_anchors_match_chromium_root_store() { + let encoded = sorted_trust_anchors(); + let mut expected = chromium_roots::trust_anchor_ids(); + expected.sort_unstable(); + assert_eq!(decode_ids(&encoded), expected); + assert_eq!(encoded.len(), CHROME_TRUST_ANCHORS.len()); } #[test] diff --git a/crates/wreq-util/src/emulate/profile/firefox/http2.rs b/crates/wreq-util/src/emulate/profile/firefox/http2.rs index b7f18f7..4c93345 100644 --- a/crates/wreq-util/src/emulate/profile/firefox/http2.rs +++ b/crates/wreq-util/src/emulate/profile/firefox/http2.rs @@ -1,9 +1,9 @@ -macro_rules! headers_stream_dependency { +macro_rules! headers_priority { (1) => { - StreamDependency::new(StreamId::zero(), 41, false) + HeadersPriority::new(HeadersDependency::Root, 41, false) }; (2) => { - StreamDependency::new(StreamId::from(13), 41, false) + HeadersPriority::new(HeadersDependency::Declared(StreamId::from(13)), 41, false) }; } @@ -52,28 +52,28 @@ macro_rules! http2_options { .initial_stream_id(3) .header_table_size(65536) .enable_push(false) - .headers_stream_dependency(headers_stream_dependency!(1)) + .headers_priority(headers_priority!(1)) .build() }; (2) => { http2_options!(@base Http2Options::builder()) .initial_stream_id(15) .header_table_size(65536) - .headers_stream_dependency(headers_stream_dependency!(2)) + .headers_priority(headers_priority!(2)) .priorities( Priorities::builder() .extend([ Priority::new( StreamId::from(3), - StreamDependency::new(StreamId::zero(), 200, false), + StreamDependency::new(StreamId::from(0), 200, false), ), Priority::new( StreamId::from(5), - StreamDependency::new(StreamId::zero(), 100, false), + StreamDependency::new(StreamId::from(0), 100, false), ), Priority::new( StreamId::from(7), - StreamDependency::new(StreamId::zero(), 0, false), + StreamDependency::new(StreamId::from(0), 0, false), ), Priority::new( StreamId::from(9), @@ -85,7 +85,7 @@ macro_rules! http2_options { ), Priority::new( StreamId::from(13), - StreamDependency::new(StreamId::zero(), 240, false), + StreamDependency::new(StreamId::from(0), 240, false), ), ]) .build(), @@ -98,7 +98,7 @@ macro_rules! http2_options { .header_table_size(65536) .enable_push(false) .max_concurrent_streams(0) - .headers_stream_dependency(headers_stream_dependency!(1)) + .headers_priority(headers_priority!(1)) .build() }; (4) => { @@ -107,7 +107,7 @@ macro_rules! http2_options { .header_table_size(4096) .enable_push(false) .initial_window_size(32768) - .headers_stream_dependency(headers_stream_dependency!(1)) + .headers_priority(headers_priority!(1)) .build() }; } diff --git a/crates/wreq-util/src/emulate/profile/okhttp.rs b/crates/wreq-util/src/emulate/profile/okhttp.rs index 5eaf2a6..6507f7a 100644 --- a/crates/wreq-util/src/emulate/profile/okhttp.rs +++ b/crates/wreq-util/src/emulate/profile/okhttp.rs @@ -69,14 +69,13 @@ macro_rules! mod_generator { use super::*; pub fn emulation(emulation: Emulation) -> wreq::Emulation { - build_emulation(stringify!($mod_name), emulation, $cipher, $ua) + build_emulation(emulation, $cipher, $ua) } } }; } fn build_emulation( - group: &'static str, emulation: Emulation, cipher_list: &'static str, user_agent: &'static str, @@ -127,7 +126,7 @@ fn build_emulation( headers }); - build_standard_emulation(group, tls_options, http2_options, headers) + build_standard_emulation(tls_options, http2_options, headers) } mod_generator!( diff --git a/crates/wreq-util/src/emulate/profile/opera/http2.rs b/crates/wreq-util/src/emulate/profile/opera/http2.rs index 070d50a..ddc27dd 100644 --- a/crates/wreq-util/src/emulate/profile/opera/http2.rs +++ b/crates/wreq-util/src/emulate/profile/opera/http2.rs @@ -1,6 +1,6 @@ -macro_rules! headers_stream_dependency { +macro_rules! headers_priority { () => { - StreamDependency::new(StreamId::zero(), 255, true) + HeadersPriority::new(HeadersDependency::Root, 255, true) }; } @@ -42,7 +42,7 @@ macro_rules! http2_options { .max_header_list_size(262144) .header_table_size(65536) .enable_push(false) - .headers_stream_dependency(headers_stream_dependency!()) + .headers_priority(headers_priority!()) .headers_pseudo_order(pseudo_order!()) .settings_order(settings_order!()) .build() diff --git a/crates/wreq-util/src/tower/delay.rs b/crates/wreq-util/src/tower/delay.rs index 2bb0ff5..cbcf2d5 100644 --- a/crates/wreq-util/src/tower/delay.rs +++ b/crates/wreq-util/src/tower/delay.rs @@ -10,9 +10,9 @@ //! ```no_run //! use std::time::Duration; //! use wreq::Client; -//! use wreq_util::middleware::delay::DelayLayer; +//! use wreq_util::tower::delay::DelayLayer; //! -//! let client = Client::builder() +//! let client = Client::builder_tokio() //! .layer(DelayLayer::new(Duration::from_secs(1))) //! .build()?; //! # Ok::<(), wreq::Error>(()) @@ -23,9 +23,9 @@ //! ```no_run //! use std::time::Duration; //! use wreq::Client; -//! use wreq_util::middleware::delay::JitterDelayLayer; +//! use wreq_util::tower::delay::JitterDelayLayer; //! -//! let client = Client::builder() +//! let client = Client::builder_tokio() //! .layer(JitterDelayLayer::new(Duration::from_secs(1), 0.2)) //! .build()?; //! # Ok::<(), wreq::Error>(()) diff --git a/crates/wreq-util/src/tower/delay/layer.rs b/crates/wreq-util/src/tower/delay/layer.rs index 043e126..73f90b3 100644 --- a/crates/wreq-util/src/tower/delay/layer.rs +++ b/crates/wreq-util/src/tower/delay/layer.rs @@ -29,10 +29,10 @@ pub struct DelayLayerWith

{ /// ```no_run /// use std::time::Duration; /// use wreq::Client; -/// use wreq_util::middleware::delay::JitterDelayLayer; +/// use wreq_util::tower::delay::JitterDelayLayer; /// /// // Creates delays in range [0.8s, 1.2s] (1s ± 20%) -/// let client = Client::builder() +/// let client = Client::builder_tokio() /// .layer(JitterDelayLayer::new(Duration::from_secs(1), 0.2)) /// .build()?; /// # Ok::<(), wreq::Error>(()) @@ -71,7 +71,7 @@ impl DelayLayer { /// ```ignore /// use std::time::Duration; /// use http::Request; - /// use wreq_util::middleware::delay::DelayLayer; + /// use wreq_util::tower::delay::DelayLayer; /// /// // Only delay POST requests /// let layer = DelayLayer::new(Duration::from_secs(1)) @@ -129,7 +129,7 @@ impl JitterDelayLayer { /// /// ``` /// use std::time::Duration; - /// use wreq_util::middleware::delay::JitterDelayLayer; + /// use wreq_util::tower::delay::JitterDelayLayer; /// /// // Creates delays in range [800ms, 1200ms] /// let layer = JitterDelayLayer::new(Duration::from_secs(1), 0.2); @@ -151,7 +151,7 @@ impl JitterDelayLayer { /// ```ignore /// use std::time::Duration; /// use http::Request; - /// use wreq_util::middleware::delay::JitterDelayLayer; + /// use wreq_util::tower::delay::JitterDelayLayer; /// /// // Only delay requests to paths starting with "/slow" /// let layer = JitterDelayLayer::new(Duration::from_secs(1), 0.2) diff --git a/crates/wreq-util/tests/client.rs b/crates/wreq-util/tests/client.rs index 3881397..14ba500 100644 --- a/crates/wreq-util/tests/client.rs +++ b/crates/wreq-util/tests/client.rs @@ -80,7 +80,7 @@ async fn assert_emulation_headers(profile: Profile, expected: &'static [&'static let server = server::low_level_with_response(move |request, stream| { check_header_order(request, stream, expected) }); - let response = Client::builder() + let response = Client::builder_tokio() .emulation(profile) .build() .expect("client") @@ -95,7 +95,11 @@ async fn assert_emulation_headers(profile: Profile, expected: &'static [&'static #[tokio::test] async fn test_client_emulation_device() { let server = server::http(move |req| async move { - let header = |name| req.headers().get(name).and_then(|value| value.to_str().ok()); + let header = |name| { + req.headers() + .get(name) + .and_then(|value| value.to_str().ok()) + }; assert_eq!( header("user-agent"), @@ -113,7 +117,7 @@ async fn test_client_emulation_device() { }); let url = format!("http://{}/ua", server.addr()); - let res = Client::builder() + let res = Client::builder_tokio() .emulation( Emulation::builder() .profile(Emulation::Chrome151) diff --git a/crates/wreq-util/tests/emulate_firefox.rs b/crates/wreq-util/tests/emulate_firefox.rs index 29cf391..28a7595 100644 --- a/crates/wreq-util/tests/emulate_firefox.rs +++ b/crates/wreq-util/tests/emulate_firefox.rs @@ -118,9 +118,8 @@ test_emulation!( /// /// Every profile is listed rather than a range, so adding one is a deliberate choice about /// which side of 147 it falls on. -#[test] -fn firefox_accept_language_matches_the_profile_version() { - use wreq::IntoEmulation; +#[tokio::test] +async fn firefox_accept_language_matches_the_profile_version() { use wreq_util::{Platform, Profile}; const PRE_147: &[(&str, Profile)] = &[ @@ -149,23 +148,29 @@ fn firefox_accept_language_matches_the_profile_version() { ("Firefox152", Emulation::Firefox152), ]; - fn accept_language(profile: Profile) -> String { - Emulation::builder() - .profile(profile) - .platform(Platform::Linux) - .build() - .into_emulation() - .headers - .get("accept-language") - .and_then(|value| value.to_str().ok()) - .unwrap_or_default() - .to_owned() - } - - for (name, profile) in PRE_147 { - assert_eq!("en-US,en;q=0.5", accept_language(*profile), "{name}"); - } - for (name, profile) in POST_147 { - assert_eq!("en-US,en;q=0.9", accept_language(*profile), "{name}"); + let server = support::server::http(|request| async move { + let mut response = http::Response::default(); + response.headers_mut().insert( + "accept-language", + request.headers()["accept-language"].clone(), + ); + response + }); + let client = wreq::Client::builder_tokio().no_proxy().build().unwrap(); + for (profiles, expected) in [(PRE_147, "en-US,en;q=0.5"), (POST_147, "en-US,en;q=0.9")] { + for (name, profile) in profiles { + let response = client + .get(format!("http://{}/", server.addr())) + .emulation( + Emulation::builder() + .profile(*profile) + .platform(Platform::Linux) + .build(), + ) + .send() + .await + .unwrap(); + assert_eq!(response.headers()["accept-language"], expected, "{name}"); + } } } diff --git a/crates/wreq-util/tests/support/mod.rs b/crates/wreq-util/tests/support/mod.rs index c57ae63..cc59664 100644 --- a/crates/wreq-util/tests/support/mod.rs +++ b/crates/wreq-util/tests/support/mod.rs @@ -14,7 +14,7 @@ pub static DEFAULT_USER_AGENT: &str = pub static TEST_SEMAPHORE: LazyLock = LazyLock::new(|| Semaphore::new(1)); pub static CLIENT: LazyLock = LazyLock::new(|| { - Client::builder() + Client::builder_tokio() .connect_timeout(Duration::from_secs(60)) .build() .unwrap() diff --git a/lib/wreq_ruby/client.rb b/lib/wreq_ruby/client.rb index 592e1d2..14e9ee6 100644 --- a/lib/wreq_ruby/client.rb +++ b/lib/wreq_ruby/client.rb @@ -5,7 +5,7 @@ module Wreq # HTTP client with extensive configuration options. # # This class wraps a native Rust implementation providing high-performance - # HTTP/1.1 and HTTP/2 client functionality with support for connection pooling, + # HTTP/1.1, HTTP/2 and HTTP/3 client functionality with support for connection pooling, # compression, redirects, proxies, and fine-grained timeout controls. # # The client is thread-safe and maintains an internal connection pool for @@ -110,25 +110,37 @@ class Client # allowing the reuse of local addresses in TIME_WAIT state. Useful for # reducing port exhaustion in high-throughput scenarios. # - # @param pool_idle_timeout [Integer, nil] Time in seconds before idle - # connections in the pool are evicted and closed. Helps free up - # resources for long-running applications. + # @param pool_idle_timeout [Integer, nil] Idle connection reuse timeout in + # seconds. Defaults to 90 when omitted or nil. Does not expire a busy + # HTTP/2 or HTTP/3 connection. # - # @param pool_max_idle_per_host [Integer, nil] Maximum number of idle - # connections to maintain per host in the connection pool. Connections - # beyond this limit will be closed immediately after use. + # @param pool_max_idle_per_host [Integer, nil] Maximum idle HTTP/1 + # connections retained per compatibility group, which includes the host + # and connection configuration. Defaults to unlimited when omitted or + # nil; 0 disables connection reuse. Does not limit active connections. # - # @param pool_max_size [Integer, nil] Total maximum size of the connection - # pool across all hosts. Once reached, new requests may need to wait - # for existing connections to become available. + # @param pool_max_size [Integer, nil] Maximum compatibility groups retaining + # idle HTTP/1 or shared HTTP/2 and HTTP/3 connections. Defaults to unlimited + # when omitted, nil or 0. A full pool evicts the least recently used idle + # group; it does not make requests wait or limit physical connections. # # @param http1_only [Boolean, nil] Force the client to use HTTP/1.1 only, # even if HTTP/2 is available. Useful for compatibility with servers - # that have problematic HTTP/2 implementations. + # that have problematic HTTP/2 implementations. Cannot be combined with + # http2_only or http3_only. An explicit request version overrides this + # preference. # # @param http2_only [Boolean, nil] Force the client to use HTTP/2 only. # Requests to servers that don't support HTTP/2 will fail. Cannot be - # combined with http1_only. + # combined with http1_only or http3_only. An explicit request version + # overrides this preference, including HTTP/3 over QUIC. + # + # @param http3_only [Boolean, nil] Use HTTP/3 over QUIC without falling back + # to TCP. Defaults to false when omitted or nil. Requires HTTPS and UDP + # connectivity. Cannot be combined with http1_only or http2_only. An + # explicit HTTP/1 or HTTP/2 request version overrides this preference. + # HTTP/HTTPS proxies, including environment proxies, cannot carry HTTP/3; + # use no_proxy: true, a SOCKS5 UDP proxy, or a QUIC MASQUE proxy instead. # # @param https_only [Boolean, nil] Reject plain HTTP connections and # only allow HTTPS. Provides an additional layer of security by @@ -149,7 +161,9 @@ class Client # environment. # # @param proxy [String, nil] Proxy server URI to use for all requests. - # Supports HTTP, HTTPS, and SOCKS5 proxies. Format: "protocol://host:port" + # Supports HTTP, HTTPS, SOCKS and QUIC proxies. HTTP/3 can use SOCKS5 UDP + # ASSOCIATE or a `quic://` MASQUE proxy, but not HTTP CONNECT proxies. + # Format: "protocol://host:port" # Example: "http://proxy.example.com:8080" # @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable. # @param interface [String, nil] Bind sockets to a network interface on diff --git a/lib/wreq_ruby/emulate.rb b/lib/wreq_ruby/emulate.rb index 7dc4dcd..cedffa1 100644 --- a/lib/wreq_ruby/emulate.rb +++ b/lib/wreq_ruby/emulate.rb @@ -267,6 +267,9 @@ def hash # for HTTP/2 and automatic default headers. The actual implementation is # provided by Rust. # + # Profiles configure TLS over TCP, HTTP/2 and request headers. They do not + # configure HTTP/3 or QUIC fingerprints; HTTP/3 uses the backend defaults. + # # Construction generates the native configuration once. For Chrome 152/153, # the TLS trust_anchors extension's ID order is randomized at construction; # Chrome 154 and later sort those IDs by their raw bytes instead. Reusing this object diff --git a/lib/wreq_ruby/http.rb b/lib/wreq_ruby/http.rb index 2bf701e..4fb38fb 100644 --- a/lib/wreq_ruby/http.rb +++ b/lib/wreq_ruby/http.rb @@ -42,7 +42,7 @@ def to_sym # Value-based equality. Returns true when both represent the same HTTP method. # @param other [Object] - # @return [Boolean] + # @return [Boolean] unless method_defined?(:==) def ==(other) end @@ -77,7 +77,14 @@ class Version HTTP_10 = nil # @return [Wreq::Version] HTTP/1.0 HTTP_11 = nil # @return [Wreq::Version] HTTP/1.1 HTTP_2 = nil # @return [Wreq::Version] HTTP/2 - HTTP_3 = nil # @return [Wreq::Version] HTTP/3 + # Select HTTP/3 over QUIC with `version: Wreq::Version::HTTP_3` on a request. + # To use it by default, construct a client with `http3_only: true` instead. + # Requires an HTTPS URL and a reachable UDP endpoint. There is no automatic + # Alt-Svc discovery or fallback to HTTP/1.1 or HTTP/2. + # HTTP CONNECT proxies cannot carry these requests; use a direct connection, + # a SOCKS5 UDP relay or a `quic://` MASQUE proxy. + # @return [Wreq::Version] HTTP/3 + HTTP_3 = nil end # Returns a string representation of the HTTP version. diff --git a/src/client.rs b/src/client.rs index e42b488..23f387d 100644 --- a/src/client.rs +++ b/src/client.rs @@ -76,11 +76,11 @@ struct Builder { tcp_reuse_address: Option, // ========= Connection pool options ========= - /// Set an optional timeout for idle sockets being kept-alive. (in seconds) + /// Idle connection reuse timeout, in seconds. pool_idle_timeout: Option, - /// Sets the maximum idle connection per host allowed in the pool. + /// Maximum idle HTTP/1 connections retained per compatibility group. pool_max_idle_per_host: Option, - /// Sets the maximum number of connections in the pool. + /// Maximum compatibility groups retaining reusable connections; zero is unlimited. pool_max_size: Option, // ========= Protocol options ========= @@ -88,6 +88,8 @@ struct Builder { http1_only: Option, /// Whether to use the HTTP/2 protocol only. http2_only: Option, + /// Whether to use HTTP/3 over QUIC without falling back to TCP. + http3_only: Option, /// Whether to use HTTPS only. https_only: Option, @@ -147,6 +149,7 @@ impl Builder { .reject_conflicts([ (stringify!(http1_only), builder.http1_only == Some(true)), (stringify!(http2_only), builder.http2_only == Some(true)), + (stringify!(http3_only), builder.http3_only == Some(true)), ]) .reject_conflicts([ (stringify!(proxy), options.is_non_nil(stringify!(proxy))), @@ -222,7 +225,7 @@ impl Client { .map(|jar| jar.clone_store(ruby)) .transpose()?; let result = gvl::nogvl(|| { - let mut builder = wreq::Client::builder(); + let mut builder = wreq::Client::builder_tokio(); // Emulation options. apply_option!(set_if_some_inner, builder, params.emulation, emulation); @@ -345,6 +348,7 @@ impl Client { // Protocol options. apply_option!(set_if_true, builder, params.http1_only, http1_only, false); apply_option!(set_if_true, builder, params.http2_only, http2_only, false); + apply_option!(set_if_true, builder, params.http3_only, http3_only, false); apply_option!(set_if_some, builder, params.https_only, https_only); // TLS options. diff --git a/test/option_validation_test.rb b/test/option_validation_test.rb index fce6e06..75c76c2 100644 --- a/test/option_validation_test.rb +++ b/test/option_validation_test.rb @@ -227,12 +227,21 @@ def test_authentication_options_are_mutually_exclusive end def test_protocol_only_options_are_mutually_exclusive - error = assert_raises(ArgumentError) do - Wreq::Client.new(http1_only: true, http2_only: true) + [:http1_only, :http2_only, :http3_only].combination(2) do |first, second| + error = assert_raises(ArgumentError) do + Wreq::Client.new(**{first => true, second => true}) + end + + assert_includes error.message, ":#{first}" + assert_includes error.message, ":#{second}" end - assert_includes error.message, ":http1_only" - assert_includes error.message, ":http2_only" + assert_instance_of Wreq::Client, + Wreq::Client.new(http3_only: true, http1_only: false, http2_only: nil) + assert_instance_of Wreq::Client, + Wreq::Client.new(http1_only: true, http3_only: false) + assert_instance_of Wreq::Client, + Wreq::Client.new(http2_only: true, http3_only: nil) end def test_validation_reports_the_first_failed_rule From 8009ae833248849fa0a097a10ea3335af12b4ab9 Mon Sep 17 00:00:00 2001 From: gngpp Date: Wed, 11 Nov 2026 05:53:34 +0800 Subject: [PATCH 35/38] chore(release): prepare v1.3.3 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f59208c..ecc2af9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1922,7 +1922,7 @@ dependencies = [ [[package]] name = "wreq-ruby" -version = "1.3.2" +version = "1.3.3" dependencies = [ "arc-swap", "bytes", diff --git a/Cargo.toml b/Cargo.toml index e3d1cd1..3e89eda 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = ["SearchApi "] homepage = "https://github.com/SearchApi/wreq-ruby" repository = "https://github.com/SearchApi/wreq-ruby" edition = "2024" -version = "1.3.2" +version = "1.3.3" rust-version = "1.98" [lib] From 2a21f7903a0821338e322a754131729a9f0fc9c9 Mon Sep 17 00:00:00 2001 From: 0x676e67 Date: Wed, 11 Nov 2026 19:25:53 +0800 Subject: [PATCH 36/38] fix(conn): report proxy dial timeouts as proxy connect errors --- Cargo.lock | 2 +- Cargo.toml | 2 +- test/error_handling_test.rb | 39 +++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ecc2af9..9111aca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1883,7 +1883,7 @@ dependencies = [ [[package]] name = "wreq" version = "0.16.1" -source = "git+https://github.com/0x676e67/wreq?rev=10029bb86ff88d8ed88b8e10518fe6e1f7ff322c#10029bb86ff88d8ed88b8e10518fe6e1f7ff322c" +source = "git+https://github.com/0x676e67/wreq?rev=18d500474139c6740c841d3263f82a7eb1ac4883#18d500474139c6740c841d3263f82a7eb1ac4883" dependencies = [ "btls", "btls-sys", diff --git a/Cargo.toml b/Cargo.toml index 3e89eda..930db11 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -79,5 +79,5 @@ netty = { git = "https://github.com/0x676e67/netty", rev = "0e1e53c0d9e500b25336 btls = { git = "https://github.com/0x676e67/btls", rev = "5ec1c113a03626a5877b34dd6d2ea8d440897a91" } btls-sys = { git = "https://github.com/0x676e67/btls", rev = "5ec1c113a03626a5877b34dd6d2ea8d440897a91" } tokio-btls = { git = "https://github.com/0x676e67/btls", rev = "5ec1c113a03626a5877b34dd6d2ea8d440897a91" } -wreq = { git = "https://github.com/0x676e67/wreq", rev = "10029bb86ff88d8ed88b8e10518fe6e1f7ff322c" } +wreq = { git = "https://github.com/0x676e67/wreq", rev = "18d500474139c6740c841d3263f82a7eb1ac4883" } wreq-util = { path = "crates/wreq-util" } diff --git a/test/error_handling_test.rb b/test/error_handling_test.rb index e229dba..abee6f9 100644 --- a/test/error_handling_test.rb +++ b/test/error_handling_test.rb @@ -121,8 +121,47 @@ def test_proxy_error_handling end end + def test_proxy_tcp_connect_timeout_keeps_proxy_error + skip "Requires a stalled TCP handshake from a full loopback accept queue" unless RUBY_PLATFORM.include?("linux") || Gem.win_platform? + + with_stalled_tcp_listener do |port| + %w[http socks5h].each do |scheme| + client = Wreq::Client.new(proxy: "#{scheme}://127.0.0.1:#{port}", connect_timeout: 1, timeout: 5) + start = Process.clock_gettime(Process::CLOCK_MONOTONIC) + + error = assert_raises(Wreq::ProxyConnectionError, "#{scheme} proxy TCP deadline") do + client.get("https://127.0.0.1:443/") + end + assert_instance_of Wreq::ProxyConnectionError, error + assert_operator Process.clock_gettime(Process::CLOCK_MONOTONIC) - start, :>=, 0.9, + "#{scheme} proxy should time out, not fail immediately" + end + end + end + private + def with_stalled_tcp_listener + sockets = [] + listener = Socket.new(:INET, :STREAM) + listener.bind(Socket.sockaddr_in(0, "127.0.0.1")) + listener.listen(0) + address = listener.local_address + + # Leave the accept queue full and verify a subsequent dial stays pending. + pending = 8.times.any? do + socket = Socket.new(:INET, :STREAM) + sockets << socket + socket.connect_nonblock(address, exception: false) == :wait_writable && + IO.select(nil, [socket], nil, 0.2).nil? + end + assert pending, "Expected a stalled TCP handshake on the loopback fixture" + yield address.ip_port + ensure + sockets.each(&:close) + listener&.close + end + def with_hanging_server server = TCPServer.new("127.0.0.1", 0) accepted = Queue.new From 1e163e60dedfd7fd5d57930693ca065abbb4c0ff Mon Sep 17 00:00:00 2001 From: gngpp Date: Wed, 11 Nov 2026 19:27:10 +0800 Subject: [PATCH 37/38] chore(release): prepare v1.3.5 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9111aca..7c211a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1922,7 +1922,7 @@ dependencies = [ [[package]] name = "wreq-ruby" -version = "1.3.3" +version = "1.3.5" dependencies = [ "arc-swap", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 930db11..3a794d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = ["SearchApi "] homepage = "https://github.com/SearchApi/wreq-ruby" repository = "https://github.com/SearchApi/wreq-ruby" edition = "2024" -version = "1.3.3" +version = "1.3.5" rust-version = "1.98" [lib] From 489111f4f15b3ccb73cc144fdf7ea7a1669dec5a Mon Sep 17 00:00:00 2001 From: gngpp Date: Thu, 19 Nov 2026 11:19:43 +0800 Subject: [PATCH 38/38] feat(emulate): add Chrome 158 profile --- README.md | 2 +- crates/README.md | 5 +++ crates/wreq-util/src/emulate.rs | 1 + .../wreq-util/src/emulate/profile/chrome.rs | 35 +++++++++++++++++++ crates/wreq-util/tests/emulate_chrome.rs | 10 ++++++ lib/wreq_ruby/emulate.rb | 1 + src/emulate.rs | 6 +--- test/emulation_test.rb | 1 + 8 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 crates/README.md diff --git a/README.md b/README.md index fd5479a..67fd3b8 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ Most browser device models share identical TLS and HTTP/2 configurations, differ | **Browser** | **Versions** | | ----------- | ------------ | - | **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135`, `Chrome136`, `Chrome137`, `Chrome138`, `Chrome139`, `Chrome140`, `Chrome141`, `Chrome142`, `Chrome143`, `Chrome144`, `Chrome145`, `Chrome146`, `Chrome147`, `Chrome148`, `Chrome149`, `Chrome150`, `Chrome151`, `Chrome152`, `Chrome153`, `Chrome154`, `Chrome155`, `Chrome156`, `Chrome157` | + | **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135`, `Chrome136`, `Chrome137`, `Chrome138`, `Chrome139`, `Chrome140`, `Chrome141`, `Chrome142`, `Chrome143`, `Chrome144`, `Chrome145`, `Chrome146`, `Chrome147`, `Chrome148`, `Chrome149`, `Chrome150`, `Chrome151`, `Chrome152`, `Chrome153`, `Chrome154`, `Chrome155`, `Chrome156`, `Chrome157`, `Chrome158` | | **Edge** | `Edge101`, `Edge122`, `Edge127`, `Edge131`, `Edge134`, `Edge135`, `Edge136`, `Edge137`, `Edge138`, `Edge139`, `Edge140`, `Edge141`, `Edge142`, `Edge143`, `Edge144`, `Edge145`, `Edge146`, `Edge147`, `Edge148` | | **Firefox** | `Firefox109`, `Firefox117`, `Firefox128`, `Firefox133`, `Firefox135`, `FirefoxPrivate135`, `FirefoxAndroid135`, `Firefox136`, `FirefoxPrivate136`, `Firefox139`, `Firefox142`, `Firefox143`, `Firefox144`, `Firefox145`, `Firefox146`, `Firefox147`, `Firefox148`, `Firefox149`, `Firefox150`, `Firefox151`, `Firefox152` | | **Safari** | `Safari15_3`, `Safari15_5`, `Safari15_6_1`, `Safari16`, `Safari16_5`, `Safari17_0`, `Safari17_2_1`, `Safari17_4_1`, `Safari17_5`, `Safari17_6`, `Safari18`, `Safari18_2`, `Safari18_3`, `Safari18_3_1`, `Safari18_5`, `Safari26`, `Safari26_1`, `Safari26_2`, `SafariIos16_5`, `SafariIos17_2`, `SafariIos17_4_1`, `SafariIos18_1_1`, `SafariIos26`, `SafariIos26_2`, `SafariIPad18`, `SafariIPad26`, `SafariIpad26_2` | diff --git a/crates/README.md b/crates/README.md new file mode 100644 index 0000000..3181970 --- /dev/null +++ b/crates/README.md @@ -0,0 +1,5 @@ +# Local Rust dependencies + +- [`wreq-util`](wreq-util/) is a local copy of [0x676e67/wreq-util](https://github.com/0x676e67/wreq-util). The root [`Cargo.toml`](../Cargo.toml) resolves it from `crates/wreq-util` through `[patch.crates-io]`. + +When building or testing `wreq-util` on its own, use the Git dependency patches from the root manifest of the same branch. Cargo does not inherit those patches from the parent package. diff --git a/crates/wreq-util/src/emulate.rs b/crates/wreq-util/src/emulate.rs index ba4d792..f248c03 100644 --- a/crates/wreq-util/src/emulate.rs +++ b/crates/wreq-util/src/emulate.rs @@ -68,6 +68,7 @@ define_enum!( Chrome155 => ("chrome_155", v155::emulation), Chrome156 => ("chrome_156", v156::emulation), Chrome157 => ("chrome_157", v157::emulation), + Chrome158 => ("chrome_158", v158::emulation), // Edge versions Edge101 => ("edge_101", edge101::emulation), diff --git a/crates/wreq-util/src/emulate/profile/chrome.rs b/crates/wreq-util/src/emulate/profile/chrome.rs index f9815f4..de31e96 100644 --- a/crates/wreq-util/src/emulate/profile/chrome.rs +++ b/crates/wreq-util/src/emulate/profile/chrome.rs @@ -2070,6 +2070,41 @@ mod_generator!( ] ); +// Chrome 158 retains the Chrome 157 TLS, HTTP/2 and Accept presets. +// https://chromium.googlesource.com/chromium/src/+/b8c2be851f62f6a394ec57955d7f31335d7cb6d4/components/embedder_support/user_agent_utils.cc +mod_generator!( + v158, + v154::build_emulation, + header_initializer_chrome155, + [ + ( + MacOS, + r#""Chromium";v="158", "Not.A/Brand";v="24", "Google Chrome";v="158""#, + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/158.0.0.0 Safari/537.36" + ), + ( + Linux, + r#""Chromium";v="158", "Not.A/Brand";v="24", "Google Chrome";v="158""#, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/158.0.0.0 Safari/537.36" + ), + ( + Android, + r#""Chromium";v="158", "Not.A/Brand";v="24", "Google Chrome";v="158""#, + "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/158.0.0.0 Mobile Safari/537.36" + ), + ( + Windows, + r#""Chromium";v="158", "Not.A/Brand";v="24", "Google Chrome";v="158""#, + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/158.0.0.0 Safari/537.36" + ), + ( + IOS, + r#""Chromium";v="158", "Not.A/Brand";v="24", "Google Chrome";v="158""#, + "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/158.0.8127.35 Mobile/15E148 Safari/604.1" + ) + ] +); + mod_generator!( edge143, v132::build_emulation, diff --git a/crates/wreq-util/tests/emulate_chrome.rs b/crates/wreq-util/tests/emulate_chrome.rs index 0bcc518..f2b3f99 100644 --- a/crates/wreq-util/tests/emulate_chrome.rs +++ b/crates/wreq-util/tests/emulate_chrome.rs @@ -335,3 +335,13 @@ test_emulation!( ], "52d84b11737d980aef856699f885ca86" ); + +test_emulation!( + test_chrome158, + Emulation::Chrome158, + [ + "t13d1517h2_8daaf6152771_cb7bf5808d99", + "t13d1518h2_8daaf6152771_e2d80978ab2e" + ], + "52d84b11737d980aef856699f885ca86" +); diff --git a/lib/wreq_ruby/emulate.rb b/lib/wreq_ruby/emulate.rb index cedffa1..cc74013 100644 --- a/lib/wreq_ruby/emulate.rb +++ b/lib/wreq_ruby/emulate.rb @@ -69,6 +69,7 @@ class Profile Chrome155 = nil Chrome156 = nil Chrome157 = nil + Chrome158 = nil Edge101 = nil Edge122 = nil diff --git a/src/emulate.rs b/src/emulate.rs index 7efb010..bb3d45d 100644 --- a/src/emulate.rs +++ b/src/emulate.rs @@ -95,7 +95,7 @@ define_ruby_enum!( Chrome155, Chrome156, Chrome157, - + Chrome158, Edge101, Edge122, Edge127, @@ -115,7 +115,6 @@ define_ruby_enum!( Edge146, Edge147, Edge148, - Firefox109, Firefox117, Firefox128, @@ -137,7 +136,6 @@ define_ruby_enum!( Firefox150, Firefox151, Firefox152, - SafariIos17_2, SafariIos17_4_1, SafariIos16_5, @@ -167,7 +165,6 @@ define_ruby_enum!( SafariIos26_2, SafariIPad26, SafariIpad26_2, - OkHttp3_9, OkHttp3_11, OkHttp3_13, @@ -176,7 +173,6 @@ define_ruby_enum!( OkHttp4_10, OkHttp4_12, OkHttp5, - Opera116, Opera117, Opera118, diff --git a/test/emulation_test.rb b/test/emulation_test.rb index 3dbe07b..5384458 100644 --- a/test/emulation_test.rb +++ b/test/emulation_test.rb @@ -46,6 +46,7 @@ def test_new_browser_profiles_are_available Wreq::Profile::Chrome155 => "Chrome155", Wreq::Profile::Chrome156 => "Chrome156", Wreq::Profile::Chrome157 => "Chrome157", + Wreq::Profile::Chrome158 => "Chrome158", Wreq::Profile::Firefox152 => "Firefox152" }.each do |profile, name| assert_equal name, profile.to_s