diff --git a/db.lua b/db.lua index cf803fe..15f127a 100644 --- a/db.lua +++ b/db.lua @@ -365,7 +365,7 @@ function AuthDatabase( path, name ) end self.on_login_success = function ( username, ip ) - if data[ username ].oldlogin == -1 then + if not data[ username ].oldlogin or data[ username ].oldlogin == -1 then data[ username ].oldlogin = journal.optime end users[ username ] = data[ username ].newlogin diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..3b6efa9 --- /dev/null +++ b/depends.txt @@ -0,0 +1,2 @@ +default +formspecs \ No newline at end of file diff --git a/description.txt b/description.txt index 322cec3..4b531ec 100644 --- a/description.txt +++ b/description.txt @@ -1,3 +1 @@ Auth Redux is a drop-in replacement for the builtin authentication handler of Minetest. It is designed from the ground up to be robust and secure enough for use on high-traffic Minetest servers, while also addressing a number of outstanding engine bugs. - -For more information: https://forum.minetest.net/viewtopic.php?f=9&t=20393 diff --git a/init.lua b/init.lua index aecfbd2..5f21050 100644 --- a/init.lua +++ b/init.lua @@ -75,15 +75,32 @@ minetest.register_on_prejoinplayer( function ( player_name, player_ip ) end ) minetest.register_on_joinplayer( function ( player ) - local player_name = player:get_player_name( ) - local player_ip = minetest.get_player_information( player_name ).address -- this doesn't work in singleplayer! - auth_db.on_login_success( player_name, player_ip ) - auth_db.on_session_opened( player_name ) - auth_watchdog.on_success( convert_ipv4( player_ip ) ) + local player_name + local player_oj + local player_ip + if player ~= nil then + player_name = player:get_player_name( ) + player_oj = minetest.get_player_information( player_name ) + player_ip = player_oj.address -- this doesn't work in singleplayer! + auth_db.on_login_success( player_name, player_ip ) + auth_db.on_session_opened( player_name ) + auth_watchdog.on_success( convert_ipv4( player_ip ) ) + minetest.log( "debug", "[auth_rx] in authentication database players success joined ".. player_name ) + else + minetest.log( "error", "[auth_rx] incomplete auth process on player obj nil ip obj address" ) + end end ) minetest.register_on_leaveplayer( function ( player ) - auth_db.on_session_closed( player:get_player_name( ) ) + + local name + if player ~= nil then + name = player:get_player_name( ) + auth_db.on_session_closed( name ) + minetest.log( "debug", "[auth_rx] player "..name.." leaving" ) + else + minetest.log( "error", "[auth_rx] incomplete player leaving without writing in dbx due nil object" ) + end end ) minetest.register_on_shutdown( function( ) @@ -144,3 +161,4 @@ auth_filter.is_enabled = true __commands( { auth_db = auth_db, auth_filter = auth_filter } ) +print("[auth_rx] mod authentication database loaded" ) diff --git a/mod.conf b/mod.conf index df6b094..f84a0ea 100644 --- a/mod.conf +++ b/mod.conf @@ -2,3 +2,6 @@ name = auth_rx title = Auth Redux author = sorcerykid license = MIT +depends = default, formspecs +optional_depends = +description = Auth Redux is a drop-in replacement for the builtin authentication handler of Minetest. It is designed from the ground up to be robust and secure enough for use on high-traffic Minetest servers, while also addressing a number of outstanding engine bugs.