Skip to main content

Crate shardx

Crate shardx 

Source
Expand description

§ShardX Rust SDK

Self-contained SDK for the ShardX anti-detect browser. Mirrors the Python (shardx) and Node (@proxyshard/shardx) SDKs: on first use it downloads the engine, Widevine CDM, and the bundled fingerprint library from the ProxyShard CDN into a per-user cache dir, then launches isolated profiles with the same spoofing flags the desktop launcher uses.

use shardx::{ShardX, ShardXOptions, LaunchOptions};

let sdk = ShardX::new(ShardXOptions::default())?;

// Launch a random profile through a proxy AND attach a CDP browser.
let session = sdk
    .session(None, LaunchOptions {
        proxy: Some("socks5://user:pass@host:1080".into()),
        ..Default::default()
    })
    .await?;

let _page = session.new_page("https://example.com").await?;
// ... drive `session.browser` (chromiumoxide) ...
session.close().await?;

Re-exports§

pub use chromiumoxide;

Structs§

Archive
One downloadable archive on the CDN.
Browser
BrowserSession
A running engine process + the decisions made at launch.
FingerprintLibrary
The bundled fingerprint library (JSON files under the cache dir).
GeoInfo
HostSpec
Per-host archive set + extracted paths.
LaunchOptions
ParsedProxy
Profile
ProxyCheckResult
Result of ShardX::check_proxy — the same data the launcher uses to decide QUIC + WebRTC policy.
Runtime
Session
A launched ShardX engine with a connected CDP client.
ShardX
Top-level façade — bundles the runtime, fingerprint library, and browser launcher. Mirrors the Python ShardX class / Node ShardX.
ShardXOptions
Construction options for ShardX.

Enums§

LaunchInput
What to launch: a library id, a ready Profile, or a raw config object.
ProxyScheme
ScreenStrategy
WebRtcMode

Constants§

CHROMIUM_VERSION
LINUX_PLATFORM_VERSIONS
MACOS_PLATFORM_VERSIONS
PUB_BASE
WINDOWS_PLATFORM_VERSIONS
X86_CORES
Real x86 logical-core counts (SMT + Intel hybrid). Same array as the launcher.

Functions§

apply_engine_version
Normalise a profile config’s spoofed Chrome version to chromium_version (e.g. “149.0.7827.103”) so it always matches the running engine — bumps navigator.user_agent (Chrome/.0.0.0) and the version fields in client_hints: brand_version / brand_full_version / chrome_build / chrome_patch (derived from the version) plus, when supplied, grease_brand / grease_version / grease_full_version (GREASE rotates per release, so it can’t be derived — it comes from the manifest). Leaves platform_version, architecture, etc. intact. SDK equivalent of the launcher’s post-update profile migration.
apply_screen_strategy
Apply mode to cfg in place. No-op for Profile or when the host size can’t be probed.
default_cache_dir
Default per-user cache dir (mirrors the Node SDK layout, shardx-sdk).
default_screen_mode_for
Default screen mode for a navigator.platform, matching the launcher.
geo_check_via
Probe the geo proxy exits at, or direct geo when proxy is None.
has_auto_fields
True when the config still carries any unresolved "auto" sentinel.
host_logical_cores
Logical CPU count (SMT threads). Falls back to 8.
host_ram_bucket_gb
Round host RAM to Chrome’s deviceMemory bucket {8,16,32}; None → 16.
host_ram_gb
Physical RAM in GiB, best-effort per OS. None on failure.
host_screen_size
Primary monitor (width, height), or None on failure.
host_spec
Archives + layout for the current host; errors on unsupported platforms.
mac_hw_configs
Curated (hardware_concurrency, device_memory_gib) pairs per Mac profile id.
parse_proxy
probe_udp
UDP RTT (ms) through the SOCKS5 relay. Err when unavailable (caller maps to None). Only valid for SOCKS5.
proxy_to_arg
Format as the ShardX engine’s --proxy-server argument (URL-encoded user:pass@ when present). Mirrors the launcher’s ProxyEntry::to_proxy_server_arg.
randomize_hardware
Pick fresh (hardware_concurrency, device_memory).
randomize_platform_version
Pick a fresh navigator.platform_version (+ mirror to client_hints).
resolve_auto_fields
Apply the launcher’s “auto” resolution. Returns the GeoInfo that fed it, or None when both proxy + direct probes failed and the host fallback was used (or there was nothing to resolve).
user_data_dir
Per-profile state dir (cookies / IndexedDB / cache), preserved across launches. Defaults to <profiles_root>/<id>/.

Type Aliases§

ProgressCb
Download-progress callback: (label, received_bytes, total_bytes).
Size
Primary monitor size in CSS pixels.