From a346fe8688199d3072b926442552381e9e96e765 Mon Sep 17 00:00:00 2001 From: Zakk Date: Wed, 14 Oct 2026 12:28:14 +1100 Subject: [PATCH] fix(subscription): report provider usage and expiry --- crates/honk-core/src/marked_http.rs | 5 ++ crates/honk-core/src/native_api/providers.rs | 30 +++++++++-- .../src/native_api/providers/tests.rs | 10 +++- .../src/native_api/providers/tests/support.rs | 2 +- crates/honk-core/src/subscription.rs | 51 ++++++++++++++++--- crates/honk-core/src/subscription/network.rs | 9 ++-- .../src/subscription/network/tests.rs | 4 +- .../honk-core/src/subscription/supervisor.rs | 17 +++++-- .../src/subscription/supervisor/startup.rs | 14 +++-- .../src/subscription/supervisor/tests.rs | 4 +- crates/honk-core/src/subscription/tests.rs | 40 +++++++++++++++ doc/en/reference/api.md | 2 +- doc/zh/reference/api.md | 2 +- 13 files changed, 162 insertions(+), 28 deletions(-) diff --git a/crates/honk-core/src/marked_http.rs b/crates/honk-core/src/marked_http.rs index 431a80bb..d6314834 100644 --- a/crates/honk-core/src/marked_http.rs +++ b/crates/honk-core/src/marked_http.rs @@ -331,6 +331,7 @@ pub(crate) struct Reply { pub(crate) status: http::StatusCode, /// Unchecked, so a caller that follows it can reject one that is not text. pub(crate) location: Option, + pub(crate) subscription_userinfo: Option, pub(crate) body: Arc<[u8]>, } @@ -367,10 +368,12 @@ pub(crate) async fn read( let result = async { let status = parts.status; let location = parts.headers.get(LOCATION).cloned(); + let subscription_userinfo = parts.headers.get("subscription-userinfo").cloned(); if !wants_body(status, &parts.headers) { return Ok(Reply { status, location, + subscription_userinfo, body: Arc::from([]), }); } @@ -420,12 +423,14 @@ pub(crate) async fn read( Some(buffer) if buffer.len() == received => Ok(Reply { status, location, + subscription_userinfo, body: buffer, }), Some(_) => Err("http_failed".into()), None => Ok(Reply { status, location, + subscription_userinfo, body: grown.into(), }), } diff --git a/crates/honk-core/src/native_api/providers.rs b/crates/honk-core/src/native_api/providers.rs index ebc9fb53..e0e2e3ab 100644 --- a/crates/honk-core/src/native_api/providers.rs +++ b/crates/honk-core/src/native_api/providers.rs @@ -40,7 +40,7 @@ pub(crate) struct Provider { node_count: usize, updated_at: Option, expires_at: Option, - traffic: Option<()>, + traffic: Option, status: &'static str, last_error: Option, download: Option, @@ -58,6 +58,13 @@ impl std::fmt::Debug for Provider { } } +#[derive(Clone, Serialize)] +struct ProviderTraffic { + upload_bytes: Option, + download_bytes: Option, + total_bytes: Option, +} + #[derive(Clone, Debug, Serialize)] struct ProviderError { code: &'static str, @@ -105,8 +112,19 @@ impl Provider { url_redacted: Some(subscription.url.clone()), node_count, updated_at: load.updated_at.map(timestamp), - expires_at: None, - traffic: None, + expires_at: load + .userinfo + .expire + .and_then(|seconds| chrono::DateTime::from_timestamp(seconds.try_into().ok()?, 0)) + .map(|expires| timestamp(expires.into())), + traffic: (load.userinfo.upload.is_some() + || load.userinfo.download.is_some() + || load.userinfo.total.is_some()) + .then(|| ProviderTraffic { + upload_bytes: load.userinfo.upload.map(|bytes| bytes.to_string()), + download_bytes: load.userinfo.download.map(|bytes| bytes.to_string()), + total_bytes: load.userinfo.total.map(|bytes| bytes.to_string()), + }), status: if load.error.is_some() && node_count == 0 { "error" } else if load.updated_at.is_none() @@ -165,6 +183,12 @@ impl Provider { + self.name.capacity() + self.url_redacted.as_ref().map_or(0, String::capacity) + self.updated_at.as_ref().map_or(0, String::capacity) + + self.expires_at.as_ref().map_or(0, String::capacity) + + self.traffic.as_ref().map_or(0, |traffic| { + traffic.upload_bytes.as_ref().map_or(0, String::capacity) + + traffic.download_bytes.as_ref().map_or(0, String::capacity) + + traffic.total_bytes.as_ref().map_or(0, String::capacity) + }) } } diff --git a/crates/honk-core/src/native_api/providers/tests.rs b/crates/honk-core/src/native_api/providers/tests.rs index a7922854..fa47dec0 100644 --- a/crates/honk-core/src/native_api/providers/tests.rs +++ b/crates/honk-core/src/native_api/providers/tests.rs @@ -50,7 +50,15 @@ async fn provider_get_is_safe_pure_and_counts_accepted_provenance_not_display_na assert!(detail["updated_at"].is_string()); assert_eq!(detail["url_redacted"], subscription.url); assert_eq!(detail["name"], subscription.name); - assert!(detail["traffic"].is_null() && detail["expires_at"].is_null()); + assert_eq!( + detail["traffic"], + json!({ + "upload_bytes": "422986054", + "download_bytes": "5198408536", + "total_bytes": "214748364800", + }) + ); + assert_eq!(detail["expires_at"], "2026-12-08T06:54:09.000Z"); assert_eq!( list["providers"] .as_array() diff --git a/crates/honk-core/src/native_api/providers/tests/support.rs b/crates/honk-core/src/native_api/providers/tests/support.rs index 6068300f..d2bc9a26 100644 --- a/crates/honk-core/src/native_api/providers/tests/support.rs +++ b/crates/honk-core/src/native_api/providers/tests/support.rs @@ -65,7 +65,7 @@ pub(super) async fn respond(mut socket: TcpStream, body: &str) { socket .write_all( format!( - "HTTP/1.1 200 OK\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{body}", + "HTTP/1.1 200 OK\r\nsubscription-userinfo: upload=422986054; download=5198408536; total=214748364800; expire=1796712849\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{body}", body.len() ) .as_bytes(), diff --git a/crates/honk-core/src/subscription.rs b/crates/honk-core/src/subscription.rs index a9055040..2d0b0a67 100644 --- a/crates/honk-core/src/subscription.rs +++ b/crates/honk-core/src/subscription.rs @@ -366,10 +366,38 @@ fn subscription_client() -> anyhow::Result { crate::marked_http::Client::new() } +#[derive(Clone, Copy, Debug, Default)] +pub(crate) struct SubscriptionUserinfo { + pub(crate) upload: Option, + pub(crate) download: Option, + pub(crate) total: Option, + pub(crate) expire: Option, +} + +fn parse_subscription_userinfo(header: &str) -> SubscriptionUserinfo { + let mut userinfo = SubscriptionUserinfo::default(); + for pair in header.split(';') { + let Some((key, value)) = pair.split_once('=') else { + continue; + }; + let Ok(value) = value.trim().parse::() else { + continue; + }; + match key.trim() { + "upload" => userinfo.upload = Some(value), + "download" => userinfo.download = Some(value), + "total" => userinfo.total = (value != 0).then_some(value), + "expire" => userinfo.expire = (value != 0).then_some(value), + _ => {} + } + } + userinfo +} + async fn fetch_body( client: &crate::marked_http::Client, sub: &Subscription, -) -> anyhow::Result> { +) -> anyhow::Result<(Vec, SubscriptionUserinfo)> { fetch_following(sub, route::Hop::Direct(client)).await } @@ -392,7 +420,10 @@ fn subscription_request_headers(sub: &Subscription) -> anyhow::Result) -> anyhow::Result> { +async fn fetch_following( + sub: &Subscription, + hop: route::Hop<'_>, +) -> anyhow::Result<(Vec, SubscriptionUserinfo)> { let deadline = tokio::time::Instant::now() + SUBSCRIPTION_TIMEOUT; let mut url = reqwest::Url::parse(&sub.url)?; let mut headers = subscription_request_headers(sub)?; @@ -426,7 +457,13 @@ async fn fetch_following(sub: &Subscription, hop: route::Hop<'_>) -> anyhow::Res "subscription server answered HTTP {}", reply.status ); - return Ok(reply.body.to_vec()); + let userinfo = reply + .subscription_userinfo + .as_ref() + .and_then(|header| header.to_str().ok()) + .map(parse_subscription_userinfo) + .unwrap_or_default(); + return Ok((reply.body.to_vec(), userinfo)); } unreachable!("redirect bound checked before following"); } @@ -500,7 +537,7 @@ impl SubscriptionManager { diagnostics: &mut Vec, ) -> anyhow::Result> { let start = diagnostics.len(); - let (nodes, content) = self.fetch_content(sub, diagnostics).await?; + let (nodes, content, _) = self.fetch_content(sub, diagnostics).await?; Self::persist_content(sub, store, content, diagnostics, start).await; Ok(nodes) } @@ -509,8 +546,8 @@ impl SubscriptionManager { &self, sub: &Subscription, diagnostics: &mut Vec, - ) -> anyhow::Result<(Vec, String)> { - let body = if route::direct(sub) { + ) -> anyhow::Result<(Vec, String, SubscriptionUserinfo)> { + let (body, userinfo) = if route::direct(sub) { match &self.http { SubscriptionHttp::Shared(client) => fetch_body(client, sub).await?, #[cfg(feature = "native-api")] @@ -532,7 +569,7 @@ impl SubscriptionManager { diagnostics, )?; let nodes = parse_subscription_content_with_diagnostics(sub, &content, diagnostics)?; - Ok((nodes, content)) + Ok((nodes, content, userinfo)) } async fn persist_content( diff --git a/crates/honk-core/src/subscription/network.rs b/crates/honk-core/src/subscription/network.rs index 2ed1ed4a..501615b8 100644 --- a/crates/honk-core/src/subscription/network.rs +++ b/crates/honk-core/src/subscription/network.rs @@ -1,4 +1,4 @@ -use super::{Subscription, fetch_body, subscription_client}; +use super::{Subscription, SubscriptionUserinfo, fetch_body, subscription_client}; use std::time::{Duration, Instant}; use tokio::sync::{Mutex, mpsc, oneshot, watch}; use tokio::task::{JoinHandle, JoinSet}; @@ -10,7 +10,7 @@ type ThreadResult = Result<(), &'static str>; struct Request { subscription: Subscription, - reply: oneshot::Sender>>, + reply: oneshot::Sender, SubscriptionUserinfo)>>, } struct NetworkThread { @@ -148,7 +148,10 @@ impl SubscriptionNetwork { Self::await_ready(&mut *self.state.lock().await).await } - pub(super) async fn fetch(&self, subscription: &Subscription) -> anyhow::Result> { + pub(super) async fn fetch( + &self, + subscription: &Subscription, + ) -> anyhow::Result<(Vec, SubscriptionUserinfo)> { let sender = { let mut state = self.state.lock().await; Self::await_ready(&mut state).await?; diff --git a/crates/honk-core/src/subscription/network/tests.rs b/crates/honk-core/src/subscription/network/tests.rs index dfe817d9..a55b9009 100644 --- a/crates/honk-core/src/subscription/network/tests.rs +++ b/crates/honk-core/src/subscription/network/tests.rs @@ -44,7 +44,7 @@ async fn completed_request_leaves_no_keepalive_before_pause() { .write_all(b"HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\nbody") .await .unwrap(); - assert_eq!(fetch.await.unwrap().unwrap(), b"body"); + assert_eq!(fetch.await.unwrap().unwrap().0, b"body"); // The marked client owns one connection per request and keeps no idle pool. peer_eof(&mut socket).await; network.pause().await.unwrap(); @@ -104,7 +104,7 @@ async fn held_resolver() -> ( Arc, Arc, std::sync::mpsc::Sender<()>, - JoinHandle>>, + JoinHandle, super::super::SubscriptionUserinfo)>>, ) { let (entered, started) = oneshot::channel(); let (release, released) = std::sync::mpsc::channel(); diff --git a/crates/honk-core/src/subscription/supervisor.rs b/crates/honk-core/src/subscription/supervisor.rs index c943b839..635076df 100644 --- a/crates/honk-core/src/subscription/supervisor.rs +++ b/crates/honk-core/src/subscription/supervisor.rs @@ -7,7 +7,7 @@ use tokio::sync::{mpsc, oneshot, watch}; use tokio::task::{JoinHandle, JoinSet}; use tracing::{info, warn}; -use super::{SubscriptionManager, SubscriptionStore}; +use super::{SubscriptionManager, SubscriptionStore, SubscriptionUserinfo}; use crate::control::ControlCommand; use crate::control::ReloadOutcome; use tokio::time::Instant; @@ -27,6 +27,7 @@ pub(crate) struct SubscriptionMergeReply { #[derive(Clone, Copy, Default)] pub(crate) struct ProviderLoad { pub(crate) updated_at: Option, + pub(crate) userinfo: SubscriptionUserinfo, pub(crate) cached: bool, pub(crate) error: Option<&'static str>, /// The configuration diagnostic code behind a `publication_rejected` error. @@ -179,7 +180,7 @@ pub(crate) fn validate_subscription_ids(subscriptions: &[Subscription]) -> anyho struct FetchCompletion { authorized: AuthorizedSubscription, - result: Option>>, + result: Option, SubscriptionUserinfo)>>, diagnostics: Vec, } @@ -200,7 +201,7 @@ async fn fetch_once( } }; let result = match fetched { - Some(Ok((nodes, content))) => { + Some(Ok((nodes, content, userinfo))) => { // Once a blocking cache write starts, its owner must join it even on pause/shutdown. SubscriptionManager::persist_content( &authorized.subscription, @@ -210,7 +211,7 @@ async fn fetch_once( 0, ) .await; - Some(Ok(nodes)) + Some(Ok((nodes, userinfo))) } Some(Err(error)) => Some(Err(error)), None => None, @@ -224,6 +225,7 @@ async fn fetch_once( } struct Flight { authorized: AuthorizedSubscription, + userinfo: SubscriptionUserinfo, #[cfg(feature = "native-api")] operation: Option>, } @@ -311,6 +313,7 @@ impl SupervisorState { id, Flight { authorized: provider.authorized.clone(), + userinfo: SubscriptionUserinfo::default(), #[cfg(feature = "native-api")] operation: None, }, @@ -434,6 +437,7 @@ impl SupervisorState { "Subscription runtime publication acknowledged" ); observed.load.updated_at = Some(SystemTime::now()); + observed.load.userinfo = flight.userinfo; observed.load.cached = false; observed.load.error = matches!(reply.outcome, ReloadOutcome::CommittedDegraded { .. }) @@ -455,6 +459,7 @@ impl SupervisorState { } (Ok(reply), None) if reply.outcome.accepted() => ProviderLoad { updated_at: Some(SystemTime::now()), + userinfo: flight.userinfo, cached: false, error: matches!(reply.outcome, ReloadOutcome::CommittedDegraded { .. }) .then_some("publication_degraded"), @@ -477,7 +482,8 @@ impl SupervisorState { fn fetched(&mut self, completion: FetchCompletion, command_tx: &mpsc::Sender) { let id = completion.authorized.subscription.id; match completion.result { - Some(Ok(nodes)) => { + Some(Ok((nodes, userinfo))) => { + self.flights.get_mut(&id).unwrap().userinfo = userinfo; let command_tx = command_tx.clone(); let task = self.publications.spawn(async move { let (result, wait) = oneshot::channel(); @@ -537,6 +543,7 @@ impl SupervisorState { id, Flight { authorized: provider.authorized.clone(), + userinfo: SubscriptionUserinfo::default(), operation: Some(operation), }, ); diff --git a/crates/honk-core/src/subscription/supervisor/startup.rs b/crates/honk-core/src/subscription/supervisor/startup.rs index 92fab81f..d2f34194 100644 --- a/crates/honk-core/src/subscription/supervisor/startup.rs +++ b/crates/honk-core/src/subscription/supervisor/startup.rs @@ -24,7 +24,13 @@ impl SupervisorState { Ok(Some(nodes)) => { honk_config::diagnostic::report_detailed_diagnostics(&diagnostics); let count = nodes.len(); - if !self.add_startup_nodes(&mut config.nodes, subscription, nodes, true) { + if !self.add_startup_nodes( + &mut config.nodes, + subscription, + nodes, + true, + SubscriptionUserinfo::default(), + ) { continue; } crate::config_diagnostics::declare_provider_diagnostics( @@ -100,9 +106,9 @@ impl SupervisorState { } = completion; let subscription = authorized.subscription; match result { - Some(Ok(nodes)) => { + Some(Ok((nodes, userinfo))) => { let count = nodes.len(); - if self.add_startup_nodes(&mut config.nodes, &subscription, nodes, false) { + if self.add_startup_nodes(&mut config.nodes, &subscription, nodes, false, userinfo) { startup_diagnostics .replace_provider(subscription.id, diagnostics); info!( @@ -159,6 +165,7 @@ impl SupervisorState { subscription: &Subscription, nodes: Vec, cached: bool, + userinfo: SubscriptionUserinfo, ) -> bool { let mut ids: HashSet<_> = current .iter() @@ -180,6 +187,7 @@ impl SupervisorState { current.extend(nodes); *load = ProviderLoad { updated_at: Some(SystemTime::now()), + userinfo, cached, error: None, rejection: None, diff --git a/crates/honk-core/src/subscription/supervisor/tests.rs b/crates/honk-core/src/subscription/supervisor/tests.rs index c490588e..779bdc86 100644 --- a/crates/honk-core/src/subscription/supervisor/tests.rs +++ b/crates/honk-core/src/subscription/supervisor/tests.rs @@ -278,6 +278,7 @@ async fn shutdown_joins_fetches_and_keeps_the_accepted_load() { .unwrap() .load = ProviderLoad { updated_at: Some(accepted_at), + userinfo: SubscriptionUserinfo::default(), cached: true, error: Some("cache_load_failed"), rejection: None, @@ -356,7 +357,7 @@ fn shutdown_joins_queued_blocking_persistence() { } FetchCompletion { authorized: fetched, - result: Some(Ok(Vec::new())), + result: Some(Ok((Vec::new(), SubscriptionUserinfo::default()))), diagnostics, } }); @@ -854,6 +855,7 @@ async fn startup_fetch_replaces_the_providers_own_nodes() { .unwrap() .load = ProviderLoad { updated_at: None, + userinfo: SubscriptionUserinfo::default(), cached: true, error: Some("publication_rejected"), rejection: Some("duplicate-node-id"), diff --git a/crates/honk-core/src/subscription/tests.rs b/crates/honk-core/src/subscription/tests.rs index fb9fdfa2..f4cf1d8d 100644 --- a/crates/honk-core/src/subscription/tests.rs +++ b/crates/honk-core/src/subscription/tests.rs @@ -18,6 +18,46 @@ fn parse_clash_subscription( parse_clash_proxies(proxies, subscription_id) } +#[test] +fn subscription_userinfo_parses_known_unsigned_fields() { + let cases = [ + ("", [None, None, None, None]), + ( + "upload=422986054; download=5198408536; total=214748364800; expire=1796712849", + [ + Some(422986054), + Some(5198408536), + Some(214748364800), + Some(1796712849), + ], + ), + ( + " upload = 0 ; download = 0 ; total = 0 ; expire = 0 ", + [Some(0), Some(0), None, None], + ), + ( + "download=12; ignored=34; upload=7", + [Some(7), Some(12), None, None], + ), + ( + "upload=-1; download=no; total=18446744073709551616; expire=1=2; broken", + [None, None, None, None], + ), + ( + "upload=18446744073709551615; total=1; expire=2", + [Some(u64::MAX), None, Some(1), Some(2)], + ), + ]; + for (header, expected) in cases { + let parsed = parse_subscription_userinfo(header); + assert_eq!( + [parsed.upload, parsed.download, parsed.total, parsed.expire], + expected, + "{header}" + ); + } +} + #[test] fn private_literal_hosts_are_recognized_by_address_not_name() { for url in [ diff --git a/doc/en/reference/api.md b/doc/en/reference/api.md index 7a380cc1..935c087c 100644 --- a/doc/en/reference/api.md +++ b/doc/en/reference/api.md @@ -289,7 +289,7 @@ For accepted `.dae` rules, including those in credential-bearing sources, `/rule ### Provider observations and refresh -Admitted anonymous loopback requests read the same provider data as bearer-authenticated requests. Provider GETs do no networking. List accepts `limit` (1–1000, default 100) and `cursor`, with eight 30-second snapshots and 4 MiB aggregate retention; a list that cannot fit returns `503 snapshot_unavailable` with `Retry-After`. An unrecognised provider cursor returns `410 snapshot_expired`; a recognised cursor sent with different filters or a different `limit` returns `400 invalid_request`. IDs join accepted `Node.provider_id`. Subscriptions return their configured names and full URLs in `url_redacted`; the field name remains for compatibility. GET and successful operation results use the same representation. Usage and expiry remain null. A configured name matching the former `provider-` label is an ordinary name, never an ID alias. Their status comes from the subscription owner: `ok` requires a successful usable publication; cached, pending, never-loaded, disabled or failed-with-retained-nodes providers are `stale`. `error` requires a real failure with no nodes. Never-loaded/disabled-without-cache rows have zero nodes and null update/error, not fabricated failures. Subscription rows also carry `download`, the route their fetches take from `download_detour`, shaped like the geodata route: `route` is `routing`, `direct` or `group`, and `group_id` is the group's `GET /groups` ID, null for other routes and for a group that no longer exists. File and inline rows report null. A failed fetch reports `last_error.code` `fetch_failed`, or `route_unavailable` when the subscription's download route has no usable node yet; see the [subscription reference](./subscription.md#fetch-persistence-and-recovery). A publication that configuration validation rejects, such as a node that duplicates a static node, reports `publication_rejected` with the diagnostic in `details.diagnostic_code` (for example `duplicate-node-id`); a failed refresh operation carries the same details. +Admitted anonymous loopback requests read the same provider data as bearer-authenticated requests. Provider GETs do no networking. List accepts `limit` (1–1000, default 100) and `cursor`, with eight 30-second snapshots and 4 MiB aggregate retention; a list that cannot fit returns `503 snapshot_unavailable` with `Retry-After`. An unrecognised provider cursor returns `410 snapshot_expired`; a recognised cursor sent with different filters or a different `limit` returns `400 invalid_request`. IDs join accepted `Node.provider_id`. Subscriptions return their configured names and full URLs in `url_redacted`; the field name remains for compatibility. GET and successful operation results use the same representation. `traffic` and `expires_at` come from the provider's `subscription-userinfo` header and are null without it. A configured name matching the former `provider-` label is an ordinary name, never an ID alias. Their status comes from the subscription owner: `ok` requires a successful usable publication; cached, pending, never-loaded, disabled or failed-with-retained-nodes providers are `stale`. `error` requires a real failure with no nodes. Never-loaded/disabled-without-cache rows have zero nodes and null update/error, not fabricated failures. Subscription rows also carry `download`, the route their fetches take from `download_detour`, shaped like the geodata route: `route` is `routing`, `direct` or `group`, and `group_id` is the group's `GET /groups` ID, null for other routes and for a group that no longer exists. File and inline rows report null. A failed fetch reports `last_error.code` `fetch_failed`, or `route_unavailable` when the subscription's download route has no usable node yet; see the [subscription reference](./subscription.md#fetch-persistence-and-recovery). A publication that configuration validation rejects, such as a node that duplicates a static node, reports `publication_rejected` with the diagnostic in `details.diagnostic_code` (for example `duplicate-node-id`); a failed refresh operation carries the same details. `POST /providers/{id}/refresh` takes an empty body and optional `Idempotency-Key`, returning a 202 operation. Success requires actual revision-authorized runtime publication, not just fetch or cache write; disconnecting HTTP does not cancel admitted work. A distinct concurrent refresh for the same provider conflicts (409), while retained same-key replay returns the original operation first. Disabled providers, or a runtime without a subscription owner (`can_refresh: false`), return `404 capability_not_supported`; stopped/capacity-limited owners return 503. The virtual `inline` provider is not refreshable or deletable; it groups static non-builtin nodes, whose `provider_id` is `inline`. Builtins retain null provider ownership. Subscription IDs remain UUIDs. diff --git a/doc/zh/reference/api.md b/doc/zh/reference/api.md index dab63a2d..2ab246da 100644 --- a/doc/zh/reference/api.md +++ b/doc/zh/reference/api.md @@ -297,7 +297,7 @@ PUT 仅在耐久写入并进入真实 reload 队列后返回 `202`;显式 POST ### Provider 观测与刷新 -获准访问的匿名 loopback 请求与 bearer 认证请求读取相同的 provider 数据。Provider GET 不联网。订阅条目连接真实 SubscriptionSupervisor 观测与已接受节点的 `subscription_id`,`Node.provider_id` 可用于关联。订阅返回配置名称,`url_redacted` 返回完整 URL;为兼容客户端保留字段名。GET 与成功操作结果使用相同表示。未观测 usage/expiry 仍为 null。与旧 `provider-` 标签相同的配置名称只是普通名称,不作为 ID 别名。从未加载、等待加载或禁用且无缓存时是 stale、零节点及 null 时间/错误;真实失败且无节点才是 error,保留旧/缓存节点时为 stale。订阅条目还带有 `download`,即由 `download_detour` 决定的拉取路由,结构与 geodata 路由相同:`route` 为 `routing`、`direct` 或 `group`,`group_id` 为该组在 `GET /groups` 中的 ID,其他路由或组已不存在时为 null。文件与 inline 条目为 null。拉取失败时 `last_error.code` 为 `fetch_failed`;订阅的下载路由尚无可用节点时为 `route_unavailable`,见[订阅参考](./subscription.md#拉取持久化与恢复)。配置校验拒绝发布时(例如节点与静态节点重复),`last_error.code` 为 `publication_rejected`,诊断代码写在 `details.diagnostic_code`(例如 `duplicate-node-id`);失败的 refresh operation 带相同的 details。列表 `limit` 默认 100、范围 1–1000,snapshot 上限 8 份/30 秒/4 MiB,放不下时返回 `503 snapshot_unavailable` 并带 `Retry-After`;游标无法识别时同样返回 `410 snapshot_expired`,带不同过滤器或 `limit` 的已识别游标返回 `400 invalid_request`。启用且有运行 supervisor 的订阅可 POST refresh;订阅已禁用或未挂接 supervisor(`can_refresh: false`)时返回 `404 capability_not_supported`;同 provider 的不同并发 refresh 为 409,保留的幂等重放先于冲突检查。刷新成功须真实 revision-fenced publication 被接受,fetch 或写缓存不等于成功,HTTP 断连不丢失结果。虚拟 inline provider 不可刷新/删除;它关联 `provider_id: inline` 的静态非 builtin 节点,builtin 归属保持 null,订阅 ID 仍为 UUID。 +获准访问的匿名 loopback 请求与 bearer 认证请求读取相同的 provider 数据。Provider GET 不联网。订阅条目连接真实 SubscriptionSupervisor 观测与已接受节点的 `subscription_id`,`Node.provider_id` 可用于关联。订阅返回配置名称,`url_redacted` 返回完整 URL;为兼容客户端保留字段名。GET 与成功操作结果使用相同表示。`traffic` 与 `expires_at` 来自 provider 的 `subscription-userinfo` 响应头,没有该响应头时为 null。与旧 `provider-` 标签相同的配置名称只是普通名称,不作为 ID 别名。从未加载、等待加载或禁用且无缓存时是 stale、零节点及 null 时间/错误;真实失败且无节点才是 error,保留旧/缓存节点时为 stale。订阅条目还带有 `download`,即由 `download_detour` 决定的拉取路由,结构与 geodata 路由相同:`route` 为 `routing`、`direct` 或 `group`,`group_id` 为该组在 `GET /groups` 中的 ID,其他路由或组已不存在时为 null。文件与 inline 条目为 null。拉取失败时 `last_error.code` 为 `fetch_failed`;订阅的下载路由尚无可用节点时为 `route_unavailable`,见[订阅参考](./subscription.md#拉取持久化与恢复)。配置校验拒绝发布时(例如节点与静态节点重复),`last_error.code` 为 `publication_rejected`,诊断代码写在 `details.diagnostic_code`(例如 `duplicate-node-id`);失败的 refresh operation 带相同的 details。列表 `limit` 默认 100、范围 1–1000,snapshot 上限 8 份/30 秒/4 MiB,放不下时返回 `503 snapshot_unavailable` 并带 `Retry-After`;游标无法识别时同样返回 `410 snapshot_expired`,带不同过滤器或 `limit` 的已识别游标返回 `400 invalid_request`。启用且有运行 supervisor 的订阅可 POST refresh;订阅已禁用或未挂接 supervisor(`can_refresh: false`)时返回 `404 capability_not_supported`;同 provider 的不同并发 refresh 为 409,保留的幂等重放先于冲突检查。刷新成功须真实 revision-fenced publication 被接受,fetch 或写缓存不等于成功,HTTP 断连不丢失结果。虚拟 inline provider 不可刷新/删除;它关联 `provider_id: inline` 的静态非 builtin 节点,builtin 归属保持 null,订阅 ID 仍为 UUID。 ### 原生日志与运行时设置