From aa194caea3d935a6a2d5a7c23fb54a544011ccdd Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 31 Jan 2016 20:27:53 -0500 Subject: [PATCH] fixed bug preventing save of routage info in distant messaging --- libretroshare/src/grouter/p3grouter.cc | 26 ++++++++++++------- libretroshare/src/services/p3msgservice.cc | 1 + .../gui/statistics/GlobalRouterStatistics.cpp | 10 ++++--- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/libretroshare/src/grouter/p3grouter.cc b/libretroshare/src/grouter/p3grouter.cc index f8bccaa0f..bbee74c8f 100644 --- a/libretroshare/src/grouter/p3grouter.cc +++ b/libretroshare/src/grouter/p3grouter.cc @@ -191,6 +191,7 @@ #include "turtle/p3turtle.h" #include "gxs/rsgixs.h" #include "retroshare/rspeers.h" +#include "retroshare/rsreputations.h" #include "p3grouter.h" #include "grouteritems.h" @@ -1170,8 +1171,6 @@ void p3GRouter::locked_collectAvailableFriends(const GRouterKeyId& gxs_id,const for(uint32_t i=0;i > mypairs ; for(uint32_t i=0;i=0 && n::iterator it=_pending_messages.begin();it!=_pending_messages.end();) - if( (it->second.data_status == RS_GROUTER_DATA_STATUS_DONE && - (!(it->second.routing_flags & GRouterRoutingInfo::ROUTING_FLAGS_IS_DESTINATION) + if( (it->second.data_status == RS_GROUTER_DATA_STATUS_DONE && (!(it->second.routing_flags & GRouterRoutingInfo::ROUTING_FLAGS_IS_DESTINATION) || it->second.received_time_TS + MAX_DESTINATION_KEEP_TIME < now)) || ((it->second.received_time_TS + GROUTER_ITEM_MAX_CACHE_KEEP_TIME < now) && !(it->second.routing_flags & GRouterRoutingInfo::ROUTING_FLAGS_IS_ORIGIN) @@ -1490,7 +1487,6 @@ void p3GRouter::handleIncomingReceiptItem(RsGRouterSignedReceiptItem *receipt_it // in the proxy case, we should only store the receipt. GRouterClientService *client_service = NULL; - GRouterServiceId service_id ; GRouterMsgPropagationId mid = 0 ; { @@ -1953,7 +1949,11 @@ bool p3GRouter::verifySignedDataItem(RsGRouterAbstractMsgItem *item) { try { - RsTlvSecurityKey signature_key ; + if(rsReputations->isIdentityBanned(item->signature.keyId)) + { + std::cerr << "(WW) received global router message from banned identity " << item->signature.keyId << ". Rejecting the message." << std::endl; + return false ; + } uint32_t data_size = item->signed_data_size() ; RsTemporaryMemory data(data_size) ; @@ -1966,12 +1966,20 @@ bool p3GRouter::verifySignedDataItem(RsGRouterAbstractMsgItem *item) uint32_t error_status ; - + if(!mGixs->validateData(data,data_size,item->signature,true,error_status)) { switch(error_status) { - case RsGixs::RS_GIXS_ERROR_KEY_NOT_AVAILABLE: std::cerr << "(EE) Key for GXS Id " << item->signature.keyId << " is not available. Cannot verify." << std::endl; + case RsGixs::RS_GIXS_ERROR_KEY_NOT_AVAILABLE: + { + std::list peer_ids ; + peer_ids.push_back(item->PeerId()) ; + + std::cerr << "(EE) Key for GXS Id " << item->signature.keyId << " is not available. Cannot verify. Asking key to peer " << item->PeerId() << std::endl; + + mGixs->requestKey(item->signature.keyId,peer_ids) ; // request the key around + } break ; case RsGixs::RS_GIXS_ERROR_SIGNATURE_MISMATCH: std::cerr << "(EE) Signature mismatch. Spoofing/Corrupted/MITM?." << std::endl; break ; diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index 0473d0e3c..d3e37ea90 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -2032,6 +2032,7 @@ void p3MsgService::sendDistantMsgItem(RsMsgItem *msgitem) RS_STACK_MUTEX(mMsgMtx) ; _ongoing_messages[grouter_message_id] = msgitem->msgId ; } + IndicateConfigChanged(); // save _ongoing_messages } diff --git a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp index 1ec95b2f3..e5a35b28c 100644 --- a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp @@ -54,7 +54,7 @@ #define COL_SEND 8 #define COL_DUPLICATION_FACTOR 9 -static const int PARTIAL_VIEW_SIZE = 5 ; +static const int PARTIAL_VIEW_SIZE = 9 ; static const int MAX_TUNNEL_REQUESTS_DISPLAY = 10 ; static QColor colorScale(float f) @@ -350,7 +350,6 @@ void GlobalRouterStatisticsWidget::updateContent() //if(!is_null) //{ ids = QString::fromStdString(it->first.toStdString())+" : " ; - mMaxWheelZoneX = ox+2*cellx + fm_monospace.width(ids); painter.drawText(ox+2*cellx,oy+celly,ids) ; for(uint32_t i=0;igetIdDetails(current_id,iddetails)) painter.drawText(current_width+cellx, current_oy+celly, QString::fromUtf8(iddetails.mNickname.c_str())) ; + else + painter.drawText(current_width+cellx, current_oy+celly, tr("[Unknown identity]")) ; mMaxWheelZoneY = oy+celly ; @@ -415,10 +417,10 @@ void GlobalRouterStatisticsWidget::wheelEvent(QWheelEvent *e) return ; } - if(e->delta() > 0 && mCurrentN+PARTIAL_VIEW_SIZE/2+1 < mNumberOfKnownKeys) + if(e->delta() < 0 && mCurrentN+PARTIAL_VIEW_SIZE/2+1 < mNumberOfKnownKeys) mCurrentN++ ; - if(e->delta() < 0 && mCurrentN > PARTIAL_VIEW_SIZE/2+1) + if(e->delta() > 0 && mCurrentN > PARTIAL_VIEW_SIZE/2+1) mCurrentN-- ; updateContent();