class DBException : public PDNSException
{
public:
- DBException(const string &reason) : PDNSException(reason){}
+ DBException(const string &reason_) : PDNSException(reason_){}
};
/** helper function for both DNSPacket and addSOARecord() - converts a line into a struct, for easier parsing */
anything part of that domain will return 'true' in check */
struct SuffixMatchNode
{
- SuffixMatchNode(const std::string& name_="", bool endNode_=false) : name(name_), endNode(endNode_)
+ SuffixMatchNode(const std::string& name_="", bool endNode_=false) : d_name(name_), endNode(endNode_)
{}
- std::string name;
+ std::string d_name;
std::string d_human;
mutable std::set<SuffixMatchNode> children;
mutable bool endNode;
bool operator<(const SuffixMatchNode& rhs) const
{
- return strcasecmp(name.c_str(), rhs.name.c_str()) < 0;
+ return strcasecmp(d_name.c_str(), rhs.d_name.c_str()) < 0;
}
void add(const DNSName& name)
cas.insert(ComboAddress(*s));
}
else if(auto v = boost::get<vector<pair<unsigned int, string> > >(&in)) {
- for(const auto& s : *v)
- cas.insert(ComboAddress(s.second));
+ for(const auto&entry : *v)
+ cas.insert(ComboAddress(entry.second));
}
else {
cas.insert(boost::get<ComboAddress>(in));
if(auto rec = std::dynamic_pointer_cast<ARecordContent>(dr.d_content))
ret=rec->getCA(53);
- else if(auto rec = std::dynamic_pointer_cast<AAAARecordContent>(dr.d_content))
- ret=rec->getCA(53);
+ else if(auto aaaarec = std::dynamic_pointer_cast<AAAARecordContent>(dr.d_content))
+ ret=aaaarec->getCA(53);
return ret;
});
smn.add(DNSName(*s));
}
else if(auto v = boost::get<vector<pair<unsigned int, string> > >(&in)) {
- for(const auto& s : *v)
- smn.add(DNSName(s.second));
+ for(const auto& entry : *v)
+ smn.add(DNSName(entry.second));
}
else {
smn.add(boost::get<DNSName>(in));
}
else if(dq->followupFunction=="udpQueryResponse") {
dq->udpAnswer = GenUDPQueryResponse(dq->udpQueryDest, dq->udpQuery);
- auto func = d_lw->readVariable<boost::optional<luacall_t>>(dq->udpCallback).get_value_or(0);
- if(!func) {
+ auto cbFunc = d_lw->readVariable<boost::optional<luacall_t>>(dq->udpCallback).get_value_or(0);
+ if(!cbFunc) {
theL()<<Logger::Error<<"Attempted callback for Lua UDP Query/Response which could not be found"<<endl;
return false;
}
- bool res=func(dq);
+ bool result=cbFunc(dq);
if(variable) *variable |= dq->variable; // could still be set to indicate this *name* is variable
- if(!res) {
+ if(!result) {
return false;
}
goto loop;
class LWResException : public PDNSException
{
public:
- LWResException(const string &reason) : PDNSException(reason){}
+ LWResException(const string &reason_) : PDNSException(reason_){}
};
//! LWRes class
for(unsigned int n = 0; n+1 < bitmap.size();) {
unsigned int window=static_cast<unsigned char>(bitmap[n++]);
- unsigned int len=static_cast<unsigned char>(bitmap[n++]);
+ unsigned int blen=static_cast<unsigned char>(bitmap[n++]);
// end if zero padding and ensure packet length
- if(window == 0&&len == 0) break;
- if(n+len>bitmap.size())
+ if(window == 0 && blen == 0) break;
+ if(n + blen > bitmap.size())
throw MOADNSException("NSEC record with bitmap length > packet length");
- for(unsigned int k=0; k < len; k++) {
+ for(unsigned int k=0; k < blen; k++) {
uint8_t val=bitmap[n++];
- for(int bit = 0; bit < 8 ; ++bit , val>>=1)
- if(val & 1) {
+ for(int bit = 0; bit < 8 ; ++bit , val>>=1)
+ if(val & 1) {
ret->d_set.insert((7-bit) + 8*(k) + 256*window);
}
}
iov[0].iov_base=(void*)buf; iov[0].iov_len=2;
iov[1].iov_base=(void*)&*packet.begin(); iov[1].iov_len = packet.size();
- int ret=Utility::writev(dc->d_socket, iov, 2);
+ int wret=Utility::writev(dc->d_socket, iov, 2);
bool hadError=true;
- if(ret == 0)
+ if(wret == 0)
L<<Logger::Error<<"EOF writing TCP answer to "<<dc->getRemote()<<endl;
- else if(ret < 0 )
+ else if(wret < 0 )
L<<Logger::Error<<"Error writing TCP answer to "<<dc->getRemote()<<": "<< strerror(errno) <<endl;
- else if((unsigned int)ret != 2 + packet.size())
- L<<Logger::Error<<"Oops, partial answer sent to "<<dc->getRemote()<<" for "<<dc->d_mdp.d_qname<<" (size="<< (2 + packet.size()) <<", sent "<<ret<<")"<<endl;
+ else if((unsigned int)wret != 2 + packet.size())
+ L<<Logger::Error<<"Oops, partial answer sent to "<<dc->getRemote()<<" for "<<dc->d_mdp.d_qname<<" (size="<< (2 + packet.size()) <<", sent "<<wret<<")"<<endl;
else
hadError=false;
L<<Logger::Warning<<"Sending UDP reply to client "<<fromaddr.toStringWithPort()<<" failed with: "<<strerror(errno)<<endl;
if(response.length() >= sizeof(struct dnsheader)) {
- struct dnsheader dh;
- memcpy(&dh, response.c_str(), sizeof(dh));
- updateResponseStats(dh.rcode, fromaddr, response.length(), 0, 0);
+ struct dnsheader tmpdh;
+ memcpy(&tmpdh, response.c_str(), sizeof(tmpdh));
+ updateResponseStats(tmpdh.rcode, fromaddr, response.length(), 0, 0);
}
g_stats.avgLatencyUsec=(1-1.0/g_latencyStatSize)*g_stats.avgLatencyUsec + 0.0; // we assume 0 usec
return 0;
#ifdef SO_REUSEPORT
if(::arg().mustDo("reuseport")) {
- int one=1;
if(setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)) < 0)
throw PDNSException("SO_REUSEPORT: "+stringerror());
}
};
Lua.writeVariable("Policy", pmap);
- Lua.writeFunction("rpzFile", [&lci](const string& fname, const boost::optional<std::unordered_map<string,boost::variant<int, string>>>& options) {
+ Lua.writeFunction("rpzFile", [&lci](const string& filename, const boost::optional<std::unordered_map<string,boost::variant<int, string>>>& options) {
try {
boost::optional<DNSFilterEngine::Policy> defpol;
std::string polName("rpzFile");
}
}
const size_t zoneIdx = lci.dfe.size();
- theL()<<Logger::Warning<<"Loading RPZ from file '"<<fname<<"'"<<endl;
+ theL()<<Logger::Warning<<"Loading RPZ from file '"<<filename<<"'"<<endl;
lci.dfe.setPolicyName(zoneIdx, polName);
- loadRPZFromFile(fname, lci.dfe, defpol, zoneIdx);
- theL()<<Logger::Warning<<"Done loading RPZ from file '"<<fname<<"'"<<endl;
+ loadRPZFromFile(filename, lci.dfe, defpol, zoneIdx);
+ theL()<<Logger::Warning<<"Done loading RPZ from file '"<<filename<<"'"<<endl;
}
catch(std::exception& e) {
- theL()<<Logger::Error<<"Unable to load RPZ zone from '"<<fname<<"': "<<e.what()<<endl;
+ theL()<<Logger::Error<<"Unable to load RPZ zone from '"<<filename<<"': "<<e.what()<<endl;
}
});
}
else {
const auto& v =boost::get<vector<pair<int, string> > >(e.second);
- for(const auto& e : v)
- lci.sortlist.addEntry(formask, Netmask(e.second), order);
+ for(const auto& entry : v)
+ lci.sortlist.addEntry(formask, Netmask(entry.second), order);
}
++order;
}
theL()<<Logger::Error<<"Unable to load Lua script from '"+fname+"': ";
try {
std::rethrow_if_nested(e);
- } catch(const std::exception& e) {
- // e is the exception that was thrown from inside the lambda
- theL() << e.what() << std::endl;
+ } catch(const std::exception& exp) {
+ // exp is the exception that was thrown from inside the lambda
+ theL() << exp.what() << std::endl;
}
- catch(const PDNSException& e) {
- // e is the exception that was thrown from inside the lambda
- theL() << e.reason << std::endl;
+ catch(const PDNSException& exp) {
+ // exp is the exception that was thrown from inside the lambda
+ theL() << exp.reason << std::endl;
}
throw;
string removed("");
bool first(true);
- for (auto const &who : toRemove) {
- L<<Logger::Warning<<"Clearing Negative Trust Anchor for "<<who<<", requested via control channel"<<endl;
- g_luaconfs.modify([who](LuaConfigItems& lci) {
- lci.negAnchors.erase(who);
+ for (auto const &entry : toRemove) {
+ L<<Logger::Warning<<"Clearing Negative Trust Anchor for "<<entry<<", requested via control channel"<<endl;
+ g_luaconfs.modify([entry](LuaConfigItems& lci) {
+ lci.negAnchors.erase(entry);
});
- broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, who, true));
+ broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, entry, true));
if (!first) {
first = false;
removed += ",";
}
- removed += " " + who.toStringRootDot();
+ removed += " " + entry.toStringRootDot();
}
return "Removed Negative Trust Anchors for " + removed + "\n";
}
string removed("");
bool first(true);
- for (auto const &who : toRemove) {
- L<<Logger::Warning<<"Removing Trust Anchor for "<<who<<", requested via control channel"<<endl;
- g_luaconfs.modify([who](LuaConfigItems& lci) {
- lci.dsAnchors.erase(who);
+ for (auto const &entry : toRemove) {
+ L<<Logger::Warning<<"Removing Trust Anchor for "<<entry<<", requested via control channel"<<endl;
+ g_luaconfs.modify([entry](LuaConfigItems& lci) {
+ lci.dsAnchors.erase(entry);
});
- broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, who, true));
+ broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, entry, true));
if (!first) {
first = false;
removed += ",";
}
- removed += " " + who.toStringRootDot();
+ removed += " " + entry.toStringRootDot();
}
return "Removed Trust Anchor(s) for" + removed + "\n";
}
class ResolverException : public PDNSException
{
public:
- ResolverException(const string &reason) : PDNSException(reason){}
+ ResolverException(const string &reason_) : PDNSException(reason_){}
};
// make an IPv4 or IPv6 query socket
if (!crc) {
return;
}
- auto target=crc->getTarget();
+ auto crcTarget=crc->getTarget();
if(defpol) {
pol=*defpol;
}
- else if(target.isRoot()) {
+ else if(crcTarget.isRoot()) {
// cerr<<"Wants NXDOMAIN for "<<dr.d_name<<": ";
pol.d_kind = DNSFilterEngine::PolicyKind::NXDOMAIN;
- } else if(target==DNSName("*")) {
+ } else if(crcTarget==DNSName("*")) {
// cerr<<"Wants NODATA for "<<dr.d_name<<": ";
pol.d_kind = DNSFilterEngine::PolicyKind::NODATA;
}
- else if(target==drop) {
+ else if(crcTarget==drop) {
// cerr<<"Wants DROP for "<<dr.d_name<<": ";
pol.d_kind = DNSFilterEngine::PolicyKind::Drop;
}
- else if(target==truncate) {
+ else if(crcTarget==truncate) {
// cerr<<"Wants TRUNCATE for "<<dr.d_name<<": ";
pol.d_kind = DNSFilterEngine::PolicyKind::Truncate;
}
- else if(target==noaction) {
+ else if(crcTarget==noaction) {
// cerr<<"Wants NOACTION for "<<dr.d_name<<": ";
pol.d_kind = DNSFilterEngine::PolicyKind::NoAction;
}
else {
pol.d_kind = DNSFilterEngine::PolicyKind::Custom;
pol.d_custom = dr.d_content;
- // cerr<<"Wants custom "<<target<<" for "<<dr.d_name<<": ";
+ // cerr<<"Wants custom "<<crcTarget<<" for "<<dr.d_name<<": ";
}
}
else {
if(i->d_type == QType::A || i->d_type == QType::AAAA) {
if(auto rec = std::dynamic_pointer_cast<ARecordContent>(i->d_content))
ret.push_back(rec->getCA(53));
- else if(auto rec = std::dynamic_pointer_cast<AAAARecordContent>(i->d_content))
- ret.push_back(rec->getCA(53));
+ else if(auto aaaarec = std::dynamic_pointer_cast<AAAARecordContent>(i->d_content))
+ ret.push_back(aaaarec->getCA(53));
done=true;
}
}
ret.push_back(dr);
for(const auto& signature : signatures) {
- DNSRecord dr;
- dr.d_type=QType::RRSIG;
- dr.d_name=qname;
- dr.d_ttl=j->d_ttl - d_now.tv_sec;
- dr.d_content=signature;
- dr.d_place=DNSResourceRecord::ANSWER;
- dr.d_class=1;
- ret.push_back(dr);
+ DNSRecord sigdr;
+ sigdr.d_type=QType::RRSIG;
+ sigdr.d_name=qname;
+ sigdr.d_ttl=j->d_ttl - d_now.tv_sec;
+ sigdr.d_content=signature;
+ sigdr.d_place=DNSResourceRecord::ANSWER;
+ sigdr.d_class=1;
+ ret.push_back(sigdr);
}
if(!(qtype==QType(QType::CNAME))) { // perhaps they really wanted a CNAME!
document.dump(this->body);
}
-void HttpResponse::setErrorResult(const std::string& message, const int status)
+void HttpResponse::setErrorResult(const std::string& message, const int status_)
{
setBody(json11::Json::object { { "error", message } });
- this->status = status;
+ this->status = status_;
}
-void HttpResponse::setSuccessResult(const std::string& message, const int status)
+void HttpResponse::setSuccessResult(const std::string& message, const int status_)
{
setBody(json11::Json::object { { "result", message } });
- this->status = status;
+ this->status = status_;
}
static void bareHandlerWrapper(WebServer::HandlerFunction handler, YaHTTP::Request* req, YaHTTP::Response* resp)
}
Json::array items;
- for(const string& line : lines) {
- items.push_back(line);
+ for(const string& iline : lines) {
+ items.push_back(iline);
}
return items;
}