Skip to content

Commit

Permalink
Init proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
violet-dev committed Sep 8, 2024
1 parent 22c2174 commit add01aa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions violet/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ ajson = "0.2"
async-std = { version = "1.5", features = ["std"], default-features = false }

[target.'cfg(not(windows))'.dependencies]
rlimit = "0.3"
openssl = { version = "0.10", features = ["vendored"] }
3 changes: 2 additions & 1 deletion violet/rust/src/api/simple.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// This source code is a part of Project Violet.
// Copyright (C) 2020-2024. violet-team. Licensed under the Apache-2.0 License.

use crate::utils::decompress::to_parent_entry_extract_fn;
use crate::utils::{decompress::to_parent_entry_extract_fn, dpiproxy::init_proxy};

#[flutter_rust_bridge::frb(init)]
pub fn init_app() {
// Default utilities - feel free to customize
flutter_rust_bridge::setup_default_user_utils();
init_proxy();
}

#[flutter_rust_bridge::frb(sync)] // Synchronous mode for simplicity of the demo
Expand Down
5 changes: 5 additions & 0 deletions violet/rust/src/utils/dpiproxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ static mut DISABLED_DOH: bool = false;
static mut INSERT_SPACE_HTTP_HOST: bool = false;
static SPACE_HTTP_HOST: &'static [u8] = &[32];

pub fn init_proxy() {
#[cfg(not(windows))]
set_max_rlimit_nofile();
}

async fn proxy(mut req: Request<Body>) -> Result<Response<Body>, hyper::Error> {
let http_client = HTTP_CLIENT.clone();
let https_client = HTTPS_CLIENT.clone();
Expand Down

0 comments on commit add01aa

Please sign in to comment.