Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

statistics - remove gxs tunnels from ft; add filenames for known hashes #2291

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions libretroshare/src/ft/ftserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ class ftServer :
bool ResumeTransfers();

/*************************** p3 Config Overload ********************/

bool findRealHash(const RsFileHash& hash, RsFileHash& real_hash);

protected:
int handleIncoming() ;
bool handleCacheData() ;
Expand All @@ -386,7 +387,7 @@ class ftServer :
bool sendTurtleItem(const RsPeerId& peerId,const RsFileHash& hash,RsTurtleGenericTunnelItem *item);

// fnds out what is the real hash of encrypted hash hash
bool findRealHash(const RsFileHash& hash, RsFileHash& real_hash);
//bool findRealHash(const RsFileHash& hash, RsFileHash& real_hash);
bool findEncryptedHash(const RsPeerId& virtual_peer_id, RsFileHash& encrypted_hash);

bool checkUploadLimit(const RsPeerId& pid,const RsFileHash& hash);
Expand Down
23 changes: 4 additions & 19 deletions libretroshare/src/gxs/rsgxsnettunnel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1155,22 +1155,7 @@ void RsGxsNetTunnelService::getStatistics(std::map<RsGxsGroupId,RsGxsNetTunnelGr
bias = mRandomBias ;
}




















bool RsGxsNetTunnelService::isGXSHash(RsFileHash hash) const
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misleading because this is only valid for local hashes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand. This is wrong why?

{
return mHandledHashes.find(hash) != mHandledHashes.end();
}
1 change: 1 addition & 0 deletions libretroshare/src/gxs/rsgxsnettunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class RsGxsNetTunnelService:
std::map<RsGxsNetTunnelVirtualPeerId, RsGxsNetTunnelVirtualPeerInfo>& virtual_peers, // current virtual peers, which group they provide, and how to talk to them through turtle
std::map<TurtleVirtualPeerId,RsGxsNetTunnelVirtualPeerId>& turtle_vpid_to_net_tunnel_vpid,
Bias20Bytes& bias) const;
bool isGXSHash(RsFileHash hash) const;

protected:
// interaction with turtle router
Expand Down
1 change: 1 addition & 0 deletions libretroshare/src/retroshare/rsgxsdistsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class RsGxsDistSync
std::map<TurtleVirtualPeerId,RsGxsNetTunnelVirtualPeerId>& turtle_vpid_to_net_tunnel_vpid,
Bias20Bytes& bias
) const =0;
virtual bool isGXSHash(RsFileHash hash) const =0;
};

extern RsGxsDistSync *rsGxsDistSync ;
Expand Down
67 changes: 67 additions & 0 deletions libretroshare/src/turtle/p3turtle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "pqi/authssl.h"
#include "pqi/p3linkmgr.h"
#include "retroshare/rspeers.h"
#include <retroshare/rsgxsdistsync.h>

#include "ft/ftserver.h"
#include "ft/ftdatamultiplex.h"
Expand Down Expand Up @@ -2330,6 +2331,9 @@ void p3turtle::getInfo( std::vector<std::vector<std::string> >& hashes_info,

for(std::map<TurtleFileHash,TurtleHashInfo>::const_iterator it(_incoming_file_hashes.begin());it!=_incoming_file_hashes.end();++it)
{
if(rsGxsDistSync->isGXSHash(it->first))
continue;

hashes_info.push_back(std::vector<std::string>()) ;

std::vector<std::string>& hashes(hashes_info.back()) ;
Expand All @@ -2339,12 +2343,50 @@ void p3turtle::getInfo( std::vector<std::vector<std::string> >& hashes_info,
hashes.push_back("Name not available") ;
hashes.push_back(printNumber(it->second.tunnels.size())) ;
//hashes.push_back(printNumber(now - it->second.time_stamp)+" secs ago") ;
hashes.push_back(GetFilenameForHash(it->first,it->second.service)); // [3] fn
}

for(std::map<TurtleTunnelId,RsTurtleClientService *>::const_iterator it(_outgoing_tunnel_client_services.begin());it!=_outgoing_tunnel_client_services.end();++it)
{
RsFileHash h;
for(std::map<TurtleTunnelId,TurtleTunnel>::const_iterator it3(_local_tunnels.begin());it3!=_local_tunnels.end();++it3)
{
if(it3->first == it->first)
{
h = it3->second.hash;
break;
}
}
if(rsGxsDistSync->isGXSHash(h))
continue;

bool have = false;
for(uint16_t i=0;i<hashes_info.size();++i)
{
if(hashes_info[i][0] == h.toStdString())
{
have = true;
break;
}
}
if(!have)
{
hashes_info.push_back(std::vector<std::string>()) ;
std::vector<std::string>& hashes(hashes_info.back()) ;
hashes.push_back(h.toStdString()) ; // [0] hash
hashes.push_back("---") ; // [1] name - unused
hashes.push_back("---") ; // [2] tun.count - unused
hashes.push_back(GetFilenameForHash(h,it->second)); // [3] fn
}
}

tunnels_info.clear();

for(std::map<TurtleTunnelId,TurtleTunnel>::const_iterator it(_local_tunnels.begin());it!=_local_tunnels.end();++it)
{
if(rsGxsDistSync->isGXSHash(it->second.hash))
continue;

tunnels_info.push_back(std::vector<std::string>()) ;
std::vector<std::string>& tunnel(tunnels_info.back()) ;

Expand All @@ -2364,6 +2406,7 @@ void p3turtle::getInfo( std::vector<std::vector<std::string> >& hashes_info,
tunnel.push_back(it->second.hash.toStdString()) ;
tunnel.push_back(printNumber(now-it->second.time_stamp) + " secs ago") ;
tunnel.push_back(printFloatNumber(it->second.speed_Bps,false)) ; //

}

search_reqs_info.clear();
Expand Down Expand Up @@ -2490,3 +2533,27 @@ void p3turtle::TS_dumpState()
}
}
#endif

std::string p3turtle::GetFilenameForHash(TurtleFileHash hash, RsTurtleClientService *service) const
{
ftServer *client = dynamic_cast<ftServer*>(service) ;
if(!client)
{ std::cerr << "(EE) turtle getInfo -- client not a ftServer!!" << std::endl;
return 0;
}
bool encr = false;
RsFileHash real_hash ;
if(client->findRealHash(hash,real_hash))
{ hash = real_hash;
encr = true;
}
FileInfo fileInfo;
std::string fn = "n/a";
if(rsFiles->FileDetails(hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_DOWNLOAD | RS_FILE_HINTS_UPLOAD, fileInfo))
fn = fileInfo.fname;
else
fn = std::string("-");
if(encr)
fn += std::string(" - e2ee");
return fn;
}
1 change: 1 addition & 0 deletions libretroshare/src/turtle/p3turtle.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config
std::vector<std::vector<std::string> >&,
std::vector<TurtleSearchRequestDisplayInfo >&,
std::vector<TurtleTunnelRequestDisplayInfo >&) const ;
std::string GetFilenameForHash(TurtleFileHash hash, RsTurtleClientService *service) const;

virtual void getTrafficStatistics(TurtleTrafficStatisticsInfo& info) const ;

Expand Down
18 changes: 14 additions & 4 deletions retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,27 @@ void TurtleRouterDialog::updateTunnelRequests( const std::vector<std::vector<std
for(int i=2;i<_f2f_TW->topLevelItemCount();)
{
bool found = false ;
bool skip = false;

if(_f2f_TW->topLevelItem(i)->text(0).left(14) == tr("Unknown hashes") && unknown_hash_found)
{
found = true ;

skip = true;
}

if(_f2f_TW->topLevelItem(i)->childCount() > 0) // this saves uploading hashes
found = true ;

for(uint j=0;j<hashes_info.size() && !found;++j)
if(_f2f_TW->topLevelItem(i)->text(0).toStdString() == hashes_info[j][0])
for(uint j=0;j<hashes_info.size() && !skip;++j)
{
if(_f2f_TW->topLevelItem(i)->text(0).left(40).toStdString() == hashes_info[j][0])
{
_f2f_TW->topLevelItem(i)->setText(0,QString::fromStdString(hashes_info[j][0]) + "\t file: " + QString::fromStdString(hashes_info[j][3]));
found=true ;

break;
}
}

if(!found)
delete _f2f_TW->takeTopLevelItem(i) ;
else
Expand Down