Added size limit for chat types - Public, Private, Lobby, Distant

Set the size limit for private and distant chat to unlimited.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7761 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-12-16 10:39:56 +00:00
parent 93f77a0e2c
commit 55be6675af
6 changed files with 60 additions and 17 deletions

View file

@ -509,25 +509,42 @@ void p3ChatService::handleRecvChatAvatarItem(RsChatAvatarItem *ca)
RsServer::notify()->notifyPeerHasNewAvatar(ca->PeerId().toStdString()) ;
}
int p3ChatService::getMaxMessageSecuritySize()
uint32_t p3ChatService::getMaxMessageSecuritySize(int type)
{
switch (type)
{
case RS_CHAT_TYPE_PUBLIC:
case RS_CHAT_TYPE_LOBBY:
return MAX_MESSAGE_SECURITY_SIZE;
case RS_CHAT_TYPE_PRIVATE:
case RS_CHAT_TYPE_DISTANT:
return 0; // unlimited
}
std::cerr << "p3ChatService::getMaxMessageSecuritySize: Unknown chat type " << type << std::endl;
return MAX_MESSAGE_SECURITY_SIZE;
}
bool p3ChatService::checkForMessageSecurity(RsChatMsgItem *ci)
{
// Remove too big messages
if (ci->message.length() > MAX_MESSAGE_SECURITY_SIZE && (ci->chatFlags & RS_CHAT_FLAG_LOBBY))
if (ci->chatFlags & RS_CHAT_FLAG_LOBBY)
{
std::ostringstream os;
os << getMaxMessageSecuritySize();
uint32_t maxMessageSize = getMaxMessageSecuritySize(RS_CHAT_TYPE_LOBBY);
if (maxMessageSize > 0 && ci->message.length() > maxMessageSize)
{
std::ostringstream os;
os << getMaxMessageSecuritySize(RS_CHAT_TYPE_LOBBY);
ci->message = "**** Security warning: Message bigger than ";
ci->message += os.str();
ci->message += " characters, forwarded to you by ";
ci->message += rsPeers->getPeerName(ci->PeerId());
ci->message += ", dropped. ****";
return false;
ci->message = "**** Security warning: Message bigger than ";
ci->message += os.str();
ci->message += " characters, forwarded to you by ";
ci->message += rsPeers->getPeerName(ci->PeerId());
ci->message += ", dropped. ****";
return false;
}
}
// The following code has been suggested, but is kept suspended since it is a bit too much restrictive.

View file

@ -159,8 +159,10 @@ class p3ChatService: public p3Service, public DistantChatService, public Distrib
/*!
* Return the max message size for security forwarding
* @param type RS_CHAT_TYPE_...
* return 0 unlimited
*/
static int getMaxMessageSecuritySize();
static uint32_t getMaxMessageSecuritySize(int type);
/*!
* Checks message security, especially remove billion laughs attacks