]> granicus.if.org Git - pdns/commitdiff
amazingly, we could not *set* the local address from Lua, only add to the set of...
authorbert hubert <bert.hubert@netherlabs.nl>
Thu, 19 Nov 2015 11:05:00 +0000 (12:05 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Thu, 19 Nov 2015 11:05:00 +0000 (12:05 +0100)
pdns/README-dnsdist.md
pdns/dnsdist-lua.cc

index 01f118ba637dd5414b0e5de33a25e03db1b82e63..649885b718ab91b1590063705a9a44045eab9b72 100644 (file)
@@ -543,6 +543,9 @@ Here are all functions:
    * `addACL(netmask)`: add to the ACL set who can use this server
    * `setACL({netmask, netmask})`: replace the ACL set with these netmasks. Use `setACL({})` to reset the list, meaning no one can use us
    * `showACL()`: show our ACL set
+ * Network related:
+   * `addLocal(netmask, [false])`: add to addresses we listen on. Second optional parameter sets TCP/IP or not.
+   * `setLocal(netmask, [false])`: reset list of addresses we listen on to this address. Second optional parameter sets TCP/IP or not.
  * Blocking related:
    * `addDomainBlock(domain)`: block queries within this domain
  * Carbon/Graphite/Metronome statistics related:
index b24878384fb67b5251a735d25a50b3e24d2a1508..3a3945a6812de137effb80936b556f3b7e02eacd 100644 (file)
@@ -268,6 +268,19 @@ vector<std::function<void(void)>> setupLua(bool client, const std::string& confi
       g_ACL.modify([domain](NetmaskGroup& nmg) { nmg.addMask(domain); });
     });
 
+  g_lua.writeFunction("setLocal", [client](const std::string& addr, boost::optional<bool> doTCP) {
+      if(client)
+       return;
+      try {
+       ComboAddress loc(addr, 53);
+       g_locals.clear();
+       g_locals.push_back({loc, doTCP ? *doTCP : true}); /// only works pre-startup, so no sync necessary
+      }
+      catch(std::exception& e) {
+       g_outputBuffer="Error: "+string(e.what())+"\n";
+      }
+    });
+
   g_lua.writeFunction("addLocal", [client](const std::string& addr, boost::optional<bool> doTCP) {
       if(client)
        return;