From 88399f1adaf0fffc8a593745ff07ca55727e09e5 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 22 Aug 2021 02:03:16 +0100 Subject: [PATCH] forward Signed-off-by: Ian Jackson --- server/slocal.rs | 14 +++++++++++--- src/prelude.rs | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/server/slocal.rs b/server/slocal.rs index 893a070..eaa7ada 100644 --- a/server/slocal.rs +++ b/server/slocal.rs @@ -7,7 +7,7 @@ use super::*; #[allow(dead_code)] // xxx #[allow(unused_variables)] // xxx pub async fn run(global: Arc, - rx: mpsc::Receiver, + mut rx: mpsc::Receiver, mut ipif: Ipif) -> Result { let r = async { let mut goodness: i32 = 0; @@ -18,7 +18,15 @@ pub async fn run(global: Arc, select!{ biased; - // xxx something something rx something + data = rx.recv() => + { + let data = data.ok_or_else(|| anyhow!("rx stream end!"))?; + let mut data = &*data.data; + let mut slip_end = &[SLIP_END][..]; + let mut buf = Buf::chain(&mut data, &mut slip_end); + ipif.rx.write_all_buf(&mut buf).await + .context("write to ipif")?; + }, data = Ipif::next_frame(&mut ipif.tx) => { @@ -65,7 +73,7 @@ pub async fn run(global: Arc, } }, } - } + }, } } }.await; diff --git a/src/prelude.rs b/src/prelude.rs index 0fd6305..10b3953 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -29,7 +29,7 @@ pub use cervine::Cow as Cervine; pub use extend::ext; pub use fehler::{throw, throws}; pub use futures::{poll, future, FutureExt, StreamExt, TryStreamExt}; -pub use hyper::body::{Bytes, Buf as _}; +pub use hyper::body::{Bytes, Buf}; pub use hyper::{Method, Uri}; pub use hyper_tls::HttpsConnector; pub use ipnet::IpNet; -- 2.30.2