mirror of
https://gitlab.com/niansa/nosni.git
synced 2025-03-06 20:53:26 +01:00
40 lines
877 B
C
40 lines
877 B
C
#include "common.h"
|
|
|
|
#include <stdio.h>
|
|
#include <dlfcn.h>
|
|
#include <nss/ssl.h>
|
|
|
|
|
|
|
|
SECStatus SSL_SNISocketConfigHook(PRFileDesc *fd,
|
|
SSLSNISocketConfig f,
|
|
void *arg) {
|
|
// Debug
|
|
printf("Interrupted socket config hook setter; dummy not implemented. Returning error.\n");
|
|
fflush(stdout);
|
|
|
|
// Report failure
|
|
return SECFailure;
|
|
}
|
|
|
|
SECStatus SSL_SetURL(PRFileDesc *fd, const char *url) {
|
|
// Get original function
|
|
static typeof(SSL_SetURL) *orig = NULL;
|
|
if (!orig) orig = dlsym(RTLD_NEXT, "SSL_SetURL");
|
|
|
|
// Call original function as-is if domain isn't blocked
|
|
if (!is_domain_blocked(url)) {
|
|
return orig(fd, url);
|
|
}
|
|
|
|
// Debug
|
|
printf("Interrupted URL setter for %s; setting IP address on success.\n", url);
|
|
fflush(stdout);
|
|
|
|
// Get IP addr as string
|
|
url = resolve_hostname_to_str(url);
|
|
if (!url) return SECFailure;
|
|
|
|
// Call origin function
|
|
return orig(fd, url);;
|
|
}
|