]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: add lua binding to downstream addr
authordmachard <5562930+dmachard@users.noreply.github.com>
Mon, 18 Sep 2023 16:25:26 +0000 (18:25 +0200)
committerdmachard <5562930+dmachard@users.noreply.github.com>
Mon, 18 Sep 2023 16:25:26 +0000 (18:25 +0200)
pdns/dnsdist-lua-bindings-dnsquestion.cc
pdns/dnsdistdist/docs/reference/dq.rst

index f71a9bbf4d97863bbd574da3bd66805ec10f48d3..7427f18f6ddd1a823ee84fa3ef71ea8d1e6416d4 100644 (file)
@@ -500,5 +500,16 @@ private:
     auto query = dnsdist::getInternalQueryFromDQ(dr, false);
     return dnsdist::queueQueryResumptionEvent(std::move(query));
   });
+
+  luaCtx.registerMember<const ComboAddress (DNSResponse::*)>("selectedBackend", 
+    []( const DNSResponse& dr) -> const ComboAddress { 
+      if (dr.d_downstream == nullptr) {
+        return ComboAddress();
+      } else {
+        return dr.d_downstream->d_config.remote;
+      }
+    }, 
+    [](DNSResponse& dr, const ComboAddress newSelectedBackend) { (void) newSelectedBackend; }
+  );
 #endif /* DISABLE_NON_FFI_DQ_BINDINGS */
 }
index ef9c531b3e7bf4f21b50a0fab722ec48a37da49e..1d301588eb1caf7c6d4b36a982621cebef9d68f6 100644 (file)
@@ -403,7 +403,15 @@ DNSResponse object
   - ``useECS``
 
   If the value is really needed while the response is being processed, it is possible to set a tag while the query is processed, as tags will be passed to the response object.
-  It also has one additional method:
+  The DNSResponse object has one additional attribute:
+
+  .. attribute:: DNSResponse.selectedBackend
+
+    .. versionadded:: 1.9.0
+
+    :ref:`ComboAddress` of the selected backend.
+
+  It also has additional methods:
 
   .. method:: DNSResponse:editTTLs(func)