relay-core — zsh
$ cargo install relay-core-cli
  Installing relay-core-cli v0.3.5...
  Finished [debug] target 2.3MB 0.42s

$ relay-core-cli run --port 8080
> RelayCore v0.3.5 initializing...
> Loading configuration from ~/.relay-core/config.toml
> Starting HTTP proxy on 0.0.0.0:8080
> MCP server listening on :25519
> REST API available at http://127.0.0.1:3000/api/v1/
> 10,247 flows captured this session

RUST 编写的流量拦截引擎

零拷贝异步运行时。亚毫秒级开销。支持 HTTP/HTTPS/WebSocket 的 MITM 代理,提供完整的编程控制能力。

RelayCore 功能

完整 MITM 支持

动态 TLS 证书生成,自动 CA 安装。

WebSocket 拦截

双向 WebSocket 通信的消息级检查、修改和重放。

规则引擎

支持 headers、body、status、redirect、mock 的匹配+动作管道。

可脚本化

Deno 运行时,支持动态请求/响应修改。

拦截断点

暂停实时流量,检查、修改,然后继续或丢弃。

Prometheus 指标

内置 Prometheus 文本格式和 JSON 指标端点。

架构

┌─────────────────────────────────────────────────────┐
│                 RELAYCORE ARCHITECTURE                  │
└─────────────────────────────────────────────────────┘

         ┌──────────────────────────────────┐
         │       ADAPTER LAYER               │
         │  ┌──────┐ ┌──────┐ ┌────────┐  │
         │  │ HTTP │ │  MCP  │ │ Tauri  │  │
         │  │ API  │ │Probe  │ │Plugin  │  │
         │  └──────┘ └──────┘ └────────┘  │
         └──────────────┬───────────────────┘
                        │
                        ▼
         ┌──────────────────────────────┐
         │     relay-core-runtime       │
         │   (State, Events, Rules)     │
         └──────────────┬───────────────┘
                        │
     ┌─────────────────┼─────────────────┐
     ▼                 ▼                 ▼
┌──────────┐  ┌──────────────┐  ┌──────────────┐
│   lib    │  │   storage    │  │   script     │
│ (engine) │  │  (SQLite)    │  │  (Deno/V8)   │
└──────────┘  └──────────────┘  └──────────────┘
PUBLIC relay-core-runtime 状态编排、生命周期、规则
PUBLIC relay-core-http REST + SSE 适配器
BETA relay-core-probe AI 代理 MCP 适配器
BETA relay-core-cli 独立 CLI 和 TUI
INTERNAL relay-core-lib 核心引擎:MITM、TLS、代理
INTERNAL relay-core-storage SQLite 持久化

性能

>10K
req/s
吞吐量 (S1)
<200
ms
冷启动
<50
MB
空闲 RSS
<5
ms
P99 延迟增加
指标 RelayCore mitmproxy Charles
语言 Rust Python Java
吞吐量 10K+ req/s ~1K req/s ~2K req/s
内存 (空闲) 38MB ~150MB ~300MB
P99 开销 <5ms ~50ms ~30ms

HTTP API

GET http://127.0.0.1:3000/api/v1/flows?limit=10
Response 200 OK
// JSON response
GET /api/v1/flows 搜索和分页流量
GET /api/v1/flows/:id 获取流量详情
GET /api/v1/rules 列出所有规则
PUT /api/v1/rules 更新或创建规则
DELETE /api/v1/rules/:id 删除规则
POST /api/v1/intercepts 创建拦截规则
GET /api/v1/events SSE 实时更新流
GET /api/v1/metrics/prometheus Prometheus 格式指标

CLI 参考

$ relay-core-cli run
> RelayCore v0.3.5
> Proxy listening on 0.0.0.0:8080
> Web UI: http://127.0.0.1:8080/ui
> Press Ctrl+C to stop
$ relay-core-cli ca init
> Generating new CA certificate...
> CA certificate generated successfully
> Path: ~/.relay-core/ca.crt
$ relay-core-cli rules list
 ID       PRIORITY  FILTER                    ACTION    ENABLED
────────────────────────────────────────────────────────────
 rul_01      100     method:GET host:*.example.com  log       true
 rul_02       90     path:/api/v2/*                intercept  true
$ relay-core-cli flows --limit 5
 TIME     METHOD  PATH                    STATUS  DURATION
───────────────────────────────────────────────────────────
 10:23:45  GET     /users/relaycraft        200     45ms
 10:23:42  POST    /repos                  201     120ms
 10:23:38  GET     /search?q=relay-core     200     89ms
relay-core-cli run 启动代理服务器
relay-core-cli run --ui 启动 TUI 界面
relay-core-cli ca init CA 证书管理
relay-core-cli rules list 规则管理
relay-core-cli flows 查询捕获的流量
relay-core-cli metrics 查看运行时指标

开始使用

Cargo

cargo install relay-core-cli

npm

npm install -g @relay-core/cli

源码构建

git clone https://github.com/relaycraft/relay-core && cd relay-core && cargo build --release