Page 1 of 1

New users to only login from same subnet

PostPosted: Thu Mar 09, 2017 08:15
by rgh
Is it possible to tell the server that new users can only login if doing so from the same subnet? Once a user has logged in the first time, they would be allowed to connect from any ip address?

If this isn't possible, are there any mods that do similar things, involving account creation and ip addresses that I could look at, with a view to adapting?

Re: New users to only login from same subnet

PostPosted: Thu Mar 09, 2017 15:20
by octacian
Yes, it's possible through a mod. Essentially, you want to use minetest.register_on_prejoinplayer which if you return false, "<msg>" will prevent the player from logging in. I forgot the function, but it's also easily possible to get the player's IP address. If your server had a static IP, this could probably then be compared. At that point, if it comes from a non-local IP and is a new player, you can return false and a message. Otherwise, if it's a local IP or a past player, return true.

I'm not sure as to what the functions are to do this, and you may even have to use minetest.register_on_newplayer. Take a look at the Lua API and search around.

Re: New users to only login from same subnet

PostPosted: Fri Mar 10, 2017 11:29
by rgh
Thanks. I'll follow those suggestions up & see if I can get something working.