Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 133 additions & 1 deletion Cargo.lock

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

7 changes: 5 additions & 2 deletions crates/rproxy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rproxy"
version = "0.0.9"
version = "0.0.10"
edition = "2024"
default-run = "rproxy"

Expand Down Expand Up @@ -40,24 +40,27 @@ futures-core = "0.3.31"
hex = "0.4.3"
http = "1.3.1"
humantime = "2.2.0"
libc = "0.2.177"
moka = { version = "0.12.11", features = ["sync"] }
op-alloy-consensus = "0.20.0"
parking_lot = "0.12.4"
pin-project = "1.1.10"
pnet = "0.35.0"
prometheus-client = { git = "https://github.com/0x416e746f6e/client_rust.git", branch = "nested-labels"}
rand = { version = "0.9.2", optional = true }
rlimit = "0.10.2"
rustc-hash = "2.1.1"
rustls = "0.23.32"
rustls-pemfile = "2.2.0"
scc = "3.0.2"
serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.143"
socket2 = "0.6.0"
sysctl = "0.7.1"
thiserror = "2.0.16"
time = { version = "0.3.43", features = ["formatting"] }
tokio = { version = "1.47.1", features = ["macros", "rt", "rt-multi-thread", "signal"] }
tokio-tungstenite = "0.27.0"
tokio-tungstenite = {version = "0.27.0", features = ["rustls-tls-native-roots"] }
tokio-util = "0.7.16"
tracing = { version = "0.1.41", features = ["valuable"] }
tracing-subscriber = { version = "0.3.20", features = ["env-filter", "json", "valuable"] }
Expand Down
68 changes: 68 additions & 0 deletions crates/rproxy/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use std::{process, sync::LazyLock};

use clap::Parser;
use sysctl::Sysctl;
use thiserror::Error;
use x509_parser::asn1_rs::ToStatic;

use crate::server::{
config::{ConfigLogging, ConfigLoggingError, ConfigMetrics, ConfigMetricsError},
Expand All @@ -26,6 +28,72 @@ pub(crate) static PARALLELISM: LazyLock<usize> =

pub(crate) static PARALLELISM_STRING: LazyLock<String> = LazyLock::new(|| PARALLELISM.to_string());

pub(crate) static TCP_KEEPALIVE_INTERVAL: LazyLock<libc::c_int> = LazyLock::new(|| {
#[cfg(target_os = "linux")]
{
let mut res: libc::c_int = 75;
if let Ok(ctl) = sysctl::Ctl::new("net.ipv4.tcp_keepalive_intvl") &&
let Ok(value) = ctl.value() &&
let Ok(value) = value.into_int()
{
res = value
}
return res;
}

#[cfg(target_os = "macos")]
{
let mut res: libc::c_int = 75000;
if let Ok(ctl) = sysctl::Ctl::new("net.inet.tcp.keepintvl") &&
let Ok(value) = ctl.value() &&
let Ok(value) = value.into_int()
{
res = value / 1000 // millis on macos
}

return res;
}

#[allow(unreachable_code)]
75
});

pub(crate) static TCP_KEEPALIVE_INTERVAL_STRING: LazyLock<String> =
LazyLock::new(|| format!("{}s", TCP_KEEPALIVE_INTERVAL.to_static()));

pub(crate) static TCP_KEEPALIVE_PROBES: LazyLock<libc::c_int> = LazyLock::new(|| {
#[cfg(target_os = "linux")]
{
let mut res: libc::c_int = 9;
if let Ok(ctl) = sysctl::Ctl::new("net.ipv4.tcp_keepalive_probes") &&
let Ok(value) = ctl.value() &&
let Ok(value) = value.into_int()
{
res = value
}
return res;
}

#[cfg(target_os = "macos")]
{
let mut res: libc::c_int = 8;
if let Ok(ctl) = sysctl::Ctl::new("net.inet.tcp.keepcnt") &&
let Ok(value) = ctl.value() &&
let Ok(value) = value.into_int()
{
res = value
}

return res;
}

#[allow(unreachable_code)]
8
});

pub(crate) static TCP_KEEPALIVE_PROBES_STRING: LazyLock<String> =
LazyLock::new(|| TCP_KEEPALIVE_PROBES.to_string());

// Config --------------------------------------------------------------

#[derive(Clone, Parser)]
Expand Down
Loading