Hi,
In /usr/local/etc/unbound/unbound.conf I have added the following code:
server:
module-config: "python validator iterator"
python:
python-script: "/usr/local/etc/unbound/filter-domains.py"
and in the same folder I have create the file "filter-domains.py", which is:
def init_standard(id, env):
log_info("init_standard loaded")
return True
def init(id, cfg):
log_info("init loaded")
return True
def deinit(id):
log_info("deinit loaded")
return True
def inform_super(id, qstate, superqstate, qdata):
return True
def operate(id, event, qstate, qdata):
return True
init_standard and deinit are loaded when I restart unbound, but I get the following error when it try to load init:
(https://i.ibb.co/2tnP4qd/image.png)
I have tried to move the script in /var/unbound, I rebooted, nothing, it doesn't work.
Any help?
Hi,
/usr/local/etc/unbound/unbound.conf is the wrong file. Also I don't know if multiple Python scripts in Unbound are even supported. It all has to go through the template system and the chroot which tends to be a bit complicated to get right.
Cheers,
Franco
Hi Franco,
Thanks for answer me. I moved to the /var/unbound folder and I have included my script to be called from the dnsbl_module.py.
If I throw a random "myfunction_to_log("test")" around the dnbl_module, for example in the deinit method, my function works and the "test" is being logged but, if I do the same thing on the method "operate" then it is not being called.
How is it possible that is not being called since its the main method that handles queries and responses? I tried to play with the module-config order but still nothing.
In addition, when I restart the unbound it doesn't mention "python loaded" even if my test function works.
PS: When I reboot the system, all my configuration made in dnsbl_module.py disappears. How can I make it permanent?
please see the documentation for advanced configurations https://docs.opnsense.org/manual/unbound.html#advanced-configurations