From: bert hubert Date: Wed, 28 Oct 2015 10:49:37 +0000 (+0100) Subject: move fillSOAData around so dns.cc is no longer authoritative specific and can be... X-Git-Tag: dnsdist-1.0.0-alpha1~230^2~21 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ceea1ba6a62cb4c968b92edc6adea81b0a14079a;p=pdns move fillSOAData around so dns.cc is no longer authoritative specific and can be used in recursor and sdig --- diff --git a/pdns/dns.cc b/pdns/dns.cc index bebfb8a73..46da40b1c 100644 --- a/pdns/dns.cc +++ b/pdns/dns.cc @@ -134,50 +134,6 @@ uint32_t hashQuestion(const char* packet, uint16_t len, uint32_t init) return ret; } -void fillSOAData(const string &content, SOAData &data) -{ - // content consists of fields separated by spaces: - // nameservername hostmaster serial-number [refresh [retry [expire [ minimum] ] ] ] - - // fill out data with some plausible defaults: - // 10800 3600 604800 3600 - vectorparts; - stringtok(parts,content); - int pleft=parts.size(); - - // cout<<"'"<1) - data.hostmaster=DNSName(attodot(parts[1])); // ahu@ds9a.nl -> ahu.ds9a.nl, piet.puk@ds9a.nl -> piet\.puk.ds9a.nl - - data.serial = pleft > 2 ? pdns_strtoui(parts[2].c_str(), NULL, 10) : 0; - if (data.serial == UINT_MAX && errno == ERANGE) throw PDNSException("serial number too large in '"+parts[2]+"'"); - - data.refresh = pleft > 3 ? atoi(parts[3].c_str()) - : ::arg().asNum("soa-refresh-default"); - - data.retry = pleft > 4 ? atoi(parts[4].c_str()) - : ::arg().asNum("soa-retry-default"); - - data.expire = pleft > 5 ? atoi(parts[5].c_str()) - : ::arg().asNum("soa-expire-default"); - - data.default_ttl = pleft > 6 ?atoi(parts[6].c_str()) - : ::arg().asNum("soa-minimum-ttl"); -} - -string serializeSOAData(const SOAData &d) -{ - ostringstream o; - // nameservername hostmaster serial-number [refresh [retry [expire [ minimum] ] ] ] - o<parts; + stringtok(parts,content); + int pleft=parts.size(); + + // cout<<"'"<1) + data.hostmaster=DNSName(attodot(parts[1])); // ahu@ds9a.nl -> ahu.ds9a.nl, piet.puk@ds9a.nl -> piet\.puk.ds9a.nl + + data.serial = pleft > 2 ? pdns_strtoui(parts[2].c_str(), NULL, 10) : 0; + if (data.serial == UINT_MAX && errno == ERANGE) throw PDNSException("serial number too large in '"+parts[2]+"'"); + + data.refresh = pleft > 3 ? atoi(parts[3].c_str()) + : ::arg().asNum("soa-refresh-default"); + + data.retry = pleft > 4 ? atoi(parts[4].c_str()) + : ::arg().asNum("soa-retry-default"); + + data.expire = pleft > 5 ? atoi(parts[5].c_str()) + : ::arg().asNum("soa-expire-default"); + + data.default_ttl = pleft > 6 ?atoi(parts[6].c_str()) + : ::arg().asNum("soa-minimum-ttl"); +} + +string serializeSOAData(const SOAData &d) +{ + ostringstream o; + // nameservername hostmaster serial-number [refresh [retry [expire [ minimum] ] ] ] + o<