aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2019-05-08 18:23:29 +0200
committerHarald Eilertsen <haraldei@anduin.net>2019-05-08 18:30:46 +0200
commitbb7eb2da2918dcfdb9b5d672b4165449230c5532 (patch)
treedcc2de852e03796c90a01899a111dd2cd206d109 /src/lib.rs
parent5c258209dc3f0c175d6338a3c658d7a8e01aedc0 (diff)
downloadphisher-bb7eb2da2918dcfdb9b5d672b4165449230c5532.tar.gz
phisher-bb7eb2da2918dcfdb9b5d672b4165449230c5532.tar.bz2
phisher-bb7eb2da2918dcfdb9b5d672b4165449230c5532.zip
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.
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs8
1 files changed, 7 insertions, 1 deletions
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<Phish>,
}
@@ -60,6 +59,13 @@ pub fn load_phistank<R: BufRead>(input: R) -> Result<PhishTank, io::Error> {
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