luacheck and fixed bugs
parent
7f409e4564
commit
c6240dac77
|
@ -0,0 +1,14 @@
|
|||
max_line_length = false
|
||||
|
||||
read_globals = {
|
||||
"minetest",
|
||||
"irc",
|
||||
"irc2",
|
||||
"vector",
|
||||
}
|
||||
|
||||
globals = {
|
||||
"verbana",
|
||||
"sqlite3",
|
||||
}
|
||||
|
3
chat.lua
3
chat.lua
|
@ -3,9 +3,6 @@ verbana.chat = {}
|
|||
local data = verbana.data
|
||||
local privs = verbana.privs
|
||||
|
||||
local mod_priv = privs.moderator
|
||||
local admin_priv = privs.admin
|
||||
|
||||
function verbana.chat.tell_mods(message, ...)
|
||||
message = message:format(...)
|
||||
if minetest.global_exists('irc') then irc:say(message) end
|
||||
|
|
15
commands.lua
15
commands.lua
|
@ -724,7 +724,7 @@ register_chatcommand('asn_suspect', {
|
|||
else
|
||||
log('action', '%s suspected A%s', caller, asn)
|
||||
end
|
||||
return true, ('Suspected A%s'):format(asn)
|
||||
return true, ('Suspected A%s (%s)'):format(asn, description)
|
||||
end
|
||||
})
|
||||
|
||||
|
@ -752,7 +752,7 @@ register_chatcommand('asn_unsuspect', {
|
|||
else
|
||||
log('action', '%s unsuspected A%s', caller, asn)
|
||||
end
|
||||
return true, ('Unsuspected A%s'):format(asn)
|
||||
return true, ('Unsuspected A%s (%q)'):format(asn, description)
|
||||
end
|
||||
})
|
||||
|
||||
|
@ -802,7 +802,7 @@ register_chatcommand('asn_block', {
|
|||
log('action', '%s blocked A%s', caller, asn)
|
||||
end
|
||||
end
|
||||
return true, ('Blocked A%s'):format(asn)
|
||||
return true, ('Blocked A%s (%q)'):format(asn, description)
|
||||
end
|
||||
})
|
||||
|
||||
|
@ -830,7 +830,7 @@ register_chatcommand('asn_unblock', {
|
|||
else
|
||||
log('action', '%s unblocked A%s', caller, asn)
|
||||
end
|
||||
return true, ('Unblocked A%s'):format(asn)
|
||||
return true, ('Unblocked A%s (%q)'):format(asn, description)
|
||||
end
|
||||
})
|
||||
---------------- GET LOGS ---------------
|
||||
|
@ -1081,7 +1081,6 @@ register_chatcommand('ip_inspect', {
|
|||
timespan = 60*60*24*7
|
||||
end
|
||||
local ipint = lib_ip.ipstr_to_ipint(ipstr)
|
||||
local start_time = os.time() - timespan
|
||||
local rows = data.get_ip_associations(ipint, timespan)
|
||||
if not rows then
|
||||
return false, 'An error occurred (see server logs)'
|
||||
|
@ -1206,7 +1205,7 @@ register_chatcommand('cluster', {
|
|||
register_chatcommand('who2', {
|
||||
description='Show current connected players, statuses, and sources',
|
||||
privs={[mod_priv]=true},
|
||||
func=function(caller, params)
|
||||
func=function(caller)
|
||||
local names = {}
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
table.insert(names, player:get_player_name())
|
||||
|
@ -1382,8 +1381,8 @@ register_chatcommand('master', {
|
|||
elseif not master_id then
|
||||
return false, ('Unknown player %s'):format(master_name)
|
||||
end
|
||||
local status, message = data.set_master(alt_id, master_id)
|
||||
if not status then
|
||||
local set_status, message = data.set_master(alt_id, master_id)
|
||||
if not set_status then
|
||||
return false, ('An error occured (%s). Check logs.'):format(message)
|
||||
end
|
||||
local true_master_id, true_master_name = data.get_master(alt_id)
|
||||
|
|
42
data.lua
42
data.lua
|
@ -219,7 +219,7 @@ function verbana.data.import_from_sban(filename)
|
|||
if not insert_assoc_statement then return _error() end
|
||||
local insert_log_statement = prepare('INSERT OR IGNORE INTO connection_log (player_id, ip, asn, success, timestamp) VALUES (?, ?, ?, ?, ?)', 'insert connection log')
|
||||
if not insert_log_statement then return _error() end
|
||||
for name, ipstr, created, last_login in sban_db:urows('SELECT name, ip, created, last_login FROM playerdata') do
|
||||
for name, ipstr, created in sban_db:urows('SELECT name, ip, created FROM playerdata') do
|
||||
local player_id = player_id_by_name[name]
|
||||
if not lib_ip.is_valid_ip(ipstr) then
|
||||
return _error('%s is not a valid IPv4 address', ipstr)
|
||||
|
@ -367,7 +367,7 @@ function verbana.data.set_player_status(player_id, executor_id, status_id, reaso
|
|||
if not execute_bind_one(code, 'set player status', player_id, executor_id, status_id, reason, expires, os.time()) then return false end
|
||||
if not no_update_current then
|
||||
local last_id = db:last_insert_rowid()
|
||||
local code = 'UPDATE player SET current_status_id = ? WHERE id = ?'
|
||||
code = 'UPDATE player SET current_status_id = ? WHERE id = ?'
|
||||
if not execute_bind_one(code, 'update player last status id', last_id, player_id) then return false end
|
||||
end
|
||||
return true
|
||||
|
@ -384,7 +384,7 @@ function verbana.data.get_ip_status(ipint, create_if_new)
|
|||
if cached_status then return cached_status end
|
||||
local code = [[
|
||||
SELECT executor.id executor_id
|
||||
, executor.name executor
|
||||
, executor.name executor_name
|
||||
, status.id id
|
||||
, status.name name
|
||||
, log.timestamp timestamp
|
||||
|
@ -421,7 +421,7 @@ function verbana.data.set_ip_status(ipint, executor_id, status_id, reason, expir
|
|||
]]
|
||||
if not execute_bind_one(code, 'set ip status', ipint, executor_id, status_id, reason, expires, os.time()) then return false end
|
||||
local last_id = db:last_insert_rowid()
|
||||
local code = 'UPDATE ip SET current_status_id = ? WHERE ip = ?'
|
||||
code = 'UPDATE ip SET current_status_id = ? WHERE ip = ?'
|
||||
if not execute_bind_one(code, 'update ip last status id', last_id, ipint) then return false end
|
||||
return true
|
||||
end
|
||||
|
@ -437,7 +437,7 @@ function verbana.data.get_asn_status(asn, create_if_new)
|
|||
if cached_status then return cached_status end
|
||||
local code = [[
|
||||
SELECT executor.id executor_id
|
||||
, executor.name executor
|
||||
, executor.name executor_name
|
||||
, status.id id
|
||||
, status.name name
|
||||
, log.timestamp timestamp
|
||||
|
@ -474,7 +474,7 @@ function verbana.data.set_asn_status(asn, executor_id, status_id, reason, expire
|
|||
]]
|
||||
if not execute_bind_one(code, 'set asn status', asn, executor_id, status_id, reason, expires, os.time()) then return false end
|
||||
local last_id = db:last_insert_rowid()
|
||||
local code = 'UPDATE asn SET current_status_id = ? WHERE asn = ?'
|
||||
code = 'UPDATE asn SET current_status_id = ? WHERE asn = ?'
|
||||
if not execute_bind_one(code, 'update asn last status id', last_id, asn) then return false end
|
||||
return true
|
||||
end
|
||||
|
@ -649,6 +649,32 @@ function verbana.data.get_asn_connection_log(asn, limit)
|
|||
return verbana.util.table_reversed(t)
|
||||
end
|
||||
|
||||
function verbana.data.get_network_connection_log(asn, limit)
|
||||
local code = [[
|
||||
SELECT player.name player_name
|
||||
, player.id player_id
|
||||
, log.ip ipint
|
||||
, log.success success
|
||||
, log.timestamp timestamp
|
||||
, player_status_log.status_id player_status_id
|
||||
, ip.current_status_id ip_status_id
|
||||
FROM connection_log log
|
||||
JOIN player ON player.id == log.player_id
|
||||
LEFT JOIN player_status_log ON player_status_log.id == player.current_status_id
|
||||
JOIN ip ON ip.ip == log.ip
|
||||
LEFT JOIN ip_status_log ON ip.current_status_id == ip_status_log.id
|
||||
WHERE log.asn == ?
|
||||
ORDER BY timestamp DESC
|
||||
LIMIT ?
|
||||
]]
|
||||
if not limit or type(limit) ~= 'number' or limit < 0 then
|
||||
limit = 20
|
||||
end
|
||||
local t = get_full_ntable(code, 'asn connection log', asn, limit)
|
||||
return verbana.util.table_reversed(t)
|
||||
end
|
||||
|
||||
|
||||
function verbana.data.get_player_associations(player_id)
|
||||
local code = [[
|
||||
SELECT assoc.ip ipint
|
||||
|
@ -855,7 +881,7 @@ function verbana.data.set_master(player_id, master_id)
|
|||
if not execute_bind_one(code, 'set master 1', master_id, player_id) then
|
||||
return false, 'error'
|
||||
end
|
||||
local code = [[
|
||||
code = [[
|
||||
UPDATE player
|
||||
SET master_id = ?
|
||||
WHERE master_id = ?
|
||||
|
@ -881,7 +907,7 @@ function verbana.data.swap_master(player_id, master_id)
|
|||
if not execute_bind_one(code, 'swap master 2', player_id, master_id) then
|
||||
return false, 'error'
|
||||
end
|
||||
local code = [[
|
||||
code = [[
|
||||
UPDATE player
|
||||
SET master_id = ?
|
||||
WHERE master_id = ?
|
||||
|
|
|
@ -12,7 +12,7 @@ function verbana.settings.set_universal_verification(value)
|
|||
end
|
||||
|
||||
local function get_setting(name, default)
|
||||
local setting = settings:get('verbana.db_path')
|
||||
local setting = settings:get(name)
|
||||
if not setting or setting == '' then
|
||||
return default
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue