@@ -26,6 +26,7 @@ use librad::identities::SomeIdentity;
2626use librad:: paths:: Paths ;
2727use librad:: profile:: Profile ;
2828use librad:: PeerId ;
29+ use serde_json:: json;
2930use tokio:: sync:: RwLock ;
3031use warp:: hyper:: StatusCode ;
3132use warp:: reply;
@@ -295,7 +296,15 @@ pub async fn run(options: Options) -> anyhow::Result<()> {
295296 . map ( Some )
296297 . or_else ( |_| async { Ok :: < ( Option < PeerId > , ) , Infallible > ( ( None , ) ) } ) ;
297298
298- let server = warp:: filters:: any:: any ( )
299+ let _ctx = ctx. clone ( ) ;
300+ let info = warp:: path ( "info" ) . and (
301+ warp:: get ( )
302+ . map ( move || _ctx. clone ( ) )
303+ . and ( path:: end ( ) )
304+ . and_then ( info_handler) ,
305+ ) ;
306+
307+ let git = warp:: filters:: any:: any ( )
299308 . map ( move || ctx. clone ( ) )
300309 . and ( warp:: method ( ) )
301310 . and ( warp:: filters:: header:: headers_cloned ( ) )
@@ -312,7 +321,9 @@ pub async fn run(options: Options) -> anyhow::Result<()> {
312321 . and_then ( git_handler)
313322 . recover ( recover)
314323 . with ( warp:: log ( "radicle_git_server" ) ) ;
315- let server = warp:: serve ( server) ;
324+
325+ let routes = info. or ( git) ;
326+ let server = warp:: serve ( routes) ;
316327
317328 if let ( Some ( cert) , Some ( key) ) = ( options. tls_cert , options. tls_key ) {
318329 server
@@ -384,6 +395,33 @@ async fn git_handler(
384395 Ok ( Box :: new ( response) )
385396}
386397
398+ async fn info_handler ( ctx : Context ) -> Result < impl Reply , Rejection > {
399+ let git_version = Command :: new ( "git" )
400+ . arg ( "version" )
401+ . output ( )
402+ . map_err ( Error :: from) ?
403+ . stdout ;
404+
405+ let git_version = std:: str:: from_utf8 ( & git_version)
406+ . map_err ( Error :: from) ?
407+ . trim ( ) ;
408+
409+ let mut authorized_keys = ctx. load_authorized_keys ( ) . map_err ( Error :: from) ?;
410+ if authorized_keys. is_empty ( ) && ctx. allow_unauthorized_keys {
411+ authorized_keys. push ( String :: from ( "*" ) ) ;
412+ }
413+
414+ let response = json ! ( {
415+ "git" : {
416+ "version" : git_version
417+ } ,
418+ "root" : ctx. root,
419+ "authorized-keys" : authorized_keys,
420+ } ) ;
421+
422+ Ok ( warp:: reply:: json ( & response) )
423+ }
424+
387425async fn git (
388426 ctx : Context ,
389427 method : Method ,
0 commit comments