#define KEEP_DEFAULT 20
uint16_t g_keep = KEEP_DEFAULT;
+#define AXFRTIMEOUT_DEFAULT 20
+uint16_t g_axfrTimeout = AXFRTIMEOUT_DEFAULT;
+
NetmaskGroup g_acl;
void handleSignal(int signum) {
Resolver::res_t nop;
vector<DNSRecord> chunk;
records_t records;
- while(axfr.getChunk(nop, &chunk)) {
+ while(axfr.getChunk(nop, &chunk, g_axfrTimeout)) {
for(auto& dr : chunk) {
if(dr.d_type == QType::TSIG)
continue;
("server-address", po::value<string>()->default_value("127.0.0.1:5300"), "server address")
("work-dir", po::value<string>()->default_value("."), "Directory for storing AXFR and IXFR data")
("keep", po::value<uint16_t>()->default_value(KEEP_DEFAULT), "Number of old zone versions to retain")
+ ("axfr-timeout", po::value<uint16_t>()->default_value(AXFRTIMEOUT_DEFAULT), "Timeout in seconds for an AXFR to complete")
;
po::options_description alloptions;
po::options_description hidden("hidden options");
g_keep = g_vm["keep"].as<uint16_t>();
}
+ if (g_vm.count("axfr-timeout") > 0) {
+ g_axfrTimeout = g_vm["axfr-timeout"].as<uint16_t>();
+ }
+
vector<ComboAddress> listen_addresses = {ComboAddress("127.0.0.1:53")};
if (g_vm.count("listen-address") > 0) {
-int AXFRRetriever::getChunk(Resolver::res_t &res, vector<DNSRecord>* records) // Implementation is making sure RFC2845 4.4 is followed.
+int AXFRRetriever::getChunk(Resolver::res_t &res, vector<DNSRecord>* records, uint16_t timeout) // Implementation is making sure RFC2845 4.4 is followed.
{
if(d_soacount > 1)
return false;
if (d_maxReceivedBytes > 0 && (d_maxReceivedBytes - d_receivedBytes) < (size_t) len)
throw ResolverException("Reached the maximum number of received bytes during AXFR");
- timeoutReadn(len);
+ timeoutReadn(len, timeout);
d_receivedBytes += (uint16_t) len;
return true;
}
-void AXFRRetriever::timeoutReadn(uint16_t bytes)
+void AXFRRetriever::timeoutReadn(uint16_t bytes, uint16_t timeoutsec)
{
- time_t start=time(0);
+ time_t start=time(nullptr);
int n=0;
int numread;
while(n<bytes) {
- int res=waitForData(d_sock, 10-(time(0)-start));
+ int res=waitForData(d_sock, timeoutsec-(time(nullptr)-start));
if(res<0)
throw ResolverException("Reading data from remote nameserver over TCP: "+stringerror());
if(!res)
const ComboAddress* laddr = NULL,
size_t maxReceivedBytes=0);
~AXFRRetriever();
- int getChunk(Resolver::res_t &res, vector<DNSRecord>* records=0);
+ int getChunk(Resolver::res_t &res, vector<DNSRecord>* records=0, uint16_t timeout=10);
private:
void connect();
int getLength();
- void timeoutReadn(uint16_t bytes);
+ void timeoutReadn(uint16_t bytes, uint16_t timeoutsec=10);
shared_array<char> d_buf;
string d_domain;