From f26748035f74333e6a7ccd2e12c490a321e84259 Mon Sep 17 00:00:00 2001 From: _ <> Date: Fri, 10 Sep 2021 12:30:12 -0500 Subject: [PATCH] the HTTP server now lists which end servers are connected --- .../src/bin/quic_demo_relay_server.rs | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/prototypes/quic_demo/src/bin/quic_demo_relay_server.rs b/prototypes/quic_demo/src/bin/quic_demo_relay_server.rs index 3c57459..72e47d5 100644 --- a/prototypes/quic_demo/src/bin/quic_demo_relay_server.rs +++ b/prototypes/quic_demo/src/bin/quic_demo_relay_server.rs @@ -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| { - - - async { - Ok::<_, String> (service_fn (move |req| { - - - handle_http (req, ()) - })) - } - }); + let make_svc = { + let relay_state = Arc::clone (&relay_state); + make_service_fn (move |_conn| { + let relay_state = Arc::clone (&relay_state); + + async move { + Ok::<_, String> (service_fn (move |req| { + let relay_state = Arc::clone (&relay_state); + + 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
, _state: ()) +async fn handle_http (req: Request , relay_state: Arc