About this project
stab is a modern, simple, compact, high-performance TCP tunneling tool designed to easily expose local ports to remote servers. Written in Rust, it offers both command-line and configuration file usage, and supports embedding into other programs.
Key features include:
- High performance
- Heartbeat detection
- Traffic statistics
- Web management page with manual disconnect support
- Expose multiple local ports simultaneously
- Automatic reconnect on disconnection (configurable)
- Local IPC API: can be launched by other programs with zero configuration and dynamically receive configurations
Installation methods:
- Install via cargo: `cargo install stab`
- Download precompiled binaries from GitHub Releases
Usage:
1. Start the server on a remote host: `stab server`, with default control port 5656 and web management port 3400. Ports, data port ranges, and connection pool sizes can be modified.
2. Establish a tunnel locally: `stab local -l 8000=server.com`, mapping local ports to the remote server, with remote ports auto-assigned or specified.
3. Support setting all parameters via configuration files (TOML), with command-line arguments taking precedence.
4. Support shared secret authentication to prevent abuse.
5. Web management page can be password-protected.
Embedding into other programs:
- Start with `stab local --api`, using named pipes (Windows) or Unix Domain Sockets to provide the IPC API.
- The protocol uses length-prefixed JSON frames, supporting methods like ping, get_status, set_config, add_link, remove_link, list_links, clear_links, and shutdown.
- Host processes can dynamically add/remove tunnels, update configurations, and retrieve status.
Configuration file examples:
- Server `server.toml`: sets mode, port, secret, logging, web port, port range, connection pool size, etc.
- Local `local.toml`: sets mode, port, secret, logging, default remote host, reconnect policy, tunnel list, etc.
Command-line parameter overview:
- `server` / `local`: run mode
- `-f, --file`: configuration file path
- `-c, --control-port`: control port
- `-s, --secret`: tunnel secret
- `--log`: log level
- `--log-path`: log directory
- `-l, --link`: tunnel mapping
- `--api`: enable IPC API
- `--api-path`: IPC path
- `--api-token`: IPC token
- `-w, --web-port`: web management port
- `-p, --port-range`: data port range
- `--pool-size`: connection pool size
The project provides documentation in both Chinese and English, suitable for developers and operators needing to quickly expose local services.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.