]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
document various toStringWithPort and getPort() functions, and add them to examples 3180/head
authorbert hubert <bert.hubert@powerdns.com>
Thu, 7 Jan 2016 14:15:23 +0000 (15:15 +0100)
committerbert hubert <bert.hubert@powerdns.com>
Thu, 7 Jan 2016 14:15:23 +0000 (15:15 +0100)
docs/markdown/recursor/scripting.md
pdns/README-dnsdist.md
pdns/dnsdistconf.lua

index b1cae513d61d354c11bf06758b0736610cc2bc86..e57f1f7bc9abb0c535dc45081c93d20930feb96c 100644 (file)
@@ -65,7 +65,7 @@ find it [here](https://github.com/PowerDNS/pdns/blob/master/pdns/powerdns-exampl
 
 In the 4.x API, addresses and DNS Names are not passed as strings but as native objects. This allows for
 easy checking against netmasks and domain sets. It also means that to print such names, the `:toString` 
-method must be used.
+method must be used (or even `:toStringWithPort` for addresses).
 
 Comparing IP addresses and DNSNames is not done with '==' but with the `:equal` method. 
 
@@ -178,7 +178,7 @@ A minimal sample script:
 ```
 function nxdomain(dq)
        print("Intercepting NXDOMAIN for: ",dq.qname:toString())
-       if dq.qtype == pdns.A 
+       if dq.qtype == pdns.A
        then
                dq.rcode=0 -- make it a normal answer
                dq:addAnswer(pdns.A, "192.168.1.1")
@@ -224,6 +224,9 @@ it against a NetmaskGroup as described above.
 
 To compare the address (so not the port) of two ComboAddresses, use `:equal`. 
 
+To convert an address to human-friendly representation, use `:toString()` or `:toStringWithPort()`. To 
+get only the port number, use `:getPort()`.
+
 ### Metrics
 You can custom metrics which will be shown in the output of 'rec_control get-all' and sent to the metrics server over the Carbon protocol,
 and also appear in the JSON HTTP API. 
index 73580778253ae9c71e20367b203d6c8fa8cb7f10..ed8dd20e0905372e0178c216fb2def9469ecb102 100644 (file)
@@ -847,7 +847,9 @@ instantiate a server with additional parameters
  * Advanced functions for writing your own policies and hooks
    * ComboAddress related:
      * `newCA(address)`: return a new ComboAddress
+     * `getPort()`: return the port number
      * `tostring()`: return in human-friendly format
+     * `tostringWithPort()`: return in human-friendly format, with port number
    * DNSName related:
      * `newDNSName(name)`: make a DNSName based on this .-terminated name
      * member `isPartOf(dnsname)`: is this dnsname part of that dnsname
index bdb37edf356d1f269a7f848f690b164e4490b5dc..35aee47d6ac268642868f168cc44885fa19a56b5 100644 (file)
@@ -55,6 +55,7 @@ truncateNMG:addMask("fe80::/16")
 print(string.format("Have %d entries in truncate NMG", truncateNMG:size()))
 
 function blockFilter(remote, qname, qtype, dh)
+        print(string.format("Got query from %s, (%s) port number: %d", remote:tostring(), remote:tostringWithPort(), remote:getPort()))
         if(qtype==255 or truncateNMG:match(remote)) 
         then
 --             print("any query, tc=1")