]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
wrap DownstreamState instead of ComboAddress 13275/head
authordmachard <5562930+dmachard@users.noreply.github.com>
Tue, 19 Sep 2023 15:47:44 +0000 (17:47 +0200)
committerdmachard <5562930+dmachard@users.noreply.github.com>
Tue, 19 Sep 2023 15:47:44 +0000 (17:47 +0200)
pdns/dnsdist-lua-bindings-dnsquestion.cc
pdns/dnsdistdist/docs/reference/dq.rst

index 7427f18f6ddd1a823ee84fa3ef71ea8d1e6416d4..057f71c9073a795ef5a3b3de0b5ec8dab738a8a0 100644 (file)
@@ -501,15 +501,8 @@ private:
     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; }
-  );
+  luaCtx.registerFunction<std::shared_ptr<DownstreamState>(DNSResponse::*)(void)const>("getSelectedBackend", [](const DNSResponse& dr) {
+    return dr.d_downstream;
+  });
 #endif /* DISABLE_NON_FFI_DQ_BINDINGS */
 }
index 1d301588eb1caf7c6d4b36a982621cebef9d68f6..08bb84cde74d64b61ac5a03469f7dd1ef8a4d48a 100644 (file)
@@ -403,15 +403,13 @@ 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.
-  The DNSResponse object has one additional attribute:
+  It also has additional methods:
 
-  .. attribute:: DNSResponse.selectedBackend
+  .. method:: DNSResponse.getSelectedBackend() -> Server
 
     .. versionadded:: 1.9.0
 
-    :ref:`ComboAddress` of the selected backend.
-
-  It also has additional methods:
+    Get the selected backend :class:`Server` or nil
 
   .. method:: DNSResponse:editTTLs(func)