CLI 参考
relay-core-cli 二进制文件提供了功能完整的命令行界面,用于运行代理和管理流量、规则和证书。
命令
run
启动代理服务器。
relay-core-cli run [options]
Options:
--port <PORT> 代理端口(默认:8080)
--ui 启用 TUI 界面
--config <PATH> 配置文件路径
--verbose 启用详细日志 ca
管理用于 HTTPS 拦截的 CA 证书。
relay-core-cli ca <subcommand>
Subcommands:
init 生成新的 CA 证书
install 将 CA 安装到系统
status 显示 CA 证书状态
export <path> 导出 CA 证书到文件
uninstall 移除已安装的 CA rules
管理拦截规则。
relay-core-cli rules <subcommand>
Subcommands:
list 列出所有规则
validate <file> 验证规则文件
export 导出规则为 YAML
import <file> 从 YAML 导入规则 flows
查询捕获的流量。
relay-core-cli flows [options]
Options:
--filter <EXPR> 过滤表达式
--limit <N> 最大结果数(默认:50)
--offset <N> 分页偏移
--format <json|table> 输出格式 metrics
显示运行时指标。
relay-core-cli metrics [options]
Options:
--format <json|prometheus> 输出格式(默认:table)
--reset 显示后重置计数器 scripts
管理用于请求/响应修改的 Deno 脚本。
relay-core-cli scripts <subcommand>
Subcommands:
list 列出已加载的脚本
load <path> 加载脚本
unload <name> 卸载脚本 过滤表达式
使用表达式语法过滤流量:
# 按方法
method:GET
method:POST
# 按主机(支持通配符)
host:example.com
host:*.example.com
# 按路径
path:/api/users
path:/api/v2/*
# 按状态码
status:200
status:[200 TO 299]
status:[400 TO 499]
# 使用 AND/OR 组合
method:GET AND host:*.example.com
method:POST OR method:PUT
# 取反
NOT method:OPTIONS 配置文件
创建 ~/.relay-core/config.toml:
[proxy]
port = 8080
bind_address = "0.0.0.0"
upstream_proxy = "http://parent-proxy:8080" # 可选
[storage]
sqlite_path = "~/.relay-core/flows.db"
max_flows = 10000
flow_ttl_hours = 24
[logging]
level = "info" # debug, info, warn, error
access_log = true
[mcp]
enabled = true
port = 25519
[tls]
insecure_skip_verify = false
cert_cache_size = 100 环境变量
RELAY_CORE_CONFIG # 配置文件路径
RELAY_CORE_PORT # 代理端口
RELAY_CORE_LOG_LEVEL # 日志级别
RELAY_CORE_DATA_DIR # 数据目录(默认:~/.relay-core)