-- 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
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)`
+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 = {