]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix the documentation of the `StatNode` object 12690/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 27 Mar 2023 15:17:55 +0000 (17:17 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 27 Mar 2023 15:17:55 +0000 (17:17 +0200)
pdns/dnsdist-lua-inspection.cc
pdns/dnsdistdist/docs/reference/config.rst

index 86b3e0b5918c324128aa1cd99a2ff2c818ff50d7..07dd86b68b3b3dbe48f0e557c656732930dc0ffb 100644 (file)
@@ -780,10 +780,10 @@ void setupLuaInspection(LuaContext& luaCtx)
   luaCtx.writeFunction("getRespRing", getRespRing);
 
   /* StatNode */
-  luaCtx.registerFunction<StatNode, unsigned int()>("numChildren",
-                                                   [](StatNode& sn) -> unsigned int {
-                                                     return sn.children.size();
-                                                   } );
+  luaCtx.registerFunction<unsigned int(StatNode::*)()const>("numChildren",
+                                                            [](const StatNode& sn) -> unsigned int {
+                                                              return sn.children.size();
+                                                            } );
   luaCtx.registerMember("fullname", &StatNode::fullname);
   luaCtx.registerMember("labelsCount", &StatNode::labelsCount);
   luaCtx.registerMember("servfails", &StatNode::Stat::servfails);
index d7c41e7317e6d16035d19ac082ce2a5b837e4faf..749beea2b96e0f359d8bd9902bad4bb1d340bb09 100644 (file)
@@ -1549,7 +1549,7 @@ faster than the existing rules.
     .. versionchanged:: 1.7.0
       This visitor function can now optionally return an additional string which will be set as the ``reason`` for the dynamic block.
 
-    Set a Lua visitor function that will be called for each label of every domain seen in queries and responses. The function receives a `StatNode` object representing the stats of the parent, a second one with the stats of the current label and one with the stats of the current node plus all its children.
+    Set a Lua visitor function that will be called for each label of every domain seen in queries and responses. The function receives a :class:`StatNode` object representing the stats of the parent, a :class:`StatNodeStats` one with the stats of the current label and a second :class:`StatNodeStats` with the stats of the current node plus all its children.
     Note that this function will not be called if a FFI version has been set using :meth:`DynBlockRulesGroup:setSuffixMatchRuleFFI`
     If the function returns true, the current label will be blocked according to the `seconds`, `reason`, `blockingTime` and `action` parameters. Since 1.7.0, the function can return an additional string, in addition to the boolean, which will be set as the ``reason`` for the dynamic block.
     Selected domains can be excluded from this processing using the :meth:`DynBlockRulesGroup:excludeDomains` method.
@@ -1623,15 +1623,7 @@ StatNode
 
 .. class:: StatNode
 
-  Represent metrics about a given node, for the visitor functions used with :meth:`DynBlockRulesGroup:setSuffixMatchRule` and :meth:`DynBlockRulesGroup:setSuffixMatchRuleFFI`. Note that some nodes includes the metrics for their children as well as their own.
-
-  .. attribute:: StatNode.bytes
-
-    The number of bytes for all responses returned for that node.
-
-  .. attribute:: StatNode.drops
-
-    The number of drops for that node.
+  Represent a given node, for the visitor functions used with :meth:`DynBlockRulesGroup:setSuffixMatchRule` and :meth:`DynBlockRulesGroup:setSuffixMatchRuleFFI`.
 
   .. attribute:: StatNode.fullname
 
@@ -1641,26 +1633,38 @@ StatNode
 
     The number of labels in that node, for example 3 for 'www.powerdns.com'.
 
-  .. attribute:: StatNode.noerrors
+  .. method:: StatNode:numChildren
+
+    The number of children of that node.
+
+.. class:: StatNodeStats
+
+  Represent the metrics for a given node, for the visitor functions used with :meth:`DynBlockRulesGroup:setSuffixMatchRule` and :meth:`DynBlockRulesGroup:setSuffixMatchRuleFFI`.
+
+  .. attribute:: StatNodeStats.bytes
+
+    The number of bytes for all responses returned for that node.
+
+  .. attribute:: StatNodeStats.drops
+
+    The number of drops for that node.
+
+  .. attribute:: StatNodeStats.noerrors
 
     The number of No Error answers returned for that node.
 
-  .. attribute:: StatNode.nxdomains
+  .. attribute:: StatNodeStats.nxdomains
 
     The number of NXDomain answers returned for that node.
 
-  .. attribute:: StatNode.queries
+  .. attribute:: StatNodeStats.queries
 
     The number of queries for that node.
 
-  .. attribute:: StatNode.servfails
+  .. attribute:: StatNodeStats.servfails
 
     The number of Server Failure answers returned for that node.
 
-  .. method:: StatNode:numChildren
-
-    The number of children of that node.
-
 SuffixMatchNode
 ~~~~~~~~~~~~~~~