]> granicus.if.org Git - pdns/commitdiff
lua-base4: Add newDRR for making DNSResourceRecords
authorAki Tuomi <cmouse@cmouse.fi>
Sun, 7 Jan 2018 16:45:58 +0000 (18:45 +0200)
committerAki Tuomi <cmouse@cmouse.fi>
Tue, 6 Mar 2018 07:56:41 +0000 (09:56 +0200)
pdns/lua-base4.cc

index eb37dd92aa054d882696ac283423306e7013302e..4ac452ab4d93694e0734cc8b868e74bb175a3320 100644 (file)
@@ -71,6 +71,18 @@ void BaseLua4::prepareContext() {
   d_lw->registerFunction<bool(DNSName::*)()>("chopOff", [](DNSName&dn ) { return dn.chopOff(); });
 
   // DNSResourceRecord
+  d_lw->writeFunction("newDRR", [](const DNSName& qname, const string& qtype, const unsigned int ttl, const string& content, boost::optional<int> domain_id, boost::optional<int> auth){
+    auto drr = DNSResourceRecord();
+    drr.qname = qname;
+    drr.qtype = qtype;
+    drr.ttl = ttl;
+    drr.setContent(content);
+    if (domain_id)
+      drr.domain_id = *domain_id;
+    if (auth)
+      drr.auth = *auth;
+     return drr;
+  });
   d_lw->registerEqFunction(&DNSResourceRecord::operator==);
   d_lw->registerFunction("__lt", &DNSResourceRecord::operator<);
   d_lw->registerFunction<string(DNSResourceRecord::*)()>("toString", [](const DNSResourceRecord& rec) { return rec.getZoneRepresentation();} );