From d47e87e390b018ac5510bb2143eb0e66f6bc2eeb Mon Sep 17 00:00:00 2001 From: Diego Martinez Date: Wed, 21 May 2014 07:07:37 -0300 Subject: Allow importing old databases. Currently: - Minetest (`ipban.txt') - xban v1 (`players.iplist') --- importers/minetest.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 importers/minetest.lua (limited to 'importers/minetest.lua') diff --git a/importers/minetest.lua b/importers/minetest.lua new file mode 100644 index 0000000..e19c3c6 --- /dev/null +++ b/importers/minetest.lua @@ -0,0 +1,29 @@ + +function xban.importers.minetest() + local f, e = io.open(minetest.get_worldpath().."/ipban.txt") + if not f then + return false, "Unable to open `ipban.txt': "..e + end + for line in f:lines() do + local ip, name = line:match("([^|]+)%|(.+)") + if ip and name then + local entry + entry = xban.find_entry(ip, true) + entry.banned = true + entry.reason = "Banned in `ipban.txt'" + entry.names[name] = true + entry.names[ip] = true + entry.time = os.time() + entry.expires = nil + entry.source = "xban:importer_minetest" + table.insert(entry.record, { + source = entry.source, + reason = entry.reason, + time = entry.time, + expires = nil, + }) + end + end + f:close() + return true +end -- cgit v1.2.3