mirror of
https://gitlab.com/niansa/nosni.git
synced 2025-03-06 20:53:26 +01:00
Restructured Makefile
This commit is contained in:
parent
5368108949
commit
875137914a
4 changed files with 48 additions and 14 deletions
15
Makefile
15
Makefile
|
@ -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
|
||||
|
|
37
common.cpp
37
common.cpp
|
@ -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
|
||||
|
||||
}
|
||||
|
|
1
common.h
1
common.h
|
@ -1 +1,2 @@
|
|||
const char *resolve_hostname_to_str(const char *hostname);
|
||||
_Bool is_domain_blocked(const char *hostname);
|
||||
|
|
9
nss.c
9
nss.c
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue