Skip to content

Commit 5dab0ec

Browse files
committed
Update proxer-cli to version 0.3.6 and enhance connection limit handling
- 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.
1 parent 51631f7 commit 5dab0ec

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "proxer-cli"
3-
version = "0.3.5"
3+
version = "0.3.6"
44
edition = "2021"
55
authors = ["doroved"]
66
description = "Proxy TCP traffic on macOS with domain filtering."

src/server/mod.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use hyper_util::rt::TokioIo;
1616
use serde::{Deserialize, Serialize};
1717
use system_proxy::{ProxyState, SystemProxy};
1818
use tokio::net::TcpListener;
19-
use utils::terminate_proxer;
19+
use utils::{terminate_proxer, tracing_error};
2020

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

51-
// Set open connection limit
52-
let default_connection_limit = rlimit::Resource::NOFILE.get_soft()?;
53-
let _ = rlimit::setrlimit(rlimit::Resource::NOFILE, 999999, rlimit::INFINITY);
5451
tracing::info!(
55-
"Setting open connection limit to {}, default limit is {}",
56-
rlimit::Resource::NOFILE.get_soft()?,
57-
default_connection_limit
52+
"Default connection limit (soft, hard): {:?}",
53+
rlimit::Resource::NOFILE.get()?
5854
);
5955

56+
// Set max open connection limit
57+
match rlimit::increase_nofile_limit(rlimit::INFINITY) {
58+
Ok(limit) => {
59+
tracing::info!("Setting max open connection limit to {}", limit);
60+
}
61+
Err(e) => {
62+
tracing::error!("\x1B[31mFailed to increase the open connection limit: {e}\x1B[0m");
63+
std::process::exit(1);
64+
}
65+
}
66+
6067
// Read the config file or use the default one
6168
let config_path = options.config.unwrap_or_else(|| {
6269
tracing::info!("Using default config file ~/.proxer-cli/config.json5");
@@ -106,7 +113,7 @@ pub async fn run() -> Result<(), Box<dyn std::error::Error>> {
106113
.with_upgrades()
107114
.await
108115
{
109-
tracing::error!("Server error: {}", err);
116+
tracing_error(&format!("Server error: {}", err));
110117
}
111118
});
112119
}

0 commit comments

Comments
 (0)