From: Ian Jackson Date: Sun, 8 Aug 2021 16:59:31 +0000 (+0100) Subject: server: wip, identify cliient X-Git-Tag: hippotat/1.0.0~205 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=d14529ec2800b92f90e3b0a2b2919151e4163ae3;p=hippotat.git server: wip, identify cliient Signed-off-by: Ian Jackson --- diff --git a/src/bin/server.rs b/src/bin/server.rs index 9bba6dd..cb24b2a 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -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 {