From 6a2181ca145c51040ad75c6a5c89f5b961471788 Mon Sep 17 00:00:00 2001 From: RetroPooh Date: Fri, 10 Mar 2017 09:27:46 +0300 Subject: [PATCH 1/4] transfers - add peer names for turtle routed sources --- libretroshare/src/retroshare/rsturtle.h | 2 ++ libretroshare/src/turtle/p3turtle.cc | 19 +++++++++++++++++++ libretroshare/src/turtle/p3turtle.h | 2 ++ .../src/gui/FileTransfer/TransfersDialog.cpp | 7 +++++-- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/retroshare/rsturtle.h b/libretroshare/src/retroshare/rsturtle.h index 59b787c8e..4ad7f2d02 100644 --- a/libretroshare/src/retroshare/rsturtle.h +++ b/libretroshare/src/retroshare/rsturtle.h @@ -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 >&, diff --git a/libretroshare/src/turtle/p3turtle.cc b/libretroshare/src/turtle/p3turtle.cc index 997fe0e7e..53e3bf9d8 100644 --- a/libretroshare/src/turtle/p3turtle.cc +++ b/libretroshare/src/turtle/p3turtle.cc @@ -2001,6 +2001,25 @@ void p3turtle::getTrafficStatistics(TurtleTrafficStatisticsInfo& info) const } } +std::string p3turtle::getPeerNameForVirtualPeerId(const RsPeerId& virtual_peer_id) +{ + std::string name = "unknown"; + std::map::const_iterator it(_virtual_peers.find(virtual_peer_id)) ; + if(it != _virtual_peers.end()) + { + TurtleTunnelId tunnel_id = it->second ; + std::map::iterator it2( _local_tunnels.find(tunnel_id) ) ; + 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 >& hashes_info, std::vector >& tunnels_info, std::vector& search_reqs_info, diff --git a/libretroshare/src/turtle/p3turtle.h b/libretroshare/src/turtle/p3turtle.h index d9d51456b..ab523f63f 100644 --- a/libretroshare/src/turtle/p3turtle.h +++ b/libretroshare/src/turtle/p3turtle.h @@ -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 >&, diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index 522ac5fb8..60d42af3f 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -58,6 +58,8 @@ #include #include +#include + /* Images for context menu icons */ #define IMAGE_INFO ":/images/fileinfo.png" #define IMAGE_CANCEL ":/images/delete.png" @@ -1388,10 +1390,11 @@ QString TransfersDialog::getPeerName(const RsPeerId& id) const // if(res == "") { + res = QString::fromStdString(rsTurtle->getPeerNameForVirtualPeerId(id)); if(rsFiles->isEncryptedSource(id)) - return tr("Anonymous end-to-end encrypted tunnel 0x")+QString::fromStdString(id.toStdString()).left(8) ; + return tr("e2ee tunnel ")+QString::fromStdString(id.toStdString()).left(8) + " via " +res ; else - return tr("Anonymous tunnel 0x")+QString::fromStdString(id.toStdString()).left(8) ; + return tr("Anon tunnel ")+QString::fromStdString(id.toStdString()).left(8) + " via " +res ; } else return res ; From 06e4c6806582f47ca2b74eb4e9bd4af0e526d62a Mon Sep 17 00:00:00 2001 From: RetroPooh Date: Fri, 10 Mar 2017 11:15:39 +0300 Subject: [PATCH 2/4] upd --- libretroshare/src/turtle/p3turtle.cc | 4 ++-- retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/turtle/p3turtle.cc b/libretroshare/src/turtle/p3turtle.cc index 53e3bf9d8..371651865 100644 --- a/libretroshare/src/turtle/p3turtle.cc +++ b/libretroshare/src/turtle/p3turtle.cc @@ -2003,12 +2003,12 @@ 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::const_iterator it(_virtual_peers.find(virtual_peer_id)) ; if(it != _virtual_peers.end()) { - TurtleTunnelId tunnel_id = it->second ; - std::map::iterator it2( _local_tunnels.find(tunnel_id) ) ; + std::map::iterator it2( _local_tunnels.find(it->second) ) ; if(it2 != _local_tunnels.end()) { if(it2->second.local_src == _own_id) diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index 60d42af3f..17df9d2fc 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -1392,9 +1392,9 @@ QString TransfersDialog::getPeerName(const RsPeerId& id) const { res = QString::fromStdString(rsTurtle->getPeerNameForVirtualPeerId(id)); if(rsFiles->isEncryptedSource(id)) - return tr("e2ee tunnel ")+QString::fromStdString(id.toStdString()).left(8) + " via " +res ; + return tr("Anonymous E2EE tunnel ")+QString::fromStdString(id.toStdString()).left(8) + " via " +res ; else - return tr("Anon tunnel ")+QString::fromStdString(id.toStdString()).left(8) + " via " +res ; + return tr("Anonymous tunnel id # ")+QString::fromStdString(id.toStdString()).left(8) + " via " +res ; } else return res ; From 72dc1c7da405a03d1b47e0ec6356c80e1793321a Mon Sep 17 00:00:00 2001 From: Pooh Date: Mon, 25 Sep 2017 21:50:12 +0300 Subject: [PATCH 3/4] Update TransfersDialog.cpp --- retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index 9ce204f18..faac246a7 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -1512,7 +1512,7 @@ QString TransfersDialog::getPeerName(const RsPeerId& id, QString &iconName, QStr 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; From f98f16fb15b9af904919a48e80d3c85f23204060 Mon Sep 17 00:00:00 2001 From: Pooh Date: Mon, 25 Sep 2017 22:31:49 +0300 Subject: [PATCH 4/4] Update TransfersDialog.cpp --- retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index faac246a7..aecc53bef 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -1502,7 +1502,7 @@ QString TransfersDialog::getPeerName(const RsPeerId& id, QString &iconName, QStr // if(res == "") { - res = QString::fromStdString(rsTurtle->getPeerNameForVirtualPeerId(id)); + res = QString::fromUtf8(rsTurtle->getPeerNameForVirtualPeerId(id).c_str()); if(rsFiles->isEncryptedSource(id)) { iconName = IMAGE_TUNNEL_ANON_E2E;