Skip to content

Commit

Permalink
dnsdist: Fix clang-tidy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rgacogne committed Dec 5, 2023
1 parent eeaf281 commit 88f5117
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions pdns/dnsdist-lua-actions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2497,11 +2497,11 @@ void setupLuaActions(LuaContext& luaCtx)

luaCtx.writeFunction("SpoofRawAction", [](LuaTypeOrArrayOf<std::string> inp, boost::optional<responseParams_t> vars) {
vector<string> raws;
if (auto str = boost::get<std::string>(&inp)) {
if (const auto* str = boost::get<std::string>(&inp)) {
raws.push_back(*str);
} else {
const auto& vect = boost::get<LuaArray<std::string>>(inp);
for(const auto& raw: vect) {
for (const auto& raw: vect) {
raws.push_back(raw.second);
}
}
Expand Down
10 changes: 5 additions & 5 deletions pdns/dnsdist-lua-bindings-dnsquestion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx)
return true;
});

luaCtx.registerFunction<void(DNSQuestion::*)(const boost::variant<LuaArray<ComboAddress>, LuaArray<std::string>>&, boost::optional<uint16_t>)>("spoof", [](DNSQuestion& dq, const boost::variant<LuaArray<ComboAddress>, LuaArray<std::string>>& response, boost::optional<uint16_t> typeForAny) {
luaCtx.registerFunction<void(DNSQuestion::*)(const boost::variant<LuaArray<ComboAddress>, LuaArray<std::string>>&, boost::optional<uint16_t>)>("spoof", [](DNSQuestion& dnsQuestion, const boost::variant<LuaArray<ComboAddress>, LuaArray<std::string>>& response, boost::optional<uint16_t> typeForAny) {
if (response.type() == typeid(LuaArray<ComboAddress>)) {
std::vector<ComboAddress> data;
auto responses = boost::get<LuaArray<ComboAddress>>(response);
Expand All @@ -236,8 +236,8 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx)
data.push_back(resp.second);
}
std::string result;
SpoofAction sa(data);
sa(&dq, &result);
SpoofAction tempSpoofAction(data);
tempSpoofAction(&dnsQuestion, &result);
return;
}
if (response.type() == typeid(LuaArray<std::string>)) {
Expand All @@ -248,8 +248,8 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx)
data.push_back(resp.second);
}
std::string result;
SpoofAction sa(data, typeForAny ? *typeForAny : std::optional<uint16_t>());
sa(&dq, &result);
SpoofAction tempSpoofAction(data, typeForAny ? *typeForAny : std::optional<uint16_t>());
tempSpoofAction(&dnsQuestion, &result);
return;
}
});
Expand Down
20 changes: 10 additions & 10 deletions pdns/dnsdist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -863,8 +863,8 @@ static void spoofResponseFromString(DNSQuestion& dq, const string& spoofContent,
if (raw) {
std::vector<std::string> raws;
stringtok(raws, spoofContent, ",");
SpoofAction sa(raws, std::nullopt);
sa(&dq, &result);
SpoofAction tempSpoofAction(raws, std::nullopt);
tempSpoofAction(&dq, &result);
}
else {
std::vector<std::string> addrs;
Expand All @@ -873,13 +873,13 @@ static void spoofResponseFromString(DNSQuestion& dq, const string& spoofContent,
if (addrs.size() == 1) {
try {
ComboAddress spoofAddr(spoofContent);
SpoofAction sa({spoofAddr});
sa(&dq, &result);
SpoofAction tempSpoofAction({spoofAddr});
tempSpoofAction(&dq, &result);
}
catch(const PDNSException &e) {
DNSName cname(spoofContent);
SpoofAction sa(cname); // CNAME then
sa(&dq, &result);
SpoofAction tempSpoofAction(cname); // CNAME then
tempSpoofAction(&dq, &result);
}
} else {
std::vector<ComboAddress> cas;
Expand All @@ -890,8 +890,8 @@ static void spoofResponseFromString(DNSQuestion& dq, const string& spoofContent,
catch (...) {
}
}
SpoofAction sa(cas);
sa(&dq, &result);
SpoofAction tempSpoofAction(cas);
tempSpoofAction(&dq, &result);
}
}
}
Expand All @@ -900,8 +900,8 @@ static void spoofPacketFromString(DNSQuestion& dq, const string& spoofContent)
{
string result;

SpoofAction sa(spoofContent.c_str(), spoofContent.size());
sa(&dq, &result);
SpoofAction tempSpoofAction(spoofContent.c_str(), spoofContent.size());
tempSpoofAction(&dq, &result);
}

bool processRulesResult(const DNSAction::Action& action, DNSQuestion& dq, std::string& ruleresult, bool& drop)
Expand Down
12 changes: 6 additions & 6 deletions pdns/dnsdistdist/dnsdist-lua-ffi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,8 @@ void dnsdist_ffi_dnsquestion_send_trap(dnsdist_ffi_dnsquestion_t* dq, const char
void dnsdist_ffi_dnsquestion_spoof_packet(dnsdist_ffi_dnsquestion_t* dq, const char* raw, size_t len)
{
std::string result;
SpoofAction sa(raw, len);
sa(dq->dq, &result);
SpoofAction tempSpoofAction(raw, len);
tempSpoofAction(dq->dq, &result);
}

void dnsdist_ffi_dnsquestion_spoof_raw(dnsdist_ffi_dnsquestion_t* dq, const dnsdist_ffi_raw_value_t* values, size_t valuesCount)
Expand All @@ -602,8 +602,8 @@ void dnsdist_ffi_dnsquestion_spoof_raw(dnsdist_ffi_dnsquestion_t* dq, const dnsd
}

std::string result;
SpoofAction sa(data, std::nullopt);
sa(dq->dq, &result);
SpoofAction tempSpoofAction(data, std::nullopt);
tempSpoofAction(dq->dq, &result);
}

void dnsdist_ffi_dnsquestion_spoof_addrs(dnsdist_ffi_dnsquestion_t* dq, const dnsdist_ffi_raw_value_t* values, size_t valuesCount)
Expand Down Expand Up @@ -631,8 +631,8 @@ void dnsdist_ffi_dnsquestion_spoof_addrs(dnsdist_ffi_dnsquestion_t* dq, const dn
}

std::string result;
SpoofAction sa(data);
sa(dq->dq, &result);
SpoofAction tempSpoofAction(data);
tempSpoofAction(dq->dq, &result);
}

void dnsdist_ffi_dnsquestion_set_max_returned_ttl(dnsdist_ffi_dnsquestion_t* dq, uint32_t max)
Expand Down

0 comments on commit 88f5117

Please sign in to comment.