From 478746f2b255bee1cd9e741b25ca55a51a221dd3 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 8 Dec 2016 23:53:28 +0100 Subject: [PATCH] moved incoming msg time check to RsGenExchange validation method --- libretroshare/src/gxs/rsgenexchange.cc | 10 +++++++++- libretroshare/src/gxs/rsgxsnetservice.cc | 24 +++--------------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index 4fed3ec29..b69f2945f 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -1629,7 +1629,7 @@ uint32_t RsGenExchange::getSyncPeriod(const RsGxsGroupId& grpId) if(mNetService != NULL) return mNetService->getSyncAge(grpId); else - return mNetService->getDefaultSyncAge(); + return RS_GXS_DEFAULT_MSG_REQ_PERIOD; } void RsGenExchange::setSyncPeriod(const RsGxsGroupId& grpId,uint32_t age_in_secs) @@ -2723,6 +2723,14 @@ void RsGenExchange::processRecvdMessages() msg->metaData = meta; + uint32_t max_sync_age = ( mNetService != NULL)?( mNetService->getSyncAge(msg->metaData->mGroupId)):RS_GXS_DEFAULT_MSG_REQ_PERIOD; + + if(max_sync_age != 0 && msg->metaData->mPublishTs + max_sync_age < time(NULL)) + { + std::cerr << "(WW) not validating message " << msg->metaData->mMsgId << " in group " << msg->metaData->mGroupId << " because it is older than synchronisation limit. This message was probably sent by a friend node that does not accept sync limits already." << std::endl; + ok = false ; + } + #ifdef GEN_EXCH_DEBUG std::cerr << " deserialised info: grp id=" << meta->mGroupId << ", msg id=" << meta->mMsgId ; #endif diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index e8a1dee31..d73e45a68 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -266,8 +266,8 @@ static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_GXS_KEY_MISSING = 0x05 ; || defined(NXS_NET_DEBUG_4) || defined(NXS_NET_DEBUG_5) || defined(NXS_NET_DEBUG_6) || defined(NXS_NET_DEBUG_7) static const RsPeerId peer_to_print = RsPeerId(std::string("")) ; -//static const RsGxsGroupId group_id_to_print = RsGxsGroupId(std::string("cb98f4013f7b4ed4245e54ca7095925b")) ; // use this to allow to this group id only, or "" for all IDs -static const RsGxsGroupId group_id_to_print = RsGxsGroupId(std::string("")) ; // use this to allow to this group id only, or "" for all IDs +static const RsGxsGroupId group_id_to_print = RsGxsGroupId(std::string("cb98f4013f7b4ed4245e54ca7095925b")) ; // use this to allow to this group id only, or "" for all IDs +//static const RsGxsGroupId group_id_to_print = RsGxsGroupId(std::string("")) ; // use this to allow to this group id only, or "" for all IDs static const uint32_t service_to_print = 0x215 ; // use this to allow to this service id only, or 0 for all services // warning. Numbers should be SERVICE IDS (see serialiser/rsserviceids.h. E.g. 0x0215 for forums) @@ -2474,29 +2474,11 @@ void RsGxsNetService::locked_processCompletedIncomingTrans(NxsTransaction* tr) if(msg) { if(grpId.isNull()) - { grpId = msg->grpId; - GrpConfigMap::const_iterator it = mServerGrpConfigMap.find(grpId) ; - - if(it == mServerGrpConfigMap.end()) - max_sync_age = RS_GXS_DEFAULT_MSG_REQ_PERIOD ; - else - { - max_sync_age = it->second.msg_req_delay ; - - if(max_sync_age == 0 || max_sync_age > it->second.msg_keep_delay) - max_sync_age = it->second.msg_keep_delay ; - } - } - tr->mItems.pop_front(); - if(max_sync_age == 0 || msg->metaData->mPublishTs + max_sync_age > now) - msgs.push_back(msg); - else - std::cerr << "(WW) not storing message " << msg->metaData->mMsgId << " in group " << grpId << " because it is older than synchronisation limit. This message was probably sent by a friend node that does not accept sync limits already." << std::endl; - + msgs.push_back(msg); #ifdef NXS_NET_DEBUG_0 GXSNETDEBUG_PG(tr->mTransaction->PeerId(),msg->grpId) << " pushing grpId="<< msg->grpId << ", msgsId=" << msg->msgId << " to list of incoming messages" << std::endl; #endif