From: Pieter Lexis Date: Tue, 18 Jun 2019 15:39:48 +0000 (+0200) Subject: auth+rec secpoll: Use early return X-Git-Tag: dnsdist-1.4.0-rc1~93^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0a444ae4ac699d3604bbbe1e3dde01a0a4d89434;p=pdns auth+rec secpoll: Use early return instead of nested if's --- diff --git a/pdns/secpoll-auth.cc b/pdns/secpoll-auth.cc index 4166108e0..57b4ba61c 100644 --- a/pdns/secpoll-auth.cc +++ b/pdns/secpoll-auth.cc @@ -45,29 +45,31 @@ void doSecPoll(bool first) boost::replace_all(query, "+", "_"); boost::replace_all(query, "~", "_"); - vector ret; + int security_status = 0; + vector ret; int res=stubDoResolve(DNSName(query), QType::TXT, ret); - int security_status=0; - - if(!res && !ret.empty()) { - string content=getRR(ret.begin()->dr)->d_text; - - pair split = splitField(unquotify(content), ' '); - - security_status = std::stoi(split.first); - g_security_message = split.second; - - } - else { + if (res != 0) { // not NOERROR string pkgv(PACKAGEVERSION); - if (std::count(pkgv.begin(), pkgv.end(), '.') > 2) + if (std::count(pkgv.begin(), pkgv.end(), '.') > 2) { g_log<getZoneRepresentation(); - } + if (res != 0) { // Not NOERROR + if(g_security_status == 1) // it was ok, now it is unknown + g_security_status = 0; - if(!content.empty() && content[0]=='"' && content[content.size()-1]=='"') { - content=content.substr(1, content.length()-2); + if (std::count(pkgv.begin(), pkgv.end(), '.') > 2) { + g_log< split = splitField(content, ' '); - - g_security_status = std::stoi(split.first); - g_security_message = split.second; + g_log< split = splitField(content, ' '); + + g_security_status = std::stoi(split.first); + g_security_message = split.second; + if(g_security_status == 2) { g_log<