]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Take the DNSName docs from auth, they are more complete. 10076/head
authorOtto <otto.moerbeek@open-xchange.com>
Wed, 10 Feb 2021 13:55:54 +0000 (14:55 +0100)
committerOtto <otto.moerbeek@open-xchange.com>
Wed, 10 Feb 2021 13:55:54 +0000 (14:55 +0100)
We really should be having one source for all common Lua docs.
Fixes #9608.

pdns/recursordist/docs/lua-scripting/dnsname.rst

index 0014afe8ff8269439ef904b25d4bfc2bbcb10edd..909e5e1506d418534f58a9b236f55fdddb631e7a 100644 (file)
@@ -28,6 +28,9 @@ A small example of the functionality of a :class:`DNSName` is shown below:
     print('it is')
   end
 
+Functions and methods of a ``DNSName``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
 .. function:: newDN(name) -> DNSName
 
   Returns the :class:`DNSName` object of ``name``.
@@ -37,44 +40,71 @@ A small example of the functionality of a :class:`DNSName` is shown below:
 .. class:: DNSName
 
   A ``DNSName`` object represents a name in the DNS.
+  It is returned by several functions and has several functions to programmatically interact with it.
 
-  .. method:: DNSName:chopOff() -> bool
+  .. method:: DNSName:canonCompare(name) -> bool
 
-    Removes the left-most label and returns ``true``.
-    ``false`` is returned if no label was removed
+    Performs a comparison of DNS names in canonical order.
+    Returns true if the DNSName comes before ``name``.
+    See https://tools.ietf.org/html/rfc4034#section-6
 
-  .. method:: DNSName:countLabels() -> int
+    :param DNSName name: The name to compare to
 
-    Returns the number of DNSLabels in the name
+  .. method:: DNSName:makeRelative(name) -> DNSName
+
+    Returns a new DNSName that is relative to ``name``
 
-  .. method:: DNSName:equal(name) -> bool
+    .. code-block:: lua
 
-    Returns true when both names are equal for the DNS, i.e case insensitive.
-    
-    To compare two ``DNSName`` objects, use ``==``.
+      name = newDN("bb.a.example.com.")
+      parent = newDN("example.com.")
+      rel = name:makeRelative(parent) -- contains DNSName("bb.a.")
 
-    :param DNSName string: The name to compare against.
+    :param DNSName name: The name to compare to
 
   .. method:: DNSName:isPartOf(name) -> bool
 
     Returns true if the DNSName is part of the DNS tree of ``name``.
 
-    .. code-block:: Lua
+    :param DNSName name: The name to check against
 
-      newDN("www.powerdns.com"):isPartOf(newDN("CoM.")) -- true
+  .. method:: DNSName:toString() -> string
 
-    :param DNSName name: The name to check against
+    Returns a human-readable form of the DNSName
+
+  .. method:: DNSName:toStringNoDot() -> string
 
-  .. method:: DNSName:toString() -> str
-              DNSName:toStringNoDot() -> str
+    Returns a human-readable form of the DNSName without the trailing dot
 
-    Returns a human-readable form of the DNSName.
-    With or without trailing dot.
+  .. method:: DNSName:chopOff() -> bool
 
-  .. method:: DNSName:wirelength() -> int
+    Removes the left-most label and returns ``true``.
+    ``false`` is returned if no label was removed
+
+  .. method:: DNSName:countLabels() -> int
+
+    Returns the number of DNSLabels in the name
+
+  .. method:: DNSName:wireLength() -> int
 
     Returns the length in bytes of the DNSName as it would be on the wire.
 
+  .. method:: DNSName::getRawLabels() -> [ string ]
+
+    Returns a table that contains the raw labels of the DNSName
+
+  .. method:: DNSName::countLabels() -> int
+
+    Returns the number of labels of the DNSName
+
+  .. method:: DNSName::equal(name) -> bool
+
+    Perform a comparison of the DNSName to the given ``name``.
+    You can also compare directly two DNSName objects using
+    the ``==`` operator
+
+    :param string name: The name to compare to
+
 DNS Suffix Match Groups
 -----------------------