mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-04 20:34:26 -04:00
Merge branch 'master' into gxs_mail_experiments
This commit is contained in:
commit
5159e326c7
335 changed files with 12307 additions and 24670 deletions
|
@ -41,7 +41,7 @@
|
|||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
|
||||
#define LIMIT_CERTIFICATE_SIZE 1
|
||||
#define MAX_CERTIFICATE_SIZE 10000
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include "pqinetwork.h"
|
||||
#include "authgpg.h"
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "util/rsstring.h"
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include <util/rsdiscspace.h>
|
||||
#include "util/rsstring.h"
|
||||
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
|
||||
/*
|
||||
#define CONFIG_DEBUG 1
|
||||
|
|
|
@ -92,7 +92,7 @@ dhtPeerEntry::dhtPeerEntry()
|
|||
return;
|
||||
}
|
||||
|
||||
p3DhtMgr::p3DhtMgr(std::string id, pqiConnectCb *cb)
|
||||
p3DhtMgr::p3DhtMgr(RsPeerId id, pqiConnectCb *cb)
|
||||
:pqiNetAssistConnect(id, cb), dhtMtx("p3DhtMgr"), mStunRequired(true)
|
||||
{
|
||||
/* setup own entry */
|
||||
|
@ -237,13 +237,13 @@ bool p3DhtMgr::setExternalInterface(
|
|||
|
||||
|
||||
/* add / remove peers */
|
||||
bool p3DhtMgr::findPeer(std::string id)
|
||||
bool p3DhtMgr::findPeer(const RsPeerId& id)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/
|
||||
|
||||
mDhtModifications = true;
|
||||
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
it = peers.find(id);
|
||||
if (it != peers.end())
|
||||
{
|
||||
|
@ -281,14 +281,14 @@ bool p3DhtMgr::findPeer(std::string id)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3DhtMgr::dropPeer(std::string id)
|
||||
bool p3DhtMgr::dropPeer(const RsPeerId& id)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/
|
||||
|
||||
mDhtModifications = true;
|
||||
|
||||
/* once we are connected ... don't worry about them anymore */
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
it = peers.find(id);
|
||||
if (it == peers.end())
|
||||
{
|
||||
|
@ -302,14 +302,14 @@ bool p3DhtMgr::dropPeer(std::string id)
|
|||
}
|
||||
|
||||
/* post DHT key saying we should connect */
|
||||
bool p3DhtMgr::notifyPeer(std::string id)
|
||||
bool p3DhtMgr::notifyPeer(const RsPeerId& id)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/
|
||||
#ifdef DHT_DEBUG
|
||||
std::cerr << "p3DhtMgr::notifyPeer() " << id << std::endl;
|
||||
std::cerr << "p3DhtMgr::notifyPeer() " << id.toStdString() << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
it = peers.find(id);
|
||||
if (it == peers.end())
|
||||
{
|
||||
|
@ -333,7 +333,7 @@ bool p3DhtMgr::notifyPeer(std::string id)
|
|||
#ifdef DHT_LOGS
|
||||
{
|
||||
/* Log */
|
||||
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::notifyPeer() Id: " + id + " TO SOON - DROPPING");
|
||||
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::notifyPeer() Id: " + id.toStdString() + " TO SOON - DROPPING");
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -352,7 +352,7 @@ bool p3DhtMgr::notifyPeer(std::string id)
|
|||
#ifdef DHT_LOGS
|
||||
{
|
||||
/* Log */
|
||||
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::notifyPeer() Id: " + id + " PEER NOT FOUND - Trigger Search");
|
||||
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::notifyPeer() Id: " + id.toStdString() + " PEER NOT FOUND - Trigger Search");
|
||||
}
|
||||
#endif
|
||||
it->second.lastTS = 0;
|
||||
|
@ -364,14 +364,14 @@ bool p3DhtMgr::notifyPeer(std::string id)
|
|||
}
|
||||
|
||||
/* extract current peer status */
|
||||
bool p3DhtMgr::getPeerStatus(std::string id,
|
||||
struct sockaddr_in &laddr,
|
||||
struct sockaddr_in &raddr,
|
||||
bool p3DhtMgr::getPeerStatus(const RsPeerId &id,
|
||||
struct sockaddr_in &laddr,
|
||||
struct sockaddr_in &raddr,
|
||||
uint32_t &type, uint32_t &state)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /* LOCK MUTEX */
|
||||
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
it = peers.find(id);
|
||||
|
||||
/* ignore OFF peers */
|
||||
|
@ -776,7 +776,7 @@ int p3DhtMgr::checkPeerDHTKeys()
|
|||
dhtMtx.lock(); /* LOCK MUTEX */
|
||||
|
||||
/* iterate through and find min time and suitable candidate */
|
||||
std::map<std::string, dhtPeerEntry>::iterator it,pit;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it,pit;
|
||||
time_t now = time(NULL);
|
||||
uint32_t period = 0;
|
||||
uint32_t repeatPeriod = 6000;
|
||||
|
@ -802,7 +802,7 @@ int p3DhtMgr::checkPeerDHTKeys()
|
|||
period = DHT_CHECK_PERIOD;
|
||||
}
|
||||
#ifdef DHT_DEBUG
|
||||
std::cerr << "p3DhtMgr::checkPeerDHTKeys() Peer: " << it->second.id;
|
||||
std::cerr << "p3DhtMgr::checkPeerDHTKeys() Peer: " << it->second.id.toStdString();
|
||||
std::cerr << " Period: " << period;
|
||||
std::cerr << " Delta: " << delta;
|
||||
std::cerr << std::endl;
|
||||
|
@ -865,7 +865,7 @@ int p3DhtMgr::checkNotifyDHT()
|
|||
RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/
|
||||
|
||||
/* iterate through and find min time and suitable candidate */
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
time_t now = time(NULL);
|
||||
int repeatPeriod = DHT_DEFAULT_PERIOD;
|
||||
|
||||
|
@ -1015,7 +1015,7 @@ int p3DhtMgr::checkStunState()
|
|||
if (mDhtState == DHT_STATE_CHECK_PEERS)
|
||||
{
|
||||
/* check that they have all be searched for */
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
for(it = peers.begin(); it != peers.end(); it++)
|
||||
{
|
||||
if (it->second.state == DHT_PEER_INIT)
|
||||
|
@ -1287,7 +1287,7 @@ int p3DhtMgr::status(std::ostream &out)
|
|||
out << "OWN DETAILS END----------------------------------------" << std::endl;
|
||||
|
||||
/* now peers states */
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
out << "PEER DETAILS ------------------------------------------" << std::endl;
|
||||
for(it = peers.begin(); it != peers.end(); it++)
|
||||
{
|
||||
|
@ -1622,15 +1622,13 @@ bool p3DhtMgr::dhtResultNotify(std::string idhash)
|
|||
std::cerr << "p3DhtMgr::dhtResultNotify() from idhash: ";
|
||||
std::cerr << RsUtil::BinToHex(idhash) << std::endl;
|
||||
#endif
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
time_t now = time(NULL);
|
||||
|
||||
/* if notify - we must match on the second hash */
|
||||
for(it = peers.begin(); (it != peers.end()) && ((it->second).hash2 != idhash); it++) ;
|
||||
|
||||
/* update data */
|
||||
std::string peerid;
|
||||
|
||||
/* ignore OFF peers */
|
||||
if ((it != peers.end()) && (it->second.state != DHT_PEER_OFF))
|
||||
{
|
||||
|
@ -1677,7 +1675,7 @@ bool p3DhtMgr::dhtResultSearch(std::string idhash,
|
|||
std::cerr << "p3DhtMgr::dhtResultSearch() for idhash: ";
|
||||
std::cerr << RsUtil::BinToHex(idhash) << std::endl;
|
||||
#endif
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
bool doCb = false;
|
||||
bool doStun = false;
|
||||
uint32_t stunFlags = 0;
|
||||
|
@ -1780,7 +1778,7 @@ bool p3DhtMgr::dhtResultSearch(std::string idhash,
|
|||
void printDhtPeerEntry(dhtPeerEntry *ent, std::ostream &out)
|
||||
{
|
||||
|
||||
out << "DhtEntry: ID: " << ent->id;
|
||||
out << "DhtEntry: ID: " << ent->id.toStdString();
|
||||
out << " State: " << ent->state;
|
||||
out << " lastTS: " << ent->lastTS;
|
||||
out << " notifyPending: " << ent->notifyPending;
|
||||
|
|
|
@ -78,7 +78,7 @@ class dhtPeerEntry
|
|||
public:
|
||||
dhtPeerEntry();
|
||||
|
||||
std::string id;
|
||||
RsPeerId id;
|
||||
uint32_t state;
|
||||
time_t lastTS;
|
||||
|
||||
|
@ -97,7 +97,7 @@ class p3DhtMgr: public pqiNetAssistConnect, public RsThread
|
|||
/*
|
||||
*/
|
||||
public:
|
||||
p3DhtMgr(std::string id, pqiConnectCb *cb);
|
||||
p3DhtMgr(RsPeerId id, pqiConnectCb *cb);
|
||||
|
||||
/********** External DHT Interface ************************
|
||||
* These Functions are the external interface
|
||||
|
@ -121,15 +121,15 @@ virtual bool setExternalInterface(struct sockaddr_in laddr,
|
|||
struct sockaddr_in raddr, uint32_t type);
|
||||
|
||||
/* add / remove peers */
|
||||
virtual bool findPeer(std::string id);
|
||||
virtual bool dropPeer(std::string id);
|
||||
virtual bool findPeer(const RsPeerId& id);
|
||||
virtual bool dropPeer(const RsPeerId& id);
|
||||
|
||||
/* post DHT key saying we should connect (callback when done) */
|
||||
virtual bool notifyPeer(std::string id);
|
||||
virtual bool notifyPeer(const RsPeerId& id);
|
||||
|
||||
/* extract current peer status */
|
||||
virtual bool getPeerStatus(std::string id,
|
||||
struct sockaddr_in &laddr, struct sockaddr_in &raddr,
|
||||
virtual bool getPeerStatus(const RsPeerId& id,
|
||||
struct sockaddr_in &laddr, struct sockaddr_in &raddr,
|
||||
uint32_t &type, uint32_t &mode);
|
||||
|
||||
/* stun */
|
||||
|
@ -154,17 +154,17 @@ virtual bool dhtResultBootstrap(std::string idhash);
|
|||
protected:
|
||||
|
||||
/* can block briefly (called only from thread) */
|
||||
virtual bool dhtPublish(std::string id,
|
||||
virtual bool dhtPublish(std::string idhash,
|
||||
struct sockaddr_in &laddr,
|
||||
struct sockaddr_in &raddr,
|
||||
uint32_t type, std::string sign);
|
||||
|
||||
virtual bool dhtNotify(std::string peerid, std::string ownId,
|
||||
virtual bool dhtNotify(std::string idhash, std::string ownIdHash,
|
||||
std::string sign);
|
||||
|
||||
virtual bool dhtSearch(std::string id, uint32_t mode);
|
||||
virtual bool dhtSearch(std::string idhash, uint32_t mode);
|
||||
|
||||
virtual bool dhtBootstrap(std::string storehash, std::string ownIdHash,
|
||||
virtual bool dhtBootstrap(std::string idhash, std::string ownIdHash,
|
||||
std::string sign); /* to publish bootstrap */
|
||||
|
||||
|
||||
|
@ -232,7 +232,7 @@ std::string randomBootstrapId();
|
|||
|
||||
dhtPeerEntry ownEntry;
|
||||
time_t ownNotifyTS;
|
||||
std::map<std::string, dhtPeerEntry> peers;
|
||||
std::map<RsPeerId, dhtPeerEntry> peers;
|
||||
|
||||
std::list<std::string> stunIds;
|
||||
bool mStunRequired;
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
#include <time.h>
|
||||
|
||||
#include "p3historymgr.h"
|
||||
#include "serialiser/rshistoryitems.h"
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsitems/rshistoryitems.h"
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
#include "retroshare/rsiface.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "serialiser/rsmsgitems.h"
|
||||
#include "rsitems/rsmsgitems.h"
|
||||
#include "rsserver/p3face.h"
|
||||
#include "util/rsstring.h"
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <map>
|
||||
#include <list>
|
||||
|
||||
#include "serialiser/rshistoryitems.h"
|
||||
#include "rsitems/rshistoryitems.h"
|
||||
#include "retroshare/rshistory.h"
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@
|
|||
#include "util/rsprint.h"
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsstring.h"
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
|
||||
#include "retroshare/rsiface.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
|
|
|
@ -42,7 +42,8 @@
|
|||
struct RsLog::logInfo p3netmgrzoneInfo = {RsLog::Default, "p3netmgr"};
|
||||
#define p3netmgrzone &p3netmgrzoneInfo
|
||||
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
|
||||
#include "retroshare/rsiface.h"
|
||||
#include "retroshare/rsconfig.h"
|
||||
#include "retroshare/rsbanlist.h"
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "util/rsstring.h"
|
||||
#include "util/rsdebug.h"
|
||||
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsitems/rsconfigitems.h"
|
||||
|
||||
#include "retroshare/rsiface.h" // Needed for rsicontrol (should remove this dependancy)
|
||||
#include "retroshare/rspeers.h" // Needed for Group Parameters.
|
||||
|
@ -2295,43 +2295,6 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
|||
continue;
|
||||
}
|
||||
|
||||
RsPeerGroupItem_deprecated *gitem = dynamic_cast<RsPeerGroupItem_deprecated *>(*it) ;
|
||||
|
||||
if (gitem)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() Peer group item:" << std::endl;
|
||||
gitem->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
RsGroupInfo ginfo ;
|
||||
ginfo.flag = gitem->flag ;
|
||||
ginfo.name = gitem->name ;
|
||||
ginfo.peerIds = gitem->pgpList.ids ;
|
||||
|
||||
do { ginfo.id = RsNodeGroupId::random(); } while(groupList.find(ginfo.id) != groupList.end()) ;
|
||||
|
||||
// Ensure backward compatibility when loading the group in old format. The id must matchthe standard default id.
|
||||
|
||||
if(gitem->id == std::string(RS_GROUP_DEFAULT_NAME_FRIENDS )) ginfo.id = RS_GROUP_ID_FRIENDS ;
|
||||
if(gitem->id == std::string(RS_GROUP_DEFAULT_NAME_COWORKERS)) ginfo.id = RS_GROUP_ID_COWORKERS ;
|
||||
if(gitem->id == std::string(RS_GROUP_DEFAULT_NAME_FAMILY )) ginfo.id = RS_GROUP_ID_FAMILY ;
|
||||
if(gitem->id == std::string(RS_GROUP_DEFAULT_NAME_FAVORITES)) ginfo.id = RS_GROUP_ID_FAVORITES ;
|
||||
if(gitem->id == std::string(RS_GROUP_DEFAULT_NAME_OTHERS )) ginfo.id = RS_GROUP_ID_OTHERS ;
|
||||
|
||||
if(!ginfo.id.isNull())
|
||||
{
|
||||
groupList[ginfo.id] = ginfo ;
|
||||
std::cerr << "(II) Creating new group for old format local group \"" << gitem->name << "\". Id=" << ginfo.id << std::endl;
|
||||
}
|
||||
else
|
||||
std::cerr << "(EE) no group corresponding to old format group with ID=\"" << gitem->id << "\"" << std::endl;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
RsNodeGroupItem *gitem2 = dynamic_cast<RsNodeGroupItem*>(*it) ;
|
||||
|
||||
if (gitem2)
|
||||
|
|
|
@ -397,7 +397,7 @@ private:
|
|||
std::map<RsPeerId,sockaddr_storage> mReportedOwnAddresses ;
|
||||
|
||||
std::map<RsNodeGroupId,RsGroupInfo> groupList;
|
||||
uint32_t lastGroupId;
|
||||
//uint32_t lastGroupId;
|
||||
|
||||
std::list<RsItem *> saveCleanupList; /* TEMPORARY LIST WHEN SAVING */
|
||||
|
||||
|
|
|
@ -26,10 +26,12 @@
|
|||
#include <iostream>
|
||||
|
||||
#include "p3servicecontrol.h"
|
||||
#include "serialiser/rsserviceids.h"
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
#include "rsitems/rsserviceids.h"
|
||||
#include "rsitems/rsitem.h"
|
||||
#include "serialiser/rstypeserializer.h"
|
||||
#include "rsitems/rsnxsitems.h"
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
#include "pqi/pqiservice.h"
|
||||
|
||||
/*******************************/
|
||||
// #define SERVICECONTROL_DEBUG 1
|
||||
|
@ -41,184 +43,40 @@ class RsServiceControlItem: public RsItem
|
|||
{
|
||||
public:
|
||||
RsServiceControlItem(uint8_t item_subtype) : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_TYPE_SERVICE_CONTROL,item_subtype) {}
|
||||
|
||||
virtual uint32_t serial_size() const =0;
|
||||
virtual bool serialise(uint8_t *data,uint32_t size) const =0;
|
||||
|
||||
bool serialise_header(void *data,uint32_t& pktsize,uint32_t& tlvsize, uint32_t& offset) const
|
||||
{
|
||||
tlvsize = serial_size() ;
|
||||
offset = 0;
|
||||
|
||||
if (pktsize < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
pktsize = tlvsize;
|
||||
|
||||
if(!setRsItemHeader(data, tlvsize, PacketId(), tlvsize))
|
||||
{
|
||||
std::cerr << "RsFileTransferItem::serialise_header(): ERROR. Not enough size!" << std::endl;
|
||||
return false ;
|
||||
}
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileItemSerialiser::serialiseData() Header: " << ok << std::endl;
|
||||
#endif
|
||||
offset += 8;
|
||||
|
||||
return true ;
|
||||
}
|
||||
};
|
||||
|
||||
class RsServicePermissionItem: public RsServiceControlItem, public RsServicePermissions
|
||||
{
|
||||
public:
|
||||
RsServicePermissionItem()
|
||||
: RsServiceControlItem(RS_PKT_SUBTYPE_SERVICE_CONTROL_SERVICE_PERMISSIONS) {}
|
||||
RsServicePermissionItem(const RsServicePermissions& perms)
|
||||
: RsServiceControlItem(RS_PKT_SUBTYPE_SERVICE_CONTROL_SERVICE_PERMISSIONS),
|
||||
RsServicePermissions(perms) {}
|
||||
RsServicePermissionItem(): RsServiceControlItem(RS_PKT_SUBTYPE_SERVICE_CONTROL_SERVICE_PERMISSIONS) {}
|
||||
RsServicePermissionItem(const RsServicePermissions& perms) : RsServiceControlItem(RS_PKT_SUBTYPE_SERVICE_CONTROL_SERVICE_PERMISSIONS), RsServicePermissions(perms) {}
|
||||
|
||||
virtual uint32_t serial_size() const
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
uint32_t s = 8 ; // header
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,mServiceId,"mServiceId") ;
|
||||
RsTypeSerializer::serial_process (j,ctx,TLV_TYPE_STR_NAME,mServiceName,"mServiceName") ;
|
||||
RsTypeSerializer::serial_process<bool> (j,ctx,mDefaultAllowed,"mDefaultAllowed") ;
|
||||
|
||||
s += 4 ; // mServiceId
|
||||
s += GetTlvStringSize(mServiceName) ;
|
||||
s += 1 ; // mDefaultAllowed
|
||||
s += 4 ; // mPeersAllowed.size()
|
||||
s += mPeersAllowed.size() * RsPeerId::serial_size() ;
|
||||
s += 4 ; // mPeersAllowed.size()
|
||||
s += mPeersDenied.size() * RsPeerId::serial_size() ;
|
||||
|
||||
return s ;
|
||||
}
|
||||
virtual bool serialise(uint8_t *data,uint32_t size) const
|
||||
{
|
||||
uint32_t tlvsize,offset=0;
|
||||
bool ok = true;
|
||||
|
||||
if(!serialise_header(data,size,tlvsize,offset))
|
||||
return false ;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, mServiceId);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, mServiceName);
|
||||
ok &= setRawUInt8(data, tlvsize, &offset, mDefaultAllowed);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, mPeersAllowed.size());
|
||||
|
||||
for(std::set<RsPeerId>::const_iterator it(mPeersAllowed.begin());it!=mPeersAllowed.end();++it)
|
||||
(*it).serialise(data,tlvsize,offset) ;
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, mPeersDenied.size());
|
||||
|
||||
for(std::set<RsPeerId>::const_iterator it(mPeersDenied.begin());it!=mPeersDenied.end();++it)
|
||||
(*it).serialise(data,tlvsize,offset) ;
|
||||
|
||||
if(offset != tlvsize)
|
||||
{
|
||||
std::cerr << "RsGxsChannelSerialiser::serialiseGxsChannelGroupItem() FAIL Size Error! " << std::endl;
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
std::cerr << "RsGxsChannelSerialiser::serialiseGxsChannelGroupItem() NOK" << std::endl;
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static RsServicePermissionItem *deserialise(uint8_t *data, uint32_t size)
|
||||
{
|
||||
RsServicePermissionItem *item = new RsServicePermissionItem ;
|
||||
|
||||
uint32_t offset = 8; // skip the header
|
||||
uint32_t rssize = getRsItemSize(data);
|
||||
bool ok = true ;
|
||||
|
||||
if(rssize > size)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": error while deserialising! Item will be dropped." << std::endl;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= getRawUInt32(data, rssize, &offset, &item->mServiceId);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->mServiceName);
|
||||
|
||||
uint8_t v;
|
||||
ok &= getRawUInt8(data, rssize, &offset, &v) ;
|
||||
|
||||
if (v != 0 && v != 1)
|
||||
ok = false;
|
||||
else
|
||||
item->mDefaultAllowed = (bool)v ;
|
||||
|
||||
uint32_t tmp ;
|
||||
ok &= getRawUInt32(data, rssize, &offset, &tmp);
|
||||
|
||||
for(uint32_t i=0;i<tmp && offset < rssize;++i)
|
||||
{
|
||||
RsPeerId peer_id ;
|
||||
ok &= peer_id.deserialise(data,rssize,offset) ;
|
||||
item->mPeersAllowed.insert(peer_id) ;
|
||||
}
|
||||
|
||||
ok &= getRawUInt32(data, rssize, &offset, &tmp);
|
||||
|
||||
for(uint32_t i=0;i<tmp && offset < rssize;++i)
|
||||
{
|
||||
RsPeerId peer_id ;
|
||||
ok &= peer_id.deserialise(data,rssize,offset) ;
|
||||
item->mPeersDenied.insert(peer_id) ;
|
||||
}
|
||||
if (offset != rssize || !ok)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": error while deserialising! Item will be dropped." << std::endl;
|
||||
delete(item);
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
return item;
|
||||
RsTypeSerializer::serial_process (j,ctx,mPeersAllowed,"mPeersAllowed");
|
||||
RsTypeSerializer::serial_process (j,ctx,mPeersDenied ,"mPeersDenied");
|
||||
}
|
||||
|
||||
virtual void clear() {}
|
||||
virtual std::ostream& print(std::ostream& out,uint16_t)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": not implemented!" << std::endl;
|
||||
return out ;
|
||||
}
|
||||
};
|
||||
|
||||
class ServiceControlSerialiser: public RsSerialType
|
||||
class ServiceControlSerialiser: public RsServiceSerializer
|
||||
{
|
||||
public:
|
||||
ServiceControlSerialiser() : RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_SERVICE_CONTROL) {}
|
||||
ServiceControlSerialiser() : RsServiceSerializer(RS_SERVICE_TYPE_SERVICE_CONTROL) {}
|
||||
|
||||
virtual uint32_t size (RsItem *item)
|
||||
virtual RsItem *create_item(uint16_t service,uint8_t item_subtype) const
|
||||
{
|
||||
RsServiceControlItem *scitem = dynamic_cast<RsServiceControlItem *>(item);
|
||||
if (!scitem)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return scitem->serial_size() ;
|
||||
}
|
||||
virtual bool serialise(RsItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
RsServiceControlItem *scitem = dynamic_cast<RsServiceControlItem *>(item);
|
||||
if (!scitem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return scitem->serialise((uint8_t*)data,*size) ;
|
||||
}
|
||||
virtual RsItem *deserialise (void *data, uint32_t *size)
|
||||
{
|
||||
uint32_t rstype = getRsItemId(data);
|
||||
if(RS_SERVICE_TYPE_SERVICE_CONTROL != service)
|
||||
return NULL;
|
||||
|
||||
if(RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype) || RS_SERVICE_TYPE_SERVICE_CONTROL != getRsItemService(rstype)) { return NULL; /* wrong type */ }
|
||||
|
||||
switch(getRsItemSubType(rstype))
|
||||
switch(item_subtype)
|
||||
{
|
||||
case RS_PKT_SUBTYPE_SERVICE_CONTROL_SERVICE_PERMISSIONS:return RsServicePermissionItem::deserialise((uint8_t*)data, *size);
|
||||
case RS_PKT_SUBTYPE_SERVICE_CONTROL_SERVICE_PERMISSIONS: return new RsServicePermissionItem();
|
||||
default:
|
||||
return NULL ;
|
||||
}
|
||||
|
@ -248,6 +106,13 @@ const RsPeerId& p3ServiceControl::getOwnId()
|
|||
return mOwnPeerId;
|
||||
}
|
||||
|
||||
bool p3ServiceControl::getServiceItemNames(uint32_t serviceId,std::map<uint8_t,std::string>& names)
|
||||
{
|
||||
if(mServiceServer != NULL)
|
||||
return mServiceServer->getServiceItemNames(serviceId,names) ;
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
/* Interface for Services */
|
||||
bool p3ServiceControl::registerService(const RsServiceInfo &info, bool defaultOn)
|
||||
|
@ -537,7 +402,7 @@ bool p3ServiceControl::updateServicePermissions(uint32_t serviceId, const RsServ
|
|||
{
|
||||
for(pit = onlinePeers.begin(); pit != onlinePeers.end(); ++pit)
|
||||
{
|
||||
if (it->second.peerHasPermission(*pit) !=
|
||||
if (it->second.peerHasPermission(*pit) !=
|
||||
permissions.peerHasPermission(*pit))
|
||||
{
|
||||
mUpdatedSet.insert(*pit);
|
||||
|
@ -597,7 +462,7 @@ bool p3ServiceControl::checkFilter(uint32_t serviceId, const RsPeerId &peerId)
|
|||
#endif
|
||||
|
||||
// must allow ServiceInfo through, or we have nothing!
|
||||
#define FULLID_SERVICEINFO ((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + ((RS_SERVICE_TYPE_SERVICEINFO) << 8))
|
||||
#define FULLID_SERVICEINFO ((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + ((RS_SERVICE_TYPE_SERVICEINFO) << 8))
|
||||
|
||||
//if (serviceId == RS_SERVICE_TYPE_SERVICEINFO)
|
||||
if (serviceId == FULLID_SERVICEINFO)
|
||||
|
@ -691,21 +556,21 @@ bool ServiceInfoCompatible(const RsServiceInfo &info1, const RsServiceInfo &info
|
|||
}
|
||||
|
||||
// ensure that info1 meets minimum requirements for info2
|
||||
if (!versionOkay(info1.mVersionMajor, info1.mVersionMinor,
|
||||
if (!versionOkay(info1.mVersionMajor, info1.mVersionMinor,
|
||||
info2.mMinVersionMajor, info2.mMinVersionMinor))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// ensure that info2 meets minimum requirements for info1
|
||||
if (!versionOkay(info2.mVersionMajor, info2.mVersionMinor,
|
||||
if (!versionOkay(info2.mVersionMajor, info2.mVersionMinor,
|
||||
info1.mMinVersionMajor, info1.mMinVersionMinor))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool p3ServiceControl::updateFilterByPeer(const RsPeerId &peerId)
|
||||
{
|
||||
|
@ -790,8 +655,8 @@ bool p3ServiceControl::updateFilterByPeer_locked(const RsPeerId &peerId)
|
|||
std::cerr << "p3ServiceControl::updateFilterByPeer_locked() Empty ... Clearing";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
// empty, remove...
|
||||
|
||||
// empty, remove...
|
||||
recordFilterChanges_locked(peerId, originalFilter, peerFilter);
|
||||
if (fit != mPeerFilterMap.end())
|
||||
{
|
||||
|
@ -882,7 +747,7 @@ bool p3ServiceControl::updateFilterByPeer_locked(const RsPeerId &peerId)
|
|||
std::cerr << "p3ServiceControl::updateFilterByPeer_locked() Empty(2) ... Clearing";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
if (fit != mPeerFilterMap.end())
|
||||
{
|
||||
mPeerFilterMap.erase(fit);
|
||||
|
@ -900,7 +765,7 @@ bool p3ServiceControl::updateFilterByPeer_locked(const RsPeerId &peerId)
|
|||
return true;
|
||||
}
|
||||
|
||||
void p3ServiceControl::recordFilterChanges_locked(const RsPeerId &peerId,
|
||||
void p3ServiceControl::recordFilterChanges_locked(const RsPeerId &peerId,
|
||||
ServicePeerFilter &originalFilter, ServicePeerFilter &updatedFilter)
|
||||
{
|
||||
#ifdef SERVICECONTROL_DEBUG
|
||||
|
@ -1202,7 +1067,7 @@ bool p3ServiceControl::loadList(std::list<RsItem *>& loadList)
|
|||
|
||||
if(item != NULL)
|
||||
mServicePermissionMap[item->mServiceId] = *item ;
|
||||
|
||||
|
||||
delete *it ;
|
||||
}
|
||||
|
||||
|
@ -1396,49 +1261,49 @@ void p3ServiceControl::notifyServices()
|
|||
std::cerr << "p3ServiceControl::notifyServices(): Noone Monitoring ... skipping";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
std::list<pqiServicePeer> peers;
|
||||
std::set<RsPeerId>::const_iterator pit;
|
||||
for(pit = it->second.mAdded.begin();
|
||||
for(pit = it->second.mAdded.begin();
|
||||
pit != it->second.mAdded.end(); ++pit)
|
||||
{
|
||||
pqiServicePeer peer;
|
||||
peer.id = *pit;
|
||||
peer.actions = RS_SERVICE_PEER_CONNECTED;
|
||||
|
||||
|
||||
peers.push_back(peer);
|
||||
|
||||
|
||||
#ifdef SERVICECONTROL_DEBUG
|
||||
std::cerr << "p3ServiceControl::notifyServices(): Peer: " << *pit << " CONNECTED";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
for(pit = it->second.mRemoved.begin();
|
||||
|
||||
for(pit = it->second.mRemoved.begin();
|
||||
pit != it->second.mRemoved.end(); ++pit)
|
||||
{
|
||||
pqiServicePeer peer;
|
||||
peer.id = *pit;
|
||||
peer.actions = RS_SERVICE_PEER_DISCONNECTED;
|
||||
|
||||
|
||||
peers.push_back(peer);
|
||||
|
||||
|
||||
#ifdef SERVICECONTROL_DEBUG
|
||||
std::cerr << "p3ServiceControl::notifyServices(): Peer: " << *pit << " DISCONNECTED";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
for(; sit != eit; ++sit)
|
||||
{
|
||||
#ifdef SERVICECONTROL_DEBUG
|
||||
std::cerr << "p3ServiceControl::notifyServices(): Sending to Monitoring Service";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
sit->second->statusChange(peers);
|
||||
}
|
||||
}
|
||||
|
@ -1500,17 +1365,17 @@ void RsServicePermissions::resetPermission(const RsPeerId& peerId)
|
|||
}
|
||||
|
||||
RsServiceInfo::RsServiceInfo(
|
||||
const uint16_t service_type,
|
||||
const std::string service_name,
|
||||
const uint16_t service_type,
|
||||
const std::string service_name,
|
||||
const uint16_t version_major,
|
||||
const uint16_t version_minor,
|
||||
const uint16_t min_version_major,
|
||||
const uint16_t min_version_minor)
|
||||
:mServiceName(service_name),
|
||||
mServiceType((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + (((uint32_t) service_type) << 8)),
|
||||
mVersionMajor(version_major),
|
||||
:mServiceName(service_name),
|
||||
mServiceType((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + (((uint32_t) service_type) << 8)),
|
||||
mVersionMajor(version_major),
|
||||
mVersionMinor(version_minor),
|
||||
mMinVersionMajor(min_version_major),
|
||||
mMinVersionMajor(min_version_major),
|
||||
mMinVersionMinor(min_version_minor)
|
||||
{
|
||||
return;
|
||||
|
@ -1518,7 +1383,7 @@ RsServiceInfo::RsServiceInfo(
|
|||
|
||||
|
||||
RsServiceInfo::RsServiceInfo()
|
||||
:mServiceName("unknown"),
|
||||
:mServiceName("unknown"),
|
||||
mServiceType(0),
|
||||
mVersionMajor(0),
|
||||
mVersionMinor(0),
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#include "pqi/pqiservicemonitor.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
|
||||
class p3ServiceServer ;
|
||||
|
||||
class ServiceNotifications
|
||||
{
|
||||
public:
|
||||
|
@ -101,6 +103,9 @@ virtual bool updateServicePermissions(uint32_t serviceId, const RsServicePermiss
|
|||
virtual void getPeersConnected(const uint32_t serviceId, std::set<RsPeerId> &peerSet);
|
||||
virtual bool isPeerConnected(const uint32_t serviceId, const RsPeerId &peerId);
|
||||
|
||||
// Gets the list of items used by that service
|
||||
virtual bool getServiceItemNames(uint32_t serviceId,std::map<uint8_t,std::string>& names) ;
|
||||
|
||||
/**
|
||||
* Registration for all Services.
|
||||
*/
|
||||
|
@ -132,6 +137,8 @@ virtual bool updateServicesProvided(const RsPeerId &peerId, const RsPeerServiceI
|
|||
// pqiMonitor.
|
||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||
|
||||
virtual void setServiceServer(p3ServiceServer *p) { mServiceServer = p ; }
|
||||
|
||||
protected:
|
||||
// configuration.
|
||||
virtual bool saveList(bool &cleanup, std::list<RsItem *>&);
|
||||
|
@ -196,6 +203,7 @@ bool peerHasPermissionForService_locked(const RsPeerId &peerId, uint32_t service
|
|||
// Below here is saved in Configuration.
|
||||
std::map<uint32_t, RsServicePermissions> mServicePermissionMap;
|
||||
|
||||
p3ServiceServer *mServiceServer ;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
#ifndef PQI_TOP_HEADER
|
||||
#define PQI_TOP_HEADER
|
||||
|
||||
#include "serialiser/rsserial.h"
|
||||
|
||||
#include "rsitems/rsitem.h"
|
||||
|
||||
class P3Interface
|
||||
{
|
||||
|
|
|
@ -61,14 +61,20 @@ void pqiConnectCbDummy::peerStatus(const RsPeerId& id, const pqiIpAddrSet &ad
|
|||
std::cerr << out << std::endl;
|
||||
}
|
||||
|
||||
void pqiConnectCbDummy::peerConnectRequest(const RsPeerId& id,
|
||||
const struct sockaddr_storage &raddr, uint32_t source)
|
||||
void pqiConnectCbDummy::peerConnectRequest(const RsPeerId &id, const sockaddr_storage &raddr
|
||||
, const sockaddr_storage &proxyaddr, const sockaddr_storage &srcaddr
|
||||
, uint32_t source, uint32_t flags, uint32_t delay, uint32_t bandwidth)
|
||||
{
|
||||
std::cerr << "pqiConnectCbDummy::peerConnectRequest()";
|
||||
std::cerr << " id: " << id;
|
||||
std::cerr << " raddr: " << sockaddr_storage_tostring(raddr);
|
||||
std::cerr << " proxyaddr: " << sockaddr_storage_tostring(proxyaddr);
|
||||
std::cerr << " srcaddr: " << sockaddr_storage_tostring(srcaddr);
|
||||
std::cerr << " source: " << source;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << " flags: " << flags;
|
||||
std::cerr << " delay: " << delay;
|
||||
std::cerr << " bandwidth: " << bandwidth;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
void pqiMonitor::disconnectPeer(const RsPeerId &/*peer*/)
|
||||
|
|
|
@ -179,8 +179,9 @@ virtual ~pqiConnectCbDummy();
|
|||
virtual void peerStatus(const RsPeerId& id, const pqiIpAddrSet &addrs,
|
||||
uint32_t type, uint32_t mode, uint32_t source);
|
||||
|
||||
virtual void peerConnectRequest(const RsPeerId& id,
|
||||
const struct sockaddr_storage &raddr, uint32_t source);
|
||||
virtual void peerConnectRequest(const RsPeerId& id, const struct sockaddr_storage &raddr,
|
||||
const struct sockaddr_storage &proxyaddr, const struct sockaddr_storage &srcaddr,
|
||||
uint32_t source, uint32_t flags, uint32_t delay, uint32_t bandwidth);
|
||||
|
||||
//virtual void stunStatus(std::string id, const struct sockaddr_storage &raddr, uint32_t type, uint32_t flags);
|
||||
};
|
||||
|
|
|
@ -40,7 +40,7 @@ static struct RsLog::logInfo pqipersonzoneInfo = {RsLog::Default, "pqiperson"};
|
|||
|
||||
pqiperson::pqiperson(const RsPeerId& id, pqipersongrp *pg) :
|
||||
PQInterface(id), mNotifyMtx("pqiperson-notify"), mPersonMtx("pqiperson"),
|
||||
active(false), activepqi(NULL), inConnectAttempt(false), waittimes(0),
|
||||
active(false), activepqi(NULL), inConnectAttempt(false),// waittimes(0),
|
||||
pqipg(pg) {} // TODO: must check id!
|
||||
|
||||
pqiperson::~pqiperson()
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#define MRK_PQI_PERSON_HEADER
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "pqi/pqi.h"
|
||||
#include "util/rsnet.h"
|
||||
|
||||
|
@ -66,7 +67,7 @@ public:
|
|||
virtual int reset() { pqistreamer::reset(); return ni->reset(); }
|
||||
virtual int disconnect() { return reset() ; }
|
||||
virtual bool connect_parameter(uint32_t type, uint32_t value) { return ni->connect_parameter(type, value);}
|
||||
virtual bool connect_parameter(uint32_t type, std::string value) { return ni->connect_parameter(type, value);}
|
||||
virtual bool connect_parameter(uint32_t type, const std::string &value) { return ni->connect_parameter(type, value);}
|
||||
virtual bool connect_additional_address(uint32_t type, const struct sockaddr_storage &addr) { return ni->connect_additional_address(type, addr); }
|
||||
virtual int getConnectAddress(struct sockaddr_storage &raddr){ return ni->getConnectAddress(raddr); }
|
||||
|
||||
|
@ -171,7 +172,7 @@ private:
|
|||
bool active;
|
||||
pqiconnect *activepqi;
|
||||
bool inConnectAttempt;
|
||||
int waittimes;
|
||||
//int waittimes;
|
||||
time_t lastHeartbeatReceived; // use to track connection failure
|
||||
pqipersongrp *pqipg; /* parent for callback */
|
||||
};
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "pqi/p3linkmgr.h"
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsprint.h"
|
||||
#include "serialiser/rsserviceserialiser.h"
|
||||
#include "serialiser/rsserializer.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -699,7 +699,7 @@ pqiperson * pqipersongrpDummy::locked_createPerson(const RsPeerId& id, pqilisten
|
|||
NetBinDummy *d1 = new NetBinDummy(pqip, id, PQI_CONNECT_TCP);
|
||||
|
||||
RsSerialiser *rss = new RsSerialiser();
|
||||
rss->addSerialType(new RsServiceSerialiser());
|
||||
rss->addSerialType(new RsRawSerialiser());
|
||||
|
||||
pqiconnect *pqic = new pqiconnect(pqip, rss, d1);
|
||||
|
||||
|
@ -709,7 +709,7 @@ pqiperson * pqipersongrpDummy::locked_createPerson(const RsPeerId& id, pqilisten
|
|||
NetBinDummy *d2 = new NetBinDummy(pqip, id, PQI_CONNECT_UDP);
|
||||
|
||||
RsSerialiser *rss2 = new RsSerialiser();
|
||||
rss2->addSerialType(new RsServiceSerialiser());
|
||||
rss2->addSerialType(new RsRawSerialiser());
|
||||
|
||||
pqiconnect *pqic2 = new pqiconnect(pqip, rss2, d2);
|
||||
|
||||
|
|
|
@ -11,7 +11,9 @@ const uint32_t pqiQoS::MAX_PACKET_COUNTER_VALUE = (1 << 24) ;
|
|||
pqiQoS::pqiQoS(uint32_t nb_levels,float alpha)
|
||||
: _item_queues(nb_levels),_alpha(alpha)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
assert(pow(alpha,nb_levels) < 1e+20) ;
|
||||
#endif
|
||||
|
||||
float c = 1.0f ;
|
||||
float inc = alpha ;
|
||||
|
@ -110,7 +112,9 @@ void *pqiQoS::out_rsItem(uint32_t max_slice_size, uint32_t& size, bool& starts,
|
|||
|
||||
if(last >= 0)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
assert(_nb_items > 0) ;
|
||||
#endif
|
||||
|
||||
// now chop a slice of this item
|
||||
|
||||
|
|
|
@ -79,11 +79,26 @@ int p3ServiceServer::addService(pqiService *ts, bool defaultOn)
|
|||
services[info.mServiceType] = ts;
|
||||
|
||||
// This doesn't need to be in Mutex.
|
||||
mServiceControl->registerService(info, defaultOn);
|
||||
mServiceControl->registerService(info,defaultOn);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool p3ServiceServer::getServiceItemNames(uint32_t service_type,std::map<uint8_t,std::string>& names)
|
||||
{
|
||||
RsStackMutex stack(srvMtx); /********* LOCKED *********/
|
||||
|
||||
std::map<uint32_t, pqiService *>::iterator it=services.find(service_type) ;
|
||||
|
||||
if(it != services.end())
|
||||
{
|
||||
it->second->getItemNames(names) ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
int p3ServiceServer::removeService(pqiService *ts)
|
||||
{
|
||||
RsStackMutex stack(srvMtx); /********* LOCKED *********/
|
||||
|
|
|
@ -60,24 +60,26 @@ class p3ServiceServerIface;
|
|||
|
||||
class pqiService
|
||||
{
|
||||
protected:
|
||||
protected:
|
||||
|
||||
pqiService() // our type of packets.
|
||||
:mServiceServer(NULL) { return; }
|
||||
:mServiceServer(NULL) { return; }
|
||||
|
||||
virtual ~pqiService() { return; }
|
||||
virtual ~pqiService() { return; }
|
||||
|
||||
public:
|
||||
void setServiceServer(p3ServiceServerIface *server);
|
||||
//
|
||||
virtual bool recv(RsRawItem *) = 0;
|
||||
virtual bool send(RsRawItem *item);
|
||||
public:
|
||||
void setServiceServer(p3ServiceServerIface *server);
|
||||
//
|
||||
virtual bool recv(RsRawItem *) = 0;
|
||||
virtual bool send(RsRawItem *item);
|
||||
|
||||
virtual RsServiceInfo getServiceInfo() = 0;
|
||||
virtual RsServiceInfo getServiceInfo() = 0;
|
||||
|
||||
virtual int tick() { return 0; }
|
||||
virtual int tick() { return 0; }
|
||||
|
||||
private:
|
||||
virtual void getItemNames(std::map<uint8_t,std::string>& /*names*/) const {} // This does nothing by default. Service should derive it in order to give info for the UI
|
||||
|
||||
private:
|
||||
p3ServiceServerIface *mServiceServer; // const, no need for mutex.
|
||||
};
|
||||
|
||||
|
@ -97,10 +99,10 @@ public:
|
|||
virtual ~p3ServiceServerIface() {}
|
||||
|
||||
|
||||
virtual bool recvItem(RsRawItem *) = 0;
|
||||
virtual bool sendItem(RsRawItem *) = 0;
|
||||
|
||||
virtual bool recvItem(RsRawItem *) = 0;
|
||||
virtual bool sendItem(RsRawItem *) = 0;
|
||||
|
||||
virtual bool getServiceItemNames(uint32_t service_type,std::map<uint8_t,std::string>& names) =0;
|
||||
};
|
||||
|
||||
class p3ServiceServer : public p3ServiceServerIface
|
||||
|
@ -108,13 +110,15 @@ class p3ServiceServer : public p3ServiceServerIface
|
|||
public:
|
||||
p3ServiceServer(pqiPublisher *pub, p3ServiceControl *ctrl);
|
||||
|
||||
int addService(pqiService *, bool defaultOn);
|
||||
int removeService(pqiService *);
|
||||
int addService(pqiService *, bool defaultOn);
|
||||
int removeService(pqiService *);
|
||||
|
||||
bool recvItem(RsRawItem *);
|
||||
bool sendItem(RsRawItem *);
|
||||
bool recvItem(RsRawItem *);
|
||||
bool sendItem(RsRawItem *);
|
||||
|
||||
int tick();
|
||||
bool getServiceItemNames(uint32_t service_type, std::map<uint8_t,std::string>& names) ;
|
||||
|
||||
int tick();
|
||||
public:
|
||||
|
||||
private:
|
||||
|
@ -122,7 +126,7 @@ private:
|
|||
pqiPublisher *mPublisher; // constant no need for mutex.
|
||||
p3ServiceControl *mServiceControl;
|
||||
|
||||
RsMutex srvMtx;
|
||||
RsMutex srvMtx;
|
||||
std::map<uint32_t, pqiService *> services;
|
||||
|
||||
};
|
||||
|
|
|
@ -1009,7 +1009,7 @@ int pqissl::Basic_Connection_Complete()
|
|||
|
||||
return -1;
|
||||
}
|
||||
else if ((err == ECONNREFUSED))
|
||||
else if (err == ECONNREFUSED)
|
||||
{
|
||||
rslog(RSL_WARNING, pqisslzone, "pqissl::Basic_Connection_Complete() ECONNREFUSED: cert: " + PeerId().toStdString());
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "serialiser/rsserviceserialiser.h"
|
||||
#include "serialiser/rsserializer.h"
|
||||
#include "util/rsdebug.h"
|
||||
|
||||
#include "pqi/pqisslpersongrp.h"
|
||||
|
@ -87,7 +87,7 @@ pqiperson * pqisslpersongrp::locked_createPerson(const RsPeerId& id, pqilistener
|
|||
|
||||
|
||||
RsSerialiser *rss = new RsSerialiser();
|
||||
rss->addSerialType(new RsServiceSerialiser());
|
||||
rss->addSerialType(new RsRawSerialiser());
|
||||
|
||||
pqiconnect *pqisc = new pqiconnect(pqip, rss, pqis);
|
||||
|
||||
|
@ -141,7 +141,7 @@ pqiperson * pqisslpersongrp::locked_createPerson(const RsPeerId& id, pqilistener
|
|||
ssl_tunnels[id] = pqis ; // keeps for getting crypt info per peer.
|
||||
|
||||
RsSerialiser *rss = new RsSerialiser();
|
||||
rss->addSerialType(new RsServiceSerialiser());
|
||||
rss->addSerialType(new RsRawSerialiser());
|
||||
|
||||
pqiconnect *pqisc = new pqiconnect(pqip, rss, pqis);
|
||||
|
||||
|
@ -151,7 +151,7 @@ pqiperson * pqisslpersongrp::locked_createPerson(const RsPeerId& id, pqilistener
|
|||
pqissludp *pqius = new pqissludp(pqip, mLinkMgr);
|
||||
|
||||
RsSerialiser *rss2 = new RsSerialiser();
|
||||
rss2->addSerialType(new RsServiceSerialiser());
|
||||
rss2->addSerialType(new RsRawSerialiser());
|
||||
|
||||
pqiconnect *pqiusc = new pqiconnect(pqip, rss2, pqius);
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ static const uint32_t PQI_SSLUDP_DEF_CONN_PERIOD = 300; /* 5 minutes? */
|
|||
/********** PQI SSL UDP STUFF **************************************/
|
||||
|
||||
pqissludp::pqissludp(PQInterface *parent, p3LinkMgr *lm) :
|
||||
pqissl(NULL, parent, lm), tou_bio(NULL), listen_checktime(0),
|
||||
pqissl(NULL, parent, lm), tou_bio(NULL),// listen_checktime(0),
|
||||
mConnectPeriod(PQI_SSLUDP_DEF_CONN_PERIOD), mConnectFlags(0),
|
||||
mConnectBandwidth(0)
|
||||
{
|
||||
|
|
|
@ -95,7 +95,7 @@ private:
|
|||
|
||||
BIO *tou_bio; // specific to ssludp.
|
||||
|
||||
long listen_checktime;
|
||||
//long listen_checktime;
|
||||
|
||||
uint32_t mConnectPeriod;
|
||||
uint32_t mConnectFlags;
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "rsitems/rsitem.h"
|
||||
#include "pqi/pqistore.h"
|
||||
#include "serialiser/rsserial.h"
|
||||
#include <iostream>
|
||||
|
@ -309,24 +310,25 @@ int pqistore::readPkt(RsItem **item_out)
|
|||
}
|
||||
|
||||
// workout how much more to read.
|
||||
int extralen = getRsItemSize(block) - blen;
|
||||
int totallen = extralen+blen;
|
||||
|
||||
// make sure that totallen is not a crazy number. If so, we drop the entire stream that might be corrupted.
|
||||
|
||||
if(totallen > 1024*1024)
|
||||
int blocklength = getRsItemSize(block);
|
||||
|
||||
// make sure that blocklength is not a crazy number. If so, we drop the entire stream that might be corrupted.
|
||||
|
||||
if(blocklength < blen || blocklength > 1024*1024*10)
|
||||
{
|
||||
std::cerr << "pqistore: ERROR: trying to realloc memory for packet of length" << totallen <<", which exceeds the allowed limit (1MB)" << std::endl ;
|
||||
std::cerr << "pqistore: ERROR: trying to realloc memory for packet of length" << blocklength <<", which is either too small, or exceeds the safety limit (10 MB)" << std::endl ;
|
||||
free(block) ;
|
||||
bStopReading=true;
|
||||
return 0 ;
|
||||
}
|
||||
void *tmp = realloc(block, totallen);
|
||||
int extralen = blocklength - blen;
|
||||
|
||||
void *tmp = realloc(block, blocklength);
|
||||
|
||||
if (tmp == NULL)
|
||||
{
|
||||
free(block);
|
||||
std::cerr << "pqistore: ERROR: trying to realloc memory for packet of length" << totallen << std::endl ;
|
||||
std::cerr << "pqistore: ERROR: trying to realloc memory for packet of length" << blocklength << std::endl ;
|
||||
std::cerr << "Have you got enought memory?" << std::endl ;
|
||||
bStopReading=true;
|
||||
return 0 ;
|
||||
|
@ -520,17 +522,18 @@ int pqiSSLstore::readPkt(RsItem **item_out)
|
|||
}
|
||||
|
||||
// workout how much more to read.
|
||||
int extralen = getRsItemSize(block) - blen;
|
||||
int totallen = extralen+blen;
|
||||
int blocklength = getRsItemSize(block);
|
||||
|
||||
if(totallen > 1024*1024)
|
||||
if(blocklength < blen || blocklength > 1024*1024*10)
|
||||
{
|
||||
free(block);
|
||||
std::cerr << "pqiSSLstore: ERROR: trying to realloc memory for packet of length" << totallen << ", that exceeds the limit of 1MB" << std::endl ;
|
||||
std::cerr << "pqiSSLstore: ERROR: block length has invalid value " << blocklength << " (either too small, or exceeds the safety limit of 10 MB)" << std::endl ;
|
||||
bStopReading=true;
|
||||
return 0 ;
|
||||
}
|
||||
void *tmp = realloc(block, totallen);
|
||||
int extralen = blocklength - blen;
|
||||
|
||||
void *tmp = realloc(block, blocklength);
|
||||
|
||||
if (tmp == NULL)
|
||||
{
|
||||
|
|
|
@ -627,7 +627,7 @@ bool getX509id(X509 *x509, RsPeerId& xid)
|
|||
* more randomness
|
||||
*/
|
||||
|
||||
#warning this is cryptographically horrible. We should do a hash of the public key here!!!
|
||||
#warning csoler 2017-02-19: This is cryptographically horrible. We should do a hash of the public key here!!!
|
||||
|
||||
xid = RsPeerId(&signdata[signlen - CERTSIGNLEN]) ;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue