]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
ixfrdist: Add an option to enable record compression, off by default 6895/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 29 Aug 2018 12:52:29 +0000 (14:52 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 29 Aug 2018 12:52:29 +0000 (14:52 +0200)
docs/manpages/ixfrdist.yml.5.rst
pdns/ixfrdist.cc
pdns/ixfrdist.example.yml

index 349c5f8fb5048476bbb670bdab2ee6bd8458f13a..4570fe7c82e0c155d8dda6675ce92a4b28a6cf07 100644 (file)
@@ -59,6 +59,10 @@ Options
   Increase this when the network to the authoritative servers is slow or the domains are very large and you experience timeouts.
   Defaults to 20.
 
+:compress:
+  Whether record compression should be enabled, leading to smaller answers at the cost of an increased CPU and memory usage.
+  Defaults to false.
+
 :work-dir:
   The directory where the domain data is stored.
   When not set, the current working directory is used.
index afe682ad1f79382bc08fe41f7f6e5299b915f25f..bf8813d278537150866da9d4a5629231965a2c7c 100644 (file)
@@ -118,22 +118,23 @@ struct ixfrdistdomain_t {
 };
 
 // This contains the configuration for each domain
-map<DNSName, ixfrdistdomain_t> g_domainConfigs;
+static map<DNSName, ixfrdistdomain_t> g_domainConfigs;
 
 // Map domains and their data
-std::map<DNSName, std::shared_ptr<ixfrinfo_t>> g_soas;
-std::mutex g_soas_mutex;
+static std::map<DNSName, std::shared_ptr<ixfrinfo_t>> g_soas;
+static std::mutex g_soas_mutex;
 
 // Condition variable for TCP handling
-std::condition_variable g_tcpHandlerCV;
-std::queue<pair<int, ComboAddress>> g_tcpRequestFDs;
-std::mutex g_tcpRequestFDsMutex;
+static std::condition_variable g_tcpHandlerCV;
+static std::queue<pair<int, ComboAddress>> g_tcpRequestFDs;
+static std::mutex g_tcpRequestFDsMutex;
 
 namespace po = boost::program_options;
 
-bool g_exiting = false;
+static bool g_exiting = false;
 
-NetmaskGroup g_acl;
+static NetmaskGroup g_acl;
+static bool g_compress = false;
 
 static void handleSignal(int signum) {
   g_log<<Logger::Notice<<"Got "<<strsignal(signum)<<" signal";
@@ -495,9 +496,9 @@ static bool sendPacketOverTCP(int fd, const std::vector<uint8_t>& packet)
   return true;
 }
 
-static bool addRecordToWriter(DNSPacketWriter& pw, const DNSName& zoneName, const DNSRecord& record)
+static bool addRecordToWriter(DNSPacketWriter& pw, const DNSName& zoneName, const DNSRecord& record, bool compress)
 {
-  pw.startRecord(record.d_name + zoneName, record.d_type, record.d_ttl);
+  pw.startRecord(record.d_name + zoneName, record.d_type, record.d_ttl, QClass::IN, DNSResourceRecord::ANSWER, compress);
   record.d_content->toPacket(pw);
   if (pw.size() > 65535) {
     pw.rollback();
@@ -524,7 +525,7 @@ template <typename T> static bool sendRecordsOverTCP(int fd, const MOADNSParser&
         continue;
       }
 
-      if (addRecordToWriter(pw, mdp.d_qname, *it)) {
+      if (addRecordToWriter(pw, mdp.d_qname, *it, g_compress)) {
         recordsAdded = true;
         it++;
       }
@@ -1000,6 +1001,19 @@ static bool parseAndCheckConfig(const string& configpath, YAML::Node& config) {
     retval = false;
   }
 
+  if (config["compress"]) {
+    try {
+      config["compress"].as<bool>();
+    }
+    catch (const runtime_error &e) {
+      g_log<<Logger::Error<<"Unable to read 'compress' value: "<<e.what()<<endl;
+      retval = false;
+    }
+  }
+  else {
+    config["compress"] = false;
+  }
+
   return retval;
 }
 
@@ -1075,6 +1089,13 @@ int main(int argc, char** argv) {
   }
   g_log<<Logger::Notice<<"ACL set to "<<g_acl.toString()<<"."<<endl;
 
+  if (config["compress"]) {
+    g_compress = config["compress"].as<bool>();
+    if (g_compress) {
+      g_log<<Logger::Notice<<"Record compression is enabled."<<endl;
+    }
+  }
+
   FDMultiplexer* fdm = FDMultiplexer::getMultiplexerSilent();
   if (fdm == nullptr) {
     g_log<<Logger::Error<<"Could not enable a multiplexer for the listen sockets!"<<endl;
index 6d991c6ed085fa0e578502f6b62d6737ec854029..4a2b8c1833e23f3cf735cd8c19afe06cd3ce32c4 100644 (file)
@@ -35,6 +35,11 @@ acl:
 #
 axfr-timeout: 20
 
+# Whether record compression should be enabled, leading to smaller answers
+# at the cost of an increased CPU and memory usage. Defaults to false.
+#
+compress: false
+
 # Amount of older copies/IXFR diffs to keep for every domain. This is set to
 # 20 by default or when unset.
 #