fixed bug preventing save of routage info in distant messaging

This commit is contained in:
csoler 2016-01-31 20:27:53 -05:00
parent a85b5d2fab
commit aa194caea3
3 changed files with 24 additions and 13 deletions

View file

@ -191,6 +191,7 @@
#include "turtle/p3turtle.h" #include "turtle/p3turtle.h"
#include "gxs/rsgixs.h" #include "gxs/rsgixs.h"
#include "retroshare/rspeers.h" #include "retroshare/rspeers.h"
#include "retroshare/rsreputations.h"
#include "p3grouter.h" #include "p3grouter.h"
#include "grouteritems.h" #include "grouteritems.h"
@ -1170,8 +1171,6 @@ void p3GRouter::locked_collectAvailableFriends(const GRouterKeyId& gxs_id,const
for(uint32_t i=0;i<tmp_peers.size();++i) for(uint32_t i=0;i<tmp_peers.size();++i)
std::cerr << " " << tmp_peers[i] << ", probability: " << probas[i] << std::endl; std::cerr << " " << tmp_peers[i] << ", probability: " << probas[i] << std::endl;
#endif #endif
float probability_threshold = RS_GROUTER_PROBABILITY_THRESHOLD_FOR_RANDOM_ROUTING ;
std::vector<std::pair<float,RsPeerId> > mypairs ; std::vector<std::pair<float,RsPeerId> > mypairs ;
for(uint32_t i=0;i<tmp_peers.size();++i) for(uint32_t i=0;i<tmp_peers.size();++i)
@ -1184,7 +1183,6 @@ void p3GRouter::locked_collectAvailableFriends(const GRouterKeyId& gxs_id,const
uint32_t n=0 ; uint32_t n=0 ;
float duplication_factor_delta =0.0; float duplication_factor_delta =0.0;
uint32_t duplication_factor_buff =duplication_factor ;
for(int i=mypairs.size()-1;i>=0 && n<max_count;--i) for(int i=mypairs.size()-1;i>=0 && n<max_count;--i)
{ {
@ -1294,8 +1292,7 @@ void p3GRouter::autoWash()
RS_STACK_MUTEX(grMtx) ; RS_STACK_MUTEX(grMtx) ;
for(std::map<GRouterMsgPropagationId, GRouterRoutingInfo>::iterator it=_pending_messages.begin();it!=_pending_messages.end();) for(std::map<GRouterMsgPropagationId, GRouterRoutingInfo>::iterator it=_pending_messages.begin();it!=_pending_messages.end();)
if( (it->second.data_status == RS_GROUTER_DATA_STATUS_DONE && if( (it->second.data_status == RS_GROUTER_DATA_STATUS_DONE && (!(it->second.routing_flags & GRouterRoutingInfo::ROUTING_FLAGS_IS_DESTINATION)
(!(it->second.routing_flags & GRouterRoutingInfo::ROUTING_FLAGS_IS_DESTINATION)
|| it->second.received_time_TS + MAX_DESTINATION_KEEP_TIME < now)) || it->second.received_time_TS + MAX_DESTINATION_KEEP_TIME < now))
|| ((it->second.received_time_TS + GROUTER_ITEM_MAX_CACHE_KEEP_TIME < now) || ((it->second.received_time_TS + GROUTER_ITEM_MAX_CACHE_KEEP_TIME < now)
&& !(it->second.routing_flags & GRouterRoutingInfo::ROUTING_FLAGS_IS_ORIGIN) && !(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. // in the proxy case, we should only store the receipt.
GRouterClientService *client_service = NULL; GRouterClientService *client_service = NULL;
GRouterServiceId service_id ;
GRouterMsgPropagationId mid = 0 ; GRouterMsgPropagationId mid = 0 ;
{ {
@ -1953,7 +1949,11 @@ bool p3GRouter::verifySignedDataItem(RsGRouterAbstractMsgItem *item)
{ {
try 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() ; uint32_t data_size = item->signed_data_size() ;
RsTemporaryMemory data(data_size) ; RsTemporaryMemory data(data_size) ;
@ -1971,7 +1971,15 @@ bool p3GRouter::verifySignedDataItem(RsGRouterAbstractMsgItem *item)
{ {
switch(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<RsPeerId> 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 ; break ;
case RsGixs::RS_GIXS_ERROR_SIGNATURE_MISMATCH: std::cerr << "(EE) Signature mismatch. Spoofing/Corrupted/MITM?." << std::endl; case RsGixs::RS_GIXS_ERROR_SIGNATURE_MISMATCH: std::cerr << "(EE) Signature mismatch. Spoofing/Corrupted/MITM?." << std::endl;
break ; break ;

View file

@ -2032,6 +2032,7 @@ void p3MsgService::sendDistantMsgItem(RsMsgItem *msgitem)
RS_STACK_MUTEX(mMsgMtx) ; RS_STACK_MUTEX(mMsgMtx) ;
_ongoing_messages[grouter_message_id] = msgitem->msgId ; _ongoing_messages[grouter_message_id] = msgitem->msgId ;
} }
IndicateConfigChanged(); // save _ongoing_messages
} }

View file

@ -54,7 +54,7 @@
#define COL_SEND 8 #define COL_SEND 8
#define COL_DUPLICATION_FACTOR 9 #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 const int MAX_TUNNEL_REQUESTS_DISPLAY = 10 ;
static QColor colorScale(float f) static QColor colorScale(float f)
@ -350,7 +350,6 @@ void GlobalRouterStatisticsWidget::updateContent()
//if(!is_null) //if(!is_null)
//{ //{
ids = QString::fromStdString(it->first.toStdString())+" : " ; ids = QString::fromStdString(it->first.toStdString())+" : " ;
mMaxWheelZoneX = ox+2*cellx + fm_monospace.width(ids);
painter.drawText(ox+2*cellx,oy+celly,ids) ; painter.drawText(ox+2*cellx,oy+celly,ids) ;
for(uint32_t i=0;i<matrix_info.friend_ids.size();++i) for(uint32_t i=0;i<matrix_info.friend_ids.size();++i)
@ -368,10 +367,13 @@ void GlobalRouterStatisticsWidget::updateContent()
//} //}
} }
mMaxWheelZoneX = ox+matrix_info.friend_ids.size()*cellx + fm_monospace.width(ids);
RsIdentityDetails iddetails ; RsIdentityDetails iddetails ;
if(rsIdentity->getIdDetails(current_id,iddetails)) if(rsIdentity->getIdDetails(current_id,iddetails))
painter.drawText(current_width+cellx, current_oy+celly, QString::fromUtf8(iddetails.mNickname.c_str())) ; 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 ; mMaxWheelZoneY = oy+celly ;
@ -415,10 +417,10 @@ void GlobalRouterStatisticsWidget::wheelEvent(QWheelEvent *e)
return ; return ;
} }
if(e->delta() > 0 && mCurrentN+PARTIAL_VIEW_SIZE/2+1 < mNumberOfKnownKeys) if(e->delta() < 0 && mCurrentN+PARTIAL_VIEW_SIZE/2+1 < mNumberOfKnownKeys)
mCurrentN++ ; mCurrentN++ ;
if(e->delta() < 0 && mCurrentN > PARTIAL_VIEW_SIZE/2+1) if(e->delta() > 0 && mCurrentN > PARTIAL_VIEW_SIZE/2+1)
mCurrentN-- ; mCurrentN-- ;
updateContent(); updateContent();