update
Some checks failed
ci/woodpecker/push/build Pipeline failed

This commit is contained in:
JMARyA 2025-01-02 19:00:47 +01:00
parent 0f6e5f5b10
commit 8df8edeeca
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
15 changed files with 591 additions and 124 deletions

View file

@ -1,17 +1,17 @@
use crate::conf::get_config;
/// Checks if a domain is present in the blacklist of unwanted domains.
///
/// This function checks the `$BLACKLIST_DOMAINS` environment variable for a comma-separated list of regular expressions to match against.
/// If a match is found, it immediately returns `true`. Otherwise, it returns `false`.
pub fn check_blacklist(domain: &str) -> bool {
let blacklist_raw = std::env::var("BLACKLIST_DOMAINS").unwrap_or_default();
let conf = get_config();
let conf = conf.websites.as_ref();
if blacklist_raw.is_empty() {
return false;
}
let blacklisted_domains = conf
.map(|x| x.BLACKLIST_DOMAINS.as_ref())
.unwrap_or_default();
let blacklist: Vec<&str> = blacklist_raw.split(',').collect();
for domain_regex in blacklist {
for domain_regex in blacklisted_domains.unwrap_or(&Vec::new()) {
let rgx = regex::Regex::new(domain_regex).unwrap();
if rgx.is_match(domain) {
return true;