-
-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Executing Custom Code for Domains Not Found in Any List #2092
Comments
No, arbitrary code injection is not regularly supported, you could either patch some function in the binary, or, better, modify the code yourself after each update Lines 958 to 962 in 963dec4
You could add your own code after these lines in the style of if(!blockDomain)
... What are you trying to achieve exactly? If it is something we can think of having a broad(er) application for more users, we could maybe implement this officially, taking away the need for you to manually patch on updates. P.S. My link above goes to the close-to-release Pi-hole v6.0 code. We are mostly updating outdated documentation at this point and then we'll be waiting from the team from everyone across the globe to have some time simultaneously. |
I'm trying to run custom code whenever a domain isn't found on any blocklists. To get familiar with the code, I started by adding logging to see what data I have access to and to start hooking into Pi-hole: if (!blockDomain) {
// Inline file logging
FILE *log_file = fopen("/var/log/pihole/logfile.log", "a");
if (log_file != NULL) {
fprintf(log_file, "%s\n", name);
fclose(log_file);
} else {
perror("Error opening file");
}
} For some reason, though, nothing is getting logged. Ideally, I’d like to set this up to call a function in C, Bash, or any other language, passing in the relevant data to decide on blocking. If this seems like a feature that could benefit others, I’d be happy to submit a pull request once it’s fully implemented. |
If your intention is to identify if a domain is blocked by Pi-hole, you could try to use
and check the returned JSON. If {
"results": {
"domains":{ "exact":0, "regex":0 },
"gravity":{ "allow":0, "block":0 },
"total":0
},
"parameters": { "N":20, "partial":false, "domain":"example.com", "debug":false }
} Note: |
I want it to be done as the request is being processed. So that I have full control over what's returned as a response. |
I want to run custom code when a domain query is not found on any blocklists. I believe the correct place for this is in
dnsmasq_interface.c
. I tried adding logging there but didn't get any results.Is there a recommended way to hook into Pi-hole's query handling for this purpose? Any guidance on where to implement this or how to debug would be appreciated.
The text was updated successfully, but these errors were encountered: