]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Apply Otto's suggestion to the Lua FFI proxy protocol API 14716/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 25 Sep 2024 13:12:09 +0000 (15:12 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 26 Sep 2024 12:27:42 +0000 (14:27 +0200)
(cherry picked from commit 70530852d01f6c96606ff6d27c9487238c2cf95c)

pdns/dnsdistdist/dnsdist-lua-ffi.cc

index 723fda4e75ac31c18027cc3d8f60bee9b2d96872..f2af6c19f02d1a52771495b7134103895a3f782a 100644 (file)
@@ -1112,9 +1112,12 @@ bool dnsdist_ffi_dnsquestion_add_proxy_protocol_values(dnsdist_ffi_dnsquestion_t
 
 size_t dnsdist_ffi_dnsquestion_get_proxy_protocol_values(dnsdist_ffi_dnsquestion_t* dnsQuestion, const dnsdist_ffi_proxy_protocol_value_t** out)
 {
-  size_t count = 0;
-  if (dnsQuestion == nullptr || dnsQuestion->dq == nullptr || out == nullptr || !dnsQuestion->dq->proxyProtocolValues) {
-    return count;
+  if (dnsQuestion == nullptr || dnsQuestion->dq == nullptr || !dnsQuestion->dq->proxyProtocolValues) {
+    return 0;
+  }
+
+  if (out == nullptr) {
+    return dnsQuestion->proxyProtocolValuesVect->size();
   }
 
   dnsQuestion->proxyProtocolValuesVect = std::make_unique<std::vector<dnsdist_ffi_proxy_protocol_value_t>>(dnsQuestion->dq->proxyProtocolValues->size());
@@ -1124,11 +1127,10 @@ size_t dnsdist_ffi_dnsquestion_get_proxy_protocol_values(dnsdist_ffi_dnsquestion
     targetEntry.size = entry.content.size();
     targetEntry.value = entry.content.data();
     targetEntry.type = entry.type;
-    ++count;
   }
 
   *out = dnsQuestion->proxyProtocolValuesVect->data();
-  return count;
+  return dnsQuestion->proxyProtocolValuesVect->size();
 }
 
 struct dnsdist_ffi_domain_list_t