]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon: optional FFI to support e500
authorMarek Vavruša <marek.vavrusa@nic.cz>
Thu, 17 Dec 2015 14:17:08 +0000 (15:17 +0100)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Thu, 17 Dec 2015 14:17:16 +0000 (15:17 +0100)
daemon/lua/kres.lua
daemon/lua/sandbox.lua
daemon/lua/trust_anchors.lua

index c073312651d2d5116e4ba95fefa518151702bc95..0834b65d7f010a2ae7ce767ae3a5343c95799a33 100644 (file)
@@ -1,7 +1,12 @@
 -- LuaJIT ffi bindings for libkres, a DNS resolver library.
 -- @note Since it's statically compiled, it expects to find the symbols in the C namespace.
 
-local ffi = require('ffi')
+local ffi_ok, ffi = pcall(require, 'ffi')
+if not ffi_ok then
+       local M = { error = 'FFI not available, resolver bindings disabled.' }
+       setmetatable(M, {__index = function(t,k,v) error(rawget(M, 'error')) end })
+       return M
+end
 local bit = require('bit')
 local bor = bit.bor
 local band = bit.band
index 87758828cc90548c0d095d475ba155517f909816..933100313b02773e8629b6166f75b559c6ef5998 100644 (file)
@@ -12,7 +12,9 @@ day = 24 * hour
 kres = require('kres')
 trust_anchors = require('trust_anchors')
 resolve = worker.resolve
-todname = kres.str2dname
+if rawget(kres, 'str2dname') ~= nil then
+       todname = kres.str2dname
+end
 
 -- Function aliases
 -- `env.VAR returns os.getenv(VAR)`
index 6d401d061708a7f73537b159ef979ec9d39ea972..3ffb123e8e1b4ac4922f42aa4bcd6e19afe962d0 100644 (file)
@@ -1,5 +1,9 @@
+local ffi_ok, ffi = pcall(require, 'ffi')
+if not ffi_ok then
+       return { error = 'FFI not available, trust_anchors disabled.' }
+end
 local kres = require('kres')
-local C = require('ffi').C
+local C = ffi.C
 
 -- RFC5011 state table
 local key_state = {