resgen.py python module example not working

Chris Narkiewicz hello at ezaquarii.com
Mon Dec 17 14:16:46 CET 2018


Hi,

I tried to run resgen.py python script downloaded from
https://github.com/NLnetLabs/unbound/blob/master/pythonmod/examples/resgen.py

but it doesn't run. It looks like the script is no longer
maching the swig binding:

Traceback (most recent call last):
   File "/etc/unbound/test.py", line 42, in operate
   File "/etc/unbound/test.py", line 42, in operate
     if (qstate.qinfo.qname_str.endswith(".localdomain.")): #query name 
ends with localdomain
   File "/usr/lib/python3/dist-packages/unboundmodule.py", line 129, in 
_get_qname_str
     def _get_qname_str(self): return dnameAsStr(self.qname)
     if (qstate.qinfo.qname_str.endswith(".localdomain.")): #query name 
ends with localdomain
TypeError: in method 'dnameAsStr', argument 1 of type 'char const *'
   File "/usr/lib/python3/dist-packages/unboundmodule.py", line 129, in 
_get_qname_str
     def _get_qname_str(self): return dnameAsStr(self.qname)
TypeError: in method 'dnameAsStr', argument 1 of type 'char const *'


Long story short, I'd like to perform a db lookup and if return
a custom response for selected domains to implement ad blocking
with query statictis. The pseudocode would be:

if qstate.qinfo.qname in bad_domains:
	log_bad_domain_hit_in_database()
	return 127.0.0.1
else:
	log_good_domain_hit_in_database()
	contue as usual

Can you assist me with running this example?

Best regards,
Chris


More information about the Unbound-users mailing list