mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-14 00:49:41 -05:00
added GUI to display authenticated tunnel info. Added counting of data sent/recvd.
This commit is contained in:
parent
60d948b509
commit
81b196d38d
@ -140,9 +140,11 @@ void p3GxsTunnelService::flush()
|
||||
{
|
||||
RS_STACK_MUTEX(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
while(!pendingDHItems.empty())
|
||||
if(locked_sendClearTunnelData(pendingDHItems.front()) )
|
||||
pendingDHItems.pop_front() ;
|
||||
for(std::list<RsGxsTunnelDHPublicKeyItem*>::iterator it=pendingDHItems.begin();it!=pendingDHItems.end();)
|
||||
if(locked_sendClearTunnelData(*it) )
|
||||
it = pendingDHItems.erase(it) ;
|
||||
else
|
||||
++it ;
|
||||
}
|
||||
|
||||
// Flush items that could not be sent, probably because of a Mutex protected zone.
|
||||
@ -150,13 +152,16 @@ void p3GxsTunnelService::flush()
|
||||
{
|
||||
RS_STACK_MUTEX(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
while(!pendingGxsTunnelItems.empty())
|
||||
if(locked_sendEncryptedTunnelData(pendingGxsTunnelItems.front()))
|
||||
pendingGxsTunnelItems.pop_front() ;
|
||||
#ifdef DEBUG_GXS_TUNNEL
|
||||
for(std::list<RsGxsTunnelItem*>::iterator it=pendingGxsTunnelItems.begin();it!=pendingGxsTunnelItems.end();)
|
||||
if(locked_sendEncryptedTunnelData(*it) )
|
||||
it = pendingGxsTunnelItems.erase(it) ;
|
||||
else
|
||||
std::cerr << "Cannot send encrypted data item to tunnel " << pendingGxsTunnelItems.front()->PeerId() << std::endl;
|
||||
{
|
||||
++it ;
|
||||
#ifdef DEBUG_GXS_TUNNEL
|
||||
std::cerr << "Cannot send encrypted data item to tunnel " << (*it)->PeerId() << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Look at pending data item, and re-send them if necessary.
|
||||
@ -772,6 +777,8 @@ bool p3GxsTunnelService::handleEncryptedData(const uint8_t *data_bytes,uint32_t
|
||||
return true;
|
||||
}
|
||||
|
||||
it2->second.total_received += decrypted_size ;
|
||||
|
||||
// DH key items are sent even before we know who we speak to, so the virtual peer id is used in this
|
||||
// case only.
|
||||
|
||||
@ -1158,6 +1165,8 @@ bool p3GxsTunnelService::locked_sendEncryptedTunnelData(RsGxsTunnelItem *item)
|
||||
return false;
|
||||
}
|
||||
|
||||
it->second.total_sent += rssize ; // counts the size of clear data that is sent
|
||||
|
||||
memcpy(aes_key,it->second.aes_key,GXS_TUNNEL_AES_KEY_SIZE) ;
|
||||
RsPeerId virtual_peer_id = it->second.virtual_peer_id ;
|
||||
|
||||
@ -1387,9 +1396,8 @@ bool p3GxsTunnelService::getTunnelInfo(const RsGxsTunnelId& tunnel_id,GxsTunnelI
|
||||
info.destination_gxs_id = it->second.to_gxs_id;
|
||||
info.source_gxs_id = it->second.own_gxs_id;
|
||||
info.tunnel_status = it->second.status;
|
||||
#warning data missing here
|
||||
info.total_size_sent = 0;
|
||||
info.total_size_received= 0;
|
||||
info.total_size_sent = it->second.total_sent;
|
||||
info.total_size_received= it->second.total_received;
|
||||
|
||||
// Data packets
|
||||
|
||||
@ -1400,24 +1408,6 @@ bool p3GxsTunnelService::getTunnelInfo(const RsGxsTunnelId& tunnel_id,GxsTunnelI
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool p3GxsTunnelService::getTunnelStatus(const RsGxsTunnelId& tunnel_id,uint32_t& status)
|
||||
{
|
||||
RsStackMutex stack(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
std::map<RsGxsTunnelId,GxsTunnelPeerInfo>::const_iterator it = _gxs_tunnel_contacts.find(tunnel_id) ;
|
||||
|
||||
if(it != _gxs_tunnel_contacts.end())
|
||||
{
|
||||
status = it->second.status ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
status = RS_GXS_TUNNEL_STATUS_UNKNOWN ;
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
bool p3GxsTunnelService::closeExistingTunnel(const RsGxsTunnelId& tunnel_id, uint32_t service_id)
|
||||
{
|
||||
// two cases:
|
||||
@ -1499,7 +1489,28 @@ bool p3GxsTunnelService::closeExistingTunnel(const RsGxsTunnelId& tunnel_id, uin
|
||||
|
||||
// GxsTunnelService::removeVirtualPeerId() will be called by the turtle service.
|
||||
}
|
||||
return true ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool p3GxsTunnelService::getTunnelsInfo(std::vector<RsGxsTunnelService::GxsTunnelInfo> &infos)
|
||||
{
|
||||
RS_STACK_MUTEX(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
for(std::map<RsGxsTunnelId,GxsTunnelPeerInfo>::const_iterator it(_gxs_tunnel_contacts.begin());it!=_gxs_tunnel_contacts.end();++it)
|
||||
{
|
||||
GxsTunnelInfo ti ;
|
||||
|
||||
ti.tunnel_id = it->first ;
|
||||
ti.destination_gxs_id = it->second.to_gxs_id ;
|
||||
ti.source_gxs_id = it->second.own_gxs_id ;
|
||||
ti.tunnel_status = it->second.status ;
|
||||
ti.total_size_sent = it->second.total_sent ;
|
||||
ti.total_size_received = it->second.total_received ;
|
||||
|
||||
infos.push_back(ti) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
void p3GxsTunnelService::debug_dump()
|
||||
|
@ -138,7 +138,7 @@ public:
|
||||
virtual bool requestSecuredTunnel(const RsGxsId& to_id,const RsGxsId& from_id,RsGxsTunnelId& tunnel_id,uint32_t service_id,uint32_t& error_code) ;
|
||||
|
||||
virtual bool closeExistingTunnel(const RsGxsTunnelId &tunnel_id,uint32_t service_id) ;
|
||||
virtual bool getTunnelStatus(const RsGxsTunnelId& tunnel_id,uint32_t &status);
|
||||
virtual bool getTunnelsInfo(std::vector<GxsTunnelInfo>& infos);
|
||||
virtual bool getTunnelInfo(const RsGxsTunnelId& tunnel_id,GxsTunnelInfo& info);
|
||||
virtual bool sendData(const RsGxsTunnelId& tunnel_id,uint32_t service_id,const uint8_t *data,uint32_t size) ;
|
||||
|
||||
@ -159,6 +159,9 @@ private:
|
||||
GxsTunnelPeerInfo() : last_contact(0), last_keep_alive_sent(0), status(0), direction(0)
|
||||
{
|
||||
memset(aes_key, 0, GXS_TUNNEL_AES_KEY_SIZE);
|
||||
|
||||
total_sent = 0 ;
|
||||
total_received = 0 ;
|
||||
}
|
||||
|
||||
time_t last_contact ; // used to keep track of working connexion
|
||||
@ -173,6 +176,8 @@ private:
|
||||
RsTurtleGenericTunnelItem::Direction direction ; // specifiec wether we are client(managing the tunnel) or server.
|
||||
TurtleFileHash hash ; // hash that is last used. This is necessary for handling tunnel establishment
|
||||
std::set<uint32_t> client_services ;// services that used this tunnel
|
||||
uint32_t total_sent ;
|
||||
uint32_t total_received ;
|
||||
};
|
||||
|
||||
class GxsTunnelDHInfo
|
||||
|
@ -68,8 +68,9 @@ public:
|
||||
class GxsTunnelInfo
|
||||
{
|
||||
public:
|
||||
// Tunnel information
|
||||
|
||||
// Tunnel information
|
||||
|
||||
RsGxsTunnelId tunnel_id ;
|
||||
RsGxsId destination_gxs_id ; // GXS Id we're talking to
|
||||
RsGxsId source_gxs_id ; // GXS Id we're using to talk
|
||||
uint32_t tunnel_status ; // active, requested, DH pending, etc.
|
||||
@ -89,7 +90,7 @@ public:
|
||||
// Debugging info //
|
||||
//===================================================//
|
||||
|
||||
//virtual bool getGxsTunnelsInfo(std::vector<GxsTunnelInfo>& infos) =0;
|
||||
virtual bool getTunnelsInfo(std::vector<GxsTunnelInfo>& infos) =0;
|
||||
virtual bool getTunnelInfo(const RsGxsTunnelId& tunnel_id,GxsTunnelInfo& info) =0;
|
||||
|
||||
// retrieve the routing probabilities
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <QObject>
|
||||
#include <retroshare/rsturtle.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsgxstunnel.h>
|
||||
#include "TurtleRouterDialog.h"
|
||||
#include <QPainter>
|
||||
#include <QStylePainter>
|
||||
@ -222,7 +223,7 @@ QTreeWidgetItem *TurtleRouterDialog::findParentHashItem(const std::string& hash)
|
||||
GxsTunnelsDialog::GxsTunnelsDialog(QWidget *parent)
|
||||
: RsAutoUpdatePage(2000,parent)
|
||||
{
|
||||
setupUi(this) ;
|
||||
// setupUi(this) ;
|
||||
|
||||
m_bProcessSettings = false;
|
||||
|
||||
@ -230,7 +231,7 @@ GxsTunnelsDialog::GxsTunnelsDialog(QWidget *parent)
|
||||
float fact = fontHeight/14.0;
|
||||
|
||||
maxWidth = 200 ;
|
||||
maxHeight = 0 ;
|
||||
maxHeight = 200 ;
|
||||
|
||||
// load settings
|
||||
processSettings(true);
|
||||
@ -262,36 +263,68 @@ void GxsTunnelsDialog::processSettings(bool bLoad)
|
||||
|
||||
void GxsTunnelsDialog::updateDisplay()
|
||||
{
|
||||
// Request info about ongoing tunnels
|
||||
|
||||
std::vector<RsGxsTunnelService::GxsTunnelInfo> tunnel_infos ;
|
||||
|
||||
rsGxsTunnel->getTunnelsInfo(tunnel_infos) ;
|
||||
|
||||
// // Tunnel information
|
||||
//
|
||||
// GxsTunnelId tunnel_id ; // GXS Id we're talking to
|
||||
// RsGxsId destination_gxs_id ; // GXS Id we're talking to
|
||||
// RsGxsId source_gxs_id ; // GXS Id we're using to talk
|
||||
// uint32_t tunnel_status ; // active, requested, DH pending, etc.
|
||||
// uint32_t total_size_sent ; // total bytes sent through that tunnel since openned (including management).
|
||||
// uint32_t total_size_received ; // total bytes received through that tunnel since openned (including management).
|
||||
|
||||
// // Data packets
|
||||
|
||||
// uint32_t pending_data_packets; // number of packets not acknowledged by other side, still on their way. Should be 0 unless something bad happens.
|
||||
// uint32_t total_data_packets_sent ; // total number of data packets sent (does not include tunnel management)
|
||||
// uint32_t total_data_packets_received ; // total number of data packets received (does not include tunnel management)
|
||||
|
||||
// now draw the shit
|
||||
QPixmap tmppixmap(maxWidth, maxHeight);
|
||||
tmppixmap.fill(Qt::transparent);
|
||||
setFixedHeight(maxHeight);
|
||||
//setFixedHeight(maxHeight);
|
||||
|
||||
QPainter painter(&tmppixmap);
|
||||
painter.initFrom(this);
|
||||
|
||||
// extracts the height of the fonts in pixels. This is used to callibrate the size of the objects to draw.
|
||||
// extracts the height of the fonts in pixels. This is used to calibrate the size of the objects to draw.
|
||||
|
||||
float fontHeight = QFontMetricsF(font()).height();
|
||||
float fact = fontHeight/14.0;
|
||||
maxHeight = 500*fact ;
|
||||
//maxHeight = 500*fact ;
|
||||
|
||||
int cellx = 6*fact ;
|
||||
int celly = (10+4)*fact ;
|
||||
int ox=5*fact,oy=5*fact ;
|
||||
|
||||
// std::cerr << "Drawing into pixmap of size " << maxWidth << "x" << maxHeight << std::endl;
|
||||
// draw...
|
||||
int ox=5*fact,oy=5*fact ;
|
||||
|
||||
// painter.setPen(QColor::fromRgb(70,70,70)) ;
|
||||
// painter.drawLine(0,oy,maxWidth,oy) ;
|
||||
// oy += celly ;
|
||||
|
||||
painter.setPen(QColor::fromRgb(0,0,0)) ;
|
||||
painter.drawText(ox+2*cellx,oy+celly,tr("Authenticated tunnels:")) ; oy += celly ;
|
||||
|
||||
for(uint32_t i=0;i<tunnel_infos.size();++i)
|
||||
{
|
||||
// std::cerr << "Drawing into pixmap of size " << maxWidth << "x" << maxHeight << std::endl;
|
||||
// draw...
|
||||
|
||||
painter.drawText(ox+4*cellx,oy+celly,tr("Tunnel ID: %1").arg(QString::fromStdString(tunnel_infos[i].tunnel_id.toStdString()))) ; oy += celly ;
|
||||
painter.drawText(ox+6*cellx,oy+celly,tr("from: %1").arg(QString::fromStdString(tunnel_infos[i].source_gxs_id.toStdString()))) ; oy += celly ;
|
||||
painter.drawText(ox+6*cellx,oy+celly,tr("to: %1").arg(QString::fromStdString(tunnel_infos[i].destination_gxs_id.toStdString()))) ; oy += celly ;
|
||||
painter.drawText(ox+6*cellx,oy+celly,tr("status: %1").arg(QString::number(tunnel_infos[i].tunnel_status))) ; oy += celly ;
|
||||
painter.drawText(ox+6*cellx,oy+celly,tr("total sent: %1 bytes").arg(QString::number(tunnel_infos[i].total_size_sent))) ; oy += celly ;
|
||||
painter.drawText(ox+6*cellx,oy+celly,tr("total recv: %1 bytes").arg(QString::number(tunnel_infos[i].total_size_received))) ; oy += celly ;
|
||||
|
||||
// painter.drawLine(0,oy,maxWidth,oy) ;
|
||||
// oy += celly ;
|
||||
}
|
||||
|
||||
// update the pixmap
|
||||
//
|
||||
pixmap = tmppixmap;
|
||||
maxHeight = oy ;
|
||||
maxHeight = std::max(oy,10*celly);
|
||||
}
|
||||
|
||||
QString GxsTunnelsDialog::getPeerName(const RsPeerId &peer_id)
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <retroshare/rsturtle.h>
|
||||
#include <retroshare/rstypes.h>
|
||||
#include "ui_TurtleRouterDialog.h"
|
||||
#include "ui_TurtleRouterStatistics.h"
|
||||
#include "RsAutoUpdatePage.h"
|
||||
|
||||
|
||||
@ -36,7 +37,7 @@ class TurtleRouterDialog: public RsAutoUpdatePage, public Ui::TurtleRouterDialog
|
||||
|
||||
} ;
|
||||
|
||||
class GxsTunnelsDialog: public RsAutoUpdatePage, public Ui::TurtleRouterDialogForm
|
||||
class GxsTunnelsDialog: public RsAutoUpdatePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user