aboutsummaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-08-12 11:55:51 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-08-12 11:55:51 +0300
commit7aa72c56b6a3d3af8a7dbef36d3a71fa311a7242 (patch)
tree7d4be0b6e2c2734eacf6a8adcf4d12e8e0966e55 /src/server.cpp
parent3028bbb95bb7f61bd7756527aaa5513f1e500ccd (diff)
parent5784c14ab798847248e4682ef28434767a549fc6 (diff)
downloadminetest-7aa72c56b6a3d3af8a7dbef36d3a71fa311a7242.tar.gz
minetest-7aa72c56b6a3d3af8a7dbef36d3a71fa311a7242.tar.bz2
minetest-7aa72c56b6a3d3af8a7dbef36d3a71fa311a7242.zip
Merge remote-tracking branch 'speedprog/banByIp'
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/server.cpp b/src/server.cpp
index 176a13e38..65ea45330 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -1063,6 +1063,7 @@ Server::Server(
m_env(new ServerMap(mapsavedir), this),
m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, this),
m_authmanager(mapsavedir+"/auth.txt"),
+ m_banmanager(mapsavedir+"/ipban.txt"),
m_thread(this),
m_emergethread(this),
m_time_counter(0),
@@ -1834,6 +1835,10 @@ void Server::AsyncRunStep()
// Auth stuff
if(m_authmanager.isModified())
m_authmanager.save();
+
+ //Bann stuff
+ if(m_banmanager.isModified())
+ m_banmanager.save();
// Map
JMutexAutoLock lock(m_env_mutex);
@@ -1923,6 +1928,14 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
<<peer_id<<" not found"<<std::endl;
return;
}
+
+ // drop player if is ip is banned
+ if(m_banmanager.isIpBanned(peer->address.serializeString())){
+ SendAccessDenied(m_con, peer_id,
+ L"Your ip is banned!");
+ m_con.deletePeer(peer_id, false);
+ return;
+ }
u8 peer_ser_ver = getClient(peer->id)->serialization_version;
@@ -1959,7 +1972,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
//peer->serialization_version = deployed;
getClient(peer->id)->pending_serialization_version = deployed;
-
+
if(deployed == SER_FMT_VER_INVALID)
{
derr_server<<DTIME<<"Server: Cannot negotiate "