diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2019-02-06 12:31:02 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2019-02-06 12:31:02 +0000 |
commit | 9c9d011eed674ddd7e4a0a148691887afb9e75cd (patch) | |
tree | cd45bceeed24e66e5b2838e8589d2c111cf691c6 /pythonmod/examples/inplace_callbacks.py | |
parent | 089d83fbd0b24f957b753d440f188ddadaabf4ff (diff) |
Notes
Diffstat (limited to 'pythonmod/examples/inplace_callbacks.py')
-rw-r--r-- | pythonmod/examples/inplace_callbacks.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pythonmod/examples/inplace_callbacks.py b/pythonmod/examples/inplace_callbacks.py index e47fc8292be2..776add8c29ad 100644 --- a/pythonmod/examples/inplace_callbacks.py +++ b/pythonmod/examples/inplace_callbacks.py @@ -247,6 +247,25 @@ def inplace_servfail_callback(qinfo, qstate, rep, rcode, edns, opt_list_out, return True +def inplace_query_callback(qinfo, flags, qstate, addr, zone, region, **kwargs): + """ + Function that will be registered as an inplace callback function. + It will be called before sending a query to a backend server. + + :param qinfo: query_info struct; + :param flags: flags of the query; + :param qstate: module qstate. opt_lists are available here; + :param addr: struct sockaddr_storage. Address of the backend server; + :param zone: zone name in binary; + :param region: region to allocate temporary data. Needs to be used when we + want to append a new option to opt_lists. + :param **kwargs: Dictionary that may contain parameters added in a future + release. + """ + log_info("python: outgoing query to {}@{}".format(addr.addr, addr.port)) + return True + + def init_standard(id, env): """ New version of the init function. @@ -281,6 +300,11 @@ def init_standard(id, env): if not register_inplace_cb_reply_servfail(inplace_servfail_callback, env, id): return False + # Register the inplace_query_callback function as an inplace callback + # before sending a query to a backend server. + if not register_inplace_cb_query(inplace_query_callback, env, id): + return False + return True |