Merge pull request #744 from RetroPooh/tunnel-names

transfers - add peer names for turtle routed sources
This commit is contained in:
csoler 2017-09-25 21:35:59 +02:00 committed by GitHub
commit cbeefda151
4 changed files with 28 additions and 2 deletions

View File

@ -129,6 +129,8 @@ class RsTurtle
///
virtual void registerTunnelService(RsTurtleClientService *service) = 0;
virtual std::string getPeerNameForVirtualPeerId(const RsPeerId& virtual_peer_id) = 0;
// Get info from the turtle router. I use std strings to hide the internal structs.
//
virtual void getInfo(std::vector<std::vector<std::string> >&,std::vector<std::vector<std::string> >&,

View File

@ -2020,6 +2020,25 @@ void p3turtle::getTrafficStatistics(TurtleTrafficStatisticsInfo& info) const
}
}
std::string p3turtle::getPeerNameForVirtualPeerId(const RsPeerId& virtual_peer_id)
{
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
std::string name = "unknown";
std::map<TurtleVirtualPeerId,TurtleTunnelId>::const_iterator it(_virtual_peers.find(virtual_peer_id)) ;
if(it != _virtual_peers.end())
{
std::map<TurtleTunnelId,TurtleTunnel>::iterator it2( _local_tunnels.find(it->second) ) ;
if(it2 != _local_tunnels.end())
{
if(it2->second.local_src == _own_id)
mLinkMgr->getPeerName(it2->second.local_dst,name);
else
mLinkMgr->getPeerName(it2->second.local_src,name);
}
}
return name;
}
void p3turtle::getInfo( std::vector<std::vector<std::string> >& hashes_info,
std::vector<std::vector<std::string> >& tunnels_info,
std::vector<TurtleRequestDisplayInfo >& search_reqs_info,

View File

@ -275,6 +275,8 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config
///
virtual void registerTunnelService(RsTurtleClientService *service) ;
virtual std::string getPeerNameForVirtualPeerId(const RsPeerId& virtual_peer_id);
/// get info about tunnels
virtual void getInfo(std::vector<std::vector<std::string> >&,
std::vector<std::vector<std::string> >&,

View File

@ -60,6 +60,8 @@
#include <retroshare/rsdisc.h>
#include <retroshare/rsplugin.h>
#include <retroshare/rsturtle.h>
/* Images for context menu icons */
#define IMAGE_INFO ":/images/fileinfo.png"
#define IMAGE_CANCEL ":/images/delete.png"
@ -1500,16 +1502,17 @@ QString TransfersDialog::getPeerName(const RsPeerId& id, QString &iconName, QStr
//
if(res == "")
{
res = QString::fromUtf8(rsTurtle->getPeerNameForVirtualPeerId(id).c_str());
if(rsFiles->isEncryptedSource(id))
{
iconName = IMAGE_TUNNEL_ANON_E2E;
tooltip = tr("Anonymous end-to-end encrypted tunnel 0x")+QString::fromStdString(id.toStdString()).left(8);
return tr("Tunnel 0x")+QString::fromStdString(id.toStdString()).left(8);
return tr("Tunnel") + " via " + res ;
}
iconName = IMAGE_TUNNEL_ANON;
tooltip = tr("Anonymous tunnel 0x")+QString::fromStdString(id.toStdString()).left(8);
return tr("Tunnel 0x")+QString::fromStdString(id.toStdString()).left(8);
return tr("Tunnel") + " via " + res ;
}
iconName = IMAGE_TUNNEL_FRIEND;