|
|
@ -34,7 +34,6 @@ bansFile = script_path().."/".."banned.json"
|
|
|
|
|
|
|
|
|
|
|
|
loggedIn = {} -- {{"koncord", "127.0.0.1"}}
|
|
|
|
loggedIn = {} -- {{"koncord", "127.0.0.1"}}
|
|
|
|
banned = {}
|
|
|
|
banned = {}
|
|
|
|
|
|
|
|
|
|
|
|
if type(admins) ~= "table" then
|
|
|
|
if type(admins) ~= "table" then
|
|
|
|
error("\"admins.lua\" is not configured.")
|
|
|
|
error("\"admins.lua\" is not configured.")
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -42,7 +41,7 @@ end
|
|
|
|
local json = require ("dkjson");
|
|
|
|
local json = require ("dkjson");
|
|
|
|
|
|
|
|
|
|
|
|
function ban(addr, admin, reason, dontInsert)
|
|
|
|
function ban(addr, admin, reason, dontInsert)
|
|
|
|
entry = {
|
|
|
|
local entry = {
|
|
|
|
address = addr,
|
|
|
|
address = addr,
|
|
|
|
date = os.date("%s"),
|
|
|
|
date = os.date("%s"),
|
|
|
|
by = admin,
|
|
|
|
by = admin,
|
|
|
@ -71,14 +70,13 @@ function loadBans()
|
|
|
|
file:close()
|
|
|
|
file:close()
|
|
|
|
|
|
|
|
|
|
|
|
banned = json.decode(content, 1, nil)
|
|
|
|
banned = json.decode(content, 1, nil)
|
|
|
|
for idx, entry in pairs(banned) do
|
|
|
|
for _, entry in pairs(banned) do
|
|
|
|
ban(entry.address, entry.admin, entry.reason, true)
|
|
|
|
ban(entry.address, entry.admin, entry.reason, true)
|
|
|
|
unban(entry.address)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function saveBans()
|
|
|
|
function saveBans()
|
|
|
|
local content = json.encode(banned, { indent = true, keyorder = {"address", "date", "by", "reason"}})
|
|
|
|
local content = json.encode(banned, { indent = true, --[[keyorder = {"address", "date", "by", "reason"}]]})
|
|
|
|
if content ~= "null" then
|
|
|
|
if content ~= "null" then
|
|
|
|
local file = assert(io.open(bansFile, 'w+b'), 'Error loading file: ' .. bansFile)
|
|
|
|
local file = assert(io.open(bansFile, 'w+b'), 'Error loading file: ' .. bansFile)
|
|
|
|
file:write(content)
|
|
|
|
file:write(content)
|
|
|
@ -141,7 +139,7 @@ function OnCommand(command, v, address)
|
|
|
|
|
|
|
|
|
|
|
|
if command == "ban" then
|
|
|
|
if command == "ban" then
|
|
|
|
print("Ban address: " .. v["address"])
|
|
|
|
print("Ban address: " .. v["address"])
|
|
|
|
ban(v["address"])
|
|
|
|
ban(v["address"], loggedIn[loginId][1], v["reason"])
|
|
|
|
elseif command == "unban" then
|
|
|
|
elseif command == "unban" then
|
|
|
|
print("Unban address: " .. v["address"])
|
|
|
|
print("Unban address: " .. v["address"])
|
|
|
|
unban(v["address"])
|
|
|
|
unban(v["address"])
|
|
|
|