Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(client): Optional enable enable_ech_grease/permute_extensions #369

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion openai/src/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,24 @@ impl AuthClientBuilder {
self
}

/// Controls the use of certificate validation.
pub fn danger_accept_invalid_certs(mut self, enable: bool) -> Self {
self.inner = self.inner.danger_accept_invalid_certs(enable);
self
}

/// Enable Encrypted Client Hello (Secure SNI)
pub fn enable_ech_grease(mut self, enable: bool) -> Self {
self.inner = self.inner.enable_ech_grease(enable);
self
}

/// Enable TLS permute_extensions
pub fn permute_extensions(mut self, enable: bool) -> Self {
self.inner = self.inner.permute_extensions(enable);
self
}

pub fn build(self) -> AuthClient {
let client = self
.inner
Expand Down Expand Up @@ -493,7 +511,6 @@ impl AuthClientBuilder {
pub fn builder() -> AuthClientBuilder {
AuthClientBuilder {
inner: Client::builder()
.danger_accept_invalid_certs(true)
.connect_timeout(Duration::from_secs(10))
.timeout(Duration::from_secs(30))
.redirect(Policy::none()),
Expand Down
5 changes: 5 additions & 0 deletions openai/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ fn build_client(
builder
.impersonate(random_impersonate(config.random_chrome_ua))
.danger_accept_invalid_certs(true)
.permute_extensions(true)
.enable_ech_grease(true)
.connect_timeout(Duration::from_secs(config.connect_timeout))
.timeout(Duration::from_secs(config.timeout))
.dns_resolver(trust_dns_resolver)
Expand Down Expand Up @@ -400,6 +402,9 @@ fn build_auth_client(

builder
.impersonate(random_impersonate(config.random_chrome_ua))
.danger_accept_invalid_certs(true)
.permute_extensions(true)
.enable_ech_grease(true)
.timeout(Duration::from_secs(config.timeout))
.connect_timeout(Duration::from_secs(config.connect_timeout))
.dns_resolver(trust_dns_resolver)
Expand Down
Loading