
. 一个面向 Rust 的高级隐身 HTTP 客户端。
专为注重隐私的开发者打造,让你能够完全掌控自己的网络指纹。
看起来像浏览器。行为像浏览器。用 Rust 编写。
基于 bogdanfinn/tls-client 构建 —— 这是业界领先的 TLS 指纹库,受到全球安全专业人士的信赖。我们通过 FFI 绑定使用 bogdanfinn 久经考验的共享库(.dll/.so/.dylib),原因如下:
RustTLSX 以类型安全、人性化的 API 将这一成熟技术带入 Rust,其速度比 Python 替代方案快 6 倍。
现代 Web 应用会分析你 HTTP 请求的方方面面——不仅是请求头和 Cookie,还包括 TLS 握手的深层加密签名。标准 Rust HTTP 客户端(reqwest、hyper、ureq)会生成容易被检测的模式,从而立即识别出自动化流量。
RustTLSX 通过以下方式解决这一问题:
从 tls-client releases 下载适用于你平台所需的 TLS 客户端库:
tls-client-windows-64-1.3.3.dlltls-client-linux-ubuntu-amd64-1.3.3.sotls-client-darwin-amd64-1.3.3.dylib将库文件放在项目根目录、系统库路径(/usr/local/lib/)中,或确保可通过 PATH 访问。
将 RustTLSX 添加到你的 Cargo.toml:
[dependencies]
rust-tlsx = "0.1"
use rust_tlsx::{TlsClient, BrowserProfile};
fn main() -> anyhow::Result<()> {
let client = TlsClient::new(BrowserProfile::Firefox120)
.header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0")
.timeout(30);
let response = client.get("https://example.com")?;
println!("Status: {}", response.status);
println!("Body: {}", response.body);
Ok(())
}
RustTLSX 支持跨主流浏览器的 30 多种浏览器配置文件:
// Chrome versions
BrowserProfile::Chrome103
BrowserProfile::Chrome107
BrowserProfile::Chrome109
BrowserProfile::Chrome120
// Firefox versions
BrowserProfile::Firefox102
BrowserProfile::Firefox105
BrowserProfile::Firefox108
BrowserProfile::Firefox120
// Safari versions
BrowserProfile::Safari15_6_1
BrowserProfile::Safari16_0
BrowserProfile::SafariIos16_0
// Opera and others
BrowserProfile::Opera89
BrowserProfile::Opera90
let client = TlsClient::new(BrowserProfile::Chrome109)
.header("Accept", "application/json")
.header("Accept-Language", "en-US,en;q=0.9")
.cookie("session", "abc123")
.cookie("token", "xyz789");
let response = client.get("https://api.example.com")?;
let body = r#"{"username": "user", "password": "pass"}"#;
let response = client.post("https://example.com/login", Some(body.to_string()))?;
let client = TlsClient::new(BrowserProfile::Firefox120)
.timeout(60); // seconds
let response = client.get("https://slow-api.example.com")?;
RustTLSX 建立在久经验证的卓越基础之上,而不是重复造轮子。我们通过 FFI 使用 bogdanfinn 编译好的库(.dll/.so/.dylib),原因如下:
研究投入:Bogdanfinn 投入了数千小时逆向工程浏览器 TLS 行为。重复这项研究需要数年时间,而且很可能得到较差的结果。
久经考验的可靠性:这些库被全球主要安全公司、隐私工具和研究机构使用。它们已经过所有主要防护系统的测试。
持续演进:浏览器指纹不断变化。Bogdanfinn 的库会定期更新,以匹配新的浏览器版本和防护系统更新。
性能优化:原生 C/Go 实现对速度和内存效率进行了深度优化,提供了纯 Rust 实现无法企及的性能。
运行时动态加载:使用 FFI 按需加载库,消除了静态链接的复杂性,同时保持性能。
内存管理:Rust 的所有权模型确保了与原生库的安全交互,防止了 C/C++ 实现中常见的内存泄漏和释放后使用(use-after-free)错误。
错误处理:基于 Result 的全面错误处理在保持类型安全的同时提供详细的诊断信息。
连接管理:对 TLS 连接进行智能池化与复用,行为模式与浏览器一致。
底层库管理浏览器 TLS 行为的方方面面:
use rust_tlsx::{TlsClient, BrowserProfile};
fn main() -> anyhow::Result<()> {
let client = TlsClient::new(BrowserProfile::Chrome109);
let response = client.get("https://httpbin.org/get")?;
println!("Status: {}", response.status);
println!("Body: {}", response.body);
Ok(())
}
use rust_tlsx::{TlsClient, BrowserProfile};
fn main() -> anyhow::Result<()> {
let client = TlsClient::new(BrowserProfile::Firefox120);
let response = client.get("https://tls.peet.ws/api/all")?;
println!("TLS Fingerprint Analysis:\n{}", response.body);
Ok(())
}
use rust_tlsx::{TlsClient, BrowserProfile};
fn main() -> anyhow::Result<()> {
let client = TlsClient::new(BrowserProfile::Chrome109)
.header("Authorization", "Bearer YOUR_TOKEN")
.header("Content-Type", "application/json");
let response = client.get("https://api.example.com/data")?;
match response.status {
200 => println!("Success: {}", response.body),
401 => eprintln!("Authentication failed"),
_ => eprintln!("Request failed with status {}: {}", response.status, response.body),
}
Ok(())
}
use rust_tlsx::{TlsClient, BrowserProfile};
fn main() -> anyhow::Result<()> {
// Create a client that appears as a real Firefox browser
let client = TlsClient::new(BrowserProfile::Firefox120)
.header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0")
.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8")
.header("Accept-Language", "en-US,en;q=0.5")
.header("Accept-Encoding", "gzip, deflate, br")
.header("DNT", "1") // Privacy-focused: Do Not Track
.timeout(30);
// Include session cookies for authenticated requests
let client = client.cookie("session_id", "your_session_token");
let response = client.get("https://example-site.com/data")?;
match response.status {
200 => println!("Data retrieved successfully with browser-like privacy"),
403 => println!("Authentication required - check session cookies"),
_ => println!("Response: {}", response.status),
}
Ok(())
}
use rust_tlsx::{TlsClient, BrowserProfile};
use std::collections::HashMap;
fn main() -> anyhow::Result<()> {
// Simulate a specific browser environment
let mut headers = HashMap::new();
headers.insert("User-Agent".to_string(),
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36".to_string());
headers.insert("Sec-Fetch-Site".to_string(), "same-origin".to_string());
headers.insert("Sec-Fetch-Mode".to_string(), "navigate".to_string());
headers.insert("Sec-Fetch-Dest".to_string(), "document".to_string());
let client = TlsClient::new(BrowserProfile::Chrome120)
.headers(headers)
.timeout(45);
// Make request that's indistinguishable from real browser
let response = client.get("https://api.example.com/sensitive-data")?;
println!("Retrieved data with perfect browser mimicry");
println!("Protocol used: {}", response.used_protocol);
Ok(())
}
与所有标准 Rust HTTP 客户端相比,RustTLSX 提供卓越的性能与隐私保护: