if (!dnsQuestion->dq->proxyProtocolValues) {
dnsQuestion->dq->proxyProtocolValues = make_unique<std::vector<ProxyProtocolValue>>();
}
- if (valuesCount > 0) {
- dnsQuestion->dq->proxyProtocolValues->reserve(dnsQuestion->dq->proxyProtocolValues->size() + valuesCount);
- for (size_t idx = 0; idx < valuesCount; idx++) {
- dnsQuestion->dq->proxyProtocolValues->push_back({ std::string(values[idx].value, values[idx].size), values[idx].type });
- }
+
+ dnsQuestion->dq->proxyProtocolValues->reserve(dnsQuestion->dq->proxyProtocolValues->size() + valuesCount);
+ for (size_t idx = 0; idx < valuesCount; idx++) {
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic): the Lua FFI API is a C API..
+ dnsQuestion->dq->proxyProtocolValues->push_back({ std::string(values[idx].value, values[idx].size), values[idx].type });
}
return true;
pwQ.getHeader()->rd = 1;
pwQ.getHeader()->id = htons(42);
- DNSQuestion dq(ids, query);
- dnsdist_ffi_dnsquestion_t lightDQ(&dq);
+ DNSQuestion dnsQuestion(ids, query);
+ dnsdist_ffi_dnsquestion_t lightDQ(&dnsQuestion);
std::vector<dnsdist_ffi_proxy_protocol_value> values;
values.push_back({"test-value", 10U, 1U});
{
auto added = dnsdist_ffi_dnsquestion_add_proxy_protocol_values(&lightDQ, values.size(), values.data());
BOOST_CHECK_EQUAL(added, true);
- BOOST_REQUIRE(dq.proxyProtocolValues != nullptr);
- BOOST_REQUIRE_EQUAL(dq.proxyProtocolValues->size(), values.size());
- BOOST_CHECK_EQUAL(dq.proxyProtocolValues->at(0).type, values.at(0).type);
- BOOST_REQUIRE_EQUAL(dq.proxyProtocolValues->at(0).content.size(), values.at(0).size);
- BOOST_CHECK_EQUAL(memcmp(dq.proxyProtocolValues->at(0).content.data(), values.at(0).value, values.at(0).size), 0);
+ BOOST_REQUIRE(dnsQuestion.proxyProtocolValues != nullptr);
+ BOOST_REQUIRE_EQUAL(dnsQuestion.proxyProtocolValues->size(), values.size());
+ BOOST_CHECK_EQUAL(dnsQuestion.proxyProtocolValues->at(0).type, values.at(0).type);
+ BOOST_REQUIRE_EQUAL(dnsQuestion.proxyProtocolValues->at(0).content.size(), values.at(0).size);
+ BOOST_CHECK_EQUAL(memcmp(dnsQuestion.proxyProtocolValues->at(0).content.data(), values.at(0).value, values.at(0).size), 0);
}
}