diff --git a/Cargo.lock b/Cargo.lock index 120582a..c7d366a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -759,6 +759,16 @@ dependencies = [ "utf-8", ] +[[package]] +name = "fdlimit" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e182f7dbc2ef73d9ef67351c5fbbea084729c48362d3ce9dd44c28e32e277fe5" +dependencies = [ + "libc", + "thiserror", +] + [[package]] name = "filetime" version = "0.2.25" @@ -3130,6 +3140,7 @@ dependencies = [ "crossterm", "fast-socks5", "fastwebsockets", + "fdlimit", "futures-util", "hickory-resolver", "http-body-util", diff --git a/Cargo.toml b/Cargo.toml index 7bb9e16..6d4cc43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,8 @@ hickory-resolver = { version = "0.24.1", features = ["tokio", "dns-over-https-ru ppp = { version = "2.2.0", features = [] } async-channel = { version = "2.3.1", features = [] } +fdlimit = "0.3.0" + # For config file parsing regex = { version = "1.11.0", default-features = false, features = ["std", "perf"] } serde_regex = "1.1.0" diff --git a/src/main.rs b/src/main.rs index 3f3ecc6..1012ee0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,7 +19,7 @@ use base64::Engine; use clap::Parser; use hyper::header::HOST; use hyper::http::{HeaderName, HeaderValue}; -use log::debug; +use log::{debug, warn}; use parking_lot::{Mutex, RwLock}; use std::collections::BTreeMap; use std::fmt::Debug; @@ -727,6 +727,9 @@ async fn main() -> anyhow::Result<()> { } else { logger.init(); }; + if let Err(err) = fdlimit::raise_fd_limit() { + warn!("Failed to set soft filelimit to hard file limit: {}", err) + } match args.commands { Commands::Client(args) => {