1
0
Fork 0
mirror of https://gitlab.com/niansa/nosni.git synced 2025-03-06 20:53:26 +01:00
nosni/common.cpp
2023-04-13 09:32:48 +02:00

36 lines
700 B
C++

#include <string>
#include <string_view>
#include <unordered_map>
#include <optional>
#include <curlpp/cURLpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>
static
std::unordered_map<std::string, bool> cache;
static
std::optional<bool> cached_is_domain_blocked(const char *hostname) {
auto fres = cache.find(hostname);
if (fres != cache.end()) {
return fres->second;
}
return {};
}
extern "C"
bool is_domain_blocked(const char *hostname) {
// Check cache first
{
auto fres = cached_is_domain_blocked(hostname);
if (fres.has_value()) {
return fres.value();
}
}
// Use curlpp to check for HTTP != 200
}