From: Remi Gacogne Date: Wed, 29 Aug 2018 12:52:29 +0000 (+0200) Subject: ixfrdist: Add an option to enable record compression, off by default X-Git-Tag: dnsdist-1.3.3~122^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=971e59119ac6a32193f78296364235729f629023;p=pdns ixfrdist: Add an option to enable record compression, off by default --- diff --git a/docs/manpages/ixfrdist.yml.5.rst b/docs/manpages/ixfrdist.yml.5.rst index 349c5f8fb..4570fe7c8 100644 --- a/docs/manpages/ixfrdist.yml.5.rst +++ b/docs/manpages/ixfrdist.yml.5.rst @@ -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. diff --git a/pdns/ixfrdist.cc b/pdns/ixfrdist.cc index afe682ad1..bf8813d27 100644 --- a/pdns/ixfrdist.cc +++ b/pdns/ixfrdist.cc @@ -118,22 +118,23 @@ struct ixfrdistdomain_t { }; // This contains the configuration for each domain -map g_domainConfigs; +static map g_domainConfigs; // Map domains and their data -std::map> g_soas; -std::mutex g_soas_mutex; +static std::map> g_soas; +static std::mutex g_soas_mutex; // Condition variable for TCP handling -std::condition_variable g_tcpHandlerCV; -std::queue> g_tcpRequestFDs; -std::mutex g_tcpRequestFDsMutex; +static std::condition_variable g_tcpHandlerCV; +static std::queue> 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<& 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 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(); + } + catch (const runtime_error &e) { + g_log<(); + if (g_compress) { + g_log<