mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-06-21 00:20:53 +00:00
Merge branch 'master' into linux
This commit is contained in:
commit
7216793088
1 changed files with 4 additions and 4 deletions
|
@ -577,7 +577,7 @@ impl<'a> TunToProxy<'a> {
|
||||||
assert!(state.dns_over_tcp_expiry.is_some());
|
assert!(state.dns_over_tcp_expiry.is_some());
|
||||||
state.dns_over_tcp_expiry = Some(Self::common_udp_life_timeout());
|
state.dns_over_tcp_expiry = Some(Self::common_udp_life_timeout());
|
||||||
|
|
||||||
let vecbuf = Self::read_data_from_tcp_stream(&mut state.mio_stream, info)?;
|
let vecbuf = Self::read_data_from_tcp_stream(&mut state.mio_stream)?;
|
||||||
|
|
||||||
let data_event = IncomingDataEvent {
|
let data_event = IncomingDataEvent {
|
||||||
direction: IncomingDirection::FromServer,
|
direction: IncomingDirection::FromServer,
|
||||||
|
@ -1042,7 +1042,7 @@ impl<'a> TunToProxy<'a> {
|
||||||
let state = self.connection_map.get_mut(&conn_info).ok_or(e)?;
|
let state = self.connection_map.get_mut(&conn_info).ok_or(e)?;
|
||||||
|
|
||||||
// TODO: Move this reading process to its own function.
|
// TODO: Move this reading process to its own function.
|
||||||
let vecbuf = Self::read_data_from_tcp_stream(&mut state.mio_stream, &conn_info)?;
|
let vecbuf = Self::read_data_from_tcp_stream(&mut state.mio_stream)?;
|
||||||
|
|
||||||
let data_event = IncomingDataEvent {
|
let data_event = IncomingDataEvent {
|
||||||
direction: IncomingDirection::FromServer,
|
direction: IncomingDirection::FromServer,
|
||||||
|
@ -1108,13 +1108,13 @@ impl<'a> TunToProxy<'a> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_data_from_tcp_stream(stream: &mut TcpStream, conn_info: &ConnectionInfo) -> Result<Vec<u8>> {
|
fn read_data_from_tcp_stream(stream: &mut TcpStream) -> Result<Vec<u8>> {
|
||||||
let mut vecbuf = Vec::<u8>::new();
|
let mut vecbuf = Vec::<u8>::new();
|
||||||
loop {
|
loop {
|
||||||
let mut tmp: [u8; 4096] = [0_u8; 4096];
|
let mut tmp: [u8; 4096] = [0_u8; 4096];
|
||||||
match stream.read(&mut tmp) {
|
match stream.read(&mut tmp) {
|
||||||
Ok(0) => {
|
Ok(0) => {
|
||||||
log::info!("{} closed", conn_info);
|
// The tcp connection closed
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Ok(read_result) => {
|
Ok(read_result) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue