From 896a64e835da666b7a5c56c6da48c2373b222454 Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Fri, 9 Jun 2023 00:11:03 -0400 Subject: [PATCH] improve the auth handler on fails for recent versions of mineshit * i dont use troltest 5.6 version so i try to provide compatibility layer in some way this means that for older engines we dont have in 0.4.X or 5.1.X way to know what was the fail player, 5.2+ has such feature. --- init.lua | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index 3d02216..e4e9c8e 100644 --- a/init.lua +++ b/init.lua @@ -23,12 +23,28 @@ AuthInitFile( world_path, "auth.db" ) local auth_filter = AuthFilter( world_path, "greenlist.mt" ) local auth_db = AuthDatabase( world_path, "auth.db" ) local auth_watchdog = AuthWatchdog( ) +local is_50 = minetest.has_feature("object_use_texture_alpha") +local is_54 = minetest.has_feature("object_use_texture_alpha") -if minetest.register_on_auth_fail then - minetest.register_on_auth_fail( function ( player_name, player_ip ) - auth_db.on_login_failure( player_name, player_ip ) - auth_watchdog.on_failure( convert_ipv4( player_ip ) ) - end ) +if is_50 then + if minetest.register_on_auth_fail then + minetest.register_on_auth_fail( function ( player_name, player_ip ) + auth_db.on_login_failure( player_name, player_ip ) + auth_watchdog.on_failure( convert_ipv4( player_ip ) ) + end ) + end +end + +if is_54 then + if minetest.register_on_authplayer then + minetest.register_on_authplayer( function ( player_name, player_ip, is_success ) + if is_success then + return + end + auth_db.on_login_failure( player_name, player_ip ) + auth_watchdog.on_failure( convert_ipv4( player_ip ) ) + end ) + end end minetest.register_on_prejoinplayer( function ( player_name, player_ip )