]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Add DNSQuestion:setEDNSOption() Lua binding
authorRemi Gacogne <remi.gacogne@powerdns.com>
Sat, 2 Jul 2022 10:42:29 +0000 (12:42 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Sat, 2 Jul 2022 12:17:54 +0000 (14:17 +0200)
pdns/dnsdist-lua-bindings-dnsquestion.cc
pdns/dnsdistdist/docs/reference/dq.rst

index a6b80078cd8049e6f876ce0d3b1d2a1a5d7e4d40..18cb03d4eb5e446da024fba029a30cb86c88b225 100644 (file)
@@ -180,6 +180,12 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx)
       }
   });
 
+  luaCtx.registerFunction<void(DNSQuestion::*)(uint16_t code, const std::string&)>("setEDNSOption", [](DNSQuestion& dq, uint16_t code, const std::string& data) {
+    std::string result;
+    SetEDNSOptionAction seoa(code, data);
+    seoa(&dq, &result);
+  });
+
   /* LuaWrapper doesn't support inheritance */
   luaCtx.registerMember<const ComboAddress (DNSResponse::*)>("localaddr", [](const DNSResponse& dq) -> const ComboAddress { return *dq.local; }, [](DNSResponse& dq, const ComboAddress newLocal) { (void) newLocal; });
   luaCtx.registerMember<const DNSName (DNSResponse::*)>("qname", [](const DNSResponse& dq) -> const DNSName { return *dq.qname; }, [](DNSResponse& dq, const DNSName newName) { (void) newName; });
index d80a5bb9276b26bfcedf0b02b0073c0f2550aa90..6e262b53140f9dfa334b5ab81795239bbb4f3629 100644 (file)
@@ -206,6 +206,15 @@ This state can be modified from the various hooks.
 
     :param string reason: An optional string describing the reason why this trap was sent
 
+  .. method:: DNSQuestion:setEDNSOption(code, data)
+
+    .. versionadded:: 1.8.0
+
+    Add arbitrary EDNS option and data to the query. Any existing EDNS content with the same option code will be overwritten.
+
+    :param int code: The EDNS option code
+    :param string data: The EDNS option raw data
+
   .. method:: DNSQuestion:setHTTPResponse(status, body, contentType="")
 
     .. versionadded:: 1.4.0