Ban players connected through multiple accounts at the same time

Post Reply
User avatar
Minix
Member
Posts: 55
Joined: Thu Nov 12, 2020 13:51
In-game: Minix

Ban players connected through multiple accounts at the same time

by Minix » Post

Hello, some people on my server like to open multiple minetest instances and log in with different accounts at the same time. I wouldn't mind this if it weren't because it produces more load on the network and results in bandwidth wasted. I was wondering if there is a mod to prevent this ? I searched around and found mods to ban players but not one for this scenario

User avatar
Festus1965
Member
Posts: 1644
Joined: Sun Jan 03, 2016 11:58
In-game: Thomas Thailand Explorer
Location: Thailand ChiangMai
Contact:

Re: Ban players connected through multiple accounts at the same time

by Festus1965 » Post

Minix wrote:
Wed Feb 10, 2021 01:08
I was wondering if there is a mod to prevent this ?
There is, ... something "like login per IP" Instance per IP ...

added: found it
* names_per_ip
Last edited by Festus1965 on Wed Feb 10, 2021 11:37, edited 1 time in total.
Human has no future (climate change)
If urgend, you find me in Roblox (as CNXThomas)

User avatar
sorcerykid
Member
Posts: 1539
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: Ban players connected through multiple accounts at the same time

by sorcerykid » Post

The following script should do what you need.

Code: Select all

local addrs = { }

minetest.register_privilege( "bypass_addr", {
        description = "Permit multiple sessions from the same IP address.",
} )

minetest.register_on_joinplayer( function ( player )
        local name = player:get_player_name( )
        local ip = minetest.get_player_information( name ).address

        if addrs[ ip ] and not minetest.check_player_privs( name, { bypass_addr = true } ) then
                minetest.kick_player( name, "Multiple sessions from the same IP address are not permitted." )
        else
                addrs[ ip ] = name
        end
end )

minetest.register_on_leaveplayer( function ( player )
        local name = player:get_player_name( )

        for k, v in pairs( addrs ) do
                if v == name then
                        addrs[ k ] = nil
                        return
                end
        end
end )

User avatar
joe7575
Member
Posts: 541
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: Ban players connected through multiple accounts at the same time

by joe7575 » Post

But two or more siblings behind a router/gateway/modem will then have problems...
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, Iron Age, Minecart, Signs Bot.

User avatar
Festus1965
Member
Posts: 1644
Joined: Sun Jan 03, 2016 11:58
In-game: Thomas Thailand Explorer
Location: Thailand ChiangMai
Contact:

Re: Ban players connected through multiple accounts at the same time

by Festus1965 » Post

joe7575 wrote:
Wed Feb 10, 2021 11:35
But two or more siblings behind a router/gateway/modem will then have problems...
This often lie I know well already, but
* it is possible to set exceptions for some ip for this, AFTER
* the siblings can proof that they are active with all accounts same time (admin keep checking this ! after also)
(as often a second account is used for home-stay and activating machines, gardening, ...)
Human has no future (climate change)
If urgend, you find me in Roblox (as CNXThomas)

User avatar
Minix
Member
Posts: 55
Joined: Thu Nov 12, 2020 13:51
In-game: Minix

Re: Ban players connected through multiple accounts at the same time

by Minix » Post

Great that's exactly what I needed, thank you !

I added a minetest.after with a delay of 1 second to wait for the client to be fully initialized because it was crashing the server every time it kicked someone.

Code: Select all

local addrs = { }

minetest.register_privilege( "bypass_addr", {
        description = "Permit multiple sessions from the same IP address.",
} )

minetest.register_on_joinplayer( function ( player )
        local name = player:get_player_name( )
        local ip = minetest.get_player_information( name ).address

        if addrs[ ip ] and not minetest.check_player_privs( name, { bypass_addr = true } ) then
                minetest.after(1.0, minetest.kick_player, name, "Multiple sessions from the same IP address are not permitted.")
        else
                addrs[ ip ] = name
        end
end )

minetest.register_on_leaveplayer( function ( player )
        local name = player:get_player_name( )

        for k, v in pairs( addrs ) do
                if v == name then
                        addrs[ k ] = nil
                        return
                end
        end
end )
For other people: create a folder named multi_ip (or the name you want really), then inside that folder create an empty file called init.lua and copy the code in it, after that copy that folder to your server's mods folder and restart.

Yes, multiple people connecting from inside the same network would be kicked as well, but admins can grant them bypass_addr

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests