Put verbose byte count output behind verbose feature
This commit is contained in:
parent
da86f8da72
commit
327a23d82d
@ -23,6 +23,7 @@ include = [
|
|||||||
default = []
|
default = []
|
||||||
tls = ["openssl"]
|
tls = ["openssl"]
|
||||||
openssl_vendored = ["openssl/vendored"]
|
openssl_vendored = ["openssl/vendored"]
|
||||||
|
verbose = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
openssl = { version = "0.10.26", optional = true }
|
openssl = { version = "0.10.26", optional = true }
|
||||||
|
@ -111,14 +111,12 @@ impl<T: Write + Read + TryClone<T> + Send + 'static> TcpUdpPipe<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn send_udp(&mut self, len: usize) -> Result<()> {
|
fn send_udp(&mut self, len: usize) -> Result<()> {
|
||||||
|
#[cfg(feature = "verbose")]
|
||||||
println!("udp got len: {}", len);
|
println!("udp got len: {}", len);
|
||||||
|
|
||||||
self.buf[0] = ((len >> 8) & 0xFF) as u8;
|
self.buf[0] = ((len >> 8) & 0xFF) as u8;
|
||||||
self.buf[1] = (len & 0xFF) as u8;
|
self.buf[1] = (len & 0xFF) as u8;
|
||||||
|
|
||||||
//let test_len = ((self.buf[0] as usize) << 8) + self.buf[1] as usize;
|
|
||||||
//println!("tcp sending test_len: {}", test_len);
|
|
||||||
|
|
||||||
Ok(self.tcp_stream.write_all(&self.buf[..len + 2])?)
|
Ok(self.tcp_stream.write_all(&self.buf[..len + 2])?)
|
||||||
// todo: do this? self.tcp_stream.flush()
|
// todo: do this? self.tcp_stream.flush()
|
||||||
}
|
}
|
||||||
@ -126,8 +124,10 @@ impl<T: Write + Read + TryClone<T> + Send + 'static> TcpUdpPipe<T> {
|
|||||||
pub fn tcp_to_udp(&mut self) -> Result<usize> {
|
pub fn tcp_to_udp(&mut self) -> Result<usize> {
|
||||||
self.tcp_stream.read_exact(&mut self.buf[..2])?;
|
self.tcp_stream.read_exact(&mut self.buf[..2])?;
|
||||||
let len = ((self.buf[0] as usize) << 8) + self.buf[1] as usize;
|
let len = ((self.buf[0] as usize) << 8) + self.buf[1] as usize;
|
||||||
|
#[cfg(feature = "verbose")]
|
||||||
println!("tcp expecting len: {}", len);
|
println!("tcp expecting len: {}", len);
|
||||||
self.tcp_stream.read_exact(&mut self.buf[..len])?;
|
self.tcp_stream.read_exact(&mut self.buf[..len])?;
|
||||||
|
#[cfg(feature = "verbose")]
|
||||||
println!("tcp got len: {}", len);
|
println!("tcp got len: {}", len);
|
||||||
Ok(self.udp_socket.send(&self.buf[..len])?)
|
Ok(self.udp_socket.send(&self.buf[..len])?)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user