作为依赖库,除固定协议规范标准外,Zenith 所有运行参数均支持运行时热更新,无需重建服务器。
| 层 | 机制 | 热更新内容 |
|---|---|---|
| L2 | eBPF config_map | MTU、协议白名单、fail-closed、期望策略 |
| L2 | XskConfig | socket 收发缓冲(so_rcvbuf/so_sndbuf)、Fill Ring 预填分块 |
| L3 | 每包预算 | parse_packet_with_budget、传输表容量 |
| L4 | ForwardConfig | 并发会话上限、单会话带宽 |
| L7 | RuntimeConfig | WAF、指纹、监听地址、缓存容量、HTTP 各协议参数 |
| L7 | ProxyConfig | 20+ 旋钮:转发超时、池、健康阈值 |
通过 ProtocolServer::update_runtime(|r| ...) 无锁原子热更新:
server.update_runtime(|r| {
// WAF 开关 / 按 host 黑白名单 / 规则集
r.waf_enabled = true;
r.set_host_blacklist(&["bad.example.com"]);
// 指纹安全 / 限流 / 阻断
r.set_fingerprint_blocklist(&["ja3:..."]);
// HTTP 各协议参数
r.http1_max_requests = 10000;
r.http1_idle_timeout_ms = 30000;
r.http2_max_frame_size = 16384;
r.http3_max_field_section = 8192;
// 缓存容量 / /metrics 令牌 / 监听地址
r.cache_capacity_bytes = 1 << 30;
r.metrics_auth_token = Some(secret);
});// L4 转发:并发上限 / 单会话带宽
server.set_forward_config(ForwardConfig {
max_concurrent_sessions: 10000,
per_session_bandwidth_bps: 100 * 1000 * 1000,
});
// L7 代理:20+ 旋钮
server.set_proxy_config(ProxyConfig {
connect_timeout_ms: 5000,
// ...
});
// 或增量更新
server.update_proxy_config(|p| p.health_threshold = 0.8);搭配 zenith-runtime 使用,热更新与运行时治理闭环: