English | 简体中文
One port. Every protocol. Zero hassle.
A lightweight, async TCP gateway written in Rust that listens on a single port, sniffs the incoming traffic, and routes it to the right backend — so your Minecraft server and HTTP services can share one public port.
- 🚪 Single-port multiplexing — one listener serves both Minecraft and HTTP traffic
- 🔍 Automatic protocol detection — sniffs the first bytes of each connection using the
guesscrate (HTTP / TLS / QUIC / web detection) - 🎯 Smart routing — HTTP goes to your web service, everything else goes to your Minecraft backend
- 🛡️ Per-IP connection limiting — protect your backends from connection floods
- ⚡ Pure async — built on
tokiowith bidirectionalcopy, one task per connection - 📝 Structured logging —
tracing-based, with daily rolling file logs + stdout output - 🧩 TOML configuration — auto-generates a default config on first run; broken configs are safely backed up (
.bak<timestamp>) instead of crashing - 📦 Cross-platform releases — prebuilt binaries via GitHub Actions (Windows x64/x86/ARM64, Linux x64)
craft-gate binds a single TCP listener (e.g. tcp://0.0.0.0:25565) and accepts every incoming
connection on it. As soon as a client connects, the gate reads the first 256 bytes and runs them
through a protocol detector powered by the guess crate, which recognizes HTTP/TLS/QUIC-style
web traffic. If the sniffed bytes look like web traffic, the connection is relayed to the HTTP
service backend; anything else — for example a Minecraft client — is relayed to the Minecraft
server backend. Before the relay starts, a per-IP connection limiter may reject the client if it
exceeds the configured limit. Each accepted relay runs as its own tokio task that bidirectionally
copies data between the client and the chosen backend, so traffic flows freely in both directions
until the connection closes.
git clone https://github.com/tangge233/craft-gate.git
cd craft-gate
cargo build --release
# run it — a default config will be generated on first launch
./target/release/craft-gateGrab the latest release for your platform from the Releases page.
Usage: craft-gate [OPTIONS]
Options:
--config-file <CONFIG_FILE> Path to the config file [default: craft-gate/config.toml]
--debug Enable debug-level logging
-h, --help Print help
The default config is written to craft-gate/config.toml on first run:
# Address the gate listens on
listen = "tcp://0.0.0.0:25565"
# Per-IP connection limiting
[ip_limit]
enable = false # set to true to enable
limits = 10 # max concurrent connections per IP
# Minecraft backend
[services.minecraft]
dest = "tcp://127.0.0.1:11451"
# HTTP backend
[services.http]
dest = "tcp://127.0.0.1:8080"
mode = "Proxy" # "Proxy" or "Redirect"Note: If a config file exists but fails to parse, craft-gate won't crash — it backs the file up as
config.bak<timestamp>and falls back to defaults.
- Logs are written to stdout and to
craft-gate/logs/as daily rolling files. - Use
--debugfor verbose protocol-detection and connection details.
cargo test- Wire up the HTTP
Redirectmode - More detection profiles (e.g. plain TCP passthrough rules)
- Windows ARM64 / macOS binaries in CI
| Component | Choice |
|---|---|
| Async runtime | tokio |
| Protocol detection | guess |
| Config | TOML via serde |
| Logging | tracing + tracing-appender |
| Concurrency primitives | dashmap |
| CLI | clap |
MIT © tangge233