Skip to content

Commit

Permalink
Update proxer-cli to version 0.3.6 and enhance connection limit handling
Browse files Browse the repository at this point in the history
- Bump version of `proxer-cli` in `Cargo.toml` and `Cargo.lock` from 0.3.5 to 0.3.6.
- Refactor connection limit handling in `src/server/mod.rs` to improve logging and error handling when setting the maximum open connection limit.
  • Loading branch information
doroved committed Dec 19, 2024
1 parent 51631f7 commit 5dab0ec
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "proxer-cli"
version = "0.3.5"
version = "0.3.6"
edition = "2021"
authors = ["doroved"]
description = "Proxy TCP traffic on macOS with domain filtering."
Expand Down
23 changes: 15 additions & 8 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use hyper_util::rt::TokioIo;
use serde::{Deserialize, Serialize};
use system_proxy::{ProxyState, SystemProxy};
use tokio::net::TcpListener;
use utils::terminate_proxer;
use utils::{terminate_proxer, tracing_error};

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct AuthCredentials {
Expand Down Expand Up @@ -48,15 +48,22 @@ pub async fn run() -> Result<(), Box<dyn std::error::Error>> {
// Parse command-line options
let options = Opt::parse();

// Set open connection limit
let default_connection_limit = rlimit::Resource::NOFILE.get_soft()?;
let _ = rlimit::setrlimit(rlimit::Resource::NOFILE, 999999, rlimit::INFINITY);
tracing::info!(
"Setting open connection limit to {}, default limit is {}",
rlimit::Resource::NOFILE.get_soft()?,
default_connection_limit
"Default connection limit (soft, hard): {:?}",
rlimit::Resource::NOFILE.get()?
);

// Set max open connection limit
match rlimit::increase_nofile_limit(rlimit::INFINITY) {
Ok(limit) => {
tracing::info!("Setting max open connection limit to {}", limit);
}
Err(e) => {
tracing::error!("\x1B[31mFailed to increase the open connection limit: {e}\x1B[0m");
std::process::exit(1);
}
}

// Read the config file or use the default one
let config_path = options.config.unwrap_or_else(|| {
tracing::info!("Using default config file ~/.proxer-cli/config.json5");
Expand Down Expand Up @@ -106,7 +113,7 @@ pub async fn run() -> Result<(), Box<dyn std::error::Error>> {
.with_upgrades()
.await
{
tracing::error!("Server error: {}", err);
tracing_error(&format!("Server error: {}", err));
}
});
}
Expand Down

0 comments on commit 5dab0ec

Please sign in to comment.