chiark / gitweb /
client: wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 25 Jul 2021 22:42:50 +0000 (23:42 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 25 Jul 2021 22:42:50 +0000 (23:42 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/client.rs
src/prelude.rs

index 2c5d0ce67c470e32d48528bd0b8c3c49050fca43..f01bb6fde8863eb586ef06fd2441c40a5e95f40d 100644 (file)
@@ -17,6 +17,33 @@ async fn run_client<C>(ic: InstanceConfig, hclient: Arc<hyper::Client<C>>)
 {
   debug!("{}: config: {:?}", &ic, &ic);
 
+  let mut ipif = tokio::process::Command::new("sh")
+    .args(&["-c", &ic.ipif])
+    .stdin (process::Stdio::piped())
+    .stdout(process::Stdio::piped())
+    .stderr(process::Stdio::piped())
+    .kill_on_drop(true)
+    .spawn().context("spawn ipif")?;
+  
+  let stderr = ipif.stderr.take().unwrap();
+  let ic_name = ic.to_string();
+  let _ = task::spawn(async move {
+    let mut stderr = tokio::io::BufReader::new(stderr).lines();
+    while let Some(l) = stderr.next_line().await? {
+      error!("{}: ipif stderr: {}", &ic_name, l.trim_end());
+    }
+    Ok::<_,io::Error>(())
+  });
+
+  let stream_for_tx = ipif.stdout.take().unwrap();
+  let stream_for_rx = ipif.stdin .take().unwrap();
+//  let txbuf = VecDeque::new();
+/*
+  async {
+    loop {
+      select! {
+        rx = stream_for_rx 
+  */  
   throw!(anyhow!("arrgh"));
 }
 
index 40847fa8e9d60aea74c9f5ab6c0d397f844a1126..b1d79383920bdb4e19649ccb01bbfea13f589cfb 100644 (file)
@@ -27,6 +27,7 @@ pub use itertools::{iproduct, Itertools};
 pub use lazy_regex::{regex_is_match, regex_replace_all};
 pub use log::{debug, info, error};
 pub use structopt::StructOpt;
+pub use tokio::io::AsyncBufReadExt;
 pub use tokio::task;
 pub use tokio::time::Duration;
 pub use void::{self, Void, ResultVoidExt, ResultVoidErrExt};