mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
when banning an ip address, terminate the connection of everyone with that address
This commit is contained in:
parent
7faa033855
commit
eb06d6b4ea
3 changed files with 21 additions and 5 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue