dnsdist: Make custom LuaAction and LuaResponsAction second return value optional #6363
Conversation
* master: use mirror for dnsperf rather than crash, sheepishly report no file/linenum dnsdist: Update deprecated syntax used in dist configuration file Update secpoll build lua2 backend packages calidns: Add the --ecs parameter to add random ECS values to queries
Looks very good, just a few nits. |
pdns/dnsdist-lua.hh
Outdated
@@ -24,7 +24,7 @@ | |||
class LuaAction : public DNSAction | |||
{ | |||
public: | |||
typedef std::function<std::tuple<int, string>(DNSQuestion* dq)> func_t; | |||
typedef std::function<std::tuple<int, boost::optional<string> >(DNSQuestion* dr)> func_t; |
rgacogne
Mar 19, 2018
Member
Just a nit but dq
made more sense than dr
here :)
Just a nit but dq
made more sense than dr
here :)
|
||
These constants represent an Action that can be returned from the functions invoked by :func:`addLuaResponseAction`. | ||
|
||
* ``DNSResponseAction.Allow``: let the query pass, skipping other rules |
rgacogne
Mar 19, 2018
Member
s/query/response/
s/query/response/
|
||
* ``DNSResponseAction.Allow``: let the query pass, skipping other rules | ||
* ``DNSResponseAction.Delay``: delay the response for the specified milliseconds (UDP-only), continue to the next rule | ||
* ``DNSResponseAction.Drop``: drop the query |
rgacogne
Mar 19, 2018
Member
s/query/response/
s/query/response/
The ``function`` should return a :ref:`DNSAction`. If the Lua code fails, ServFail is returned. | ||
The ``function`` should return both a :ref:`DNSAction` and its argument `rule`. The `rule` is used as an argument | ||
of the following :ref:`DNSAction`: `DNSAction.Spoof`, `DNSAction.Pool` and `DNSAction.Delay`. As of version `1.3.0`, you can | ||
ommit the argument. For earlier releases, simply return an empty string. If the Lua code fails, ServFail is returned. |
rgacogne
Mar 19, 2018
Member
s/ommit/omit/
s/ommit/omit/
:: | ||
|
||
function luarule(dq) | ||
if(dq.qtype==35) -- NAPTR |
rgacogne
Mar 19, 2018
Member
Wouldn't dnsdist.NAPTR
work here?
Wouldn't dnsdist.NAPTR
work here?
.. function:: addLuaResponseAction(DNSrule, function [, options]) | ||
|
||
.. versionchanged:: 1.3.0 | ||
Added the optional parameter ``options``. | ||
|
||
Invoke a Lua function that accepts a :class:`DNSResponse`. | ||
This function works similar to using :func:`LuaResponseAction`. | ||
The ``function`` should return a :ref:`DNSResponseAction`. If the Lua code fails, ServFail is returned. | ||
The ``function`` should return both a :ref:`DNSResponseAction` and its argument `rule`. The `rule` is used as an argument | ||
of the `DNSResponseAction.Delay`. As of version `1.3.0`, you can ommit the argument (see :func:`addLuaAction`). For earlier |
rgacogne
Mar 19, 2018
Member
s/ommit/omit/
s/ommit/omit/
""" | ||
Advanced: Short syntax for LuaAction return values | ||
""" | ||
name = 'refused.advanced.tests.powerdns.com.' |
rgacogne
Mar 19, 2018
Member
Would you mind using a different qname than the previous test? It often makes debugging easier.
Would you mind using a different qname than the previous test? It often makes debugging easier.
LGTM! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Short description
Make custom LuaAction and LuaResponsAction second return value optional.
This allows shorter return syntax for custom lua actions :
return DNSAction.None
instead ofreturn DNSAction.None, ""
.Fix #6346
Checklist
I have: