From c06a4d0c9a78310563b5b403e733ca474af2eacd Mon Sep 17 00:00:00 2001 From: Siavash Sameni Date: Wed, 1 Apr 2026 19:57:18 +0400 Subject: [PATCH] Add public server links to README, fix dead_code warnings - Add Free Public Servers section with US/EU endpoints and usage examples - Add Server Pro section documenting the optional pro build - Add Android/Termux to supported platforms and installation guide - Gate pro-only public functions with #[cfg(feature = "pro")] to eliminate 6 dead_code warnings in the standard build Co-Authored-By: Claude Opus 4.6 (1M context) --- README.md | 48 +++++++++++++++++++++++++++++++++++++++++++++++- src/bandwidth.rs | 1 + src/server.rs | 5 +++++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 25d0b5b..ea603be 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,25 @@ A Rust reimplementation of the [MikroTik Bandwidth Test (btest)](https://wiki.mikrotik.com/wiki/Manual:Tools/Bandwidth_Test) protocol. Both server and client modes, fully compatible with MikroTik RouterOS devices. +## Free Public Servers + +Test your MikroTik link speed right now — no setup, no registration: + +| Server | Location | Dashboard | +|--------|----------|-----------| +| `104.225.217.60` | US | [btest.home.kg](https://btest.home.kg) | +| `188.245.59.196` | EU | [btest.mikata.ru](https://btest.mikata.ru) | + +``` +/tool bandwidth-test address=104.225.217.60 user=btest password=btest protocol=tcp direction=both +``` + +After the test, visit `https://btest.home.kg/dashboard/YOUR_IP` to see your results, throughput history, and quota usage. Per-IP limits: 2 GB daily / 8 GB weekly / 24 GB monthly. + +> **Note:** TCP is recommended for remote testing. UDP bidirectional through NAT will only show one direction — this is a btest protocol limitation, not specific to btest-rs. See [KNOWN_ISSUES.md](KNOWN_ISSUES.md) for details. + +Want to run your own public server? Build with `cargo build --release --features pro` — see [Server Pro](#server-pro) below. + ## Features - **Full protocol support** -- TCP and UDP data transfer, IPv4 and IPv6 @@ -16,7 +35,7 @@ A Rust reimplementation of the [MikroTik Bandwidth Test (btest)](https://wiki.mi - **Quiet mode** -- suppress terminal output for scripted/automated use - **NAT traversal** -- probe packet to open firewall holes for UDP receive - **Single static binary** -- ~2 MB, zero runtime dependencies (musl build) -- **Cross-platform** -- macOS, Linux (x86_64, ARM64), Docker +- **Cross-platform** -- macOS, Linux (x86_64, ARM64, ARMv7), Windows, Android (Termux), Docker - **Async I/O** -- tokio-based, handles many concurrent connections efficiently ## Performance @@ -61,6 +80,10 @@ sudo mv btest /usr/local/bin/ # Windows # Download btest-windows-x86_64.zip from releases + +# Android (Termux, no root needed) +curl -L /btest-android-aarch64.tar.gz | tar xz +mv btest $PREFIX/bin/ ``` ### Raspberry Pi @@ -267,6 +290,29 @@ scripts/test-mikrotik.sh # Test against MikroTik device scripts/test-docker.sh # Docker container test ``` +## Server Pro + +An optional superset of the standard server with multi-user support, quotas, and a web dashboard. Build with `--features pro`: + +```bash +cargo build --release --features pro --bin btest-server-pro +``` + +Features: +- **SQLite user database** — add/remove users, per-user quotas +- **Per-IP bandwidth quotas** — daily, weekly, monthly limits with inline byte budget enforcement +- **Web dashboard** — session history, throughput stats, quota progress bars, JSON export +- **TCP multi-connection** — handles MikroTik's default 20-connection mode +- **MD5 auth against DB** — proper challenge-response verification + +```bash +# Create a user and start the server +btest-server-pro --users-db users.db useradd btest btest +btest-server-pro --users-db users.db --ip-daily 2147483648 --ip-weekly 8589934592 --web-port 8080 +``` + +The pro features are completely optional and don't affect the standard `btest` binary. + ## Credits - **[btest-opensource](https://github.com/samm-git/btest-opensource)** by [Alex Samorukov](https://github.com/samm-git) -- original C implementation and protocol reverse-engineering. Licensed under **MIT**. diff --git a/src/bandwidth.rs b/src/bandwidth.rs index f79e4fe..28a43a9 100644 --- a/src/bandwidth.rs +++ b/src/bandwidth.rs @@ -73,6 +73,7 @@ impl BandwidthState { } /// Set the byte budget (total bytes allowed for the entire test). + #[cfg(feature = "pro")] pub fn set_budget(&self, budget: u64) { self.byte_budget.store(budget, std::sync::atomic::Ordering::SeqCst); } diff --git a/src/server.rs b/src/server.rs index 80091cc..5ab6951 100644 --- a/src/server.rs +++ b/src/server.rs @@ -367,6 +367,7 @@ async fn handle_client( // --- TCP Test Server --- /// Public TX task for multi-connection use by server_pro. +#[cfg(feature = "pro")] pub async fn tcp_tx_task( writer: tokio::net::tcp::OwnedWriteHalf, tx_size: usize, @@ -377,6 +378,7 @@ pub async fn tcp_tx_task( } /// Public RX task for multi-connection use by server_pro. +#[cfg(feature = "pro")] pub async fn tcp_rx_task( reader: tokio::net::tcp::OwnedReadHalf, state: Arc, @@ -386,6 +388,7 @@ pub async fn tcp_rx_task( /// Run a TCP bandwidth test on an already-authenticated stream. /// Public API for use by server_pro. +#[cfg(feature = "pro")] pub async fn run_tcp_test( stream: TcpStream, cmd: Command, @@ -470,6 +473,7 @@ async fn run_tcp_test_inner(stream: TcpStream, cmd: Command, state: Arc, cmd: Command, @@ -686,6 +690,7 @@ async fn tcp_status_sender( /// Run a UDP bandwidth test on an already-authenticated stream. /// Public API for use by server_pro. Caller provides the UDP port offset. +#[cfg(feature = "pro")] pub async fn run_udp_test( stream: &mut TcpStream, peer: SocketAddr,