* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include <cstdint>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
struct GeoIPDomain
{
- int id;
+ std::uint32_t id{};
DNSName domain;
int ttl{};
map<DNSName, GeoIPService> services;
return true;
}
-bool GeoIPBackend::loadDomain(const YAML::Node& domain, unsigned int id, GeoIPDomain& dom)
+bool GeoIPBackend::loadDomain(const YAML::Node& domain, std::uint32_t domainID, GeoIPDomain& dom)
{
try {
+ dom.id = domainID;
dom.domain = DNSName(domain["domain"].as<string>());
dom.ttl = domain["ttl"].as<int>();
for (auto item = recs->second.begin(); item != recs->second.end(); item++) {
auto rec = item->begin();
GeoIPDNSResourceRecord rr;
- rr.domain_id = dom.id;
+ rr.domain_id = static_cast<int>(dom.id);
rr.ttl = dom.ttl;
rr.qname = qname;
if (rec->first.IsNull()) {
// ensure we have parent in records
DNSName name = item.first;
while (name.chopOff() && name.isPartOf(dom.domain)) {
- GeoIPDNSResourceRecord rr;
if (dom.records.find(name) == dom.records.end() && (dom.services.count(name) == 0U)) { // don't ENT out a service!
+ GeoIPDNSResourceRecord resourceRecord;
vector<GeoIPDNSResourceRecord> rrs;
- rr.domain_id = dom.id;
- rr.ttl = dom.ttl;
- rr.qname = name;
- rr.qtype = QType(0); // empty non terminal
- rr.content = "";
- rr.auth = 1;
- rr.weight = 100;
- rr.has_weight = false;
- rrs.push_back(rr);
+ resourceRecord.domain_id = static_cast<int>(dom.id);
+ resourceRecord.ttl = dom.ttl;
+ resourceRecord.qname = name;
+ resourceRecord.qtype = QType(0); // empty non terminal
+ resourceRecord.content = "";
+ resourceRecord.auth = true;
+ resourceRecord.weight = 100;
+ resourceRecord.has_weight = false;
+ rrs.push_back(resourceRecord);
std::swap(dom.records[name], rrs);
}
}
DNSName name = item.first;
while (name.chopOff() && name.isPartOf(dom.domain)) {
if (dom.records.find(name) == dom.records.end()) {
- GeoIPDNSResourceRecord rr;
+ GeoIPDNSResourceRecord resourceRecord;
vector<GeoIPDNSResourceRecord> rrs;
- rr.domain_id = dom.id;
- rr.ttl = dom.ttl;
- rr.qname = name;
- rr.qtype = QType(0);
- rr.content = "";
- rr.auth = 1;
- rr.weight = 100;
- rr.has_weight = false;
- rrs.push_back(rr);
+ resourceRecord.domain_id = static_cast<int>(dom.id);
+ resourceRecord.ttl = dom.ttl;
+ resourceRecord.qname = name;
+ resourceRecord.qtype = QType(0);
+ resourceRecord.content = "";
+ resourceRecord.auth = true;
+ resourceRecord.weight = 100;
+ resourceRecord.has_weight = false;
+ rrs.push_back(resourceRecord);
std::swap(dom.records[name], rrs);
}
}
for (YAML::const_iterator _domain = config["domains"].begin(); _domain != config["domains"].end(); _domain++) {
GeoIPDomain dom;
- auto id = tmp_domains.size();
- if (loadDomain(*_domain, id, dom)) {
+ if (loadDomain(*_domain, tmp_domains.size(), dom)) {
tmp_domains.push_back(std::move(dom));
}
}
#pragma once
#include "pdns/namespaces.hh"
+#include <cstdint>
#include <vector>
#include <map>
#include <string>
bool d_dnssec{};
bool hasDNSSECkey(const DNSName& name);
bool lookup_static(const GeoIPDomain& dom, const DNSName& search, const QType& qtype, const DNSName& qdomain, const Netmask& addr, GeoIPNetmask& gl);
- bool loadDomain(const YAML::Node& domain, unsigned int /* id */, GeoIPDomain& dom);
+ bool loadDomain(const YAML::Node& domain, std::uint32_t domainID, GeoIPDomain& dom);
void loadDomainsFromDirectory(const std::string& dir, vector<GeoIPDomain>& domains);
vector<DNSResourceRecord> d_result;
vector<GeoIPInterface> d_files;