From 50279ffa1e53bf26c00f5dda7c4dc7e62e20b96e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= <ondrej@sury.org> Date: Mon, 16 Jan 2017 15:37:39 +0100 Subject: [PATCH] Remove the code that allowed FFI to be optional --- daemon/lua/kres.lua | 8 +------- daemon/lua/trust_anchors.lua | 26 ++------------------------ modules/policy/policy.lua | 5 +---- 3 files changed, 4 insertions(+), 35 deletions(-) diff --git a/daemon/lua/kres.lua b/daemon/lua/kres.lua index 75f2332d4..a24a73a46 100644 --- a/daemon/lua/kres.lua +++ b/daemon/lua/kres.lua @@ -1,13 +1,7 @@ -- 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_ok -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 +ffi = require('ffi') local bit = require('bit') local bor = bit.bor local band = bit.band diff --git a/daemon/lua/trust_anchors.lua b/daemon/lua/trust_anchors.lua index 7416e9597..9f1df3fb9 100644 --- a/daemon/lua/trust_anchors.lua +++ b/daemon/lua/trust_anchors.lua @@ -39,30 +39,8 @@ local function bootstrap(url, ca) return rr end --- Load the module (check for FFI) -local ffi_ok, ffi = pcall(require, 'ffi') -if not ffi_ok then - -- Simplified TA management, no RFC5011 automatics - return { - -- Reuse Lua/C global function - add = trustanchor, - -- Simplified trust anchor management - config = function (path) - if not path then return end - if not io.open(path, 'r') then - local rr, err = bootstrap() - if not rr then print(err) return false end - local keyfile = assert(io.open(path, 'w')) - keyfile:write(rr..'\n') - end - for line in io.lines(path) do - trustanchor(line) - end - end, - -- Disabled - set_insecure = function () error('[ ta ] FFI not available, this function is disabled') end, - } -end +-- Load the module +local ffi = require 'ffi' local kres = require('kres') local C = ffi.C diff --git a/modules/policy/policy.lua b/modules/policy/policy.lua index 5e1bc45bd..7e3ec0d44 100644 --- a/modules/policy/policy.lua +++ b/modules/policy/policy.lua @@ -1,5 +1,6 @@ local kres = require('kres') local bit = require('bit') +local ffi = require('ffi') -- Counter of unique rules local nextid = 0 @@ -30,10 +31,6 @@ if has_socket then return s end end -local has_ffi, ffi = pcall(require, 'ffi') -if not has_ffi then - socket_client = function () return error("missing ffi library, required for this policy") end -end local function parse_target(target) local addr, port = target:match '([^@]*)@?(.*)' -- GitLab