@@ -37,12 +37,38 @@ pub fn router() -> Router<Arc<ServerState>> {
3737#[ derive( Debug , Clone , PartialEq , Serialize , Deserialize , ToSchema ) ]
3838pub struct InfoResponse {
3939 pub node : NodeStatus ,
40+ pub api_version : String ,
41+ pub portal : PortalStatus ,
4042 pub my_addresses : Vec < String > ,
4143 pub connections : Vec < PeerConnectionInfo > ,
4244 pub services : ServicesStatus ,
4345 pub warnings : Vec < String > ,
4446}
4547
48+ #[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize , ToSchema ) ]
49+ pub struct PortalStatus {
50+ pub installed : bool ,
51+ pub version : Option < String > ,
52+ pub source : Option < String > ,
53+ }
54+
55+ impl PortalStatus {
56+ fn from_state ( state : & ServerState ) -> Self {
57+ match state. portal_runtime ( ) {
58+ Some ( runtime) => Self {
59+ installed : true ,
60+ version : runtime. version . clone ( ) ,
61+ source : Some ( runtime. source . to_string ( ) ) ,
62+ } ,
63+ None => Self {
64+ installed : false ,
65+ version : None ,
66+ source : None ,
67+ } ,
68+ }
69+ }
70+ }
71+
4672#[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize , ToSchema ) ]
4773pub struct NodeStatus {
4874 pub status : ServiceStatus ,
@@ -515,6 +541,8 @@ pub async fn get_info(State(state): State<Arc<ServerState>>) -> (StatusCode, Jso
515541 peer_id : state. get_node_id ( ) . to_string ( ) ,
516542 capabilities : NodeCapabilityKind :: from ( state. node_capabilities ( ) ) ,
517543 } ,
544+ api_version : env ! ( "CARGO_PKG_VERSION" ) . to_string ( ) ,
545+ portal : PortalStatus :: from_state ( & state) ,
518546 my_addresses,
519547 connections,
520548 services : ServicesStatus {
@@ -597,8 +625,8 @@ fn transport_addr_to_string(addr: &iroh::TransportAddr) -> String {
597625mod tests {
598626 use super :: {
599627 BlobServiceStatus , DatabaseServiceStatus , InfoResponse , InterfaceServicesStatus ,
600- InterfaceStatus , NetworkServiceStatus , NodeCapabilityKind , NodeStatus , RequestSummary ,
601- ServiceStatus , ServicesStatus , get_info,
628+ InterfaceStatus , NetworkServiceStatus , NodeCapabilityKind , NodeStatus , PortalStatus ,
629+ RequestSummary , ServiceStatus , ServicesStatus , get_info,
602630 } ;
603631 use crate :: openapi:: ApiDoc ;
604632 use crate :: server_state:: ServerState ;
@@ -662,6 +690,12 @@ mod tests {
662690 response,
663691 InfoResponse {
664692 node: expected_node,
693+ api_version: env!( "CARGO_PKG_VERSION" ) . to_string( ) ,
694+ portal: PortalStatus {
695+ installed: false ,
696+ version: None ,
697+ source: None ,
698+ } ,
665699 my_addresses: Vec :: new( ) ,
666700 connections: Vec :: new( ) ,
667701 services: ServicesStatus {
0 commit comments