A fast and reliable mining tunnel built with Rust
Features • Installation • Usage • API • Configuration
- High Performance: Built with Rust for maximum speed and safety
- Real-time Monitoring: Live hashrate, shares, and network stats
- TLS Support: Secure connections with TLS encryption
- SQLite Database: Fast data storage with automatic cleanup
- REST API: Full API for integration
- Prometheus Metrics: Built-in metrics for monitoring
- WebSocket Logs: Real-time log streaming
- Multi-Pool Support: Connect to multiple mining pools
Before you start, make sure you have:
- Rust (latest stable version)
- Cargo (comes with Rust)
- Git
Linux/macOS:
sudo apt update ; apt upgrade -y
sudo apt install -y build-essential clang pkg-config libc6-dev libclang-dev
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/envWindows: Download and install from rustup.rs
rustc --version
cargo --versiongit clone https://github.com/Mytai20100/tunnel-rust.git
cd tunnel-rustLinux/macOS:
chmod +x build.sh
./build.shThe build script will:
- Install Rust (if needed)
- Check Rust version
- Build the release version
# Development build (faster, with debug info)
cargo build
# Release build (optimized, slower to build)
cargo build --releaseThe compiled binary will be in:
- Debug:
target/debug/tunnel-rust - Release:
target/release/tunnel-rust
Create a config.yml file in the project root:
pools:
pool1:
host: "pool.example.com"
port: 4444
name: "Example Pool"
pool2:
host: "another-pool.com"
port: 3333
name: "Another Pool"
tunnels:
tunnel1:
ip: "0.0.0.0"
port: 3333
pool: "pool1"
tunnel2:
ip: "0.0.0.0"
port: 3334
pool: "pool2"
api_port: 8080
database:
path: "tunnel.db"
max_connections: 10# Run with default settings
./target/release/tunnel-rust
# Show help
./target/release/tunnel-rust --help
# Show version
./target/release/tunnel-rust --version| Option | Description |
|---|---|
--nodata |
Disable database logging |
--noapi |
Disable API server |
--nodebug |
Minimal output (single line status) |
--tls |
Enable TLS encryption |
--tlscert |
TLS certificate file (default: cert.pem) |
--tlskey |
TLS key file (default: key.pem) |
# Run without database
./target/release/tunnel-rust --nodata
# Run with minimal output
./target/release/tunnel-rust --nodebug
# Run with TLS
./target/release/tunnel-rust --tls --tlscert=cert.pem --tlskey=key.pem
# Run without database and API
./target/release/tunnel-rust --nodata --noapiopenssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes./target/release/tunnel-rust --tls --tlscert=cert.pem --tlskey=key.pemGET http://localhost:8080/api/metricsGET http://localhost:8080/api/i/{wallet_address}GET http://localhost:8080/api/network/stats?hours=24GET http://localhost:8080/api/shares/stats?wallet={address}&hours=24GET http://localhost:8080/metricsWS ws://localhost:8080/api/logs/streamGET /api/metrics:
{
"system": {
"cpu_model": "Intel Core i7",
"cpu_cores": 8,
"cpu_usage": "25.50%",
"ram_total": 17179869184,
"ram_used": 8589934592,
"uptime": 3600
},
"network": {
"download_gb": 1.25,
"upload_gb": 0.85,
"packets_sent": 150000,
"packets_received": 145000
},
"miners": {
"active": 5,
"list": [...]
}
}FROM rust:latest AS builder
WORKDIR /app
COPY . .
RUN cargo build --release
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
WORKDIR /root/
COPY --from=builder /app/target/release/tunnel-rust .
COPY config.yml .
EXPOSE 3333 8080
CMD ["./tunnel-rust"]docker build -t tunnel-rust:latest .
docker run -d -p 3333:3333 -p 8080:8080 --name tunnel-rust tunnel-rust:latestCreate /etc/systemd/system/tunnel-rust.service:
[Unit]
Description=Rust Mining Tunnel
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/root/tunnel-rust
ExecStart=/root/tunnel-rust/target/release/tunnel-rust
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.targetsudo systemctl daemon-reload
sudo systemctl enable tunnel-rust
sudo systemctl start tunnel-rust
sudo systemctl status tunnel-rustcargo testcargo checkcargo fmtcargo clippy# Application logs
tail -f /var/log/tunnel-rust.log
# Systemd logs
journalctl -u tunnel-rust -fContributions are welcome! Here's how:
- Fork the repository
- Create a feature branch (
git checkout -b feature/awesome-feature) - Commit your changes (
git commit -m 'Add awesome feature') - Push to the branch (
git push origin feature/awesome-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Rust
- WebSocket support with tokio-tungstenite
- Database with rusqlite
- System metrics with sysinfo
- Issues: GitHub Issues
- Discussions: GitHub Discussions