aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElias Fleckenstein <54945686+EliasFleckenstein03@users.noreply.github.com>2021-03-19 21:45:29 +0100
committerGitHub <noreply@github.com>2021-03-19 21:45:29 +0100
commit492110a640dd8d01838e95aba00f650b37b7ed11 (patch)
treea0fe2050dcdd7a4a915fd769f4746a100b770fe4
parent59a1b53d675ee404cb32564262282a3ecf69d94c (diff)
downloadminetest-492110a640dd8d01838e95aba00f650b37b7ed11.tar.gz
minetest-492110a640dd8d01838e95aba00f650b37b7ed11.tar.bz2
minetest-492110a640dd8d01838e95aba00f650b37b7ed11.zip
Check for duplicate login in TOSERVER_INIT handler (#11017)
i.e. checks for duplicate logins before sending all media data to the client.
-rw-r--r--src/network/serverpackethandler.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp
index b863e1828..5b378a083 100644
--- a/src/network/serverpackethandler.cpp
+++ b/src/network/serverpackethandler.cpp
@@ -174,6 +174,16 @@ void Server::handleCommand_Init(NetworkPacket* pkt)
return;
}
+ RemotePlayer *player = m_env->getPlayer(playername);
+
+ // If player is already connected, cancel
+ if (player && player->getPeerId() != PEER_ID_INEXISTENT) {
+ actionstream << "Server: Player with name \"" << playername <<
+ "\" tried to connect, but player with same name is already connected" << std::endl;
+ DenyAccess(peer_id, SERVER_ACCESSDENIED_ALREADY_CONNECTED);
+ return;
+ }
+
m_clients.setPlayerName(peer_id, playername);
//TODO (later) case insensitivity