Disallow the name 'singleplayer' in a multiplayer server
authorPilzAdam <pilzadam@minetest.net>
Thu, 11 Jul 2013 22:53:30 +0000 (00:53 +0200)
committerPilzAdam <pilzadam@minetest.net>
Fri, 12 Jul 2013 00:15:09 +0000 (02:15 +0200)
src/server.cpp

index 1618a091522f885f29df63c49009135026a78558..60bf422f7fbba4d8422f98bc9fccb429326809a3 100644 (file)
@@ -1922,6 +1922,15 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
                        return;
                }
 
+               if(!isSingleplayer() && strcasecmp(playername, "singleplayer") == 0)
+               {
+                       actionstream<<"Server: Player with an invalid name "
+                                       <<"tried to connect from "<<addr_s<<std::endl;
+                       SendAccessDenied(m_con, peer_id,
+                                       L"Name is not allowed");
+                       return;
+               }
+
                infostream<<"Server: New connection: \""<<playername<<"\" from "
                                <<m_con.GetPeerAddress(peer_id).serializeString()<<std::endl;