From: dmachard <5562930+dmachard@users.noreply.github.com> Date: Tue, 19 Sep 2023 15:47:44 +0000 (+0200) Subject: wrap DownstreamState instead of ComboAddress X-Git-Tag: rec-5.0.0-alpha2~56^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ab86fe94fccc1f04c1a247aa94183bd4e82bd3d0;p=thirdparty%2Fpdns.git wrap DownstreamState instead of ComboAddress --- diff --git a/pdns/dnsdist-lua-bindings-dnsquestion.cc b/pdns/dnsdist-lua-bindings-dnsquestion.cc index 7427f18f6d..057f71c907 100644 --- a/pdns/dnsdist-lua-bindings-dnsquestion.cc +++ b/pdns/dnsdist-lua-bindings-dnsquestion.cc @@ -501,15 +501,8 @@ private: return dnsdist::queueQueryResumptionEvent(std::move(query)); }); - luaCtx.registerMember("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(DNSResponse::*)(void)const>("getSelectedBackend", [](const DNSResponse& dr) { + return dr.d_downstream; + }); #endif /* DISABLE_NON_FFI_DQ_BINDINGS */ } diff --git a/pdns/dnsdistdist/docs/reference/dq.rst b/pdns/dnsdistdist/docs/reference/dq.rst index 1d301588eb..08bb84cde7 100644 --- a/pdns/dnsdistdist/docs/reference/dq.rst +++ b/pdns/dnsdistdist/docs/reference/dq.rst @@ -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)