diff --git a/Cargo.lock b/Cargo.lock index 17537d53b3a2727ca2a4d4fb62b59f79b5c27235..63fd8071d25002d9689a56f86f3f660c8d05b521 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1376,7 +1376,7 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "sms-gateway" -version = "0.2.0" +version = "0.3.0" dependencies = [ "actix-rt", "actix-web", diff --git a/Cargo.toml b/Cargo.toml index c7020f155bc7f4bfae9f74ae7a88f2b90e01d92a..4b3b56e58ebcdec381a62133042bf1fa083bd1fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/src/sms.rs b/src/sms.rs index 70de27765dec0c0e00a704885b15a4147752f773..b302a9be4d8c27be46c779458b4263841fcc34ff 100644 --- a/src/sms.rs +++ b/src/sms.rs @@ -93,28 +93,32 @@ impl Sms { let mut path = CONFIG.sms.paths.as_ref().unwrap().outgoing.clone(); path.push(filename); - // 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 - 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.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 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())); + } } - // Check if the number matches any of the numbers on the blacklist - let in_blacklist = CONFIG.filters.whitelist.iter() - .any(|re|{ - re.is_match(&self.number) - }); - - // If this is the case, return an Error - if in_blacklist { - warn!("Refused to send SMS to \"{}\" as it was blacklisted", self.number); - return Err(SmsError::InBlackList(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|{ + re.is_match(&self.number) + }); + + // If this is the case, return an Error + if in_blacklist { + warn!("Refused to send SMS to \"{}\" as it was blacklisted", self.number); + return Err(SmsError::InBlackList(self.number.clone())); + } }