💾 Archived View for gemini.conman.org › extensions › port70 › handlers › blackhole.lua captured on 2020-10-31 at 23:59:41.
-=-=-=-=-=-=-
-- *********************************************************************** -- -- Module to prove a point about spidering gopherspace -- Copyright 2019 by Sean Conner. -- -- This program is free software: you can redistribute it and/or modify it -- under the terms of the GNU General Public License as published by the -- Free Software Foundation, either version 3 of the License, or (at your -- option) any later version. -- -- This program is distributed in the hope that it will be useful, but -- WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -- Public License for more details. -- -- You should have received a copy of the GNU General Public License along -- with this program. If not, see <http://www.gnu.org/licenses/>. -- -- Comments, questions and criticisms can be sent to: sean@conman.org -- *********************************************************************** -- luacheck: globals init handler -- luacheck: ignore 611 local uuid = require "org.conman.uuid" local mklink = require "port70.mklink" local table = require "table" local ipairs = ipairs local tostring = tostring _ENV = {} -- ************************************************************************ function init(conf) if not conf.prompt then return false,"missing prompt" end if not conf.verbiage then return false,"missing verbiage" end return true end -- ************************************************************************ function handler(conf,request) local res = {} for _,text in ipairs(conf.verbiage) do table.insert(res,mklink {type = 'info' , display = text }) end -- ---------------------------------- -- Try not to DoS ourselves here ... -- ---------------------------------- local blob if #request.match[2] == 0 then blob = tostring(uuid()) elseif #request.match[2] >= 16384 then blob = tostring(uuid()) else blob = request.match[2] end table.insert(res,mklink { type = 'dir', display = conf.prompt, selector = request.match[1] .. request.match[2] .. tostring(uuid(uuid.URL,blob)), }) return true,table.concat(res) .. ".\r\n" end -- ************************************************************************ return _ENV