Add API handler for general node info

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
Lee Smet committed 2024-02-27 11:29:17 +01:00
1 parent d0d872324b
commit b640d95e15
1 file changed
+16
+16
View File
@@ -101,6 +101,7 @@ impl Http {
message_stack,
};
let admin_routes = Router::new()
.route("/admin", get(get_info))
.route("/admin/peers", get(get_peers))
.route("/admin/routes/selected", get(get_selected_routes))
.route("/admin/routes/fallback", get(get_fallback_routes))
@@ -398,6 +399,21 @@ async fn get_fallback_routes(State(state): State<HttpServerState>) -> Json<Vec<R
Json(routes)
}
/// General info about a node.
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Info {
/// The overlay subnet in use by the node.
pub node_subnet: String,
}
/// Get general info about the node.
async fn get_info(State(state): State<HttpServerState>) -> Json<Info> {
Json(Info {
node_subnet: state.router.lock().unwrap().node_tun_subnet().to_string(),
})
}
impl Serialize for Metric {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where