mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-04-23 07:19:08 +00:00
minor changes
This commit is contained in:
parent
641363e0bc
commit
df7ecfd6a9
1 changed files with 13 additions and 5 deletions
|
@ -496,6 +496,10 @@ impl<'a> TunToProxy<'a> {
|
||||||
let server_addr = manager.get_server_addr();
|
let server_addr = manager.get_server_addr();
|
||||||
let state = self.create_new_tcp_connection_state(server_addr, origin_dst, tcp_proxy_handler, false)?;
|
let state = self.create_new_tcp_connection_state(server_addr, origin_dst, tcp_proxy_handler, false)?;
|
||||||
self.connection_map.insert(info.clone(), state);
|
self.connection_map.insert(info.clone(), state);
|
||||||
|
|
||||||
|
self.expect_smoltcp_send()?;
|
||||||
|
self.tunsocket_read_and_forward(info)?;
|
||||||
|
self.write_to_server(info)?;
|
||||||
} else {
|
} else {
|
||||||
log::trace!("DNS over TCP subsequent packet {} ({})", info, origin_dst);
|
log::trace!("DNS over TCP subsequent packet {} ({})", info, origin_dst);
|
||||||
}
|
}
|
||||||
|
@ -506,12 +510,16 @@ impl<'a> TunToProxy<'a> {
|
||||||
buf.extend_from_slice(&len.to_be_bytes());
|
buf.extend_from_slice(&len.to_be_bytes());
|
||||||
buf.extend_from_slice(payload);
|
buf.extend_from_slice(payload);
|
||||||
|
|
||||||
// FIXME: Build an IP packet with TCP and inject it into the device.
|
let err = "udp over tcp state not find";
|
||||||
|
let state = self.connection_map.get_mut(info).ok_or(err)?;
|
||||||
|
if state.tcp_proxy_handler.connection_established() {
|
||||||
|
_ = state.mio_stream.write(&buf)?;
|
||||||
|
} else {
|
||||||
|
// FIXME: Build an IP packet with TCP and inject it into the device,
|
||||||
|
// or cache them and send them when the connection is established?
|
||||||
self.device.inject_packet(&buf);
|
self.device.inject_packet(&buf);
|
||||||
|
}
|
||||||
|
|
||||||
self.expect_smoltcp_send()?;
|
|
||||||
self.tunsocket_read_and_forward(info)?;
|
|
||||||
self.write_to_server(info)?;
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue