summaryrefslogtreecommitdiffstats
path: root/tests/fakes/fake_input.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fakes/fake_input.rs')
-rw-r--r--tests/fakes/fake_input.rs33
1 files changed, 10 insertions, 23 deletions
diff --git a/tests/fakes/fake_input.rs b/tests/fakes/fake_input.rs
index 02df931..9ab1624 100644
--- a/tests/fakes/fake_input.rs
+++ b/tests/fakes/fake_input.rs
@@ -2,8 +2,7 @@ use ::ipnetwork::IpNetwork;
use ::pnet::datalink::DataLinkReceiver;
use ::pnet::datalink::NetworkInterface;
use ::std::collections::HashMap;
-use ::std::net::IpAddr;
-use ::std::net::{Ipv4Addr, SocketAddr};
+use ::std::net::{IpAddr, Ipv4Addr, SocketAddr};
use ::std::{thread, time};
use ::termion::event::Event;
@@ -83,27 +82,6 @@ impl DataLinkReceiver for NetworkFrames {
}
}
-// fn create_fake_socket(
-// associated_pids: Vec<u32>,
-// local_ip: IpAddr,
-// remote_ip: IpAddr,
-// local_port: u16,
-// remote_port: u16,
-// ) -> SocketInfo {
-// let protocol_socket_info = TcpSocketInfo {
-// local_addr: local_ip,
-// remote_addr: remote_ip,
-// local_port: local_port,
-// remote_port: remote_port,
-// state: TcpState::Listen,
-// };
-// SocketInfo {
-// protocol_socket_info: ProtocolSocketInfo::Tcp(protocol_socket_info),
-// associated_pids: associated_pids,
-// inode: 2,
-// }
-// }
-
pub fn get_open_sockets() -> HashMap<Connection, String> {
let mut open_sockets = HashMap::new();
open_sockets.insert(
@@ -164,3 +142,12 @@ pub fn get_interface() -> NetworkInterface {
};
interface
}
+
+pub fn create_fake_lookup_addr(ips_to_hosts: HashMap<IpAddr, String>) -> Box<Fn(&IpAddr) -> Option<String> + Send + Sync + 'static> {
+ Box::new(move |ip| {
+ match ips_to_hosts.get(ip) {
+ Some(host) => Some(host.clone()),
+ None => None
+ }
+ })
+}