when banning an ip address, terminate the connection of everyone with that address

This commit is contained in:
Max-Wilhelm Bruker
2012-01-29 20:55:24 +01:00
parent 7faa033855
commit eb06d6b4ea
3 changed files with 21 additions and 5 deletions

View File

@@ -505,16 +505,21 @@ Response::ResponseCode ServerSocketInterface::cmdBanFromServer(const Command_Ban
servatrice->execSqlQuery(query);
servatrice->dbMutex.unlock();
QList<ServerSocketInterface *> userList = servatrice->getUsersWithAddressAsList(QHostAddress(address));
ServerSocketInterface *user = static_cast<ServerSocketInterface *>(server->getUsers().value(userName));
if (user) {
if (user && !userList.contains(user))
userList.append(user);
if (!userList.isEmpty()) {
Event_ConnectionClosed event;
event.set_reason(Event_ConnectionClosed::BANNED);
if (cmd.has_visible_reason())
event.set_reason_str(cmd.visible_reason());
SessionEvent *se = user->prepareSessionEvent(event);
user->sendProtocolItem(*se);
delete se;
user->deleteLater();
for (int i = 0; i < userList.size(); ++i) {
SessionEvent *se = userList[i]->prepareSessionEvent(event);
userList[i]->sendProtocolItem(*se);
userList[i]->deleteLater();
delete se;
}
}
return Response::RespOk;