This commit applies eight low-risk internal optimizations identified
in the performance audit. No wire protocol changes — 100% MikroTik
compatible.
Changes:
- ecsrp5.rs: Cache WCurve in a global LazyLock, eliminating the
expensive BigUint modular square root recomputation on every
EC-SRP5 authentication. Also optimize the local hex::encode
module to use a single pre-allocated String instead of N format!
allocations.
- server.rs: Deduplicate Instant::now() calls in the TCP TX hot
loop, caching the result at the top of each iteration.
- csv_output.rs: Hold the CSV file handle open in a static
Mutex<Option<(String, File)>> instead of reopening the file on
every write_result call. Add explicit flush after each write.
- server_pro/user_db.rs: Replace hand-rolled Gregorian calendar
math (30+ lines looping from 1970) with chrono::Local::now().
Optimize hash_password() to write username:password directly
into the SHA256 hasher and hex-encode with a pre-allocated
String.
- server_pro/enforcer.rs: Replace allocating error string matching
(format!({}, e).as_str().contains(...)) with direct
QuotaError variant matching. Pass ip_str into flush_to_db()
to avoid a per-call ip.to_string().
- syslog_logger.rs: Move timestamp formatting outside the global
std::sync::Mutex to reduce lock hold time. Replace manual
calendar arithmetic with chrono::Local::now().format().
New dependency: chrono (already pulled in transitively by rusqlite).
73 lines
1.9 KiB
TOML
73 lines
1.9 KiB
TOML
[package]
|
|
name = "btest-rs"
|
|
version = "0.6.3"
|
|
edition = "2021"
|
|
description = "MikroTik Bandwidth Test (btest) server and client with EC-SRP5 auth — a Rust reimplementation"
|
|
license = "MIT AND Apache-2.0"
|
|
repository = "https://github.com/samm-git/btest-opensource"
|
|
keywords = ["mikrotik", "bandwidth", "btest", "network", "benchmarking"]
|
|
categories = ["command-line-utilities", "network-programming"]
|
|
|
|
[lib]
|
|
name = "btest_rs"
|
|
path = "src/lib.rs"
|
|
|
|
[[bin]]
|
|
name = "btest"
|
|
path = "src/main.rs"
|
|
|
|
[[bin]]
|
|
name = "btest-client"
|
|
path = "src/bin/client_only.rs"
|
|
|
|
[[bin]]
|
|
name = "btest-server"
|
|
path = "src/bin/server_only.rs"
|
|
|
|
[[bin]]
|
|
name = "btest-server-pro"
|
|
path = "src/server_pro/main.rs"
|
|
required-features = ["pro"]
|
|
|
|
[features]
|
|
default = []
|
|
pro = ["dep:rusqlite", "dep:ldap3", "dep:axum", "dep:tower-http", "dep:serde", "dep:serde_json", "dep:askama"]
|
|
|
|
[dependencies]
|
|
tokio = { version = "1", features = ["full"] }
|
|
clap = { version = "4", features = ["derive"] }
|
|
md-5 = "0.10"
|
|
bytes = "1"
|
|
thiserror = "2"
|
|
tracing = "0.1"
|
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
|
rand = "0.8"
|
|
socket2 = "0.5"
|
|
anyhow = "1.0.102"
|
|
num-bigint = "0.4.6"
|
|
num-traits = "0.2.19"
|
|
num-integer = "0.1.46"
|
|
sha2 = "0.11.0"
|
|
hostname = "0.4.2"
|
|
chrono = "0.4"
|
|
memchr = "2"
|
|
rusqlite = { version = "0.39.0", features = ["bundled"], optional = true }
|
|
ldap3 = { version = "0.12.1", optional = true }
|
|
axum = { version = "0.8.8", features = ["tokio"], optional = true }
|
|
tower-http = { version = "0.6.8", features = ["fs", "cors"], optional = true }
|
|
serde = { version = "1.0.228", features = ["derive"], optional = true }
|
|
serde_json = { version = "1.0.149", optional = true }
|
|
askama = { version = "0.15.6", optional = true }
|
|
|
|
[profile.release]
|
|
opt-level = 3
|
|
lto = true
|
|
strip = true
|
|
codegen-units = 1
|
|
|
|
# Minimal size profile for embedded/OpenWrt targets
|
|
[profile.release-small]
|
|
inherits = "release"
|
|
opt-level = "z"
|
|
panic = "abort"
|