chiark / gitweb /
server: wip, identify cliient
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 8 Aug 2021 16:59:31 +0000 (17:59 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 8 Aug 2021 16:59:31 +0000 (17:59 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/server.rs

index 9bba6dd8420376bb0cf1ee3d515bbd62fecc9d88..cb24b2a739937ca071bcd298772e28b3a7e16732 100644 (file)
@@ -78,8 +78,15 @@ async fn handle(
       r#"first multipart component must be name="m""#
     )) }
 
-    eprintln!("boundary={:?} initial={:?} start={} comp={:?}",
-              boundary, initial, start, &comp);
+    let nl = memchr::memchr2(b'\r', b'\n', comp.payload_start)
+      .ok_or_else(|| anyhow!("no newline in first metadata line?"))?;
+
+    let client = &comp.payload_start[0..nl];
+    let client = str::from_utf8(client).context("client addr utf-8")?;
+    let client: IpAddr = client.parse().context("client address")?;
+
+    eprintln!("boundary={:?} start={} name={:?} client={}",
+              boundary, start, &comp.name, client);
 
     Ok::<_,AE>(())
   }.await {