diff --git a/src/virtual_iface/tcp.rs b/src/virtual_iface/tcp.rs index c6c1b83..ff6d575 100644 --- a/src/virtual_iface/tcp.rs +++ b/src/virtual_iface/tcp.rs @@ -93,22 +93,15 @@ impl VirtualInterfacePoll for TcpVirtualInterface<'_> { // Create virtual interface (contains smoltcp state machine) let mut iface = Interface::new(config, &mut device, Instant::now()); iface.update_ip_addrs(|ip_addrs| { - addresses.iter().for_each(|addr| { - ip_addrs.push(*addr).unwrap(); + addresses.into_iter().for_each(|addr| { + 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 = HashMap::new(); // Create virtual server for each port forward for port_forward in self.port_forwards.iter() { let server_socket = TcpVirtualInterface::new_server_socket(*port_forward)?; - let handle = 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); + self.sockets.add(server_socket); } // 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 let mut endpoint = self.bus.new_endpoint(); + // Maps virtual port to its client socket handle + let mut port_client_handle_map: HashMap = HashMap::new(); + // Data packets to send from a virtual client let mut send_queue: HashMap> = HashMap::new(); diff --git a/src/virtual_iface/udp.rs b/src/virtual_iface/udp.rs index 9a584b4..6730c03 100644 --- a/src/virtual_iface/udp.rs +++ b/src/virtual_iface/udp.rs @@ -105,22 +105,15 @@ impl<'a> VirtualInterfacePoll for UdpVirtualInterface<'a> { // Create virtual interface (contains smoltcp state machine) let mut iface = Interface::new(config, &mut device, Instant::now()); iface.update_ip_addrs(|ip_addrs| { - addresses.iter().for_each(|addr| { - ip_addrs.push(*addr).unwrap(); + addresses.into_iter().for_each(|addr| { + 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 = HashMap::new(); // Create virtual server for each port forward for port_forward in self.port_forwards.iter() { let server_socket = UdpVirtualInterface::new_server_socket(*port_forward)?; - let handle = 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); + self.sockets.add(server_socket); } // 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 let mut endpoint = self.bus.new_endpoint(); + // Maps virtual port to its client socket handle + let mut port_client_handle_map: HashMap = HashMap::new(); + // Data packets to send from a virtual client let mut send_queue: HashMap> = HashMap::new();