Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ categories = ["network-programming", "web-programming::http-server"]

# 二进制走 CalVer,crate 走 SemVer —— 两者是两回事,卖给不同的人。
# 这里是 crate 的版本。
version = "0.92.0"
version = "0.93.0"

[workspace.dependencies]
# ── 内部 crate ───────────────────────────────────────────
Expand Down
20 changes: 19 additions & 1 deletion crates/tw-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1144,14 +1144,26 @@ pub const MSG_CODES: &str = include_str!("../msg-codes.txt");
/// 速度,请求记录里照记。新码:`gw.upstream.too_slow`、`config.min_speed_range`(`upstream`、
/// `field`、`value`、`min`、`max`);一键修复修得了它:速度越界删掉 `min_speed`,判定时长越界改回
/// 20。请求库 SCHEMA 不变
pub const CONTROL_API_VERSION: u32 = 58;
///
/// **59 起网关可额外监听多张网卡或固定 IP**:[`ListenSave`]、[`ListenView`] 增加
/// `additional`。主绑定设为回环时停用全部额外监听;来源白名单和密钥校验共用。
/// [`Status`] 增加 `gateway_addrs`(全部实际绑定的套接字)和 `gateway_probe`(公开的进程标识,
/// `/healthz` 的 `x-thinkwatch-gateway` 响应头原样返回),用于从其他网络命名空间确认连到的
/// 是当前网关。请求库 SCHEMA 不变。
pub const CONTROL_API_VERSION: u32 = 59;

/// `/live` 的速度看最近多久(见 [`LiveView::tokens_per_sec`]),毫秒
pub const LIVE_RATE_WINDOW_MS: u64 = 3_000;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "ts", derive(ts_rs::TS))]
pub struct Status {
/// Actual bound sockets, including loopback and secondary interfaces.
#[serde(default)]
pub gateway_addrs: Vec<String>,
/// Public identity echoed in the gateway health response header.
#[serde(default)]
pub gateway_probe: String,
pub api_version: u32,
/// 二进制的 CalVer
pub version: String,
Expand Down Expand Up @@ -3143,6 +3155,8 @@ pub struct KeyRotated {
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[cfg_attr(feature = "ts", derive(ts_rs::TS))]
pub struct ListenSave {
#[serde(default)]
pub additional: Vec<String>,
/// 同配置里的 `listen.gateway.bind`:`loopback` / `all` / 网卡名 / 地址
pub bind: String,
pub port: u16,
Expand Down Expand Up @@ -3174,6 +3188,8 @@ pub struct KeyValue {
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "ts", derive(ts_rs::TS))]
pub struct ListenView {
#[serde(default)]
pub additional: Vec<String>,
pub bind: String,
pub port: u16,
/// 放行网段,就是生效的那一份:配置里没写时是默认名单,空 = 除本机外
Expand Down Expand Up @@ -8025,6 +8041,8 @@ mod tests {
#[test]
fn status_round_trips() {
let s = Status {
gateway_addrs: vec!["127.0.0.1:8788".into()],
gateway_probe: "public-process-id".into(),
api_version: CONTROL_API_VERSION,
version: "2026.9.0".into(),
pid: 1,
Expand Down
Loading
Loading