From bb7eb2da2918dcfdb9b5d672b4165449230c5532 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Wed, 8 May 2019 18:23:29 +0200 Subject: Create a unix socket server to check URLs. Set up a simple unix domain socket server to handle requests to check if URLs are phishes or not. --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 26be932..8f56601 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,7 +22,6 @@ use std::net::IpAddr; use std::result::Result; use std::str::FromStr; -#[derive(Deserialize)] pub struct PhishTank { pub phishes: Vec, } @@ -60,6 +59,13 @@ pub fn load_phistank(input: R) -> Result { Ok(PhishTank { phishes }) } + +impl PhishTank { + pub fn is_phish(&self, url: &str) -> bool { + self.phishes.iter().find(|phish| phish.url == url).is_some() + } +} + // Helper function to deserialize a number represented as a string. // // The PhishTank dataset represents numbers this way, so the default -- cgit v1.2.3