mirror of
https://github.com/aramperes/onetun.git
synced 2025-09-09 11:18:30 -04:00
Revert virtual port for server socket
This commit is contained in:
parent
488a0e0807
commit
32f189e53a
2 changed files with 12 additions and 20 deletions
|
@ -93,22 +93,15 @@ impl VirtualInterfacePoll for TcpVirtualInterface<'_> {
|
||||||
// Create virtual interface (contains smoltcp state machine)
|
// Create virtual interface (contains smoltcp state machine)
|
||||||
let mut iface = Interface::new(config, &mut device, Instant::now());
|
let mut iface = Interface::new(config, &mut device, Instant::now());
|
||||||
iface.update_ip_addrs(|ip_addrs| {
|
iface.update_ip_addrs(|ip_addrs| {
|
||||||
addresses.iter().for_each(|addr| {
|
addresses.into_iter().for_each(|addr| {
|
||||||
ip_addrs.push(*addr).unwrap();
|
ip_addrs.push(addr).unwrap();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
iface.set_any_ip(true);
|
|
||||||
|
|
||||||
// Maps virtual port to its client socket handle
|
|
||||||
let mut port_client_handle_map: HashMap<VirtualPort, SocketHandle> = HashMap::new();
|
|
||||||
|
|
||||||
// Create virtual server for each port forward
|
// Create virtual server for each port forward
|
||||||
for port_forward in self.port_forwards.iter() {
|
for port_forward in self.port_forwards.iter() {
|
||||||
let server_socket = TcpVirtualInterface::new_server_socket(*port_forward)?;
|
let server_socket = TcpVirtualInterface::new_server_socket(*port_forward)?;
|
||||||
let handle = self.sockets.add(server_socket);
|
self.sockets.add(server_socket);
|
||||||
let virtual_port =
|
|
||||||
VirtualPort::new(port_forward.destination.port(), port_forward.protocol);
|
|
||||||
port_client_handle_map.insert(virtual_port, handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The next time to poll the interface. Can be None for instant poll.
|
// The next time to poll the interface. Can be None for instant poll.
|
||||||
|
@ -117,6 +110,9 @@ impl VirtualInterfacePoll for TcpVirtualInterface<'_> {
|
||||||
// Bus endpoint to read events
|
// Bus endpoint to read events
|
||||||
let mut endpoint = self.bus.new_endpoint();
|
let mut endpoint = self.bus.new_endpoint();
|
||||||
|
|
||||||
|
// Maps virtual port to its client socket handle
|
||||||
|
let mut port_client_handle_map: HashMap<VirtualPort, SocketHandle> = HashMap::new();
|
||||||
|
|
||||||
// Data packets to send from a virtual client
|
// Data packets to send from a virtual client
|
||||||
let mut send_queue: HashMap<VirtualPort, VecDeque<Bytes>> = HashMap::new();
|
let mut send_queue: HashMap<VirtualPort, VecDeque<Bytes>> = HashMap::new();
|
||||||
|
|
||||||
|
|
|
@ -105,22 +105,15 @@ impl<'a> VirtualInterfacePoll for UdpVirtualInterface<'a> {
|
||||||
// Create virtual interface (contains smoltcp state machine)
|
// Create virtual interface (contains smoltcp state machine)
|
||||||
let mut iface = Interface::new(config, &mut device, Instant::now());
|
let mut iface = Interface::new(config, &mut device, Instant::now());
|
||||||
iface.update_ip_addrs(|ip_addrs| {
|
iface.update_ip_addrs(|ip_addrs| {
|
||||||
addresses.iter().for_each(|addr| {
|
addresses.into_iter().for_each(|addr| {
|
||||||
ip_addrs.push(*addr).unwrap();
|
ip_addrs.push(addr).unwrap();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
iface.set_any_ip(true);
|
|
||||||
|
|
||||||
// Maps virtual port to its client socket handle
|
|
||||||
let mut port_client_handle_map: HashMap<VirtualPort, SocketHandle> = HashMap::new();
|
|
||||||
|
|
||||||
// Create virtual server for each port forward
|
// Create virtual server for each port forward
|
||||||
for port_forward in self.port_forwards.iter() {
|
for port_forward in self.port_forwards.iter() {
|
||||||
let server_socket = UdpVirtualInterface::new_server_socket(*port_forward)?;
|
let server_socket = UdpVirtualInterface::new_server_socket(*port_forward)?;
|
||||||
let handle = self.sockets.add(server_socket);
|
self.sockets.add(server_socket);
|
||||||
let virtual_port =
|
|
||||||
VirtualPort::new(port_forward.destination.port(), port_forward.protocol);
|
|
||||||
port_client_handle_map.insert(virtual_port, handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The next time to poll the interface. Can be None for instant poll.
|
// The next time to poll the interface. Can be None for instant poll.
|
||||||
|
@ -129,6 +122,9 @@ impl<'a> VirtualInterfacePoll for UdpVirtualInterface<'a> {
|
||||||
// Bus endpoint to read events
|
// Bus endpoint to read events
|
||||||
let mut endpoint = self.bus.new_endpoint();
|
let mut endpoint = self.bus.new_endpoint();
|
||||||
|
|
||||||
|
// Maps virtual port to its client socket handle
|
||||||
|
let mut port_client_handle_map: HashMap<VirtualPort, SocketHandle> = HashMap::new();
|
||||||
|
|
||||||
// Data packets to send from a virtual client
|
// Data packets to send from a virtual client
|
||||||
let mut send_queue: HashMap<VirtualPort, VecDeque<(PortForwardConfig, Bytes)>> =
|
let mut send_queue: HashMap<VirtualPort, VecDeque<(PortForwardConfig, Bytes)>> =
|
||||||
HashMap::new();
|
HashMap::new();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue