g_outputBuffer = "Error: " + string(e.what()) + "\n";
}
});
-#endif
luaCtx.writeFunction("generateDNSCryptProviderKeys", [client](const std::string& publicKeyFile, const std::string privateKeyFile) {
setLuaNoSideEffect();
-#ifdef HAVE_DNSCRYPT
if (client) {
return;
}
sodium_memzero(privateKey, sizeof(privateKey));
sodium_munlock(privateKey, sizeof(privateKey));
-#else
- g_outputBuffer = "Error: DNSCrypt support is not enabled.\n";
-#endif
});
luaCtx.writeFunction("printDNSCryptProviderFingerprint", [](const std::string& publicKeyFile) {
setLuaNoSideEffect();
-#ifdef HAVE_DNSCRYPT
unsigned char publicKey[DNSCRYPT_PROVIDER_PUBLIC_KEY_SIZE];
try {
errlog(e.what());
g_outputBuffer = "Error: " + string(e.what()) + "\n";
}
-#else
- g_outputBuffer = "Error: DNSCrypt support is not enabled.\n";
-#endif
});
+#endif
}
void setupLuaBindingsKVS(LuaContext& luaCtx, bool client)
{
- /* Key Value Store objects */
- luaCtx.writeFunction("KeyValueLookupKeySourceIP", [](boost::optional<uint8_t> v4Mask, boost::optional<uint8_t> v6Mask, boost::optional<bool> includePort) {
- return std::shared_ptr<KeyValueLookupKey>(new KeyValueLookupKeySourceIP(v4Mask.get_value_or(32), v6Mask.get_value_or(128), includePort.get_value_or(false)));
- });
- luaCtx.writeFunction("KeyValueLookupKeyQName", [](boost::optional<bool> wireFormat) {
- return std::shared_ptr<KeyValueLookupKey>(new KeyValueLookupKeyQName(wireFormat ? *wireFormat : true));
- });
- luaCtx.writeFunction("KeyValueLookupKeySuffix", [](boost::optional<size_t> minLabels, boost::optional<bool> wireFormat) {
- return std::shared_ptr<KeyValueLookupKey>(new KeyValueLookupKeySuffix(minLabels ? *minLabels : 0, wireFormat ? *wireFormat : true));
- });
- luaCtx.writeFunction("KeyValueLookupKeyTag", [](const std::string& tag) {
- return std::shared_ptr<KeyValueLookupKey>(new KeyValueLookupKeyTag(tag));
- });
-
#ifdef HAVE_LMDB
luaCtx.writeFunction("newLMDBKVStore", [client](const std::string& fname, const std::string& dbName, boost::optional<bool> noLock) {
if (client) {
});
#endif /* HAVE_CDB */
+#if defined(HAVE_LMDB) || defined(HAVE_CDB)
+ /* Key Value Store objects */
+ luaCtx.writeFunction("KeyValueLookupKeySourceIP", [](boost::optional<uint8_t> v4Mask, boost::optional<uint8_t> v6Mask, boost::optional<bool> includePort) {
+ return std::shared_ptr<KeyValueLookupKey>(new KeyValueLookupKeySourceIP(v4Mask.get_value_or(32), v6Mask.get_value_or(128), includePort.get_value_or(false)));
+ });
+ luaCtx.writeFunction("KeyValueLookupKeyQName", [](boost::optional<bool> wireFormat) {
+ return std::shared_ptr<KeyValueLookupKey>(new KeyValueLookupKeyQName(wireFormat ? *wireFormat : true));
+ });
+ luaCtx.writeFunction("KeyValueLookupKeySuffix", [](boost::optional<size_t> minLabels, boost::optional<bool> wireFormat) {
+ return std::shared_ptr<KeyValueLookupKey>(new KeyValueLookupKeySuffix(minLabels ? *minLabels : 0, wireFormat ? *wireFormat : true));
+ });
+ luaCtx.writeFunction("KeyValueLookupKeyTag", [](const std::string& tag) {
+ return std::shared_ptr<KeyValueLookupKey>(new KeyValueLookupKeyTag(tag));
+ });
+
luaCtx.registerFunction<std::string(std::shared_ptr<KeyValueStore>::*)(const boost::variant<ComboAddress, DNSName, std::string>, boost::optional<bool> wireFormat)>("lookup", [](std::shared_ptr<KeyValueStore>& kvs, const boost::variant<ComboAddress, DNSName, std::string> keyVar, boost::optional<bool> wireFormat) {
std::string result;
if (!kvs) {
return kvs->reload();
});
+#endif /* defined(HAVE_LMDB) || defined(HAVE_CDB) */
}