]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Apply Otto's suggestion to the Lua FFI proxy protocol API 14664/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 25 Sep 2024 13:12:09 +0000 (15:12 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 25 Sep 2024 13:12:09 +0000 (15:12 +0200)
pdns/dnsdistdist/dnsdist-lua-ffi.cc

index 49d7b47e556dd13d7aedc4d028ad0bff76b6b833..192e8f1cfd10c9c9b4e229f2872e7f4db643fc36 100644 (file)
@@ -1121,9 +1121,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());
@@ -1133,11 +1136,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