mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-05 04:44:19 -04:00
added new virtual method to refuse incoming msgs (similar to groups) in RsGenExchange, and used it in p3GxsTrans to refuse msgs from peers who send too much
This commit is contained in:
parent
f62028b2c1
commit
09ff94c9ec
4 changed files with 115 additions and 4 deletions
|
@ -2900,8 +2900,12 @@ void RsGenExchange::processRecvdMessages()
|
|||
std::cerr << " deserialised info: grp id=" << meta->mGroupId << ", msg id=" << meta->mMsgId ;
|
||||
#endif
|
||||
uint8_t validateReturn = VALIDATE_FAIL;
|
||||
bool accept_new_msg = acceptNewMessage(meta);
|
||||
|
||||
if(ok)
|
||||
if(!accept_new_msg && mNetService != NULL)
|
||||
mNetService->rejectMessage(meta->mMsgId) ; // This prevents reloading the message again at next sync.
|
||||
|
||||
if(ok && accept_new_msg)
|
||||
{
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit = grpMetas.find(msg->grpId);
|
||||
|
||||
|
@ -3042,8 +3046,8 @@ void RsGenExchange::processRecvdMessages()
|
|||
mNetService->rejectMessage(*it) ;
|
||||
}
|
||||
|
||||
bool RsGenExchange::acceptNewGroup(const RsGxsGrpMetaData* /*grpMeta*/ )
|
||||
{ return true; }
|
||||
bool RsGenExchange::acceptNewGroup(const RsGxsGrpMetaData* /*grpMeta*/ ) { return true; }
|
||||
bool RsGenExchange::acceptNewMessage(const RsGxsMsgMetaData* /*grpMeta*/ ) { return true; }
|
||||
|
||||
void RsGenExchange::processRecvdGroups()
|
||||
{
|
||||
|
|
|
@ -260,6 +260,17 @@ public:
|
|||
*/
|
||||
virtual bool acceptNewGroup(const RsGxsGrpMetaData *grpMeta) ;
|
||||
|
||||
/*!
|
||||
* \brief acceptNewMessage
|
||||
* Early checks if the message can be accepted. This is mainly used to check wether the group is for instance overloaded and the service wants
|
||||
* to put limitations to it.
|
||||
* Returns true unless derived in GXS services.
|
||||
*
|
||||
* \param grpMeta Group metadata to check
|
||||
* \return
|
||||
*/
|
||||
virtual bool acceptNewMessage(const RsGxsMsgMetaData *msgMeta) ;
|
||||
|
||||
bool subscribeToGroup(uint32_t& token, const RsGxsGroupId& grpId, bool subscribe);
|
||||
|
||||
/*!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue