diff --git a/violet/rust/Cargo.toml b/violet/rust/Cargo.toml index 40b07cdc8..cbac7f9bb 100644 --- a/violet/rust/Cargo.toml +++ b/violet/rust/Cargo.toml @@ -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"] } diff --git a/violet/rust/src/api/simple.rs b/violet/rust/src/api/simple.rs index 188b921e2..01d9de3e9 100644 --- a/violet/rust/src/api/simple.rs +++ b/violet/rust/src/api/simple.rs @@ -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 diff --git a/violet/rust/src/utils/dpiproxy.rs b/violet/rust/src/utils/dpiproxy.rs index d444869fa..452925916 100644 --- a/violet/rust/src/utils/dpiproxy.rs +++ b/violet/rust/src/utils/dpiproxy.rs @@ -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
) -> Result