]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
documentation, cleanups, travis fix
authorbert hubert <bert.hubert@netherlabs.nl>
Sun, 10 Dec 2017 19:24:25 +0000 (20:24 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Sun, 10 Dec 2017 19:24:25 +0000 (20:24 +0100)
docs/lua-records.rst
pdns/lua-record.cc
pdns/minicurl.cc

index 4b06652e3fe957af88dcfe8a655da44def11e5b4..6d5f23c0730c13a5719711ef84f275832a5062d9 100644 (file)
@@ -37,7 +37,7 @@ Here is a very basic example::
 
      www    IN    LUA    A    "ifportup(443, {'192.0.2.1', '192.0.2.2'})"
 
-This turns the 'www' name within a zone into a magical record that will
+This turns the 'www' name within a zone into a special record that will
 randomly return 192.0.2.1 or 192.0.2.2, as long as both of these IP
 addresses listen on port 443. 
 
@@ -199,10 +199,44 @@ Various options can be set in the ``options`` parameter:
  - ``stringmatch``: check ``url`` for this string, only declare 'up' if
    found
 
-``pickrandom({'ip1', ip2'})``
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+``pickrandom({'ip1', ip2',..})``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Returns a random IP address from the list supplied.
 
+``closest({'ip1', ip2',..})``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Returns IP address deemed closest to the ``bestwho`` IP address.
+
+``latlon()``
+~~~~~~~~~~~~
+Returns text listing fractional latitude/longitude associated with the ``bestwho`` IP address.
+
+``latlonloc()``
+~~~~~~~~~~~~~~~
+Returns text in LOC record format listing latitude/longitude associated with the ``bestwho`` IP address.
+
+``closestMagic()``
+~~~~~~~~~~~~~~~~~~
+Suitable for use as a wildcard LUA A record. Will parse the query name which should be in format::
+
+  192-0-2-1.192-0-2-2.198-51-100-1.magic.v4.powerdns.org
+
+It will then resolve to an A record with the IP address closest to ``bestwho`` from the list
+of supplied addresses.
+
+In the ``magic.v4.powerdns.org`` this looks like::
+  
+  *.magic.v4.powerdns.org    IN    LUA    A    "closestMagic()"
+
+
+In another zone, a record is then present like this::
+    
+  www-balanced.powerdns.org    IN    CNAME    192-0-2-1.192-0-2-2.198-51-100-1.magic.v4.powerdns.org
+
+This effectively opens up your server to being a 'geographical load balancer as a service'.
+
+Performs no uptime checking.  
+
 ``view({{{'netmask1', 'netmask2'}, {'content1', 'content2'}}, ...})``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Shorthand function to implement 'views' for all record types.
@@ -211,7 +245,7 @@ The input consists of a list of netmask/result pairs.
 
 An example::
 
-    view.v4.powerdns.org    IN    LUA    A ("return view({                           "
+    view.v4.powerdns.org    IN    LUA    A ("view({                                  "
                                             "{ {'192.168.0.0/16'}, {'192.168.1.54'}}," 
                                             "{ {'0.0.0.0/0'}, {'1.2.3.4'}}           "
                                             " }) " )
@@ -242,16 +276,20 @@ various ``weight`` parameters. Performs no uptime checking.
 Returns true if the ``bestwho`` IP address is determined to be from
 any of the listed AS numbers.
 
-``country('NL')`` or ``country({'NL',..})
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+``country('NL')`` or ``country({'NL',..})``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Returns true if the ``bestwho`` IP address of the client is within the
 two letter ISO country code passed, as described in :doc:`backends/geoip`.
 
-``continent('EU')`` or ``continent({'EU',..})
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+``continent('EU')`` or ``continent({'EU',..})``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Returns true if the ``bestwho`` IP address of the client is within the
 continent passed, as described in :doc:`backends/geoip`. 
 
+``netmask({'192.168.0.0/16', '10.0.0.0/8'})``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Returns true if ``bestwho`` is within any of the listed subnets.
+
 Details & Security
 ------------------
 LUA records are synthesized on query. They can also be transferred via AXFR
@@ -276,4 +314,4 @@ LUA records.
 
 Note that to protect operators, support for the LUA record must be enabled
 explicitly, either globally (``global-lua-record``) or per zone
-(``ENABLE-LUA-RECORD``=1).
+(``ENABLE-LUA-RECORD`` = 1).
index ebfee85bc582f0fc1664e36db1bf13a9a95e81ee..824b51a710174f9b52660b25c523aee3e2f90a18 100644 (file)
@@ -556,9 +556,6 @@ std::vector<shared_ptr<DNSRecordContent>> luaSynth(const std::string& code, cons
     });
   lua.executeCode("debug.sethook(report, '', 1000)");
 
-  lua.writeFunction("latlon", [&bestwho]() {
-      return getGeo(bestwho.toString(), GeoIPBackend::LatLon);
-    });
   
   typedef const boost::variant<string,vector<pair<int,string> > > combovar_t;
   lua.writeFunction("continent", [&bestwho](const combovar_t& continent) {
index 0c3ab98fb9444ebb21c882f46eb8ceabae260ed8..d25a83cabbf1a0348950dadc2d9b18262bd3d4b5 100644 (file)
@@ -50,7 +50,7 @@ void MiniCurl::setupURL(const std::string& str, const ComboAddress* rem, const C
     curl_easy_setopt(d_curl, CURLOPT_RESOLVE, hostlist);
   }
   if(src) {
-    curl_easy_setopt(d_curl, CURLOPT_INTERFACE, src->toString());
+    curl_easy_setopt(d_curl, CURLOPT_INTERFACE, src->toString().c_str());
   }
   curl_easy_setopt(d_curl, CURLOPT_FOLLOWLOCATION, true);
   /* only allow HTTP, TFTP and SFTP */