From 5c79174b36f7ce077b3d1b9feafe88008696fc31 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 28 Oct 2026 17:40:07 +0100 Subject: introduce relay only mode --- src/api/mod.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/api/mod.rs') diff --git a/src/api/mod.rs b/src/api/mod.rs index 45eaec4..2cb0415 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -76,6 +76,29 @@ pub(crate) fn router(state: AppState, auth_state: AuthState, debug_api: bool) -> .with_state(state) } +/// The HTTP router of a node that only relays (`--relay-only`): its figures and the log +/// filter (authenticated), and `/health`. +#[cfg_attr(not(feature = "libp2p"), allow(dead_code))] +pub(crate) fn relay_only_router( + transport: std::sync::Arc, + auth_state: AuthState, +) -> Router { + let relay = stats::RelayOnly { + transport, + started: tokio::time::Instant::now(), + }; + Router::new() + .route( + "/admin/log", + get(log::get_log_filter).put(log::put_log_filter), + ) + .route("/admin/stats", get(stats::get_relay_only_stats)) + .layer(middleware::from_fn_with_state(auth_state, basic_auth)) + .route("/health", get(health::health)) + .layer(middleware::from_fn(json_errors)) + .with_state(relay) +} + /// An error answer: `{"error": message}` with `details`' fields added (`docs/openapi.yaml`, /// `Error`). pub(crate) fn error_response( -- cgit v1.3.1