diff --git a/Makefile b/Makefile deleted file mode 100644 index 4b55dda..0000000 --- a/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -testdeps: - luarocks-5.1 install --local luaunit - luarocks-5.1 install --local lrexlib-PCRE2 - -test: - luajit test.lua diff --git a/README.md b/README.md index 5272510..0721263 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,9 @@ on top of ActivityPub implementations. ## Testing -requires luajit - -```sh -make testdeps -eval (luarocks-5.1 path --bin) -make test +``` +luarocks-5.1 install --local luaunit +luarocks-5.1 install --local lrexlib-PCRE2 +eval (luarocks-5.1 path --bin) +lua5.1 test.lua ``` diff --git a/conf.lua b/conf.lua deleted file mode 100644 index ee662d7..0000000 --- a/conf.lua +++ /dev/null @@ -1,6 +0,0 @@ -return { - version = 1, - wantedScripts = { - ['webfinger_allowlist'] = {accounts = {"example@example.com"}} - } -} diff --git a/config.lua b/config.lua deleted file mode 100644 index 8759268..0000000 --- a/config.lua +++ /dev/null @@ -1,36 +0,0 @@ -local env_config_path = os.getenv('APROXY_CONFIG_PATH') -local DEFAULT_CONFIG_PATH = ".;/etc/aproxy" -local config_path = env_config_path or DEFAULT_CONFIG_PATH - -function mysplit (inputstr, sep) - if sep == nil then - sep = "%s" - end - local t={} - for str in string.gmatch(inputstr, "([^"..sep.."]+)") do - table.insert(t, str) - end - return t -end - -local function findConfigFile() - for _, config_directory in ipairs(mysplit(config_path, ";")) do - local possible_config_path = config_directory .. "/" .. "conf.lua" - local fd = io.open(possible_config_path, "rb") - if fd then - local data = fd:read("*a") - fd:close() - return data - end - end - - return nil -end - -local function loadConfigFile() - local config_file_data = assert(findConfigFile(), 'no config file found, config path: ' .. config_path) - local config_file_function = assert(loadstring(config_file_data)) - return config_file_function() -end - -return loadConfigFile() diff --git a/ctx.lua b/ctx.lua index 6785f35..98ddcc8 100644 --- a/ctx.lua +++ b/ctx.lua @@ -8,15 +8,10 @@ function ctx:setWantedScripts(graph) self._wanted_scripts = graph end -function ctx:loadFromConfig(conf) - ctx:setWantedScripts(conf.wantedScripts) - ctx:loadChain() -end - function ctx:loadChain() self.compiled_chain = {} for module_name, module_config in pairs(self._wanted_scripts) do - local module = require('scripts.' .. module_name) + local module = require(module_name) local module_state = module.init(module_config) -- TODO is it possible to make module_config readonly? table.insert(self.compiled_chain, {module, module_config, module_state}) diff --git a/docker-compose.yaml b/docker-compose.yaml index 8cbaf3b..cee4eee 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -8,5 +8,4 @@ services: - 'LUA_PATH=/?.lua;/aproxy/?.lua' volumes: - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro - - ./conf.lua:/etc/aproxy/conf.lua:ro - .:/aproxy:ro diff --git a/main.lua b/main.lua index c2e8e40..13ee4f7 100644 --- a/main.lua +++ b/main.lua @@ -1,3 +1,4 @@ +local CONFIG_PATH = ".;/etc/aproxy" -- function loadConfig() -- -- TODO load config_path @@ -7,9 +8,11 @@ -- local config = loadConfig() local ctx = require('ctx') -local conf = require('config') -ctx:loadFromConfig(conf) +ctx:setWantedScripts({ + ['scripts.webfinger_allowlist'] = {accounts = {"example@example.com"}} +}) +ctx:loadChain() return function() ctx:onRequest() diff --git a/scripts/webfinger_allowlist.lua b/scripts/webfinger_allowlist.lua index b5f5c7e..4575e7e 100644 --- a/scripts/webfinger_allowlist.lua +++ b/scripts/webfinger_allowlist.lua @@ -25,12 +25,12 @@ return { author='luna@l4.pm', title='Webfinger Allowlist', description=[[ - Prevent unnecessary DB load by discarding requests to users that we know + Prevent unecessary DB load by discarding requests to users that we know won't exist. Useful for small instances. ]], - version=1, + apiVersion=1, init=webfingerInit, callbacks = { ['/.well-known/webfinger'] = webfingerCallback