Skip to content

Commit

Permalink
chore: Removed TLS config examples to prevent misconfigurations by in…
Browse files Browse the repository at this point in the history
…experienced users (#204)

Unless they know what they are doing...
  • Loading branch information
0x676e67 authored Dec 22, 2024
1 parent 69b52af commit dbe1818
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 193 deletions.
5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,6 @@ required-features = ["cookies"]
name = "impersonate_skip_headers"
path = "examples/impersonate_skip_headers.rs"

[[example]]
name = "impersonate_settings"
path = "examples/impersonate_settings.rs"
required-features = ["full"]

[[example]]
name = "impersonate_psk"
path = "examples/impersonate_psk.rs"
Expand Down
100 changes: 0 additions & 100 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,106 +108,6 @@ async fn main() -> Result<(), rquest::Error> {
```

Preconfigured `TLS`/`HTTP2`

```toml
[dependencies]
tokio = { version = "1", features = ["full"] }
rquest = "0.33.0"
```

```rust
use http::{header, HeaderMap, HeaderName, HeaderValue};
use rquest::{
tls::{Http2Settings, ImpersonateSettings, TlsSettings, TlsVersion},
HttpVersionPref,
};
use rquest::{PseudoOrder::*, SettingsOrder::*};
use std::borrow::Cow;

static HEADER_ORDER: &[HeaderName] = &[
header::USER_AGENT,
header::ACCEPT_LANGUAGE,
header::ACCEPT_ENCODING,
header::COOKIE,
header::HOST,
];

#[tokio::main]
async fn main() -> Result<(), rquest::Error> {
// TLS settings
let tls_settings = TlsSettings::builder()
.tls_sni(true)
.alpn_protos(HttpVersionPref::All)
.application_settings(true)
.pre_shared_key(true)
.enable_ech_grease(true)
.permute_extensions(true)
.min_tls_version(TlsVersion::TLS_1_0)
.max_tls_version(TlsVersion::TLS_1_3)
.build();

// HTTP/2 settings
let http2_settings = Http2Settings::builder()
.initial_stream_window_size(6291456)
.initial_connection_window_size(15728640)
.max_concurrent_streams(1000)
.max_header_list_size(262144)
.header_table_size(65536)
.enable_push(false)
.headers_priority((0, 255, true))
.headers_pseudo_order([Method, Scheme, Authority, Path])
.settings_order([
HeaderTableSize,
EnablePush,
MaxConcurrentStreams,
InitialWindowSize,
MaxFrameSize,
MaxHeaderListSize,
UnknownSetting8,
UnknownSetting9,
])
.build();

// Headers
let headers = {
let mut headers = HeaderMap::new();
headers.insert(header::USER_AGENT, HeaderValue::from_static("rquest"));
headers.insert(
header::ACCEPT_LANGUAGE,
HeaderValue::from_static("en-US,en;q=0.9"),
);
headers.insert(
header::ACCEPT_ENCODING,
HeaderValue::from_static("gzip, deflate, br"),
);
headers.insert(header::HOST, HeaderValue::from_static("tls.peet.ws"));
headers.insert(header::COOKIE, HeaderValue::from_static("foo=bar"));
Cow::Owned(headers)
};

// Create impersonate settings
let settings = ImpersonateSettings::builder()
.tls(tls_settings)
.http2(http2_settings)
.headers(headers)
.headers_order(Cow::Borrowed(HEADER_ORDER))
.build();

// Build a client with impersonate settings
let client = rquest::Client::builder()
.impersonate_settings(settings)
.build()?;

// Use the API you're already familiar with
let resp = client.get("https://tls.peet.ws/api/all").send().await?;
println!("{}", resp.text().await?);

Ok(())
}

```

> More examples can be found in the [examples](https://github.com/penumbra-x/rquest/tree/main/examples) directory.
## Root Certificate
Expand Down
88 changes: 0 additions & 88 deletions examples/impersonate_settings.rs

This file was deleted.

0 comments on commit dbe1818

Please sign in to comment.