Called shlib (wanted-check) in UrlBlockList::isUrlBlocked()

This commit is contained in:
Ivan Skytte Jørgensen
2017-08-10 14:13:23 +02:00
parent c67f73cdca
commit cd6699cc84
4 changed files with 31 additions and 2 deletions

@ -1,4 +1,5 @@
#include "UrlBlockList.h"
#include "WantedChecker.h"
#include "Log.h"
#include "Conf.h"
#include "Loop.h"
@ -189,6 +190,16 @@ bool UrlBlockList::isUrlBlocked(const Url &url) {
}
}
//now call the shlib functions for checking if the URL is wanted or not
if(!WantedChecker::check_domain(std::string(url.getHost(),url.getHostLen())).wanted) {
logTrace(g_conf.m_logTraceUrlBlockList, "Url block shlib matched (domain) url '%s'", url.getUrl());
return true;
}
if(!WantedChecker::check_url(std::string(url.getUrl(),url.getUrlLen())).wanted) {
logTrace(g_conf.m_logTraceUrlBlockList, "Url block shlib matched (full URL) url '%s'", url.getUrl());
return true;
}
return false;
}

@ -30,6 +30,8 @@ static WantedCheckApi::UrlCheckResult example_check_url(const std::string &url)
//filter out the fictitious scheme "spam://"
if(url.substr(0,7)=="spam://")
result.wanted = false;
if(url.find("evil-penguin-on-hoverboard")!=std::string::npos)
result.wanted = false;
return result;
}

@ -1,5 +1,4 @@
#include "WantedChecker.h"
#include "WantedCheckerApi.h"
#include "Log.h"
#include <dlfcn.h>
#include <errno.h>
@ -92,3 +91,13 @@ void WantedChecker::finalize() {
log(LOG_INFO,"Finalized wanted-checking");
}
WantedChecker::DomainCheckResult WantedChecker::check_domain(const std::string &domain) {
return effective_descriptor_block.check_domain_pfn(domain);
}
WantedChecker::UrlCheckResult WantedChecker::check_url(const std::string &url) {
return effective_descriptor_block.check_url_pfn(url);
}

@ -1,5 +1,6 @@
#ifndef WANTEDCHECKER_H_
#define WANTEDCHECKER_H_
#include "WantedCheckerApi.h"
namespace WantedChecker {
@ -7,6 +8,12 @@ namespace WantedChecker {
bool initialize();
void finalize();
}
typedef WantedCheckApi::DomainCheckResult DomainCheckResult;
DomainCheckResult check_domain(const std::string &domain);
typedef WantedCheckApi::UrlCheckResult UrlCheckResult;
UrlCheckResult check_url(const std::string &url);
} //namespace
#endif