Skip to content
Snippets Groups Projects
Commit 923b576d authored by David Huss's avatar David Huss :speech_balloon:
Browse files

Check if white/blacklist is empty

parent 415ddbd4
No related branches found
No related tags found
No related merge requests found
......@@ -1376,7 +1376,7 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]]
name = "sms-gateway"
version = "0.2.0"
version = "0.3.0"
dependencies = [
"actix-rt",
"actix-web",
......
......@@ -2,7 +2,7 @@
name = "sms-gateway"
description = "A http frontend for SMS Server Tools 3"
authors = ["David Huss <david.huss@hfbk-hamburg.de>"]
version = "0.2.0"
version = "0.3.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
......
......@@ -93,18 +93,21 @@ impl Sms {
let mut path = CONFIG.sms.paths.as_ref().unwrap().outgoing.clone();
path.push(filename);
if CONFIG.filters.whitelist.len() > 0 {
// Check if the number matches any of the numbers in the whitelist
let in_whitelist = CONFIG.filters.whitelist.iter()
.any(|re|{
re.is_match(&self.number)
});
// Return an Error if not
// Return an Error if not on the whitelist
if !in_whitelist {
warn!("Refused to send SMS to \"{}\" as it was not on the whitelist", self.number);
return Err(SmsError::NotInWhiteList(self.number.clone()));
}
}
if CONFIG.filters.blacklist.len() > 0 {
// Check if the number matches any of the numbers on the blacklist
let in_blacklist = CONFIG.filters.whitelist.iter()
.any(|re|{
......@@ -116,6 +119,7 @@ impl Sms {
warn!("Refused to send SMS to \"{}\" as it was blacklisted", self.number);
return Err(SmsError::InBlackList(self.number.clone()));
}
}
// Create an file handle for the outgoing SMS, return an Error if this fails
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment