#[throws(AE)]
fn submit_request<'r, 'c:'r, C:HCC>(
c: &'c ClientContext<C>,
+ req_num: &mut ReqNum,
reqs: &mut Vec<OutstandingRequest<'r>>,
upbound: FramesData,
) {
write!(token, " ").unwrap();
base64::encode_config_buf(&hmac, BASE64_CONFIG, &mut token);
+ let req_num = { *req_num += 1; *req_num };
+
let prefix1 = format!(into_crlfs!(
r#"--b
Content-Type: text/plain; charset="utf-8"
as_ref,
).map(|b| b.len()).sum();
+ trace!("{} #{}: frames={} bytes={}",
+ &c.ic, req_num, upbound.len(), body_len);
+
let body = hyper::body::Body::wrap_stream(
futures::stream::iter(
content!(
Ok::<_,AE>(resp)
}).await? }.await;
- let r = c.reporter.lock().report(r);
+ let r = c.reporter.lock().report(req_num, r);
if r.is_none() {
tokio::time::sleep(c.ic.http_retry).await;
Ok::<_,io::Error>(())
});
+ let mut req_num: ReqNum = 0;
+
let tx_stream = ipif.stdout.take().unwrap();
let rx_stream = ipif.stdin .take().unwrap();
Ok(())
}, |e| match e {
PE::Empty => { },
- e@ PE::Src(_) => debug!("{}: tx: discarding: {}", &ic, e),
- e => error!("{}: tx: discarding: {}", &ic, e),
+ e@ PE::Src(_) => debug!("{}: tx discarding: {}", &ic, e),
+ e => error!("{}: tx discarding: {}", &ic, e),
});
},
// xxx backpressure, if too much in rx_queue
=>
{
- submit_request(&c, &mut reqs, mem::take(&mut upbound).into())?;
+ submit_request(&c, &mut req_num, &mut reqs,
+ mem::take(&mut upbound).into())?;
},
(got, goti, _) = async { future::select_all(&mut reqs).await },
let addr = ip_packet_addr::<true>(header)?;
if addr != ic.link.client.0 { throw!(PE::Dst(addr)) }
Ok(())
- }, |e| error!("{}: rx: discarding: {}", &ic, e));
+ }, |e| error!("{} #{}: rx discarding: {}", &ic, req_num, e));
dbg!(&rx_queue.len());
rx_queue = default(); // xxx
pub use ipnet::IpNet;
pub use itertools::{iproduct, Itertools};
pub use lazy_regex::{regex_is_match, regex_replace_all};
-pub use log::{debug, info, error};
+pub use log::{trace, debug, info, warn, error};
pub use structopt::StructOpt;
pub use thiserror::Error;
pub use tokio::io::AsyncBufReadExt;
pub use crate::types::*;
pub use crate::slip::*;
+pub type ReqNum = u64;
+
pub use anyhow::Error as AE;
pub use ErrorKind as EK;
pub use PacketError as PE;
pub const SLIP_ESC: u8 = 0o333; // db
pub const SLIP_ESC_END: u8 = 0o334; // dc
pub const SLIP_ESC_ESC: u8 = 0o335; // dd
-pub const SLIP_MIME_ESC: u8 = b'-';
+pub const SLIP_MIME_ESC: u8 = b'-'; // 2d
pub use base64::STANDARD as BASE64_CONFIG;
ic
} }
- pub fn report<T>(&mut self, r: Result<T,AE>) -> Option<T> {
+ pub fn report<T>(&mut self, req_num: ReqNum, r: Result<T,AE>) -> Option<T> {
match r {
Ok(t) => {
// xxx something something success
},
Err(e) => {
// xxx something something error
- error!("ERROR {} {:?}", self.ic, e);
+ warn!("{} #{}: {:?}", self.ic, req_num, e);
None
},
}