v1.lua 788 B

12345678910111213141516171819202122232425262728293031323334
  1. function xban.importers.v1()
  2. local f, e = io.open(minetest.get_worldpath().."/players.iplist")
  3. if not f then
  4. return false, "Unable to open `players.iplist': "..e
  5. end
  6. for line in f:lines() do
  7. local list = line:split("|")
  8. if #list >= 2 then
  9. local banned = (list[1]:sub(1, 1) == "!")
  10. local entry
  11. entry = xban.find_entry(list[1], true)
  12. entry.banned = banned
  13. for _, name in ipairs(list) do
  14. entry.names[name] = true
  15. end
  16. if banned then
  17. entry.reason = "Banned in `players.iplist'"
  18. entry.time = os.time()
  19. entry.expires = nil
  20. entry.source = "xban:importer_v1"
  21. table.insert(entry.record, {
  22. source = entry.source,
  23. reason = entry.reason,
  24. time = entry.time,
  25. expires = nil,
  26. })
  27. end
  28. end
  29. end
  30. f:close()
  31. return true
  32. end