2 #include "ext/luawrapper/include/LuaContext.hpp"
6 #include "namespaces.hh"
8 #include "rec-lua-conf.hh"
10 #include "filterpo.hh"
12 #include "rpzloader.hh"
14 #include "remote_logger.hh"
15 #include "validate.hh"
16 #include "validate-recursor.hh"
17 #include "root-dnssec.hh"
19 GlobalStateHolder
<LuaConfigItems
> g_luaconfs
;
21 /* SO HOW DOES THIS WORK! AND PLEASE PAY ATTENTION!
22 This function can be called at any time. It is expected to overwrite all the contents
23 of LuaConfigItems, which is held in a GlobalStateHolder for RCU properties.
25 This function can be called again at a later date, so you must make sure that anything you
26 allow to be configured from here lives in g_luaconfs AND NOWHERE ELSE.
28 If someone loads an empty Lua file, the default LuaConfigItems struct MUST MAKE SENSE.
30 To make this easy on you, here is a LuaConfigItems constructor where you
31 can set sane defaults:
34 LuaConfigItems::LuaConfigItems()
36 DNSName
root("."); // don't use g_rootdnsname here, it might not exist yet
37 for (const auto &dsRecord
: rootDSs
) {
38 auto ds
=std::dynamic_pointer_cast
<DSRecordContent
>(DSRecordContent::make(dsRecord
));
39 dsAnchors
[root
].insert(*ds
);
43 /* DID YOU READ THE STORY ABOVE? */
46 typename
C::value_type::second_type
constGet(const C
& c
, const std::string
& name
)
48 auto iter
= c
.find(name
);
54 typedef std::unordered_map
<std::string
, boost::variant
<bool, uint32_t, std::string
, std::vector
<std::pair
<int, std::string
>> > > rpzOptions_t
;
56 static void parseRPZParameters(rpzOptions_t
& have
, std::string
& polName
, boost::optional
<DNSFilterEngine::Policy
>& defpol
, bool& defpolOverrideLocal
, uint32_t& maxTTL
, size_t& zoneSizeHint
, std::unordered_set
<std::string
>& tags
)
58 if(have
.count("policyName")) {
59 polName
= boost::get
<std::string
>(have
["policyName"]);
61 if(have
.count("defpol")) {
62 defpol
=DNSFilterEngine::Policy();
63 defpol
->d_kind
= (DNSFilterEngine::PolicyKind
)boost::get
<uint32_t>(have
["defpol"]);
64 defpol
->setName(polName
);
65 if(defpol
->d_kind
== DNSFilterEngine::PolicyKind::Custom
) {
66 defpol
->d_custom
.push_back(DNSRecordContent::mastermake(QType::CNAME
, QClass::IN
,
67 boost::get
<string
>(have
["defcontent"])));
69 if(have
.count("defttl"))
70 defpol
->d_ttl
= static_cast<int32_t>(boost::get
<uint32_t>(have
["defttl"]));
72 defpol
->d_ttl
= -1; // get it from the zone
75 if (have
.count("defpolOverrideLocalData")) {
76 defpolOverrideLocal
= boost::get
<bool>(have
["defpolOverrideLocalData"]);
79 if(have
.count("maxTTL")) {
80 maxTTL
= boost::get
<uint32_t>(have
["maxTTL"]);
82 if(have
.count("zoneSizeHint")) {
83 zoneSizeHint
= static_cast<size_t>(boost::get
<uint32_t>(have
["zoneSizeHint"]));
85 if (have
.count("tags")) {
86 const auto tagsTable
= boost::get
<std::vector
<std::pair
<int, std::string
>>>(have
["tags"]);
87 for (const auto& tag
: tagsTable
) {
88 tags
.insert(tag
.second
);
94 typedef std::unordered_map
<std::string
, boost::variant
<bool, uint64_t, std::string
, std::vector
<std::pair
<int,std::string
> > > > protobufOptions_t
;
96 static void parseProtobufOptions(boost::optional
<protobufOptions_t
> vars
, ProtobufExportConfig
& config
)
102 if (vars
->count("timeout")) {
103 config
.timeout
= boost::get
<uint64_t>((*vars
)["timeout"]);
106 if (vars
->count("maxQueuedEntries")) {
107 config
.maxQueuedEntries
= boost::get
<uint64_t>((*vars
)["maxQueuedEntries"]);
110 if (vars
->count("reconnectWaitTime")) {
111 config
.reconnectWaitTime
= boost::get
<uint64_t>((*vars
)["reconnectWaitTime"]);
114 if (vars
->count("asyncConnect")) {
115 config
.asyncConnect
= boost::get
<bool>((*vars
)["asyncConnect"]);
118 if (vars
->count("taggedOnly")) {
119 config
.taggedOnly
= boost::get
<bool>((*vars
)["taggedOnly"]);
122 if (vars
->count("logQueries")) {
123 config
.logQueries
= boost::get
<bool>((*vars
)["logQueries"]);
126 if (vars
->count("logResponses")) {
127 config
.logResponses
= boost::get
<bool>((*vars
)["logResponses"]);
130 if (vars
->count("exportTypes")) {
131 config
.exportTypes
.clear();
133 auto types
= boost::get
<std::vector
<std::pair
<int, std::string
>>>((*vars
)["exportTypes"]);
134 for (const auto& pair
: types
) {
135 const auto type
= pair
.second
;
138 for (const auto& entry
: QType::names
) {
139 if (entry
.first
== type
) {
141 config
.exportTypes
.insert(entry
.second
);
147 throw std::runtime_error("Unknown QType '" + type
+ "' in protobuf's export types");
152 #endif /* HAVE_PROTOBUF */
155 typedef std::unordered_map
<std::string
, boost::variant
<bool, uint64_t, std::string
, std::vector
<std::pair
<int,std::string
> > > > frameStreamOptions_t
;
157 static void parseFrameStreamOptions(boost::optional
<frameStreamOptions_t
> vars
, FrameStreamExportConfig
& config
)
163 if (vars
->count("logQueries")) {
164 config
.logQueries
= boost::get
<bool>((*vars
)["logQueries"]);
166 if (vars
->count("logResponses")) {
167 config
.logResponses
= boost::get
<bool>((*vars
)["logResponses"]);
170 if (vars
->count("bufferHint")) {
171 config
.bufferHint
= boost::get
<uint64_t>((*vars
)["bufferHint"]);
173 if (vars
->count("flushTimeout")) {
174 config
.flushTimeout
= boost::get
<uint64_t>((*vars
)["flushTimeout"]);
176 if (vars
->count("inputQueueSize")) {
177 config
.inputQueueSize
= boost::get
<uint64_t>((*vars
)["inputQueueSize"]);
179 if (vars
->count("outputQueueSize")) {
180 config
.outputQueueSize
= boost::get
<uint64_t>((*vars
)["outputQueueSize"]);
182 if (vars
->count("queueNotifyThreshold")) {
183 config
.queueNotifyThreshold
= boost::get
<uint64_t>((*vars
)["queueNotifyThreshold"]);
185 if (vars
->count("reopenInterval")) {
186 config
.reopenInterval
= boost::get
<uint64_t>((*vars
)["reopenInterval"]);
189 #endif /* HAVE_FSTRM */
191 void loadRecursorLuaConfig(const std::string
& fname
, luaConfigDelayedThreads
& delayedThreads
)
200 throw PDNSException("Cannot open file '"+fname
+"': "+stringerror());
202 auto luaconfsLocal
= g_luaconfs
.getLocal();
203 lci
.generation
= luaconfsLocal
->generation
+ 1;
205 // pdnslog here is compatible with pdnslog in lua-base4.cc.
206 Lua
.writeFunction("pdnslog", [](const std::string
& msg
, boost::optional
<int> loglevel
) { g_log
<< (Logger::Urgency
)loglevel
.get_value_or(Logger::Warning
) << msg
<<endl
; });
207 std::unordered_map
<string
, std::unordered_map
<string
, int>> pdns_table
;
208 pdns_table
["loglevels"] = std::unordered_map
<string
, int>{
209 {"Alert", LOG_ALERT
},
210 {"Critical", LOG_CRIT
},
211 {"Debug", LOG_DEBUG
},
212 {"Emergency", LOG_EMERG
},
214 {"Notice", LOG_NOTICE
},
215 {"Warning", LOG_WARNING
},
218 Lua
.writeVariable("pdns", pdns_table
);
220 Lua
.writeFunction("clearSortlist", [&lci
]() { lci
.sortlist
.clear(); });
222 /* we can get: "1.2.3.4"
223 {"1.2.3.4", "4.5.6.7"}
224 {"1.2.3.4", {"4.5.6.7", "8.9.10.11"}}
227 map
<string
,DNSFilterEngine::PolicyKind
> pmap
{
228 {"NoAction", DNSFilterEngine::PolicyKind::NoAction
},
229 {"Drop", DNSFilterEngine::PolicyKind::Drop
},
230 {"NXDOMAIN", DNSFilterEngine::PolicyKind::NXDOMAIN
},
231 {"NODATA", DNSFilterEngine::PolicyKind::NODATA
},
232 {"Truncate", DNSFilterEngine::PolicyKind::Truncate
},
233 {"Custom", DNSFilterEngine::PolicyKind::Custom
}
235 Lua
.writeVariable("Policy", pmap
);
237 Lua
.writeFunction("rpzFile", [&lci
](const string
& filename
, boost::optional
<rpzOptions_t
> options
) {
239 boost::optional
<DNSFilterEngine::Policy
> defpol
;
240 bool defpolOverrideLocal
= true;
241 std::string
polName("rpzFile");
242 std::shared_ptr
<DNSFilterEngine::Zone
> zone
= std::make_shared
<DNSFilterEngine::Zone
>();
243 uint32_t maxTTL
= std::numeric_limits
<uint32_t>::max();
245 auto& have
= *options
;
246 size_t zoneSizeHint
= 0;
247 std::unordered_set
<std::string
> tags
;
248 parseRPZParameters(have
, polName
, defpol
, defpolOverrideLocal
, maxTTL
, zoneSizeHint
, tags
);
249 if (zoneSizeHint
> 0) {
250 zone
->reserve(zoneSizeHint
);
252 zone
->setTags(std::move(tags
));
254 g_log
<<Logger::Warning
<<"Loading RPZ from file '"<<filename
<<"'"<<endl
;
255 zone
->setName(polName
);
256 loadRPZFromFile(filename
, zone
, defpol
, defpolOverrideLocal
, maxTTL
);
257 lci
.dfe
.addZone(zone
);
258 g_log
<<Logger::Warning
<<"Done loading RPZ from file '"<<filename
<<"'"<<endl
;
260 catch(const std::exception
& e
) {
261 g_log
<<Logger::Error
<<"Unable to load RPZ zone from '"<<filename
<<"': "<<e
.what()<<endl
;
265 Lua
.writeFunction("rpzMaster", [&lci
, &delayedThreads
](const boost::variant
<string
, std::vector
<std::pair
<int, string
> > >& masters_
, const string
& zoneName
, boost::optional
<rpzOptions_t
> options
) {
267 boost::optional
<DNSFilterEngine::Policy
> defpol
;
268 bool defpolOverrideLocal
= true;
269 std::shared_ptr
<DNSFilterEngine::Zone
> zone
= std::make_shared
<DNSFilterEngine::Zone
>();
272 size_t maxReceivedXFRMBytes
= 0;
273 uint16_t axfrTimeout
= 20;
274 uint32_t maxTTL
= std::numeric_limits
<uint32_t>::max();
275 ComboAddress localAddress
;
276 std::vector
<ComboAddress
> masters
;
277 if (masters_
.type() == typeid(string
)) {
278 masters
.push_back(ComboAddress(boost::get
<std::string
>(masters_
), 53));
281 for (const auto& master
: boost::get
<std::vector
<std::pair
<int, std::string
>>>(masters_
)) {
282 masters
.push_back(ComboAddress(master
.second
, 53));
287 std::string dumpFile
;
288 std::shared_ptr
<SOARecordContent
> sr
= nullptr;
291 std::string seedFile
;
292 std::string
polName(zoneName
);
295 auto& have
= *options
;
296 size_t zoneSizeHint
= 0;
297 std::unordered_set
<std::string
> tags
;
298 parseRPZParameters(have
, polName
, defpol
, defpolOverrideLocal
, maxTTL
, zoneSizeHint
, tags
);
299 if (zoneSizeHint
> 0) {
300 zone
->reserve(zoneSizeHint
);
302 zone
->setTags(std::move(tags
));
304 if(have
.count("tsigname")) {
305 tt
.name
=DNSName(toLower(boost::get
<string
>(have
["tsigname"])));
306 tt
.algo
=DNSName(toLower(boost::get
<string
>(have
[ "tsigalgo"])));
307 if(B64Decode(boost::get
<string
>(have
[ "tsigsecret"]), tt
.secret
))
308 throw std::runtime_error("TSIG secret is not valid Base-64 encoded");
311 if(have
.count("refresh")) {
312 refresh
= boost::get
<uint32_t>(have
["refresh"]);
314 g_log
<<Logger::Warning
<<"rpzMaster refresh value of 0 ignored"<<endl
;
318 if(have
.count("maxReceivedMBytes")) {
319 maxReceivedXFRMBytes
= static_cast<size_t>(boost::get
<uint32_t>(have
["maxReceivedMBytes"]));
322 if(have
.count("localAddress")) {
323 localAddress
= ComboAddress(boost::get
<string
>(have
["localAddress"]));
326 if(have
.count("axfrTimeout")) {
327 axfrTimeout
= static_cast<uint16_t>(boost::get
<uint32_t>(have
["axfrTimeout"]));
330 if(have
.count("seedFile")) {
331 seedFile
= boost::get
<std::string
>(have
["seedFile"]);
334 if(have
.count("dumpFile")) {
335 dumpFile
= boost::get
<std::string
>(have
["dumpFile"]);
339 if (localAddress
!= ComboAddress()) {
340 // We were passed a localAddress, check if its AF matches the masters'
341 for (const auto& master
: masters
) {
342 if (localAddress
.sin4
.sin_family
!= master
.sin4
.sin_family
) {
343 throw PDNSException("Master address("+master
.toString()+") is not of the same Address Family as the local address ("+localAddress
.toString()+").");
348 DNSName
domain(zoneName
);
349 zone
->setDomain(domain
);
350 zone
->setName(polName
);
351 zoneIdx
= lci
.dfe
.addZone(zone
);
353 if (!seedFile
.empty()) {
354 g_log
<<Logger::Info
<<"Pre-loading RPZ zone "<<zoneName
<<" from seed file '"<<seedFile
<<"'"<<endl
;
356 sr
= loadRPZFromFile(seedFile
, zone
, defpol
, defpolOverrideLocal
, maxTTL
);
358 if (zone
->getDomain() != domain
) {
359 throw PDNSException("The RPZ zone " + zoneName
+ " loaded from the seed file (" + zone
->getDomain().toString() + ") does not match the one passed in parameter (" + domain
.toString() + ")");
363 throw PDNSException("The RPZ zone " + zoneName
+ " loaded from the seed file (" + zone
->getDomain().toString() + ") has no SOA record");
366 catch(const std::exception
& e
) {
367 g_log
<<Logger::Warning
<<"Unable to pre-load RPZ zone "<<zoneName
<<" from seed file '"<<seedFile
<<"': "<<e
.what()<<endl
;
371 catch(const std::exception
& e
) {
372 g_log
<<Logger::Error
<<"Problem configuring 'rpzMaster': "<<e
.what()<<endl
;
373 exit(1); // FIXME proper exit code?
375 catch(const PDNSException
& e
) {
376 g_log
<<Logger::Error
<<"Problem configuring 'rpzMaster': "<<e
.reason
<<endl
;
377 exit(1); // FIXME proper exit code?
380 delayedThreads
.rpzMasterThreads
.push_back(std::make_tuple(masters
, defpol
, defpolOverrideLocal
, maxTTL
, zoneIdx
, tt
, maxReceivedXFRMBytes
, localAddress
, axfrTimeout
, refresh
, sr
, dumpFile
));
383 typedef vector
<pair
<int,boost::variant
<string
, vector
<pair
<int, string
> > > > > argvec_t
;
384 Lua
.writeFunction("addSortList",
385 [&lci
](const std::string
& formask_
,
386 const boost::variant
<string
, argvec_t
>& masks
,
387 boost::optional
<int> order_
)
390 Netmask
formask(formask_
);
391 int order
= order_
? (*order_
) : lci
.sortlist
.getMaxOrder(formask
)+1;
392 if(auto str
= boost::get
<string
>(&masks
))
393 lci
.sortlist
.addEntry(formask
, Netmask(*str
), order
);
396 auto vec
= boost::get
<argvec_t
>(&masks
);
397 for(const auto& e
: *vec
) {
398 if(auto s
= boost::get
<string
>(&e
.second
)) {
399 lci
.sortlist
.addEntry(formask
, Netmask(*s
), order
);
402 const auto& v
=boost::get
<vector
<pair
<int, string
> > >(e
.second
);
403 for(const auto& entry
: v
)
404 lci
.sortlist
.addEntry(formask
, Netmask(entry
.second
), order
);
410 catch(std::exception
& e
) {
411 g_log
<<Logger::Error
<<"Error in addSortList: "<<e
.what()<<endl
;
415 Lua
.writeFunction("addTA", [&lci
](const std::string
& who
, const std::string
& what
) {
416 warnIfDNSSECDisabled("Warning: adding Trust Anchor for DNSSEC (addTA), but dnssec is set to 'off'!");
418 auto ds
= std::dynamic_pointer_cast
<DSRecordContent
>(DSRecordContent::make(what
));
419 lci
.dsAnchors
[zone
].insert(*ds
);
422 Lua
.writeFunction("clearTA", [&lci
](boost::optional
<string
> who
) {
423 warnIfDNSSECDisabled("Warning: removing Trust Anchor for DNSSEC (clearTA), but dnssec is set to 'off'!");
425 lci
.dsAnchors
.erase(DNSName(*who
));
427 lci
.dsAnchors
.clear();
431 Lua
.writeFunction("addDS", [&lci
](const std::string
& who
, const std::string
& what
) {
432 warnIfDNSSECDisabled("Warning: adding Trust Anchor for DNSSEC (addDS), but dnssec is set to 'off'!");
433 g_log
<<Logger::Warning
<<"addDS is deprecated and will be removed in the future, switch to addTA"<<endl
;
435 auto ds
= std::dynamic_pointer_cast
<DSRecordContent
>(DSRecordContent::make(what
));
436 lci
.dsAnchors
[zone
].insert(*ds
);
440 Lua
.writeFunction("clearDS", [&lci
](boost::optional
<string
> who
) {
441 g_log
<<Logger::Warning
<<"clearDS is deprecated and will be removed in the future, switch to clearTA"<<endl
;
442 warnIfDNSSECDisabled("Warning: removing Trust Anchor for DNSSEC (clearDS), but dnssec is set to 'off'!");
444 lci
.dsAnchors
.erase(DNSName(*who
));
446 lci
.dsAnchors
.clear();
449 Lua
.writeFunction("addNTA", [&lci
](const std::string
& who
, const boost::optional
<std::string
> why
) {
450 warnIfDNSSECDisabled("Warning: adding Negative Trust Anchor for DNSSEC (addNTA), but dnssec is set to 'off'!");
452 lci
.negAnchors
[DNSName(who
)] = static_cast<string
>(*why
);
454 lci
.negAnchors
[DNSName(who
)] = "";
457 Lua
.writeFunction("clearNTA", [&lci
](boost::optional
<string
> who
) {
458 warnIfDNSSECDisabled("Warning: removing Negative Trust Anchor for DNSSEC (clearNTA), but dnssec is set to 'off'!");
460 lci
.negAnchors
.erase(DNSName(*who
));
462 lci
.negAnchors
.clear();
465 Lua
.writeFunction("readTrustAnchorsFromFile", [&lci
](const std::string
& fnamearg
, const boost::optional
<uint32_t> interval
) {
466 uint32_t realInterval
= 24;
468 realInterval
= static_cast<uint32_t>(*interval
);
470 warnIfDNSSECDisabled("Warning: reading Trust Anchors from file (readTrustAnchorsFromFile), but dnssec is set to 'off'!");
471 lci
.trustAnchorFileInfo
.fname
= fnamearg
;
472 lci
.trustAnchorFileInfo
.interval
= realInterval
;
473 updateTrustAnchorsFromFile(fnamearg
, lci
.dsAnchors
);
477 Lua
.writeFunction("setProtobufMasks", [&lci
](const uint8_t maskV4
, uint8_t maskV6
) {
478 lci
.protobufMaskV4
= maskV4
;
479 lci
.protobufMaskV6
= maskV6
;
482 Lua
.writeFunction("protobufServer", [&lci
](boost::variant
<const std::string
, const std::unordered_map
<int, std::string
>> servers
, boost::optional
<protobufOptions_t
> vars
) {
483 if (!lci
.protobufExportConfig
.enabled
) {
485 lci
.protobufExportConfig
.enabled
= true;
488 if (servers
.type() == typeid(std::string
)) {
489 auto server
= boost::get
<const std::string
>(servers
);
491 lci
.protobufExportConfig
.servers
.emplace_back(server
);
494 auto serversMap
= boost::get
<const std::unordered_map
<int,std::string
>>(servers
);
495 for (const auto& serverPair
: serversMap
) {
496 lci
.protobufExportConfig
.servers
.emplace_back(serverPair
.second
);
500 parseProtobufOptions(vars
, lci
.protobufExportConfig
);
502 catch(std::exception
& e
) {
503 g_log
<<Logger::Error
<<"Error while adding protobuf logger: "<<e
.what()<<endl
;
505 catch(PDNSException
& e
) {
506 g_log
<<Logger::Error
<<"Error while adding protobuf logger: "<<e
.reason
<<endl
;
510 g_log
<<Logger::Error
<<"Only one protobufServer() directive can be configured, we already have "<<lci
.protobufExportConfig
.servers
.at(0).toString()<<endl
;
514 Lua
.writeFunction("outgoingProtobufServer", [&lci
](boost::variant
<const std::string
, const std::unordered_map
<int, std::string
>> servers
, boost::optional
<protobufOptions_t
> vars
) {
515 if (!lci
.outgoingProtobufExportConfig
.enabled
) {
517 lci
.outgoingProtobufExportConfig
.enabled
= true;
520 if (servers
.type() == typeid(std::string
)) {
521 auto server
= boost::get
<const std::string
>(servers
);
523 lci
.outgoingProtobufExportConfig
.servers
.emplace_back(server
);
526 auto serversMap
= boost::get
<const std::unordered_map
<int,std::string
>>(servers
);
527 for (const auto& serverPair
: serversMap
) {
528 lci
.outgoingProtobufExportConfig
.servers
.emplace_back(serverPair
.second
);
532 parseProtobufOptions(vars
, lci
.outgoingProtobufExportConfig
);
534 catch(std::exception
& e
) {
535 g_log
<<Logger::Error
<<"Error while starting outgoing protobuf logger: "<<e
.what()<<endl
;
537 catch(PDNSException
& e
) {
538 g_log
<<Logger::Error
<<"Error while starting outgoing protobuf logger: "<<e
.reason
<<endl
;
542 g_log
<<Logger::Error
<<"Only one outgoingProtobufServer() directive can be configured, we already have "<<lci
.outgoingProtobufExportConfig
.servers
.at(0).toString()<<endl
;
548 Lua
.writeFunction("dnstapFrameStreamServer", [&lci
](boost::variant
<const std::string
, const std::unordered_map
<int, std::string
>> servers
, boost::optional
<frameStreamOptions_t
> vars
) {
549 if (!lci
.frameStreamExportConfig
.enabled
) {
551 lci
.frameStreamExportConfig
.enabled
= true;
554 if (servers
.type() == typeid(std::string
)) {
555 auto server
= boost::get
<const std::string
>(servers
);
556 if (!boost::starts_with(server
, "/")) {
557 ComboAddress
parsecheck(server
);
559 lci
.frameStreamExportConfig
.servers
.emplace_back(server
);
562 auto serversMap
= boost::get
<const std::unordered_map
<int,std::string
>>(servers
);
563 for (const auto& serverPair
: serversMap
) {
564 lci
.frameStreamExportConfig
.servers
.emplace_back(serverPair
.second
);
568 parseFrameStreamOptions(vars
, lci
.frameStreamExportConfig
);
570 catch(std::exception
& e
) {
571 g_log
<<Logger::Error
<<"Error reading config for dnstap framestream logger: "<<e
.what()<<endl
;
573 catch(PDNSException
& e
) {
574 g_log
<<Logger::Error
<<"Error reading config for dnstap framestream logger: "<<e
.reason
<<endl
;
578 g_log
<<Logger::Error
<<"Only one dnstapFrameStreamServer() directive can be configured, we already have "<<lci
.frameStreamExportConfig
.servers
.at(0)<<endl
;
581 #endif /* HAVE_FSTRM */
584 Lua
.executeCode(ifs
);
585 g_luaconfs
.setState(std::move(lci
));
587 catch(const LuaContext::ExecutionErrorException
& e
) {
588 g_log
<<Logger::Error
<<"Unable to load Lua script from '"+fname
+"': ";
590 std::rethrow_if_nested(e
);
591 } catch(const std::exception
& exp
) {
592 // exp is the exception that was thrown from inside the lambda
593 g_log
<< exp
.what() << std::endl
;
595 catch(const PDNSException
& exp
) {
596 // exp is the exception that was thrown from inside the lambda
597 g_log
<< exp
.reason
<< std::endl
;
602 catch(std::exception
& err
) {
603 g_log
<<Logger::Error
<<"Unable to load Lua script from '"+fname
+"': "<<err
.what()<<endl
;
609 void startLuaConfigDelayedThreads(const luaConfigDelayedThreads
& delayedThreads
, uint64_t generation
)
611 for (const auto& rpzMaster
: delayedThreads
.rpzMasterThreads
) {
613 std::thread
t(RPZIXFRTracker
, std::get
<0>(rpzMaster
), std::get
<1>(rpzMaster
), std::get
<2>(rpzMaster
), std::get
<3>(rpzMaster
), std::get
<4>(rpzMaster
), std::get
<5>(rpzMaster
), std::get
<6>(rpzMaster
) * 1024 * 1024, std::get
<7>(rpzMaster
), std::get
<8>(rpzMaster
), std::get
<9>(rpzMaster
), std::get
<10>(rpzMaster
), std::get
<11>(rpzMaster
), generation
);
616 catch(const std::exception
& e
) {
617 g_log
<<Logger::Error
<<"Problem starting RPZIXFRTracker thread: "<<e
.what()<<endl
;
618 exit(1); // FIXME proper exit code?
620 catch(const PDNSException
& e
) {
621 g_log
<<Logger::Error
<<"Problem starting RPZIXFRTracker thread: "<<e
.reason
<<endl
;
622 exit(1); // FIXME proper exit code?