checkpoint

master
y 2019-07-03 20:57:32 +01:00
parent fe0cd348cc
commit 939b677300
10 changed files with 98 additions and 37 deletions

3
TODO Normal file
View File

@ -0,0 +1,3 @@
add a "report" command so that players can log issues w/ other players for the mods to peruse
in login_handling.lua: register_on_auth_fail should log

View File

@ -168,7 +168,7 @@ minetest.register_chatcommand('unverify', {
minetest.set_player_privs(player_name, verbana.settings.unverified_privs)
local player = minetest.get_player_by_name(player_name)
if player then
player:set_pos(verbana.settings.verification_pos)
player:set_pos(verbana.settings.unverified_spawn_pos)
end
if reason then
verbana.log('action', '%s unverified %s because %s', caller, player_name, reason)

View File

@ -21,7 +21,7 @@ dofile(verbana.modpath .. '/privs.lua')
-- libraries
dofile(verbana.modpath .. '/util.lua')
dofile(verbana.modpath .. '/lib_ip.lua')
dofile(verbana.modpath .. '/asn.lua')
dofile(verbana.modpath .. '/lib_asn.lua')
-- connect to the DB - MAKE SURE TO CLEAN UP ALL "insecure" access points!
local sql = verbana.ie.require('lsqlite3') -- TODO what happens if this isn't installed? ....

0
lib_geo.lua Normal file
View File

View File

@ -9,12 +9,11 @@ local timer = 0
local verification_jail = verbana.settings.verification_jail
local check_player_privs = minetest.check_player_privs
local spawn_pos = verbana.settings.spawn_pos
local verification_pos = verbana.settings.verification_pos
local unverified_spawn_pos = verbana.settings.unverified_spawn_pos
local verification_jail_period = verbana.settings.verification_jail_period
local function should_rejail(player)
local name = player:get_player_name()
if not check_player_privs(name, {unverified = true}) then
local function should_rejail(player, player_status)
if player_status.status_id ~= verbana.data.player_status.unverified.id then
return false
end
local pos = player:get_pos()
@ -25,11 +24,13 @@ local function should_rejail(player)
)
end
local function should_unjail(player)
local name = player:get_player_name()
if check_player_privs(name, {unverified = true}) then
local function should_unjail(player, player_status)
if player_status.status_id == verbana.data.player_status.unverified.id then
return false
elseif verbana.privs.is_privileged(player:get_player_name()) then
return false
end
local pos = player:get_pos()
return (
verification_jail.x[1] <= pos.x and pos.x <= verification_jail.x[2] and
@ -46,8 +47,14 @@ if USING_VERIFICATION_JAIL then
end
timer = 0
for _, player in ipairs(minetest.get_connected_players()) do
if should_rejail(player) then
player:set_pos(verification_pos)
-- TODO this is pretty heavy
local name = player:get_player_name()
local player_id = verbana.data.get_player_id(name)
local player_status = verbana.data.get_player_status(player_id)
if should_rejail(player, player_status) then
player:set_pos(unverified_spawn_pos)
elseif should_unjail(player, player_status) then
player:set_pos(spawn_pos)
end
end
end)
@ -218,10 +225,10 @@ minetest.register_on_newplayer(function(player)
verbana.log('error', 'error setting unverified status on %s', name)
end
minetest.set_player_privs(name, verbana.settings.unverified_privs)
player:set_pos(verbana.settings.verification_pos)
player:set_pos(unverified_spawn_pos)
-- wait a second before moving the player to the verification area
-- because other mods sometimes try to move them around as well
minetest.after(1, function() move_to(name, verbana.settings.verification_pos) end)
minetest.after(1, function() move_to(name, unverified_spawn_pos) end)
verbana.log('action', 'new player %s sent to verification', name)
else
verbana.data.set_player_status(
@ -243,11 +250,18 @@ minetest.register_on_joinplayer(function(player)
verbana.chat.tell_mods(('*** Player %s from A%s (%s) is unverified.'):format(name, asn, asn_description))
end
if USING_VERIFICATION_JAIL then
if should_rejail(player) then
player:set_pos(verification_pos)
elseif should_unjail(player) then
local player_id = verbana.data.get_player_id(name)
local player_status = verbana.data.get_player_status(player_id)
if should_rejail(player, player_status) then
player:set_pos(unverified_spawn_pos)
elseif should_unjail(player, player_status) then
player:set_pos(spawn_pos)
end
end
end)
minetest.register_on_auth_fail(function(name, ip)
-- TODO log failure
end)

View File

@ -2,8 +2,18 @@ if not verbana then verbana = {} end
verbana.privs = {}
minetest.register_privilege('ban_admin', 'administrator for verification/bans')
-- note: unverified is not registered as a priv so you don't get it with "grant all"...
verbana.privs.admin = 'ban_admin' -- TODO load from settings
verbana.privs.moderator = 'basic_privs' -- TODO load from settings
verbana.privs.unverified = 'unverified' -- TODO load from settings
function verbana.privs.is_admin(name)
return minetest.check_player_privs(name, {[verbana.privs.admin] = true})
end
function verbana.privs.is_moderator(name)
return minetest.check_player_privs(name, {[verbana.privs.moderator] = true})
end
function verbana.privs.is_privileged(name)
return verbana.privs.is_admin(name) or verbana.privs.is_moderator(name)
end

View File

@ -1,24 +1,21 @@
verbana.settings = {}
-- config: privs_to_whitelist: if a player has this/these privs, they are treated as whitelisted
local function settings_get_set(name, default)
-- "set" here is as in a "set of items"
local value = minetest.settings:get(name)
if value then
local set = {}
-- TODO split the value on commas etc
else
return default
local settings = minetest.settings
local function get_jail_bounds()
local bounds = settings:get('verbana.jail_bounds')
if not bounds or bounds == '' then
return nil
end
end
-- TODO load priv settings
verbana.settings.verified_privs = minetest.string_to_privs(settings:get('default_privs') or '')
verbana.settings.unverified_privs = minetest.string_to_privs(settings:get('verbana.unverified_privs') or '')
verbana.settings.privs_to_whitelist = minetest.string_to_privs(settings:get('verbana.privs_to_whitelist') or '')
verbana.settings.universal_verification = settings:get_bool('verbana.universal_verification', false)
verbana.settings.verified_privs = ...
verbana.settings.unverified_privs = settings_get_set('...', {unverified = true, shout = true})
verbana.settings.privs_to_whitelist = nil
verbana.settings.universal_verification = false -- TODO this should be loaded from mod_storage?
verbana.settings.spawn_pos = {x = 111, y = 13, z = -507} -- TODO this should be grabbed from the spawn mod
verbana.settings.verification_pos = {x = 172, y = 29, z = -477} -- TODO load from config
verbana.settings.verification_jail = {x={159, 184}, y={27, 36}, z={-493, -472}}
verbana.settings.verification_jail_period = nil
verbana.settings.spawn_pos = minetest.string_to_pos(settings:get('static_spawnpoint') or '(0,0,0)')
verbana.settings.unverified_spawn_pos = minetest.string_to_pos(settings:get('verbana.unverified_spawn_pos') or '(0,0,0)')
verbana.settings.jail_bounds = get_jail_bounds()
verbana.settings.jail_check_period = settings:get('static_spawnpoint')

View File

@ -0,0 +1,28 @@
# The privilege of the Verbana adminstrator(s)
verbana.admin_priv (Priv required for Verbana administration) string ban_admin
# The privilege of the Verbana moderator(s)
verbana.moderator_priv (Priv required for Verbana moderation) string basic_privs
# Comma delimited
verbana.unverified_privs (Privs for unverified users) string shout
# Comma delimited. If a player has all of the listed privileges, they skip suspicious network checks.
verbana.privs_to_whitelist (Privs required to bypass suspicious network checks) string
# Coordinates where unverified players spawn
verbana.unverified_spawn_pos (Where unverified players spawn) string 0,0,0
# Coordinates bounding the verification jail area, if it exists.
# Format: x1,x2,y1,y2,z1,z2
verbana.jail_bounds (Bounding box of the verification jail) string
# Period between checks that unverified players haven't escaped the verification area
verbana.jail_check_period (Timespan between checks for verification jail escapees) int
# If enabled, all new users must be verified. Otherwise, only players from suspicious networks.
verbana.universal_verification (Enable verification for all new users) bool false
# In debug mode, Verbana will not block any players from connecting, change their privileges,
# or anything else that affects gameplay.
verbana.debug_mode (Whether to run verbana in debug mode) bool true

View File

@ -51,3 +51,12 @@ function verbana.util.parse_time(text)
end
return n * time_units[unit]
end
--function verbana.util.string_split(str, delim)
-- if not str:find(delim) then return {str} end
-- local bits = {}
-- while str ~= '' do
--
-- end
-- local TODO = 1 / nil
--end