1
0
Fork 0
mirror of https://gitlab.com/niansa/nosni.git synced 2025-03-06 20:53:26 +01:00

Restructured Makefile

This commit is contained in:
niansa/tuxifan 2023-04-13 09:32:48 +02:00
parent 5368108949
commit 875137914a
4 changed files with 48 additions and 14 deletions

View file

@ -1,7 +1,14 @@
libnosni.so: nss.c common.c common.cpp common.h
g++ -c common.cpp -o cpp.o
gcc -g -fPIC -shared -I /usr/include/nspr/ nss.c common.c cpp.o -o libnosni.so
rm -f cpp.o
libnosni.so: nss.o common.o common_cpp.o
g++ -g -fPIC -shared -ldl -lcurl -lcurlpp *.o -o libnosni.so
nss.o: nss.c
gcc -c -fPIC -I /usr/include/nspr/ nss.c -o nss.o
common.o: common.c common.h
gcc -c -fPIC common.c -o common.o
common_cpp.o: common.cpp common.h
g++ -c -fPIC -std=c++17 common.cpp -o common_cpp.o
clean:
rm -f *.so *.o

View file

@ -1 +1,36 @@
#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
}

View file

@ -1 +1,2 @@
const char *resolve_hostname_to_str(const char *hostname);
_Bool is_domain_blocked(const char *hostname);

9
nss.c
View file

@ -3,7 +3,6 @@
#include <stdio.h>
#include <dlfcn.h>
#include <nss/ssl.h>
#include <nss/cms.h>
@ -37,11 +36,3 @@ SECStatus SSL_SetURL(PRFileDesc *fd, const char *url) {
// Report success
return SECSuccess;
}
extern char *
NSS_CMSSignerInfo_GetSignerCommonName(NSSCMSSignerInfo *sinfo) {
printf("Interrupted common signer name getter; returning debug domain.\n");
fflush(stdout);
return strdup("hello.com");
}