mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-04-10 17:59:32 -04:00
debugging of GxsTunnel service - fixed transport layer
This commit is contained in:
parent
a29f15ae32
commit
6951d730a5
libretroshare/src
@ -58,6 +58,15 @@ static const uint32_t RS_GXS_TUNNEL_DELAY_BETWEEN_RESEND = 10 ; // re-send ever
|
||||
static const uint32_t GXS_TUNNEL_ENCRYPTION_HMAC_SIZE = SHA_DIGEST_LENGTH ;
|
||||
static const uint32_t GXS_TUNNEL_ENCRYPTION_IV_SIZE = 8 ;
|
||||
|
||||
static const uint32_t INTERVAL_BETWEEN_DEBUG_DUMP = 10 ;
|
||||
|
||||
static std::string GXS_TUNNEL_APP_NAME = "GxsTunnels" ;
|
||||
|
||||
static const uint8_t GXS_TUNNEL_APP_MAJOR_VERSION = 0x01 ;
|
||||
static const uint8_t GXS_TUNNEL_APP_MINOR_VERSION = 0x00 ;
|
||||
static const uint8_t GXS_TUNNEL_MIN_MAJOR_VERSION = 0x01 ;
|
||||
static const uint8_t GXS_TUNNEL_MIN_MINOR_VERSION = 0x00 ;
|
||||
|
||||
RsGxsTunnelService *rsGxsTunnel = NULL ;
|
||||
|
||||
p3GxsTunnelService::p3GxsTunnelService(RsGixs *pids)
|
||||
@ -91,6 +100,31 @@ bool p3GxsTunnelService::registerClientService(uint32_t service_id,RsGxsTunnelSe
|
||||
return true ;
|
||||
}
|
||||
|
||||
int p3GxsTunnelService::tick()
|
||||
{
|
||||
static time_t last_dump = 0 ;
|
||||
std::cerr << "p3GxsTunnelService::tick()" << std::endl;
|
||||
time_t now = time(NULL);
|
||||
|
||||
if(now > last_dump + INTERVAL_BETWEEN_DEBUG_DUMP )
|
||||
{
|
||||
last_dump = now ;
|
||||
debug_dump() ;
|
||||
}
|
||||
|
||||
flush() ;
|
||||
}
|
||||
|
||||
RsServiceInfo p3GxsTunnelService::getServiceInfo()
|
||||
{
|
||||
return RsServiceInfo(RS_SERVICE_TYPE_GXS_TUNNEL,
|
||||
GXS_TUNNEL_APP_NAME,
|
||||
GXS_TUNNEL_APP_MAJOR_VERSION,
|
||||
GXS_TUNNEL_APP_MINOR_VERSION,
|
||||
GXS_TUNNEL_MIN_MAJOR_VERSION,
|
||||
GXS_TUNNEL_MIN_MINOR_VERSION);
|
||||
}
|
||||
|
||||
void p3GxsTunnelService::flush()
|
||||
{
|
||||
// Flush pending DH items. This is a higher priority, so we deal with them first.
|
||||
@ -342,7 +376,7 @@ void p3GxsTunnelService::addVirtualPeer(const TurtleFileHash& hash,const TurtleV
|
||||
}
|
||||
else // client side
|
||||
{
|
||||
std::map<RsGxsTunnelId,GxsTunnelPeerInfo>::const_iterator it ;
|
||||
std::map<RsGxsTunnelId,GxsTunnelPeerInfo>::const_iterator it = _gxs_tunnel_contacts.begin();
|
||||
|
||||
while(it != _gxs_tunnel_contacts.end() && it->second.hash != hash) ++it ;
|
||||
|
||||
@ -495,7 +529,8 @@ void p3GxsTunnelService::receiveTurtleData(RsTurtleGenericTunnelItem *gitem,cons
|
||||
|
||||
// Now try deserialise the decrypted data to make an RsItem out of it.
|
||||
//
|
||||
RsItem *citem = RsGxsTunnelSerialiser().deserialise(&((uint8_t*)item->data_bytes)[8],&item->data_size-8) ;
|
||||
uint32_t pktsize = item->data_size-8;
|
||||
RsItem *citem = RsGxsTunnelSerialiser().deserialise(&((uint8_t*)item->data_bytes)[8],&pktsize) ;
|
||||
|
||||
if(citem == NULL)
|
||||
{
|
||||
@ -1340,3 +1375,41 @@ void p3GxsTunnelService::markGxsTunnelAsClosed(const RsGxsTunnelId& tunnel_id)
|
||||
}
|
||||
}
|
||||
|
||||
void p3GxsTunnelService::debug_dump()
|
||||
{
|
||||
RS_STACK_MUTEX(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
time_t now = time(NULL) ;
|
||||
|
||||
std::cerr << "p3GxsTunnelService::debug_dump()" << std::endl;
|
||||
std::cerr << " Registered client services: " << std::endl;
|
||||
|
||||
for(std::map<uint32_t,RsGxsTunnelService::RsGxsTunnelClientService*>::const_iterator it=mRegisteredServices.begin();it!=mRegisteredServices.end();++it)
|
||||
std::cerr << std::hex << " " << it->first << " - " << (void*)it->second << std::dec << std::endl;
|
||||
|
||||
std::cerr << " Active tunnels" << std::endl;
|
||||
|
||||
for(std::map<RsGxsTunnelId,GxsTunnelPeerInfo>::const_iterator it=_gxs_tunnel_contacts.begin();it!=_gxs_tunnel_contacts.end();++it)
|
||||
std::cerr << " tunnel_id=" << it->first << " vpid=" << it->second.virtual_peer_id << " status=" << it->second.status << " direction=" << it->second.direction << " last_contact=" << (now-it->second.last_contact) <<" secs ago. Last_keep_alive_sent:" << (now - it->second.last_keep_alive_sent) << " secs ago." << std::endl;
|
||||
|
||||
std::cerr << " Virtual peers:" << std::endl;
|
||||
|
||||
for(std::map<TurtleVirtualPeerId,GxsTunnelDHInfo>::const_iterator it=_gxs_tunnel_virtual_peer_ids.begin();it!=_gxs_tunnel_virtual_peer_ids.end();++it)
|
||||
std::cerr << " vpid=" << it->first << " to=" << it->second.gxs_id << " from=" << it->second.own_gxs_id << " tunnel_id=" << it->second.tunnel_id << " status=" << it->second.status << " direction=" << it->second.direction << " hash=" << it->second.hash << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -107,13 +107,14 @@
|
||||
|
||||
#include <turtle/turtleclientservice.h>
|
||||
#include <retroshare/rsgxstunnel.h>
|
||||
#include <services/p3service.h>
|
||||
#include <gxstunnel/rsgxstunnelitems.h>
|
||||
|
||||
class RsGixs ;
|
||||
|
||||
static const uint32_t GXS_TUNNEL_AES_KEY_SIZE = 16 ;
|
||||
|
||||
class p3GxsTunnelService: public RsGxsTunnelService, public RsTurtleClientService
|
||||
class p3GxsTunnelService: public RsGxsTunnelService, public RsTurtleClientService, public p3Service
|
||||
{
|
||||
public:
|
||||
p3GxsTunnelService(RsGixs *pids) ;
|
||||
@ -131,6 +132,11 @@ public:
|
||||
|
||||
virtual bool registerClientService(uint32_t service_id,RsGxsTunnelClientService *service) ;
|
||||
|
||||
// derived from p3service
|
||||
|
||||
virtual int tick();
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
|
||||
private:
|
||||
void flush() ;
|
||||
virtual void handleIncomingItem(const RsGxsTunnelId &tunnel_id, RsGxsTunnelItem *) ;
|
||||
@ -237,5 +243,7 @@ private:
|
||||
uint64_t global_item_counter ;
|
||||
|
||||
std::map<uint32_t,RsGxsTunnelClientService*> mRegisteredServices ;
|
||||
|
||||
void debug_dump();
|
||||
};
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
#include "gxstunnel/rsgxstunnelitems.h"
|
||||
|
||||
//#define GXS_TUNNEL_ITEM_DEBUG 1
|
||||
#define GXS_TUNNEL_ITEM_DEBUG 1
|
||||
|
||||
std::ostream& RsGxsTunnelDHPublicKeyItem::print(std::ostream &out, uint16_t indent)
|
||||
{
|
||||
@ -105,9 +105,7 @@ RsItem *RsGxsTunnelSerialiser::deserialise(void *data, uint32_t *pktsize)
|
||||
// look what we have...
|
||||
if (*pktsize < rssize) /* check size */
|
||||
{
|
||||
#ifdef GXS_TUNNEL_ITEM_DEBUG
|
||||
std::cerr << "GxsTunnel deserialisation: not enough size: pktsize=" << *pktsize << ", rssize=" << rssize << std::endl ;
|
||||
#endif
|
||||
return NULL; /* not enough data */
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@ extern RsPluginHandler *rsPlugins ;
|
||||
class p3Service ;
|
||||
class RsServiceControl ;
|
||||
class RsTurtle ;
|
||||
class RsGxsTunnelService ;
|
||||
class RsDht ;
|
||||
class RsDisc ;
|
||||
class RsMsgs ;
|
||||
@ -116,6 +117,7 @@ public:
|
||||
RsUtil::inited_ptr<PgpAuxUtils> mPgpAuxUtils;
|
||||
RsUtil::inited_ptr<RsGxsForums> mGxsForums;
|
||||
RsUtil::inited_ptr<RsGxsChannels> mGxsChannels;
|
||||
RsUtil::inited_ptr<RsGxsTunnelService> mGxsTunnels;
|
||||
};
|
||||
|
||||
class RsPlugin
|
||||
|
@ -1475,6 +1475,7 @@ int RsServer::StartupRetroShare()
|
||||
pqih -> addService(ftserver,true);
|
||||
|
||||
mGxsTunnels = new p3GxsTunnelService(mGxsIdService) ;
|
||||
mGxsTunnels->connectToTurtleRouter(tr) ;
|
||||
rsGxsTunnel = mGxsTunnels;
|
||||
|
||||
rsDisc = mDisc;
|
||||
@ -1495,6 +1496,7 @@ int RsServer::StartupRetroShare()
|
||||
pqih -> addService(msgSrv,true);
|
||||
pqih -> addService(chatSrv,true);
|
||||
pqih -> addService(mStatusSrv,true);
|
||||
pqih -> addService(mGxsTunnels,true);
|
||||
|
||||
// set interfaces for plugins
|
||||
//
|
||||
@ -1515,6 +1517,8 @@ int RsServer::StartupRetroShare()
|
||||
interfaces.mPgpAuxUtils = pgpAuxUtils;
|
||||
interfaces.mGxsForums = mGxsForums;
|
||||
interfaces.mGxsChannels = mGxsChannels;
|
||||
interfaces.mGxsTunnels = mGxsTunnels;
|
||||
|
||||
mPluginsManager->setInterfaces(interfaces);
|
||||
|
||||
// now add plugin objects inside the loop:
|
||||
|
Loading…
x
Reference in New Issue
Block a user