the HTTP server now lists which end servers are connected
parent
5ffdb5800d
commit
f26748035f
|
@ -31,20 +31,22 @@ async fn main () -> anyhow::Result <()> {
|
|||
println! ("Base64 cert: {}", base64::encode (&server_cert));
|
||||
tokio::fs::write ("quic_server.crt", &server_cert).await?;
|
||||
|
||||
let relay_state = RelayState::default ();
|
||||
let relay_state = Arc::new (relay_state);
|
||||
let relay_state = Arc::new (RelayState::default ());
|
||||
|
||||
let make_svc = make_service_fn (|_conn| {
|
||||
let make_svc = {
|
||||
let relay_state = Arc::clone (&relay_state);
|
||||
make_service_fn (move |_conn| {
|
||||
let relay_state = Arc::clone (&relay_state);
|
||||
|
||||
|
||||
async {
|
||||
async move {
|
||||
Ok::<_, String> (service_fn (move |req| {
|
||||
let relay_state = Arc::clone (&relay_state);
|
||||
|
||||
|
||||
handle_http (req, ())
|
||||
handle_http (req, relay_state)
|
||||
}))
|
||||
}
|
||||
});
|
||||
})
|
||||
};
|
||||
|
||||
let http_addr = SocketAddr::from (([0, 0, 0, 0], 4004));
|
||||
|
||||
|
@ -75,13 +77,20 @@ async fn main () -> anyhow::Result <()> {
|
|||
Ok (())
|
||||
}
|
||||
|
||||
async fn handle_http (req: Request <Body>, _state: ())
|
||||
async fn handle_http (req: Request <Body>, relay_state: Arc <RelayState>)
|
||||
-> anyhow::Result <Response <Body>>
|
||||
{
|
||||
let debug_string;
|
||||
{
|
||||
let p4_server_proxies = relay_state.p4_server_proxies.lock ().await;
|
||||
|
||||
debug_string = format! ("{:#?}\n", p4_server_proxies.keys ().collect::<Vec<_>> ());
|
||||
}
|
||||
|
||||
let resp = Response::builder ()
|
||||
.status (StatusCode::OK)
|
||||
.header ("content-type", "text/plain")
|
||||
.body (Body::from ("pong\n"))?;
|
||||
.body (Body::from (debug_string))?;
|
||||
|
||||
Ok (resp)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue