mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-15 09:36:23 -04:00
id cleaning - continued
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-IdCleaning@7092 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
33ab4ee3b5
commit
c4c8414a79
23 changed files with 380 additions and 389 deletions
|
@ -81,7 +81,7 @@ virtual int dhtInfoCallback(const bdId *id, uint32_t type, uint32_t flags, std::
|
|||
};
|
||||
|
||||
|
||||
p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, p3NetMgr *nm,
|
||||
p3BitDht::p3BitDht(const RsPeerId& id, pqiConnectCb *cb, p3NetMgr *nm,
|
||||
UdpStack *udpstack, std::string bootstrapfile)
|
||||
:p3Config(CONFIG_TYPE_BITDHT), pqiNetAssistConnect(id, cb), mNetMgr(nm), dhtMtx("p3BitDht")
|
||||
{
|
||||
|
|
|
@ -52,7 +52,7 @@ class DhtPeerDetails
|
|||
uint32_t mPeerType;
|
||||
|
||||
bdId mDhtId;
|
||||
std::string mRsId;
|
||||
RsPeerId mRsId;
|
||||
|
||||
/* direct from the DHT! */
|
||||
uint32_t mDhtState; // One of RSDHT_PEERDHT_[...]
|
||||
|
@ -142,7 +142,7 @@ class p3NetMgr;
|
|||
class p3BitDht: public p3Config, public pqiNetAssistConnect, public RsDht
|
||||
{
|
||||
public:
|
||||
p3BitDht(std::string id, pqiConnectCb *cb, p3NetMgr *nm,
|
||||
p3BitDht(const RsPeerId& id, pqiConnectCb *cb, p3NetMgr *nm,
|
||||
UdpStack *udpstack, std::string bootstrapfile);
|
||||
|
||||
|
||||
|
@ -155,8 +155,8 @@ virtual ~p3BitDht();
|
|||
|
||||
virtual uint32_t getNetState(uint32_t type);
|
||||
virtual int getDhtPeers(int lvl, std::list<RsDhtPeer> &peers);
|
||||
virtual int getNetPeerList(std::list<std::string> &peerIds);
|
||||
virtual int getNetPeerStatus(std::string peerId, RsDhtNetPeer &status);
|
||||
virtual int getNetPeerList(std::list<RsPeerId> &peerIds);
|
||||
virtual int getNetPeerStatus(const RsPeerId& peerId, RsDhtNetPeer &status);
|
||||
|
||||
virtual int getRelayEnds(std::list<RsDhtRelayEnd> &relayEnds);
|
||||
virtual int getRelayProxies(std::list<RsDhtRelayProxy> &relayProxies);
|
||||
|
@ -194,20 +194,20 @@ virtual bool getNetworkStats(uint32_t &netsize, uint32_t &localnetsize);
|
|||
/* pqiNetAssistConnect - external interface functions */
|
||||
|
||||
/* 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);
|
||||
|
||||
virtual int addBadPeer(const struct sockaddr_storage &addr, uint32_t reason, uint32_t flags, uint32_t age);
|
||||
virtual int addKnownPeer(const std::string &pid, const struct sockaddr_storage &addr, uint32_t flags);
|
||||
virtual int addKnownPeer(const RsPeerId &pid, const struct sockaddr_storage &addr, uint32_t flags);
|
||||
//virtual int addFriend(const std::string pid);
|
||||
//virtual int addFriendOfFriend(const std::string pid);
|
||||
//virtual int addOther(const std::string pid);
|
||||
|
||||
/* feedback on success failure of Connections */
|
||||
virtual void ConnectionFeedback(std::string pid, int state);
|
||||
virtual void ConnectionFeedback(const RsPeerId& pid, int state);
|
||||
|
||||
/* extract current peer status */
|
||||
virtual bool getPeerStatus(std::string id,
|
||||
virtual bool getPeerStatus(const RsPeerId& id,
|
||||
struct sockaddr_storage &laddr, struct sockaddr_storage &raddr,
|
||||
uint32_t &type, uint32_t &mode);
|
||||
|
||||
|
@ -255,18 +255,18 @@ int installRelayConnection(const bdId *srcId, const bdId *destId, uint32_t &ban
|
|||
int removeRelayConnection(const bdId *srcId, const bdId *destId);
|
||||
void monitorConnections();
|
||||
|
||||
void ConnectCallout(const std::string &peerId, struct sockaddr_in addr, uint32_t connectMode);
|
||||
void ConnectCallout(const RsPeerId &peerId, struct sockaddr_in addr, uint32_t connectMode);
|
||||
|
||||
void ConnectCalloutTCPAttempt(const std::string &peerId, struct sockaddr_in addr);
|
||||
void ConnectCalloutDirectOrProxy(const std::string &peerId, struct sockaddr_in raddr, uint32_t connectFlags, uint32_t delay);
|
||||
void ConnectCalloutRelay(const std::string &peerId, struct sockaddr_in srcaddr,
|
||||
void ConnectCalloutTCPAttempt(const RsPeerId &peerId, struct sockaddr_in addr);
|
||||
void ConnectCalloutDirectOrProxy(const RsPeerId &peerId, struct sockaddr_in raddr, uint32_t connectFlags, uint32_t delay);
|
||||
void ConnectCalloutRelay(const RsPeerId &peerId, struct sockaddr_in srcaddr,
|
||||
struct sockaddr_in proxyaddr, struct sockaddr_in destaddr,
|
||||
uint32_t connectMode, uint32_t bandwidth);
|
||||
|
||||
|
||||
void Feedback_Connected(std::string pid);
|
||||
void Feedback_ConnectionFailed(std::string pid);
|
||||
void Feedback_ConnectionClosed(std::string pid);
|
||||
void Feedback_Connected(const RsPeerId& pid);
|
||||
void Feedback_ConnectionFailed(const RsPeerId& pid);
|
||||
void Feedback_ConnectionClosed(const RsPeerId& pid);
|
||||
|
||||
void UdpConnectionFailed_locked(DhtPeerDetails *dpd);
|
||||
void ReleaseProxyExclusiveMode_locked(DhtPeerDetails *dpd, bool addrChgLikely);
|
||||
|
@ -337,24 +337,24 @@ int pushRelayServers();
|
|||
|
||||
public:
|
||||
|
||||
int removePeer(const std::string pid);
|
||||
int removePeer(const RsPeerId& pid);
|
||||
|
||||
// Can be used externally too.
|
||||
int calculateNodeId(const std::string pid, bdNodeId *id);
|
||||
int calculateNodeId(const RsPeerId& pid, bdNodeId *id);
|
||||
int addKnownNode(const bdId *id, uint32_t flags);
|
||||
|
||||
private:
|
||||
|
||||
DhtPeerDetails *addInternalPeer_locked(const std::string pid, uint32_t type);
|
||||
int removeInternalPeer_locked(const std::string pid);
|
||||
DhtPeerDetails *addInternalPeer_locked(const RsPeerId& pid, uint32_t type);
|
||||
int removeInternalPeer_locked(const RsPeerId& pid);
|
||||
DhtPeerDetails *findInternalDhtPeer_locked(const bdNodeId *id, uint32_t type);
|
||||
DhtPeerDetails *findInternalRsPeer_locked(const std::string &pid);
|
||||
DhtPeerDetails *findInternalRsPeer_locked(const RsPeerId &pid);
|
||||
|
||||
bool havePeerTranslation_locked(const std::string &pid);
|
||||
int lookupNodeId_locked(const std::string pid, bdNodeId *id);
|
||||
int lookupRsId_locked(const bdNodeId *id, std::string &pid);
|
||||
int storeTranslation_locked(const std::string pid);
|
||||
int removeTranslation_locked(const std::string pid);
|
||||
bool havePeerTranslation_locked(const RsPeerId &pid);
|
||||
int lookupNodeId_locked(const RsPeerId& pid, bdNodeId *id);
|
||||
int lookupRsId_locked(const bdNodeId *id, RsPeerId &pid);
|
||||
int storeTranslation_locked(const RsPeerId& pid);
|
||||
int removeTranslation_locked(const RsPeerId& pid);
|
||||
|
||||
UdpBitDht *mUdpBitDht; /* has own mutex, is static except for creation/destruction */
|
||||
UdpStunner *mDhtStunner;
|
||||
|
@ -372,14 +372,14 @@ int removeTranslation_locked(const std::string pid);
|
|||
|
||||
p3BitDhtRelayHandler *mRelayHandler;
|
||||
|
||||
std::string mOwnRsId;
|
||||
RsPeerId mOwnRsId;
|
||||
bdNodeId mOwnDhtId;
|
||||
|
||||
time_t mMinuteTS;
|
||||
|
||||
/* translation maps */
|
||||
std::map<std::string, bdNodeId> mTransToNodeId;
|
||||
std::map<bdNodeId, std::string> mTransToRsId;
|
||||
std::map<RsPeerId, bdNodeId> mTransToNodeId;
|
||||
std::map<bdNodeId, RsPeerId> mTransToRsId;
|
||||
|
||||
std::map<bdNodeId, DhtPeerDetails> mPeers;
|
||||
std::map<bdNodeId, DhtPeerDetails> mFailedPeers;
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
int p3BitDht::InfoCallback(const bdId *id, uint32_t /*type*/, uint32_t /*flags*/, std::string /*info*/)
|
||||
{
|
||||
/* translate info */
|
||||
std::string rsid;
|
||||
RsPeerId rsid;
|
||||
struct sockaddr_in addr = id->addr;
|
||||
int outtype = PNASS_TYPE_BADPEER;
|
||||
int outreason = PNASS_REASON_UNKNOWN;
|
||||
|
@ -632,7 +632,7 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId
|
|||
/* if we get here, we are an endpoint (peer specified in peerId) */
|
||||
|
||||
/* translate id into string for exclusive mode */
|
||||
std::string pid;
|
||||
RsPeerId pid;
|
||||
bdStdPrintNodeId(pid, &(peerId.id), false);
|
||||
|
||||
switch(cbtype)
|
||||
|
@ -1178,7 +1178,7 @@ int p3BitDht::doActions()
|
|||
bool grabbedExclusivePort = false;
|
||||
|
||||
/* translate id into string for exclusive mode */
|
||||
std::string pid;
|
||||
RsPeerId pid;
|
||||
bdStdPrintNodeId(pid, &(action.mDestId.id), false);
|
||||
|
||||
|
||||
|
@ -1569,7 +1569,7 @@ int p3BitDht::doActions()
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::string peerRsId;
|
||||
RsPeerId peerRsId;
|
||||
bool foundPeerId = false;
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/
|
||||
|
@ -1774,7 +1774,7 @@ int p3BitDht::checkConnectionAllowed(const bdId *peerId, int mode)
|
|||
*/
|
||||
|
||||
|
||||
void p3BitDht::ConnectCalloutTCPAttempt(const std::string &peerId, struct sockaddr_in raddrv4)
|
||||
void p3BitDht::ConnectCalloutTCPAttempt(const RsPeerId &peerId, struct sockaddr_in raddrv4)
|
||||
{
|
||||
struct sockaddr_storage raddr;
|
||||
struct sockaddr_storage proxyaddr;
|
||||
|
@ -1802,7 +1802,7 @@ void p3BitDht::ConnectCalloutTCPAttempt(const std::string &peerId, struct sockad
|
|||
}
|
||||
|
||||
|
||||
void p3BitDht::ConnectCalloutDirectOrProxy(const std::string &peerId, struct sockaddr_in raddrv4, uint32_t connectFlags, uint32_t delay)
|
||||
void p3BitDht::ConnectCalloutDirectOrProxy(const RsPeerId &peerId, struct sockaddr_in raddrv4, uint32_t connectFlags, uint32_t delay)
|
||||
{
|
||||
struct sockaddr_storage raddr;
|
||||
struct sockaddr_storage proxyaddr;
|
||||
|
@ -1827,7 +1827,7 @@ void p3BitDht::ConnectCalloutDirectOrProxy(const std::string &peerId, struct soc
|
|||
mConnCb->peerConnectRequest(peerId, raddr, proxyaddr, srcaddr, source, connectFlags, delay, bandwidth);
|
||||
}
|
||||
|
||||
void p3BitDht::ConnectCalloutRelay(const std::string &peerId,
|
||||
void p3BitDht::ConnectCalloutRelay(const RsPeerId &peerId,
|
||||
struct sockaddr_in srcaddrv4, struct sockaddr_in proxyaddrv4, struct sockaddr_in destaddrv4,
|
||||
uint32_t connectFlags, uint32_t bandwidth)
|
||||
{
|
||||
|
@ -1944,7 +1944,7 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const
|
|||
#endif
|
||||
|
||||
// uint32_t touConnectMode = 0;
|
||||
std::string rsId;
|
||||
RsPeerId rsId;
|
||||
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/
|
||||
|
@ -2054,10 +2054,10 @@ int p3BitDht::installRelayConnection(const bdId *srcId, const bdId *destId, uint
|
|||
int relayClass = UDP_RELAY_CLASS_GENERAL;
|
||||
|
||||
#ifdef DEBUG_PEERNET
|
||||
std::string strId1;
|
||||
RsPeerId strId1;
|
||||
bdStdPrintNodeId(strId1, &(srcId->id), false);
|
||||
|
||||
std::string strId2;
|
||||
RsPeerId strId2;
|
||||
bdStdPrintNodeId(strId2, &(destId->id), false);
|
||||
#endif
|
||||
|
||||
|
@ -2180,7 +2180,7 @@ void p3BitDht::monitorConnections()
|
|||
|
||||
|
||||
|
||||
void p3BitDht::Feedback_Connected(std::string pid)
|
||||
void p3BitDht::Feedback_Connected(const RsPeerId& pid)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/
|
||||
DhtPeerDetails *dpd = findInternalRsPeer_locked(pid);
|
||||
|
@ -2255,7 +2255,7 @@ void p3BitDht::Feedback_Connected(std::string pid)
|
|||
ReleaseProxyExclusiveMode_locked(dpd, true);
|
||||
}
|
||||
|
||||
void p3BitDht::Feedback_ConnectionFailed(std::string pid)
|
||||
void p3BitDht::Feedback_ConnectionFailed(const RsPeerId& pid)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/
|
||||
DhtPeerDetails *dpd = findInternalRsPeer_locked(pid);
|
||||
|
@ -2278,7 +2278,7 @@ void p3BitDht::Feedback_ConnectionFailed(std::string pid)
|
|||
return UdpConnectionFailed_locked(dpd);
|
||||
}
|
||||
|
||||
void p3BitDht::Feedback_ConnectionClosed(std::string pid)
|
||||
void p3BitDht::Feedback_ConnectionClosed(const RsPeerId& pid)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/
|
||||
DhtPeerDetails *dpd = findInternalRsPeer_locked(pid);
|
||||
|
@ -2382,7 +2382,7 @@ void p3BitDht::ReleaseProxyExclusiveMode_locked(DhtPeerDetails *dpd, bool addrCh
|
|||
std::cerr << std::endl;
|
||||
|
||||
/* translate id into string for exclusive mode */
|
||||
std::string pid;
|
||||
RsPeerId pid;
|
||||
bdStdPrintNodeId(pid, &(dpd->mDhtId.id), false);
|
||||
|
||||
|
||||
|
@ -2419,7 +2419,7 @@ void p3BitDht::ReleaseProxyExclusiveMode_locked(DhtPeerDetails *dpd, bool addrCh
|
|||
}
|
||||
|
||||
|
||||
void p3BitDht::ConnectionFeedback(std::string pid, int mode)
|
||||
void p3BitDht::ConnectionFeedback(const RsPeerId& pid, int mode)
|
||||
{
|
||||
#ifdef DEBUG_PEERNET
|
||||
std::cerr << "p3BitDht::ConnectionFeedback() peer: " << pid;
|
||||
|
|
|
@ -2138,7 +2138,7 @@ bool ftController::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||
// Remove turtle peers from sources, as they are not supposed to survive a reboot of RS, since they are dynamic sources.
|
||||
// Otherwize, such sources are unknown from the turtle router, at restart, and never get removed.
|
||||
//
|
||||
for(std::list<std::string>::iterator sit(rft->allPeerIds.ids.begin());sit!=rft->allPeerIds.ids.end();)
|
||||
for(std::list<RsPeerId>::iterator sit(rft->allPeerIds.ids.begin());sit!=rft->allPeerIds.ids.end();)
|
||||
if(mTurtle->isTurtlePeer(*sit))
|
||||
{
|
||||
std::list<std::string>::iterator sittmp(sit) ;
|
||||
|
|
|
@ -61,11 +61,11 @@ bool AuthGPG::decryptTextFromFile(std::string& text,const std::string& inputfile
|
|||
return PGPHandler::decryptTextFromFile(mOwnGpgId,text,inputfile) ;
|
||||
}
|
||||
|
||||
bool AuthGPG::removeKeysFromPGPKeyring(const std::list<std::string>& pgp_ids,std::string& backup_file,uint32_t& error_code)
|
||||
bool AuthGPG::removeKeysFromPGPKeyring(const std::list<PGPIdType>& pgp_ids,std::string& backup_file,uint32_t& error_code)
|
||||
{
|
||||
std::list<PGPIdType> pids ;
|
||||
|
||||
for(std::list<std::string>::const_iterator it(pgp_ids.begin());it!=pgp_ids.end();++it)
|
||||
for(std::list<PGPIdType>::const_iterator it(pgp_ids.begin());it!=pgp_ids.end();++it)
|
||||
pids.push_back(PGPIdType(*it)) ;
|
||||
|
||||
return PGPHandler::removeKeysFromPGPKeyring(pids,backup_file,error_code) ;
|
||||
|
@ -317,22 +317,14 @@ bool AuthGPG::VerifySignature(const void *data, int datalen, const void *sig, un
|
|||
return PGPHandler::VerifySignBin((unsigned char*)data,datalen,(unsigned char*)sig,siglen,withfingerprint) ;
|
||||
}
|
||||
|
||||
bool AuthGPG::exportProfile(const std::string& fname,const std::string& exported_id)
|
||||
bool AuthGPG::exportProfile(const std::string& fname,const PGPIdType& exported_id)
|
||||
{
|
||||
return PGPHandler::exportGPGKeyPair(fname,PGPIdType(exported_id)) ;
|
||||
return PGPHandler::exportGPGKeyPair(fname,exported_id) ;
|
||||
}
|
||||
|
||||
bool AuthGPG::importProfile(const std::string& fname,std::string& imported_id,std::string& import_error)
|
||||
bool AuthGPG::importProfile(const std::string& fname,PGPIdType& imported_id,std::string& import_error)
|
||||
{
|
||||
PGPIdType id ;
|
||||
|
||||
if(PGPHandler::importGPGKeyPair(fname,id,import_error))
|
||||
{
|
||||
imported_id = id.toStdString() ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
return PGPHandler::importGPGKeyPair(fname,imported_id,import_error) ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -343,35 +335,19 @@ bool AuthGPG::active()
|
|||
return gpgKeySelected;
|
||||
}
|
||||
|
||||
bool AuthGPG::GeneratePGPCertificate(const std::string& name,
|
||||
const std::string& email, const std::string& passwd, std::string &pgpId, std::string& errString)
|
||||
bool AuthGPG::GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, PGPIdType& pgpId, std::string& errString)
|
||||
{
|
||||
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
||||
|
||||
PGPIdType id ;
|
||||
|
||||
bool res = PGPHandler::GeneratePGPCertificate(name, email, passwd, id, errString) ;
|
||||
|
||||
pgpId = id.toStdString() ;
|
||||
return res ;
|
||||
return PGPHandler::GeneratePGPCertificate(name, email, passwd, pgpId, errString) ;
|
||||
}
|
||||
|
||||
/**** These Two are common */
|
||||
std::string AuthGPG::getGPGName(const std::string &id,bool *success)
|
||||
std::string AuthGPG::getGPGName(const PGPIdType& id,bool *success)
|
||||
{
|
||||
if(id.length() != 16)
|
||||
{
|
||||
static int already = 0 ;
|
||||
if(already < 10)
|
||||
{
|
||||
std::cerr << "Wrong string passed to getGPGDetails: \"" << id << "\"" << std::endl;
|
||||
already++ ;
|
||||
}
|
||||
return std::string() ;
|
||||
}
|
||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
|
||||
const PGPCertificateInfo *info = getCertInfoFromStdString(id) ;
|
||||
const PGPCertificateInfo *info = getCertificateInfo(id) ;
|
||||
|
||||
if(info != NULL)
|
||||
{
|
||||
|
@ -386,10 +362,10 @@ std::string AuthGPG::getGPGName(const std::string &id,bool *success)
|
|||
}
|
||||
|
||||
/**** These Two are common */
|
||||
std::string AuthGPG::getGPGEmail(const std::string &id,bool *success)
|
||||
std::string AuthGPG::getGPGEmail(const PGPIdType& id,bool *success)
|
||||
{
|
||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
const PGPCertificateInfo *info = getCertInfoFromStdString(id) ;
|
||||
const PGPCertificateInfo *info = getCertificateInfo(id) ;
|
||||
|
||||
if(info != NULL)
|
||||
{
|
||||
|
@ -413,18 +389,14 @@ PGPIdType AuthGPG::getGPGOwnId()
|
|||
|
||||
std::string AuthGPG::getGPGOwnName()
|
||||
{
|
||||
return getGPGName(mOwnGpgId.toStdString()) ;
|
||||
return getGPGName(mOwnGpgId) ;
|
||||
}
|
||||
|
||||
bool AuthGPG::getGPGAllList(std::list<std::string> &ids)
|
||||
bool AuthGPG::getGPGAllList(std::list<PGPIdType> &ids)
|
||||
{
|
||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
|
||||
std::list<PGPIdType> list ;
|
||||
PGPHandler::getGPGFilteredList(list) ;
|
||||
|
||||
for(std::list<PGPIdType>::const_iterator it(list.begin());it!=list.end();++it)
|
||||
ids.push_back( (*it).toStdString() ) ;
|
||||
PGPHandler::getGPGFilteredList(ids) ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -440,13 +412,13 @@ const PGPCertificateInfo *AuthGPG::getCertInfoFromStdString(const std::string& p
|
|||
return NULL ;
|
||||
}
|
||||
}
|
||||
bool AuthGPG::haveSecretKey(const std::string& id) const
|
||||
//bool AuthGPG::haveSecretKey(const PGPIdType& id) const
|
||||
//{
|
||||
// return PGPHandler::haveSecretKey(PGPIdType(id)) ;
|
||||
//}
|
||||
bool AuthGPG::isKeySupported(const PGPIdType& id) const
|
||||
{
|
||||
return PGPHandler::haveSecretKey(PGPIdType(id)) ;
|
||||
}
|
||||
bool AuthGPG::isKeySupported(const std::string& id) const
|
||||
{
|
||||
const PGPCertificateInfo *pc = getCertInfoFromStdString(id) ;
|
||||
const PGPCertificateInfo *pc = getCertificateInfo(id) ;
|
||||
|
||||
if(pc == NULL)
|
||||
return false ;
|
||||
|
@ -485,39 +457,39 @@ bool AuthGPG::getGPGDetails(const PGPIdType& pgp_id, RsPeerDetails &d)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool AuthGPG::getGPGFilteredList(std::list<std::string>& list,bool (*filter)(const PGPCertificateInfo&))
|
||||
{
|
||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
std::list<PGPIdType> ids ;
|
||||
|
||||
PGPHandler::getGPGFilteredList(ids,filter) ;
|
||||
|
||||
for(std::list<PGPIdType>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||
list.push_back( (*it).toStdString() ) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
//bool AuthGPG::getGPGFilteredList(std::list<PGPIdType>& list,bool (*filter)(const PGPCertificateInfo&))
|
||||
//{
|
||||
// RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
// std::list<PGPIdType> ids ;
|
||||
//
|
||||
// PGPHandler::getGPGFilteredList(ids,filter) ;
|
||||
//
|
||||
// for(std::list<PGPIdType>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||
// list.push_back( (*it).toStdString() ) ;
|
||||
//
|
||||
// return true ;
|
||||
//}
|
||||
|
||||
static bool filter_Validity(const PGPCertificateInfo& /*info*/) { return true ; } //{ return info._validLvl >= PGPCertificateInfo::GPGME_VALIDITY_MARGINAL ; }
|
||||
static bool filter_Accepted(const PGPCertificateInfo& info) { return info._flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_ACCEPT_CONNEXION ; }
|
||||
static bool filter_OwnSigned(const PGPCertificateInfo& info) { return info._flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_HAS_OWN_SIGNATURE ; }
|
||||
|
||||
bool AuthGPG::getGPGValidList(std::list<std::string> &ids)
|
||||
bool AuthGPG::getGPGValidList(std::list<PGPIdType> &ids)
|
||||
{
|
||||
return getGPGFilteredList(ids,&filter_Validity);
|
||||
}
|
||||
|
||||
bool AuthGPG::getGPGAcceptedList(std::list<std::string> &ids)
|
||||
bool AuthGPG::getGPGAcceptedList(std::list<PGPIdType> &ids)
|
||||
{
|
||||
return getGPGFilteredList(ids,&filter_Accepted);
|
||||
}
|
||||
|
||||
bool AuthGPG::getGPGSignedList(std::list<std::string> &ids)
|
||||
bool AuthGPG::getGPGSignedList(std::list<PGPIdType> &ids)
|
||||
{
|
||||
return getGPGFilteredList(ids,&filter_OwnSigned);
|
||||
}
|
||||
|
||||
bool AuthGPG::getCachedGPGCertificate(const std::string &id, std::string &certificate)
|
||||
bool AuthGPG::getCachedGPGCertificate(const PGPIdType &id, std::string &certificate)
|
||||
{
|
||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
#ifdef LIMIT_CERTIFICATE_SIZE
|
||||
|
@ -545,28 +517,28 @@ bool AuthGPG::getCachedGPGCertificate(const std::string &id, std::string &certif
|
|||
|
||||
|
||||
/* SKTAN : do not know how to use std::string id */
|
||||
std::string AuthGPG::SaveCertificateToString(const std::string &id,bool include_signatures)
|
||||
{
|
||||
|
||||
if (!isGPGId(id)) {
|
||||
std::cerr << "AuthGPG::SaveCertificateToString() unknown ID" << std::endl;
|
||||
return "";
|
||||
}
|
||||
|
||||
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
||||
|
||||
std::string tmp = PGPHandler::SaveCertificateToString(PGPIdType(id),include_signatures) ;
|
||||
|
||||
// // Try to remove signatures manually.
|
||||
// //
|
||||
// std::string cleaned_key ;
|
||||
//
|
||||
// if( (!include_signatures) && PGPKeyManagement::createMinimalKey(tmp,cleaned_key))
|
||||
// return cleaned_key ;
|
||||
// else
|
||||
|
||||
return tmp;
|
||||
}
|
||||
// std::string AuthGPG::SaveCertificateToString(const PGPIdType &id,bool include_signatures)
|
||||
// {
|
||||
//
|
||||
// if (!isGPGId(id)) {
|
||||
// std::cerr << "AuthGPG::SaveCertificateToString() unknown ID" << std::endl;
|
||||
// return "";
|
||||
// }
|
||||
//
|
||||
// RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
||||
//
|
||||
// std::string tmp = PGPHandler::SaveCertificateToString(PGPIdType(id),include_signatures) ;
|
||||
//
|
||||
// // // Try to remove signatures manually.
|
||||
// // //
|
||||
// // std::string cleaned_key ;
|
||||
// //
|
||||
// // if( (!include_signatures) && PGPKeyManagement::createMinimalKey(tmp,cleaned_key))
|
||||
// // return cleaned_key ;
|
||||
// // else
|
||||
//
|
||||
// return tmp;
|
||||
// }
|
||||
|
||||
/* import to GnuPG and other Certificates */
|
||||
bool AuthGPG::LoadCertificateFromString(const std::string &str, PGPIdType& gpg_id,std::string& error_string)
|
||||
|
@ -596,7 +568,7 @@ bool AuthGPG::LoadCertificateFromString(const std::string &str, PGPIdType& gpg_i
|
|||
/*************************************/
|
||||
|
||||
/* These take PGP Ids */
|
||||
bool AuthGPG::AllowConnection(const std::string &gpg_id, bool accept)
|
||||
bool AuthGPG::AllowConnection(const PGPIdType& gpg_id, bool accept)
|
||||
{
|
||||
#ifdef GPG_DEBUG
|
||||
std::cerr << "AuthGPG::AllowConnection(" << gpg_id << ")" << std::endl;
|
||||
|
@ -605,7 +577,7 @@ bool AuthGPG::AllowConnection(const std::string &gpg_id, bool accept)
|
|||
/* Was a "Reload Certificates" here -> be shouldn't be needed -> and very expensive, try without. */
|
||||
{
|
||||
RsStackMutex stack(gpgMtxData);
|
||||
PGPHandler::setAcceptConnexion(PGPIdType(gpg_id),accept) ;
|
||||
PGPHandler::setAcceptConnexion(gpg_id,accept) ;
|
||||
}
|
||||
|
||||
IndicateConfigChanged();
|
||||
|
@ -616,7 +588,7 @@ bool AuthGPG::AllowConnection(const std::string &gpg_id, bool accept)
|
|||
}
|
||||
|
||||
/* These take PGP Ids */
|
||||
bool AuthGPG::SignCertificateLevel0(const std::string &id)
|
||||
bool AuthGPG::SignCertificateLevel0(const PGPIdType &id)
|
||||
{
|
||||
#ifdef GPG_DEBUG
|
||||
std::cerr << "AuthGPG::SignCertificat(" << id << ")" << std::endl;
|
||||
|
@ -625,7 +597,7 @@ bool AuthGPG::SignCertificateLevel0(const std::string &id)
|
|||
return privateSignCertificate(id) ;
|
||||
}
|
||||
|
||||
bool AuthGPG::RevokeCertificate(const std::string &id)
|
||||
bool AuthGPG::RevokeCertificate(const PGPIdType &id)
|
||||
{
|
||||
/* remove unused parameter warnings */
|
||||
(void) id;
|
||||
|
@ -645,10 +617,10 @@ bool AuthGPG::TrustCertificate(const PGPIdType& id, int trustlvl)
|
|||
return privateTrustCertificate(id, trustlvl) ;
|
||||
}
|
||||
|
||||
bool AuthGPG::encryptDataBin(const std::string& pgp_id,const void *data, unsigned int datalen, unsigned char *sign, unsigned int *signlen)
|
||||
{
|
||||
return PGPHandler::encryptDataBin(PGPIdType(pgp_id),data,datalen,sign,signlen) ;
|
||||
}
|
||||
//bool AuthGPG::encryptDataBin(const PGPIdType& pgp_id,const void *data, unsigned int datalen, unsigned char *sign, unsigned int *signlen)
|
||||
//{
|
||||
// return PGPHandler::encryptDataBin(PGPIdType(pgp_id),data,datalen,sign,signlen) ;
|
||||
//}
|
||||
|
||||
bool AuthGPG::decryptDataBin(const void *data, unsigned int datalen, unsigned char *sign, unsigned int *signlen)
|
||||
{
|
||||
|
@ -666,11 +638,11 @@ bool AuthGPG::VerifySignBin(const void *data, uint32_t datalen, unsigned char *s
|
|||
|
||||
/* Sign/Trust stuff */
|
||||
|
||||
int AuthGPG::privateSignCertificate(const std::string &id)
|
||||
int AuthGPG::privateSignCertificate(const PGPIdType &id)
|
||||
{
|
||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
|
||||
int ret = PGPHandler::privateSignCertificate(mOwnGpgId,PGPIdType(id)) ;
|
||||
int ret = PGPHandler::privateSignCertificate(mOwnGpgId,id) ;
|
||||
_force_sync_database = true ;
|
||||
return ret ;
|
||||
}
|
||||
|
@ -694,7 +666,7 @@ int AuthGPG::privateTrustCertificate(const PGPIdType& id, int trustlvl)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int res = PGPHandler::privateTrustCertificate(PGPIdType(id),trustlvl) ;
|
||||
int res = PGPHandler::privateTrustCertificate(id,trustlvl) ;
|
||||
_force_sync_database = true ;
|
||||
return res ;
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ peerConnectState::peerConnectState()
|
|||
|
||||
std::string textPeerConnectState(peerConnectState &state)
|
||||
{
|
||||
return "Id: " + state.id + "\n";
|
||||
return "Id: " + state.id.toStdString() + "\n";
|
||||
}
|
||||
|
||||
/*********
|
||||
|
@ -182,11 +182,11 @@ bool p3LinkMgrIMPL::getLocalAddress(struct sockaddr_storage &addr)
|
|||
}
|
||||
|
||||
|
||||
bool p3LinkMgrIMPL::isOnline(const std::string &ssl_id)
|
||||
bool p3LinkMgrIMPL::isOnline(const RsPeerId &ssl_id)
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
it = mFriendList.find(ssl_id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -202,11 +202,11 @@ bool p3LinkMgrIMPL::isOnline(const std::string &ssl_id)
|
|||
|
||||
|
||||
|
||||
uint32_t p3LinkMgrIMPL::getLinkType(const std::string &ssl_id)
|
||||
uint32_t p3LinkMgrIMPL::getLinkType(const RsPeerId &ssl_id)
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
it = mFriendList.find(ssl_id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -222,11 +222,11 @@ uint32_t p3LinkMgrIMPL::getLinkType(const std::string &ssl_id)
|
|||
|
||||
|
||||
|
||||
void p3LinkMgrIMPL::getOnlineList(std::list<std::string> &ssl_peers)
|
||||
void p3LinkMgrIMPL::getOnlineList(std::list<RsPeerId> &ssl_peers)
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
{
|
||||
if (it->second.state & RS_PEER_S_CONNECTED)
|
||||
|
@ -237,11 +237,11 @@ void p3LinkMgrIMPL::getOnlineList(std::list<std::string> &ssl_peers)
|
|||
return;
|
||||
}
|
||||
|
||||
void p3LinkMgrIMPL::getFriendList(std::list<std::string> &ssl_peers)
|
||||
void p3LinkMgrIMPL::getFriendList(std::list<RsPeerId> &ssl_peers)
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
{
|
||||
ssl_peers.push_back(it->first);
|
||||
|
@ -249,17 +249,17 @@ void p3LinkMgrIMPL::getFriendList(std::list<std::string> &ssl_peers)
|
|||
return;
|
||||
}
|
||||
|
||||
bool p3LinkMgrIMPL::getPeerName(const std::string &ssl_id, std::string &name)
|
||||
bool p3LinkMgrIMPL::getPeerName(const RsPeerId &ssl_id, std::string &name)
|
||||
{
|
||||
return mPeerMgr->getPeerName(ssl_id, name);
|
||||
}
|
||||
|
||||
|
||||
bool p3LinkMgrIMPL::getFriendNetStatus(const std::string &id, peerConnectState &state)
|
||||
bool p3LinkMgrIMPL::getFriendNetStatus(const RsPeerId &id, peerConnectState &state)
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
it = mFriendList.find(id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -273,13 +273,13 @@ bool p3LinkMgrIMPL::getFriendNetStatus(const std::string &id, peerConnectStat
|
|||
|
||||
|
||||
|
||||
void p3LinkMgrIMPL::setFriendVisibility(const std::string &id, bool isVisible)
|
||||
void p3LinkMgrIMPL::setFriendVisibility(const RsPeerId &id, bool isVisible)
|
||||
{
|
||||
/* set visibility */
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
it = mFriendList.find(id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -327,8 +327,8 @@ void p3LinkMgrIMPL::statusTick()
|
|||
#ifdef LINKMGR_DEBUG_TICK
|
||||
std::cerr << "p3LinkMgrIMPL::statusTick()" << std::endl;
|
||||
#endif
|
||||
std::list<std::string> retryIds;
|
||||
std::list<std::string>::iterator it2;
|
||||
std::list<RsPeerId> retryIds;
|
||||
std::list<RsPeerId>::iterator it2;
|
||||
//std::list<std::string> dummyToRemove;
|
||||
|
||||
{
|
||||
|
@ -337,7 +337,7 @@ void p3LinkMgrIMPL::statusTick()
|
|||
time_t retry = now - mRetryPeriod;
|
||||
|
||||
RsStackMutex stack(mLinkMtx); /****** LOCK MUTEX ******/
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
{
|
||||
if (it->second.state & RS_PEER_S_CONNECTED)
|
||||
|
@ -421,7 +421,7 @@ void p3LinkMgrIMPL::tickMonitors()
|
|||
{
|
||||
bool doStatusChange = false;
|
||||
std::list<pqipeer> actionList;
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
@ -449,7 +449,7 @@ void p3LinkMgrIMPL::tickMonitors()
|
|||
actionList.push_back(peer);
|
||||
|
||||
#ifdef LINKMGR_DEBUG_ACTIONS
|
||||
std::cerr << "Friend: " << peer.name << " Id: " << peer.id << " State: " << peer.state;
|
||||
std::cerr << "Friend: " << peer.name << " Id: " << peer.id.toStdString() << " State: " << peer.state;
|
||||
if (peer.state & RS_PEER_S_FRIEND)
|
||||
std::cerr << " S:RS_PEER_S_FRIEND";
|
||||
if (peer.state & RS_PEER_S_ONLINE)
|
||||
|
@ -500,7 +500,7 @@ void p3LinkMgrIMPL::tickMonitors()
|
|||
it->second.actions = 0;
|
||||
|
||||
#ifdef LINKMGR_DEBUG_ACTIONS
|
||||
std::cerr << "Other: " << peer.name << " Id: " << peer.id << " State: " << peer.state;
|
||||
std::cerr << "Other: " << peer.name << " Id: " << peer.id.toStdString() << " State: " << peer.state;
|
||||
if (peer.state & RS_PEER_S_FRIEND)
|
||||
std::cerr << " S:RS_PEER_S_FRIEND";
|
||||
if (peer.state & RS_PEER_S_ONLINE)
|
||||
|
@ -576,13 +576,13 @@ void p3LinkMgrIMPL::tickMonitors()
|
|||
}
|
||||
|
||||
|
||||
const std::string p3LinkMgrIMPL::getOwnId()
|
||||
const RsPeerId p3LinkMgrIMPL::getOwnId()
|
||||
{
|
||||
return AuthSSL::getAuthSSL()->OwnId();
|
||||
}
|
||||
|
||||
|
||||
bool p3LinkMgrIMPL::connectAttempt(const std::string &id, struct sockaddr_storage &raddr,
|
||||
bool p3LinkMgrIMPL::connectAttempt(const RsPeerId &id, struct sockaddr_storage &raddr,
|
||||
struct sockaddr_storage &proxyaddr,
|
||||
struct sockaddr_storage &srcaddr,
|
||||
uint32_t &delay, uint32_t &period, uint32_t &type, uint32_t &flags, uint32_t &bandwidth,
|
||||
|
@ -592,7 +592,7 @@ bool p3LinkMgrIMPL::connectAttempt(const std::string &id, struct sockaddr_storag
|
|||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check for existing */
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
it = mFriendList.find(id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -774,7 +774,7 @@ bool p3LinkMgrIMPL::connectAttempt(const std::string &id, struct sockaddr_storag
|
|||
*
|
||||
*/
|
||||
|
||||
bool p3LinkMgrIMPL::connectResult(const std::string &id, bool success, uint32_t flags, const struct sockaddr_storage &remote_peer_address)
|
||||
bool p3LinkMgrIMPL::connectResult(const RsPeerId &id, bool success, uint32_t flags, const struct sockaddr_storage &remote_peer_address)
|
||||
{
|
||||
bool doDhtAssist = false ;
|
||||
bool updatePeerAddr = false;
|
||||
|
@ -791,7 +791,7 @@ bool p3LinkMgrIMPL::connectResult(const std::string &id, bool success, uint32_t
|
|||
return false;
|
||||
}
|
||||
/* check for existing */
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
it = mFriendList.find(id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -806,7 +806,7 @@ bool p3LinkMgrIMPL::connectResult(const std::string &id, bool success, uint32_t
|
|||
/* now we can tell if we think we were connected - proper point to log */
|
||||
|
||||
{
|
||||
std::string out = "p3LinkMgrIMPL::connectResult() id: " + id;
|
||||
std::string out = "p3LinkMgrIMPL::connectResult() id: " + id.toStdString();
|
||||
if (success)
|
||||
{
|
||||
out += " SUCCESS ";
|
||||
|
@ -1030,7 +1030,7 @@ bool p3LinkMgrIMPL::connectResult(const std::string &id, bool success, uint32_t
|
|||
*/
|
||||
|
||||
// from pqissl, when a connection failed due to security
|
||||
void p3LinkMgrIMPL::notifyDeniedConnection(const std::string& gpgid,const std::string& sslid,const std::string& sslcn,const struct sockaddr_storage &addr, bool incoming)
|
||||
void p3LinkMgrIMPL::notifyDeniedConnection(const PGPIdType& gpgid,const RsPeerId& sslid,const std::string& sslcn,const struct sockaddr_storage &addr, bool incoming)
|
||||
{
|
||||
std::cerr << "p3LinkMgrIMPL::notifyDeniedConnection()";
|
||||
std::cerr << " pgpid: " << gpgid;
|
||||
|
@ -1040,7 +1040,7 @@ void p3LinkMgrIMPL::notifyDeniedConnection(const std::string& gpgid,const std::
|
|||
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
it = mFriendList.find(sslid);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -1070,12 +1070,12 @@ void p3LinkMgrIMPL::notifyDeniedConnection(const std::string& gpgid,const std::
|
|||
}
|
||||
|
||||
|
||||
void p3LinkMgrIMPL::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
void p3LinkMgrIMPL::peerStatus(const RsPeerId& id, const pqiIpAddrSet &addrs,
|
||||
uint32_t type, uint32_t flags, uint32_t source)
|
||||
{
|
||||
/* HACKED UP FIX ****/
|
||||
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
bool isFriend = true;
|
||||
|
||||
time_t now = time(NULL);
|
||||
|
@ -1344,7 +1344,7 @@ void p3LinkMgrIMPL::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
|||
}
|
||||
|
||||
/* This has become very unwieldy - as extra arguments are required for UDP connections */
|
||||
void p3LinkMgrIMPL::peerConnectRequest(std::string id, const struct sockaddr_storage &raddr, const struct sockaddr_storage &proxyaddr, const struct sockaddr_storage &srcaddr,
|
||||
void p3LinkMgrIMPL::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)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
|
@ -1397,7 +1397,7 @@ void p3LinkMgrIMPL::peerConnectRequest(std::string id, const struct sockaddr_
|
|||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
|
@ -1449,7 +1449,7 @@ void p3LinkMgrIMPL::peerConnectRequest(std::string id, const struct sockaddr_
|
|||
/*******************************************************************/
|
||||
/*******************************************************************/
|
||||
/*************** External Control ****************/
|
||||
bool p3LinkMgrIMPL::retryConnect(const std::string &id)
|
||||
bool p3LinkMgrIMPL::retryConnect(const RsPeerId &id)
|
||||
{
|
||||
/* push all available addresses onto the connect addr stack */
|
||||
#ifdef LINKMGR_DEBUG
|
||||
|
@ -1467,7 +1467,7 @@ bool p3LinkMgrIMPL::retryConnect(const std::string &id)
|
|||
|
||||
|
||||
|
||||
bool p3LinkMgrIMPL::tryConnectUDP(const std::string &id, const struct sockaddr_storage &rUdpAddr,
|
||||
bool p3LinkMgrIMPL::tryConnectUDP(const RsPeerId &id, const struct sockaddr_storage &rUdpAddr,
|
||||
const struct sockaddr_storage &proxyaddr, const struct sockaddr_storage &srcaddr,
|
||||
uint32_t flags, uint32_t delay, uint32_t bandwidth)
|
||||
|
||||
|
@ -1514,7 +1514,7 @@ bool p3LinkMgrIMPL::tryConnectUDP(const std::string &id, const struct sockaddr
|
|||
}
|
||||
|
||||
/* look up the id */
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
|
@ -1564,7 +1564,7 @@ bool p3LinkMgrIMPL::tryConnectUDP(const std::string &id, const struct sockaddr
|
|||
|
||||
|
||||
|
||||
bool p3LinkMgrIMPL::retryConnectTCP(const std::string &id)
|
||||
bool p3LinkMgrIMPL::retryConnectTCP(const RsPeerId &id)
|
||||
{
|
||||
/* Check if we should retry first */
|
||||
{
|
||||
|
@ -1589,7 +1589,7 @@ bool p3LinkMgrIMPL::retryConnectTCP(const std::string &id)
|
|||
}
|
||||
|
||||
/* look up the id */
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
|
@ -1626,7 +1626,7 @@ bool p3LinkMgrIMPL::retryConnectTCP(const std::string &id)
|
|||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
if (mFriendList.end() != (it = mFriendList.find(id)))
|
||||
{
|
||||
locked_ConnectAttempt_ProxyAddress(&(it->second), proxy_addr, domain_addr, domain_port);
|
||||
|
@ -1652,7 +1652,7 @@ bool p3LinkMgrIMPL::retryConnectTCP(const std::string &id)
|
|||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
if (mFriendList.end() != (it = mFriendList.find(id)))
|
||||
{
|
||||
locked_ConnectAttempt_CurrentAddresses(&(it->second), lAddr, eAddr);
|
||||
|
@ -2125,7 +2125,7 @@ bool p3LinkMgrIMPL::locked_ConnectAttempt_Complete(peerConnectState *peer)
|
|||
************************************* Handling of Friends *************************************************
|
||||
***********************************************************************************************************/
|
||||
|
||||
int p3LinkMgrIMPL::addFriend(const std::string &id, bool isVisible)
|
||||
int p3LinkMgrIMPL::addFriend(const RsPeerId &id, bool isVisible)
|
||||
{
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgr::addFriend() id: " + id);
|
||||
|
||||
|
@ -2137,7 +2137,7 @@ int p3LinkMgrIMPL::addFriend(const std::string &id, bool isVisible)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
it = mFriendList.find(id);
|
||||
|
||||
if (it != mFriendList.end())
|
||||
|
@ -2166,7 +2166,7 @@ int p3LinkMgrIMPL::addFriend(const std::string &id, bool isVisible)
|
|||
}
|
||||
|
||||
|
||||
int p3LinkMgrIMPL::removeFriend(const std::string &id)
|
||||
int p3LinkMgrIMPL::removeFriend(const RsPeerId &id)
|
||||
{
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgr::removeFriend() id: " + id);
|
||||
|
||||
|
@ -2178,7 +2178,7 @@ int p3LinkMgrIMPL::removeFriend(const std::string &id)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
it = mFriendList.find(id);
|
||||
|
||||
if (it == mFriendList.end())
|
||||
|
@ -2218,10 +2218,10 @@ void p3LinkMgrIMPL::printPeerLists(std::ostream &out)
|
|||
out << std::endl;
|
||||
|
||||
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
std::map<RsPeerId, peerConnectState>::iterator it;
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
{
|
||||
out << "\t SSL ID: " << it->second.id;
|
||||
out << "\t SSL ID: " << it->second.id.toStdString();
|
||||
out << "\t State: " << it->second.state;
|
||||
out << std::endl;
|
||||
}
|
||||
|
@ -2230,7 +2230,7 @@ void p3LinkMgrIMPL::printPeerLists(std::ostream &out)
|
|||
out << std::endl;
|
||||
for(it = mOthersList.begin(); it != mOthersList.end(); it++)
|
||||
{
|
||||
out << "\t SSL ID: " << it->second.id;
|
||||
out << "\t SSL ID: " << it->second.id.toStdString();
|
||||
out << "\t State: " << it->second.state;
|
||||
}
|
||||
}
|
||||
|
@ -2242,7 +2242,7 @@ void p3LinkMgrIMPL::printPeerLists(std::ostream &out)
|
|||
void printConnectState(std::ostream &out, peerConnectState &peer)
|
||||
{
|
||||
|
||||
out << "Friend: " << peer.name << " Id: " << peer.id << " State: " << peer.state;
|
||||
out << "Friend: " << peer.name << " Id: " << peer.id.toStdString() << " State: " << peer.state;
|
||||
if (peer.state & RS_PEER_S_FRIEND)
|
||||
out << " S:RS_PEER_S_FRIEND";
|
||||
if (peer.state & RS_PEER_S_ONLINE)
|
||||
|
|
|
@ -896,7 +896,7 @@ void p3NetMgrIMPL::netExtCheck()
|
|||
}
|
||||
|
||||
/* inform DHT about our external address */
|
||||
std::string fakeId;
|
||||
RsPeerId fakeId;
|
||||
netAssistKnownPeer(fakeId, mExtAddr, NETASSIST_KNOWN_PEER_SELF | NETASSIST_KNOWN_PEER_ONLINE);
|
||||
|
||||
rslog(RSL_WARNING, p3netmgrzone, "p3NetMgr::netExtCheck() Network Setup Complete");
|
||||
|
@ -1378,7 +1378,7 @@ bool p3NetMgrIMPL::netAssistConnectShutdown()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3NetMgrIMPL::netAssistFriend(const std::string &id, bool on)
|
||||
bool p3NetMgrIMPL::netAssistFriend(const RsPeerId &id, bool on)
|
||||
{
|
||||
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
|
||||
|
||||
|
@ -1398,7 +1398,7 @@ bool p3NetMgrIMPL::netAssistFriend(const std::string &id, bool on)
|
|||
}
|
||||
|
||||
|
||||
bool p3NetMgrIMPL::netAssistKnownPeer(const std::string &id, const struct sockaddr_storage &addr, uint32_t flags)
|
||||
bool p3NetMgrIMPL::netAssistKnownPeer(const RsPeerId &id, const struct sockaddr_storage &addr, uint32_t flags)
|
||||
{
|
||||
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
|
||||
|
||||
|
@ -1449,7 +1449,7 @@ bool p3NetMgrIMPL::netAssistAttach(bool on)
|
|||
|
||||
|
||||
|
||||
bool p3NetMgrIMPL::netAssistStatusUpdate(const std::string &id, int state)
|
||||
bool p3NetMgrIMPL::netAssistStatusUpdate(const RsPeerId &id, int state)
|
||||
{
|
||||
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
|
||||
|
||||
|
|
|
@ -118,10 +118,10 @@ virtual bool setNetworkMode(uint32_t netMode) = 0;
|
|||
virtual bool setVisState(uint16_t vs_disc, uint16_t vs_dht) = 0;
|
||||
|
||||
// Switch DHT On/Off.
|
||||
virtual bool netAssistFriend(const std::string &id, bool on) = 0;
|
||||
virtual bool netAssistKnownPeer(const std::string &id, const struct sockaddr_storage &addr, uint32_t flags) = 0;
|
||||
virtual bool netAssistFriend(const RsPeerId &id, bool on) = 0;
|
||||
virtual bool netAssistKnownPeer(const RsPeerId &id, const struct sockaddr_storage &addr, uint32_t flags) = 0;
|
||||
virtual bool netAssistBadPeer(const struct sockaddr_storage &addr, uint32_t reason, uint32_t flags, uint32_t age) = 0;
|
||||
virtual bool netAssistStatusUpdate(const std::string &id, int mode) = 0;
|
||||
virtual bool netAssistStatusUpdate(const RsPeerId &id, int mode) = 0;
|
||||
|
||||
/* Get Network State */
|
||||
virtual uint32_t getNetStateMode() = 0;
|
||||
|
@ -174,10 +174,10 @@ virtual bool setNetworkMode(uint32_t netMode);
|
|||
virtual bool setVisState(uint16_t vs_disc, uint16_t vs_dht);
|
||||
|
||||
// Switch DHT On/Off.
|
||||
virtual bool netAssistFriend(const std::string &id, bool on);
|
||||
virtual bool netAssistKnownPeer(const std::string &id, const struct sockaddr_storage &addr, uint32_t flags);
|
||||
virtual bool netAssistFriend(const RsPeerId &id, bool on);
|
||||
virtual bool netAssistKnownPeer(const RsPeerId &id, const struct sockaddr_storage &addr, uint32_t flags);
|
||||
virtual bool netAssistBadPeer(const struct sockaddr_storage &addr, uint32_t reason, uint32_t flags, uint32_t age);
|
||||
virtual bool netAssistStatusUpdate(const std::string &id, int mode);
|
||||
virtual bool netAssistStatusUpdate(const RsPeerId &id, int mode);
|
||||
|
||||
/* Get Network State */
|
||||
virtual uint32_t getNetStateMode();
|
||||
|
|
|
@ -110,7 +110,7 @@ std::string textPeerConnectState(peerState &state)
|
|||
}
|
||||
|
||||
|
||||
p3PeerMgrIMPL::p3PeerMgrIMPL(const SSLIdType& ssl_own_id, const PGPIdType& gpg_own_id, const PGPIdType& gpg_own_name, const RsPeerId& ssl_own_location)
|
||||
p3PeerMgrIMPL::p3PeerMgrIMPL(const RsPeerId& ssl_own_id, const PGPIdType& gpg_own_id, const PGPIdType& gpg_own_name, const RsPeerId& ssl_own_location)
|
||||
:p3Config(CONFIG_TYPE_PEERS), mPeerMtx("p3PeerMgr"), mStatusChanged(false)
|
||||
{
|
||||
|
||||
|
@ -294,7 +294,7 @@ void p3PeerMgrIMPL::tick()
|
|||
*/
|
||||
|
||||
|
||||
const SSLIdType& p3PeerMgrIMPL::getOwnId()
|
||||
const RsPeerId& p3PeerMgrIMPL::getOwnId()
|
||||
{
|
||||
return AuthSSL::getAuthSSL()->OwnId();
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ bool p3PeerMgrIMPL::getOwnNetStatus(peerState &state)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::isFriend(const SSLIdType& id)
|
||||
bool p3PeerMgrIMPL::isFriend(const RsPeerId& id)
|
||||
{
|
||||
#ifdef PEER_DEBUG_COMMON
|
||||
std::cerr << "p3PeerMgrIMPL::isFriend(" << id << ") called" << std::endl;
|
||||
|
@ -320,12 +320,12 @@ bool p3PeerMgrIMPL::isFriend(const SSLIdType& id)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::getPeerName(const SSLIdType &ssl_id, std::string &name)
|
||||
bool p3PeerMgrIMPL::getPeerName(const RsPeerId &ssl_id, std::string &name)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check for existing */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
it = mFriendList.find(ssl_id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -336,12 +336,12 @@ bool p3PeerMgrIMPL::getPeerName(const SSLIdType &ssl_id, std::string &name)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::getGpgId(const SSLIdType &ssl_id, PGPIdType &gpgId)
|
||||
bool p3PeerMgrIMPL::getGpgId(const RsPeerId &ssl_id, PGPIdType &gpgId)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check for existing */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
it = mFriendList.find(ssl_id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -361,12 +361,12 @@ bool p3PeerMgrIMPL::isHidden()
|
|||
}
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::isHiddenPeer(const SSLIdType &ssl_id)
|
||||
bool p3PeerMgrIMPL::isHiddenPeer(const RsPeerId &ssl_id)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check for existing */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
it = mFriendList.find(ssl_id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -381,7 +381,7 @@ bool p3PeerMgrIMPL::isHiddenPeer(const SSLIdType &ssl_id)
|
|||
return (it->second).hiddenNode;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::setHiddenDomainPort(const SSLIdType &ssl_id, const std::string &domain_addr, const uint16_t domain_port)
|
||||
bool p3PeerMgrIMPL::setHiddenDomainPort(const RsPeerId &ssl_id, const std::string &domain_addr, const uint16_t domain_port)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
|
@ -414,7 +414,7 @@ bool p3PeerMgrIMPL::setHiddenDomainPort(const SSLIdType &ssl_id, const std::stri
|
|||
}
|
||||
|
||||
/* check for existing */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
it = mFriendList.find(ssl_id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -453,12 +453,12 @@ bool p3PeerMgrIMPL::getProxyServerAddress(struct sockaddr_storage &proxy_addr)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::getProxyAddress(const SSLIdType &ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port)
|
||||
bool p3PeerMgrIMPL::getProxyAddress(const RsPeerId &ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check for existing */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
it = mFriendList.find(ssl_id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -478,7 +478,7 @@ bool p3PeerMgrIMPL::getProxyAddress(const SSLIdType &ssl_id, struct sockaddr_sto
|
|||
}
|
||||
|
||||
// Placeholder until we implement this functionality.
|
||||
uint32_t p3PeerMgrIMPL::getConnectionType(const SSLIdType &/*sslId*/)
|
||||
uint32_t p3PeerMgrIMPL::getConnectionType(const RsPeerId &/*sslId*/)
|
||||
{
|
||||
return RS_NET_CONN_TYPE_FRIEND;
|
||||
}
|
||||
|
@ -487,7 +487,7 @@ int p3PeerMgrIMPL::getFriendCount(bool ssl, bool online)
|
|||
{
|
||||
if (online) {
|
||||
// count only online id's
|
||||
std::list<SSLIdType> onlineIds;
|
||||
std::list<RsPeerId> onlineIds;
|
||||
mLinkMgr->getOnlineList(onlineIds);
|
||||
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
@ -495,7 +495,7 @@ int p3PeerMgrIMPL::getFriendCount(bool ssl, bool online)
|
|||
std::set<PGPIdType> gpgIds;
|
||||
int count = 0;
|
||||
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); ++it) {
|
||||
if (online && std::find(onlineIds.begin(), onlineIds.end(), it->first) == onlineIds.end()) {
|
||||
continue;
|
||||
|
@ -523,18 +523,18 @@ int p3PeerMgrIMPL::getFriendCount(bool ssl, bool online)
|
|||
AuthGPG::getAuthGPG()->getGPGAcceptedList(gpgIds);
|
||||
|
||||
// add own gpg id, if we have more than one location
|
||||
std::list<SSLIdType> ownSslIds;
|
||||
std::list<RsPeerId> ownSslIds;
|
||||
getAssociatedPeers(AuthGPG::getAuthGPG()->getGPGOwnId(), ownSslIds);
|
||||
|
||||
return gpgIds.size() + ((ownSslIds.size() > 0) ? 1 : 0);
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::getFriendNetStatus(const SSLIdType &id, peerState &state)
|
||||
bool p3PeerMgrIMPL::getFriendNetStatus(const RsPeerId &id, peerState &state)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check for existing */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
it = mFriendList.find(id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -546,12 +546,12 @@ bool p3PeerMgrIMPL::getFriendNetStatus(const SSLIdType &id, peerState &state)
|
|||
}
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::getOthersNetStatus(const SSLIdType &id, peerState &state)
|
||||
bool p3PeerMgrIMPL::getOthersNetStatus(const RsPeerId &id, peerState &state)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check for existing */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
it = mOthersList.find(id);
|
||||
if (it == mOthersList.end())
|
||||
{
|
||||
|
@ -562,7 +562,7 @@ bool p3PeerMgrIMPL::getOthersNetStatus(const SSLIdType &id, peerState &state)
|
|||
return true;
|
||||
}
|
||||
|
||||
int p3PeerMgrIMPL::getConnectAddresses(const SSLIdType &id,
|
||||
int p3PeerMgrIMPL::getConnectAddresses(const RsPeerId &id,
|
||||
struct sockaddr_storage &lAddr, struct sockaddr_storage &eAddr,
|
||||
pqiIpAddrSet &histAddrs, std::string &dyndns)
|
||||
{
|
||||
|
@ -570,7 +570,7 @@ int p3PeerMgrIMPL::getConnectAddresses(const SSLIdType &id,
|
|||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check for existing */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
it = mFriendList.find(id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -595,7 +595,7 @@ bool p3PeerMgrIMPL::haveOnceConnected()
|
|||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check for existing */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
{
|
||||
if (it->second.lastcontact > 0)
|
||||
|
@ -623,10 +623,10 @@ bool p3PeerMgrIMPL::haveOnceConnected()
|
|||
/*******************************************************************/
|
||||
/*******************************************************************/
|
||||
|
||||
bool p3PeerMgrIMPL::addFriend(const SSLIdType& input_id, const PGPIdType& input_gpg_id, uint32_t netMode, uint16_t vs_disc, uint16_t vs_dht, time_t lastContact,ServicePermissionFlags service_flags)
|
||||
bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const PGPIdType& input_gpg_id, uint32_t netMode, uint16_t vs_disc, uint16_t vs_dht, time_t lastContact,ServicePermissionFlags service_flags)
|
||||
{
|
||||
bool notifyLinkMgr = false;
|
||||
SSLIdType id = input_id ;
|
||||
RsPeerId id = input_id ;
|
||||
PGPIdType gpg_id = input_gpg_id ;
|
||||
|
||||
rslog(RSL_WARNING, p3peermgrzone, "p3PeerMgr::addFriend() id: " + id.toStdString());
|
||||
|
@ -653,7 +653,7 @@ bool p3PeerMgrIMPL::addFriend(const SSLIdType& input_id, const PGPIdType& input_
|
|||
std::cerr << "p3PeerMgrIMPL::addFriend() " << id << "; gpg_id : " << gpg_id << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() != mFriendList.find(id))
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
|
@ -748,7 +748,7 @@ bool p3PeerMgrIMPL::addFriend(const SSLIdType& input_id, const PGPIdType& input_
|
|||
}
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::removeFriend(const SSLIdType &id, bool removePgpId)
|
||||
bool p3PeerMgrIMPL::removeFriend(const RsPeerId &id, bool removePgpId)
|
||||
{
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
|
@ -758,7 +758,7 @@ bool p3PeerMgrIMPL::removeFriend(const SSLIdType &id, bool removePgpId)
|
|||
|
||||
rslog(RSL_WARNING, p3peermgrzone, "p3PeerMgr::removeFriend() id: " + id);
|
||||
|
||||
std::list<SSLIdType> sslid_toRemove; // This is a list of SSLIds.
|
||||
std::list<RsPeerId> sslid_toRemove; // This is a list of SSLIds.
|
||||
std::list<PGPIdType> pgpid_toRemove; // This is a list of SSLIds.
|
||||
|
||||
{
|
||||
|
@ -766,7 +766,7 @@ bool p3PeerMgrIMPL::removeFriend(const SSLIdType &id, bool removePgpId)
|
|||
|
||||
/* move to othersList */
|
||||
bool success = false;
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
//remove ssl and gpg_ids
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
{
|
||||
|
@ -787,7 +787,7 @@ bool p3PeerMgrIMPL::removeFriend(const SSLIdType &id, bool removePgpId)
|
|||
}
|
||||
}
|
||||
|
||||
std::list<SSLIdType>::iterator rit;
|
||||
std::list<RsPeerId>::iterator rit;
|
||||
for(rit = sslid_toRemove.begin(); rit != sslid_toRemove.end(); rit++)
|
||||
if (mFriendList.end() != (it = mFriendList.find(*rit)))
|
||||
mFriendList.erase(it);
|
||||
|
@ -803,14 +803,14 @@ bool p3PeerMgrIMPL::removeFriend(const SSLIdType &id, bool removePgpId)
|
|||
#endif
|
||||
}
|
||||
|
||||
std::list<SSLIdType>::iterator rit;
|
||||
std::list<RsPeerId>::iterator rit;
|
||||
for(rit = sslid_toRemove.begin(); rit != sslid_toRemove.end(); rit++)
|
||||
{
|
||||
mLinkMgr->removeFriend(*rit);
|
||||
}
|
||||
|
||||
/* remove id from all groups */
|
||||
std::list<SSLIdType> peerIds;
|
||||
std::list<RsPeerId> peerIds;
|
||||
peerIds.push_back(id);
|
||||
|
||||
assignPeersToGroup("", peerIds, false);
|
||||
|
@ -835,7 +835,7 @@ void p3PeerMgrIMPL::printPeerLists(std::ostream &out)
|
|||
out << std::endl;
|
||||
|
||||
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
{
|
||||
out << "\t SSL ID: " << it->second.id;
|
||||
|
@ -948,7 +948,7 @@ bool p3PeerMgrIMPL::UpdateOwnAddress(const struct sockaddr_storage &localAddr,
|
|||
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::setLocalAddress(const SSLIdType &id, const struct sockaddr_storage &addr)
|
||||
bool p3PeerMgrIMPL::setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
|
@ -975,7 +975,7 @@ bool p3PeerMgrIMPL::setLocalAddress(const SSLIdType &id, const struct sockadd
|
|||
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
/* check if it is a friend */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
|
@ -1009,7 +1009,7 @@ bool p3PeerMgrIMPL::setLocalAddress(const SSLIdType &id, const struct sockadd
|
|||
return changed;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::setExtAddress(const SSLIdType &id, const struct sockaddr_storage &addr)
|
||||
bool p3PeerMgrIMPL::setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
|
@ -1031,7 +1031,7 @@ bool p3PeerMgrIMPL::setExtAddress(const SSLIdType &id, const struct sockaddr_
|
|||
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
/* check if it is a friend */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
|
@ -1066,7 +1066,7 @@ bool p3PeerMgrIMPL::setExtAddress(const SSLIdType &id, const struct sockaddr_
|
|||
}
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::setDynDNS(const SSLIdType &id, const std::string &dyndns)
|
||||
bool p3PeerMgrIMPL::setDynDNS(const RsPeerId &id, const std::string &dyndns)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
|
@ -1084,7 +1084,7 @@ bool p3PeerMgrIMPL::setDynDNS(const SSLIdType &id, const std::string &dyndns)
|
|||
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
/* check if it is a friend */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
|
@ -1106,7 +1106,7 @@ bool p3PeerMgrIMPL::setDynDNS(const SSLIdType &id, const std::string &dyndns)
|
|||
return changed;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::updateAddressList(const SSLIdType& id, const pqiIpAddrSet &addrs)
|
||||
bool p3PeerMgrIMPL::updateAddressList(const RsPeerId& id, const pqiIpAddrSet &addrs)
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::setAddressList() called for id : " << id << std::endl;
|
||||
|
@ -1122,7 +1122,7 @@ bool p3PeerMgrIMPL::updateAddressList(const SSLIdType& id, const pqiIpAddrSet
|
|||
}
|
||||
|
||||
/* check if it is a friend */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
|
@ -1151,7 +1151,7 @@ bool p3PeerMgrIMPL::updateAddressList(const SSLIdType& id, const pqiIpAddrSet
|
|||
}
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::updateCurrentAddress(const SSLIdType& id, const pqiIpAddress &addr)
|
||||
bool p3PeerMgrIMPL::updateCurrentAddress(const RsPeerId& id, const pqiIpAddress &addr)
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::updateCurrentAddress() called for id : " << id << std::endl;
|
||||
|
@ -1162,7 +1162,7 @@ bool p3PeerMgrIMPL::updateCurrentAddress(const SSLIdType& id, const pqiIpAddr
|
|||
/* cannot be own id */
|
||||
|
||||
/* check if it is a friend */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
|
@ -1198,7 +1198,7 @@ bool p3PeerMgrIMPL::updateCurrentAddress(const SSLIdType& id, const pqiIpAddr
|
|||
}
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::updateLastContact(const SSLIdType& id)
|
||||
bool p3PeerMgrIMPL::updateLastContact(const RsPeerId& id)
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::updateLastContact() called for id : " << id << std::endl;
|
||||
|
@ -1209,7 +1209,7 @@ bool p3PeerMgrIMPL::updateLastContact(const SSLIdType& id)
|
|||
/* cannot be own id */
|
||||
|
||||
/* check if it is a friend */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
|
@ -1226,7 +1226,7 @@ bool p3PeerMgrIMPL::updateLastContact(const SSLIdType& id)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::setNetworkMode(const SSLIdType &id, uint32_t netMode)
|
||||
bool p3PeerMgrIMPL::setNetworkMode(const RsPeerId &id, uint32_t netMode)
|
||||
{
|
||||
if (id == AuthSSL::getAuthSSL()->OwnId())
|
||||
{
|
||||
|
@ -1235,7 +1235,7 @@ bool p3PeerMgrIMPL::setNetworkMode(const SSLIdType &id, uint32_t netMode)
|
|||
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
/* check if it is a friend */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
|
@ -1257,7 +1257,7 @@ bool p3PeerMgrIMPL::setNetworkMode(const SSLIdType &id, uint32_t netMode)
|
|||
return changed;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::setLocation(const SSLIdType &id, const std::string &location)
|
||||
bool p3PeerMgrIMPL::setLocation(const RsPeerId &id, const std::string &location)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
|
@ -1276,7 +1276,7 @@ bool p3PeerMgrIMPL::setLocation(const SSLIdType &id, const std::string &locat
|
|||
}
|
||||
|
||||
/* check if it is a friend */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() != (it = mFriendList.find(id))) {
|
||||
if (it->second.location.compare(location) != 0) {
|
||||
it->second.location = location;
|
||||
|
@ -1286,7 +1286,7 @@ bool p3PeerMgrIMPL::setLocation(const SSLIdType &id, const std::string &locat
|
|||
return changed;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::setVisState(const SSLIdType &id, uint16_t vs_disc, uint16_t vs_dht)
|
||||
bool p3PeerMgrIMPL::setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht)
|
||||
{
|
||||
{
|
||||
std::string out;
|
||||
|
@ -1305,7 +1305,7 @@ bool p3PeerMgrIMPL::setVisState(const SSLIdType &id, uint16_t vs_disc, uint16
|
|||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check if it is a friend */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
|
@ -1453,7 +1453,7 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||
saveCleanupList.push_back(item);
|
||||
|
||||
/* iterate through all friends and save */
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
{
|
||||
item = new RsPeerNetItem();
|
||||
|
@ -1567,7 +1567,7 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
|||
std::cerr << "p3PeerMgrIMPL::loadList() Item Count: " << load.size() << std::endl;
|
||||
#endif
|
||||
|
||||
SSLIdType ownId = getOwnId();
|
||||
RsPeerId ownId = getOwnId();
|
||||
|
||||
/* load the list of peers */
|
||||
std::list<RsItem *>::iterator it;
|
||||
|
@ -1952,7 +1952,7 @@ bool p3PeerMgrIMPL::getGroupInfoList(std::list<RsGroupInfo> &groupInfoList)
|
|||
}
|
||||
|
||||
// groupId == "" && assign == false -> remove from all groups
|
||||
bool p3PeerMgrIMPL::assignPeersToGroup(const std::string &groupId, const std::list<SSLIdType> &peerIds, bool assign)
|
||||
bool p3PeerMgrIMPL::assignPeersToGroup(const std::string &groupId, const std::list<RsPeerId> &peerIds, bool assign)
|
||||
{
|
||||
if (groupId.empty() && assign == true) {
|
||||
return false;
|
||||
|
@ -1972,9 +1972,9 @@ bool p3PeerMgrIMPL::assignPeersToGroup(const std::string &groupId, const std::li
|
|||
if (groupId.empty() || (*groupIt)->id == groupId) {
|
||||
RsPeerGroupItem *groupItem = *groupIt;
|
||||
|
||||
std::list<std::string>::const_iterator peerIt;
|
||||
std::list<RsPeerId>::const_iterator peerIt;
|
||||
for (peerIt = peerIds.begin(); peerIt != peerIds.end(); peerIt++) {
|
||||
std::list<std::string>::iterator peerIt1 = std::find(groupItem->peerIds.begin(), groupItem->peerIds.end(), *peerIt);
|
||||
std::list<RsPeerId>::iterator peerIt1 = std::find(groupItem->peerIds.begin(), groupItem->peerIds.end(), *peerIt);
|
||||
if (assign) {
|
||||
if (peerIt1 == groupItem->peerIds.end()) {
|
||||
groupItem->peerIds.push_back(*peerIt);
|
||||
|
@ -2011,19 +2011,14 @@ bool p3PeerMgrIMPL::assignPeersToGroup(const std::string &groupId, const std::li
|
|||
**********************************************************************
|
||||
**********************************************************************/
|
||||
|
||||
ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags_sslid(const SSLIdType& ssl_id)
|
||||
ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags(const RsPeerId& ssl_id)
|
||||
{
|
||||
PGPIdType gpg_id ;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
if(ssl_id.length() != 32)
|
||||
{
|
||||
std::cerr << "(EE) p3PeerMgrIMPL::servicePermissionFlags_sslid() called with inconsistent id " << ssl_id << std::endl;
|
||||
return RS_SERVICE_PERM_ALL ;
|
||||
}
|
||||
std::map<SSLIdType, peerState>::const_iterator it = mFriendList.find(ssl_id);
|
||||
std::map<RsPeerId, peerState>::const_iterator it = mFriendList.find(ssl_id);
|
||||
|
||||
if(it == mFriendList.end())
|
||||
return RS_SERVICE_PERM_ALL ;
|
||||
|
@ -2037,13 +2032,6 @@ ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags_sslid(const SSLIdTy
|
|||
|
||||
ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags(const PGPIdType& pgp_id)
|
||||
{
|
||||
//
|
||||
if(pgp_id.length() != 16)
|
||||
{
|
||||
std::cerr << "(EE) p3PeerMgrIMPL::servicePermissionFlags() called with inconsistent id " << pgp_id << std::endl;
|
||||
return RS_SERVICE_PERM_ALL ;
|
||||
}
|
||||
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
|
@ -2062,11 +2050,6 @@ void p3PeerMgrIMPL::setServicePermissionFlags(const PGPIdType& pgp_id, const Ser
|
|||
// Check that we have a PGP id. This should not be necessary, but because
|
||||
// we use std::string, anything can get passed down here.
|
||||
//
|
||||
if(pgp_id.length() != 16)
|
||||
{
|
||||
std::cerr << "Bad parameter passed to setServicePermissionFlags(): " << pgp_id << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
mFriendsPermissionFlags[pgp_id] = flags ;
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
|
@ -2080,13 +2063,13 @@ void p3PeerMgrIMPL::setServicePermissionFlags(const PGPIdType& pgp_id, const Ser
|
|||
|
||||
bool p3PeerMgrIMPL::removeAllFriendLocations(const PGPIdType &gpgid)
|
||||
{
|
||||
std::list<SSLIdType> sslIds;
|
||||
std::list<RsPeerId> sslIds;
|
||||
if (!getAssociatedPeers(gpgid, sslIds))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::list<SSLIdType>::iterator it;
|
||||
std::list<RsPeerId>::iterator it;
|
||||
for(it = sslIds.begin(); it != sslIds.end(); it++)
|
||||
{
|
||||
removeFriend(*it, true);
|
||||
|
@ -2096,7 +2079,7 @@ bool p3PeerMgrIMPL::removeAllFriendLocations(const PGPIdType &gpgid)
|
|||
}
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::getAssociatedPeers(const PGPIdType &gpg_id, std::list<SSLIdType> &ids)
|
||||
bool p3PeerMgrIMPL::getAssociatedPeers(const PGPIdType &gpg_id, std::list<RsPeerId> &ids)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
|
@ -2105,7 +2088,7 @@ bool p3PeerMgrIMPL::getAssociatedPeers(const PGPIdType &gpg_id, std::list<SSLIdT
|
|||
#endif
|
||||
|
||||
int count = 0;
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
{
|
||||
if (it->second.gpg_id == gpg_id)
|
||||
|
@ -2126,20 +2109,20 @@ bool p3PeerMgrIMPL::getAssociatedPeers(const PGPIdType &gpg_id, std::list<SSLIdT
|
|||
|
||||
|
||||
|
||||
/* This only removes SSL certs, that are old... Can end up with no Certs per GPG Id
|
||||
* We are removing the concept of a "DummyId" - There is no need for it.
|
||||
*/
|
||||
|
||||
bool isDummyFriend(SSLIdType id)
|
||||
{
|
||||
bool ret = (id.substr(0,5) == "dummy");
|
||||
return ret;
|
||||
}
|
||||
// /* This only removes SSL certs, that are old... Can end up with no Certs per GPG Id
|
||||
// * We are removing the concept of a "DummyId" - There is no need for it.
|
||||
// */
|
||||
//
|
||||
// bool isDummyFriend(RsPeerId id)
|
||||
// {
|
||||
// bool ret = (id.substr(0,5) == "dummy");
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::removeUnusedLocations()
|
||||
{
|
||||
std::list<SSLIdType> toRemove;
|
||||
std::list<RsPeerId> toRemove;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
@ -2150,7 +2133,7 @@ bool p3PeerMgrIMPL::removeUnusedLocations()
|
|||
|
||||
time_t now = time(NULL);
|
||||
|
||||
std::map<SSLIdType, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
{
|
||||
if (now - it->second.lastcontact > VERY_OLD_PEER)
|
||||
|
@ -2163,19 +2146,19 @@ bool p3PeerMgrIMPL::removeUnusedLocations()
|
|||
|
||||
}
|
||||
|
||||
if (isDummyFriend(it->first))
|
||||
{
|
||||
toRemove.push_back(it->first);
|
||||
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3PeerMgr::removeUnusedLocations() removing Dummy Id: " << it->first << std::endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
// if (isDummyFriend(it->first))
|
||||
// {
|
||||
// toRemove.push_back(it->first);
|
||||
//
|
||||
//#ifdef P3PEERS_DEBUG
|
||||
// std::cerr << "p3PeerMgr::removeUnusedLocations() removing Dummy Id: " << it->first << std::endl;
|
||||
//#endif
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
std::list<SSLIdType>::iterator it;
|
||||
std::list<RsPeerId>::iterator it;
|
||||
|
||||
for(it = toRemove.begin(); it != toRemove.end(); it++)
|
||||
{
|
||||
|
|
|
@ -70,7 +70,7 @@ class peerState
|
|||
public:
|
||||
peerState(); /* init */
|
||||
|
||||
SSLIdType id;
|
||||
RsPeerId id;
|
||||
PGPIdType gpg_id;
|
||||
|
||||
uint32_t netMode; /* EXT / UPNP / UDP / HIDDEN / INVALID */
|
||||
|
@ -114,14 +114,14 @@ class p3PeerMgr
|
|||
p3PeerMgr() { return; }
|
||||
virtual ~p3PeerMgr() { return; }
|
||||
|
||||
virtual bool addFriend(const SSLIdType &ssl_id, const PGPIdType &gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
|
||||
virtual bool addFriend(const RsPeerId &ssl_id, const PGPIdType &gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
|
||||
uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL,
|
||||
time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_SERVICE_PERM_ALL)) = 0;
|
||||
virtual bool removeFriend(const SSLIdType &ssl_id, bool removePgpId) = 0;
|
||||
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId) = 0;
|
||||
|
||||
virtual bool isFriend(const SSLIdType& ssl_id) = 0;
|
||||
virtual bool isFriend(const RsPeerId& ssl_id) = 0;
|
||||
|
||||
virtual bool getAssociatedPeers(const PGPIdType &gpg_id, std::list<SSLIdType> &ids) = 0;
|
||||
virtual bool getAssociatedPeers(const PGPIdType &gpg_id, std::list<RsPeerId> &ids) = 0;
|
||||
virtual bool removeAllFriendLocations(const PGPIdType &gpgid) = 0;
|
||||
|
||||
|
||||
|
@ -133,10 +133,10 @@ virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo) =
|
|||
virtual bool removeGroup(const std::string &groupId) = 0;
|
||||
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
||||
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
|
||||
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<SSLIdType> &peerIds, bool assign) = 0;
|
||||
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPeerId> &peerIds, bool assign) = 0;
|
||||
|
||||
virtual ServicePermissionFlags servicePermissionFlags(const PGPIdType& gpg_id) =0;
|
||||
virtual ServicePermissionFlags servicePermissionFlags(const SSLIdType& ssl_id) =0;
|
||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) =0;
|
||||
virtual void setServicePermissionFlags(const PGPIdType& gpg_id,const ServicePermissionFlags& flags) =0;
|
||||
|
||||
/**************** Set Net Info ****************/
|
||||
|
@ -147,19 +147,19 @@ virtual bool assignPeersToGroup(const std::string &groupId, const std::list<S
|
|||
* 3) p3disc - reasonable
|
||||
*/
|
||||
|
||||
virtual bool setLocalAddress(const SSLIdType &id, const struct sockaddr_storage &addr) = 0;
|
||||
virtual bool setExtAddress(const SSLIdType &id, const struct sockaddr_storage &addr) = 0;
|
||||
virtual bool setDynDNS(const SSLIdType &id, const std::string &dyndns) = 0;
|
||||
virtual bool setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr) = 0;
|
||||
virtual bool setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr) = 0;
|
||||
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns) = 0;
|
||||
|
||||
virtual bool setNetworkMode(const SSLIdType &id, uint32_t netMode) = 0;
|
||||
virtual bool setVisState(const SSLIdType &id, uint16_t vs_disc, uint16_t vs_dht) = 0;
|
||||
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode) = 0;
|
||||
virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht) = 0;
|
||||
|
||||
virtual bool setLocation(const SSLIdType &pid, const std::string &location) = 0;
|
||||
virtual bool setHiddenDomainPort(const SSLIdType &id, const std::string &domain_addr, const uint16_t domain_port) = 0;
|
||||
virtual bool setLocation(const RsPeerId &pid, const std::string &location) = 0;
|
||||
virtual bool setHiddenDomainPort(const RsPeerId &id, const std::string &domain_addr, const uint16_t domain_port) = 0;
|
||||
|
||||
virtual bool updateCurrentAddress(const SSLIdType& id, const pqiIpAddress &addr) = 0;
|
||||
virtual bool updateLastContact(const SSLIdType& id) = 0;
|
||||
virtual bool updateAddressList(const SSLIdType& id, const pqiIpAddrSet &addrs) = 0;
|
||||
virtual bool updateCurrentAddress(const RsPeerId& id, const pqiIpAddress &addr) = 0;
|
||||
virtual bool updateLastContact(const RsPeerId& id) = 0;
|
||||
virtual bool updateAddressList(const RsPeerId& id, const pqiIpAddrSet &addrs) = 0;
|
||||
|
||||
|
||||
// THIS MUST ONLY BE CALLED BY NETMGR!!!!
|
||||
|
@ -175,18 +175,18 @@ virtual bool UpdateOwnAddress(const struct sockaddr_storage &local_addr, cons
|
|||
*/
|
||||
|
||||
virtual bool getOwnNetStatus(peerState &state) = 0;
|
||||
virtual bool getFriendNetStatus(const SSLIdType &id, peerState &state) = 0;
|
||||
virtual bool getOthersNetStatus(const SSLIdType &id, peerState &state) = 0;
|
||||
virtual bool getFriendNetStatus(const RsPeerId &id, peerState &state) = 0;
|
||||
virtual bool getOthersNetStatus(const RsPeerId &id, peerState &state) = 0;
|
||||
|
||||
virtual bool getPeerName(const SSLIdType &ssl_id, std::string &name) = 0;
|
||||
virtual bool getGpgId(const SSLIdType &sslId, PGPIdType &gpgId) = 0;
|
||||
virtual uint32_t getConnectionType(const SSLIdType &sslId) = 0;
|
||||
virtual bool getPeerName(const RsPeerId &ssl_id, std::string &name) = 0;
|
||||
virtual bool getGpgId(const RsPeerId &sslId, PGPIdType &gpgId) = 0;
|
||||
virtual uint32_t getConnectionType(const RsPeerId &sslId) = 0;
|
||||
|
||||
virtual bool setProxyServerAddress(const struct sockaddr_storage &proxy_addr) = 0;
|
||||
virtual bool getProxyServerAddress(struct sockaddr_storage &proxy_addr) = 0;
|
||||
virtual bool isHidden() = 0;
|
||||
virtual bool isHiddenPeer(const SSLIdType &ssl_id) = 0;
|
||||
virtual bool getProxyAddress(const SSLIdType &ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port) = 0;
|
||||
virtual bool isHiddenPeer(const RsPeerId &ssl_id) = 0;
|
||||
virtual bool getProxyAddress(const RsPeerId &ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port) = 0;
|
||||
|
||||
|
||||
virtual int getFriendCount(bool ssl, bool online) = 0;
|
||||
|
@ -214,14 +214,14 @@ class p3PeerMgrIMPL: public p3PeerMgr, public p3Config
|
|||
/* EXTERNAL INTERFACE */
|
||||
/************************************************************************************************/
|
||||
|
||||
virtual bool addFriend(const SSLIdType&ssl_id, const PGPIdType&gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
|
||||
virtual bool addFriend(const RsPeerId&ssl_id, const PGPIdType&gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
|
||||
uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL,
|
||||
time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_SERVICE_PERM_ALL));
|
||||
virtual bool removeFriend(const SSLIdType &ssl_id, bool removePgpId);
|
||||
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId);
|
||||
|
||||
virtual bool isFriend(const SSLIdType &ssl_id);
|
||||
virtual bool isFriend(const RsPeerId &ssl_id);
|
||||
|
||||
virtual bool getAssociatedPeers(const PGPIdType &gpg_id, std::list<SSLIdType> &ids);
|
||||
virtual bool getAssociatedPeers(const PGPIdType &gpg_id, std::list<RsPeerId> &ids);
|
||||
virtual bool removeAllFriendLocations(const PGPIdType &gpgid);
|
||||
|
||||
|
||||
|
@ -233,11 +233,11 @@ virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo);
|
|||
virtual bool removeGroup(const std::string &groupId);
|
||||
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo);
|
||||
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
|
||||
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<std::string> &peerIds, bool assign);
|
||||
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPeerId> &peerIds, bool assign);
|
||||
|
||||
virtual ServicePermissionFlags servicePermissionFlags(const std::string& gpg_id) ;
|
||||
virtual ServicePermissionFlags servicePermissionFlags_sslid(const std::string& ssl_id) ;
|
||||
virtual void setServicePermissionFlags(const std::string& gpg_id,const ServicePermissionFlags& flags) ;
|
||||
virtual ServicePermissionFlags servicePermissionFlags(const PGPIdType& gpg_id) ;
|
||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) ;
|
||||
virtual void setServicePermissionFlags(const PGPIdType& gpg_id,const ServicePermissionFlags& flags) ;
|
||||
|
||||
/**************** Set Net Info ****************/
|
||||
/*
|
||||
|
@ -247,19 +247,19 @@ virtual bool assignPeersToGroup(const std::string &groupId, const std::list<s
|
|||
* 3) p3disc - reasonable
|
||||
*/
|
||||
|
||||
virtual bool setLocalAddress(const SSLIdType &id, const struct sockaddr_storage &addr);
|
||||
virtual bool setExtAddress(const SSLIdType &id, const struct sockaddr_storage &addr);
|
||||
virtual bool setDynDNS(const SSLIdType &id, const std::string &dyndns);
|
||||
virtual bool setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr);
|
||||
virtual bool setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr);
|
||||
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns);
|
||||
|
||||
virtual bool setNetworkMode(const SSLIdType &id, uint32_t netMode);
|
||||
virtual bool setVisState(const SSLIdType &id, uint16_t vs_disc, uint16_t vs_dht);
|
||||
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode);
|
||||
virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht);
|
||||
|
||||
virtual bool setLocation(const SSLIdType &pid, const std::string &location);
|
||||
virtual bool setHiddenDomainPort(const SSLIdType &id, const std::string &domain_addr, const uint16_t domain_port);
|
||||
virtual bool setLocation(const RsPeerId &pid, const std::string &location);
|
||||
virtual bool setHiddenDomainPort(const RsPeerId &id, const std::string &domain_addr, const uint16_t domain_port);
|
||||
|
||||
virtual bool updateCurrentAddress(const SSLIdType& id, const pqiIpAddress &addr);
|
||||
virtual bool updateLastContact(const SSLIdType& id);
|
||||
virtual bool updateAddressList(const SSLIdType& id, const pqiIpAddrSet &addrs);
|
||||
virtual bool updateCurrentAddress(const RsPeerId& id, const pqiIpAddress &addr);
|
||||
virtual bool updateLastContact(const RsPeerId& id);
|
||||
virtual bool updateAddressList(const RsPeerId& id, const pqiIpAddrSet &addrs);
|
||||
|
||||
|
||||
// THIS MUST ONLY BE CALLED BY NETMGR!!!!
|
||||
|
@ -274,18 +274,18 @@ virtual bool UpdateOwnAddress(const struct sockaddr_storage &local_addr, cons
|
|||
*/
|
||||
|
||||
virtual bool getOwnNetStatus(peerState &state);
|
||||
virtual bool getFriendNetStatus(const SSLIdType &id, peerState &state);
|
||||
virtual bool getOthersNetStatus(const SSLIdType &id, peerState &state);
|
||||
virtual bool getFriendNetStatus(const RsPeerId &id, peerState &state);
|
||||
virtual bool getOthersNetStatus(const RsPeerId &id, peerState &state);
|
||||
|
||||
virtual bool getPeerName(const SSLIdType& ssl_id, std::string& name);
|
||||
virtual bool getGpgId(const SSLIdType& sslId, PGPIdType& gpgId);
|
||||
virtual uint32_t getConnectionType(const SSLIdType& sslId);
|
||||
virtual bool getPeerName(const RsPeerId& ssl_id, std::string& name);
|
||||
virtual bool getGpgId(const RsPeerId& sslId, PGPIdType& gpgId);
|
||||
virtual uint32_t getConnectionType(const RsPeerId& sslId);
|
||||
|
||||
virtual bool setProxyServerAddress(const struct sockaddr_storage &proxy_addr);
|
||||
virtual bool getProxyServerAddress(struct sockaddr_storage &proxy_addr);
|
||||
virtual bool isHidden();
|
||||
virtual bool isHiddenPeer(const SSLIdType& ssl_id);
|
||||
virtual bool getProxyAddress(const SSLIdType& ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port);
|
||||
virtual bool isHiddenPeer(const RsPeerId& ssl_id);
|
||||
virtual bool getProxyAddress(const RsPeerId& ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port);
|
||||
|
||||
virtual int getFriendCount(bool ssl, bool online);
|
||||
|
||||
|
@ -299,7 +299,7 @@ virtual bool haveOnceConnected();
|
|||
/* Extra IMPL Functions (used by p3LinkMgr, p3NetMgr + Setup) */
|
||||
/************************************************************************************************/
|
||||
|
||||
p3PeerMgrIMPL( const SSLIdType& ssl_own_id,
|
||||
p3PeerMgrIMPL( const RsPeerId& ssl_own_id,
|
||||
const PGPIdType& gpg_own_id,
|
||||
const std::string& gpg_own_name,
|
||||
const std::string& ssl_own_location) ;
|
||||
|
@ -311,11 +311,11 @@ bool setupHiddenNode(const std::string &hiddenAddress, const uint16_t hiddenPor
|
|||
|
||||
void tick();
|
||||
|
||||
const SSLIdType& getOwnId();
|
||||
const RsPeerId& getOwnId();
|
||||
bool setOwnNetworkMode(uint32_t netMode);
|
||||
bool setOwnVisState(uint16_t vs_disc, uint16_t vs_dht);
|
||||
|
||||
int getConnectAddresses(const SSLIdType &id,
|
||||
int getConnectAddresses(const RsPeerId &id,
|
||||
struct sockaddr_storage &lAddr, struct sockaddr_storage &eAddr,
|
||||
pqiIpAddrSet &histAddrs, std::string &dyndns);
|
||||
|
||||
|
@ -352,8 +352,8 @@ private:
|
|||
|
||||
peerState mOwnState;
|
||||
|
||||
std::map<SSLIdType, peerState> mFriendList; // <SSLid , peerState>
|
||||
std::map<SSLIdType, peerState> mOthersList;
|
||||
std::map<RsPeerId, peerState> mFriendList; // <SSLid , peerState>
|
||||
std::map<RsPeerId, peerState> mOthersList;
|
||||
|
||||
std::list<RsPeerGroupItem *> groupList;
|
||||
uint32_t lastGroupId;
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
/*** Base DataTypes: ****/
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "retroshare/rstypes.h"
|
||||
|
||||
|
||||
#define PQI_MIN_PORT 10 // TO ALLOW USERS TO HAVE PORT 80! - was 1024
|
||||
|
@ -186,7 +187,7 @@ class NetInterface;
|
|||
class PQInterface: public RateInterface
|
||||
{
|
||||
public:
|
||||
PQInterface(const std::string &id) :peerId(id) { return; }
|
||||
PQInterface(const RsPeerId &id) :peerId(id) { return; }
|
||||
virtual ~PQInterface() { return; }
|
||||
|
||||
/*!
|
||||
|
@ -221,7 +222,7 @@ class PQInterface: public RateInterface
|
|||
*/
|
||||
virtual int tick() { return 0; }
|
||||
virtual int status() { return 0; }
|
||||
virtual std::string PeerId() { return peerId; }
|
||||
virtual const RsPeerId& PeerId() { return peerId; }
|
||||
|
||||
// the callback from NetInterface Connection Events.
|
||||
virtual int notifyEvent(NetInterface *ni, int event, const struct sockaddr_storage &remote_peer_address)
|
||||
|
@ -234,7 +235,7 @@ class PQInterface: public RateInterface
|
|||
|
||||
private:
|
||||
|
||||
std::string peerId;
|
||||
RsPeerId peerId;
|
||||
};
|
||||
|
||||
|
||||
|
@ -353,7 +354,7 @@ public:
|
|||
/**
|
||||
* @param p_in used to notify system of connect/disconnect events
|
||||
*/
|
||||
NetInterface(PQInterface *p_in, std::string id)
|
||||
NetInterface(PQInterface *p_in, const RsPeerId& id)
|
||||
:p(p_in), peerId(id) { return; }
|
||||
|
||||
virtual ~NetInterface()
|
||||
|
@ -364,7 +365,7 @@ virtual int listen() = 0;
|
|||
virtual int stoplistening() = 0;
|
||||
virtual int disconnect() = 0;
|
||||
virtual int reset() = 0;
|
||||
virtual std::string PeerId() { return peerId; }
|
||||
virtual const RsPeerId& PeerId() { return peerId; }
|
||||
virtual int getConnectAddress(struct sockaddr_storage &raddr) = 0;
|
||||
|
||||
virtual bool connect_parameter(uint32_t type, uint32_t value) = 0;
|
||||
|
@ -376,7 +377,7 @@ PQInterface *parent() { return p; }
|
|||
|
||||
private:
|
||||
PQInterface *p;
|
||||
std::string peerId;
|
||||
RsPeerId peerId;
|
||||
};
|
||||
|
||||
//! network binary interface (abstract)
|
||||
|
@ -390,7 +391,7 @@ private:
|
|||
class NetBinInterface: public NetInterface, public BinInterface
|
||||
{
|
||||
public:
|
||||
NetBinInterface(PQInterface *parent, std::string id)
|
||||
NetBinInterface(PQInterface *parent, const RsPeerId& id)
|
||||
:NetInterface(parent, id)
|
||||
{ return; }
|
||||
virtual ~NetBinInterface() { return; }
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "retroshare/rstypes.h"
|
||||
#include "pqi/pqinetwork.h"
|
||||
#include "pqi/pqimonitor.h"
|
||||
|
||||
|
@ -109,7 +110,7 @@ class pqiNetAssistPeerShare
|
|||
public:
|
||||
|
||||
/* share Addresses for various reasons (bad peers, etc) */
|
||||
virtual void updatePeer(std::string id, const struct sockaddr_storage &addr, int type, int reason, int age) = 0;
|
||||
virtual void updatePeer(const RsPeerId& id, const struct sockaddr_storage &addr, int type, int reason, int age) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
@ -149,7 +150,7 @@ class pqiNetAssistConnect: public pqiNetAssist
|
|||
/*
|
||||
*/
|
||||
public:
|
||||
pqiNetAssistConnect(std::string id, pqiConnectCb *cb)
|
||||
pqiNetAssistConnect(const RsPeerId& id, pqiConnectCb *cb)
|
||||
:mPeerId(id), mConnCb(cb) { return; }
|
||||
|
||||
/********** External DHT Interface ************************
|
||||
|
@ -159,17 +160,17 @@ class pqiNetAssistConnect: public pqiNetAssist
|
|||
|
||||
|
||||
/* add / remove peers */
|
||||
virtual bool findPeer(std::string id) = 0;
|
||||
virtual bool dropPeer(std::string id) = 0;
|
||||
virtual bool findPeer(const RsPeerId& id) = 0;
|
||||
virtual bool dropPeer(const RsPeerId& id) = 0;
|
||||
|
||||
/* add non-active peers (can still toggle active/non-active via above) */
|
||||
virtual int addBadPeer(const struct sockaddr_storage &addr, uint32_t reason, uint32_t flags, uint32_t age) = 0;
|
||||
virtual int addKnownPeer(const std::string &pid, const struct sockaddr_storage &addr, uint32_t flags) = 0;
|
||||
virtual int addKnownPeer(const RsPeerId &pid, const struct sockaddr_storage &addr, uint32_t flags) = 0;
|
||||
|
||||
virtual void ConnectionFeedback(std::string pid, int mode) = 0;
|
||||
virtual void ConnectionFeedback(const RsPeerId& pid, int mode) = 0;
|
||||
|
||||
/* extract current peer status */
|
||||
virtual bool getPeerStatus(std::string id,
|
||||
virtual bool getPeerStatus(const RsPeerId& id,
|
||||
struct sockaddr_storage &laddr, struct sockaddr_storage &raddr,
|
||||
uint32_t &type, uint32_t &mode) = 0; // DEPRECIATE.
|
||||
|
||||
|
@ -179,7 +180,7 @@ virtual bool setAttachMode(bool on) = 0; // FIXUP.
|
|||
virtual bool getNetworkStats(uint32_t &netsize, uint32_t &localnetsize) = 0; // DEPRECIATE.
|
||||
|
||||
protected:
|
||||
std::string mPeerId;
|
||||
RsPeerId mPeerId;
|
||||
pqiConnectCb *mConnCb;
|
||||
};
|
||||
|
||||
|
|
|
@ -493,7 +493,7 @@ bool BinMemInterface::readfromfile(const char *fname)
|
|||
/**************************************************************************/
|
||||
|
||||
|
||||
void printNetBinID(std::ostream &out, std::string id, uint32_t t)
|
||||
void printNetBinID(std::ostream &out, const RsPeerId& id, uint32_t t)
|
||||
{
|
||||
out << "NetBinId(" << id << ",";
|
||||
if (t == PQI_CONNECT_TCP)
|
||||
|
@ -520,9 +520,8 @@ void printNetBinID(std::ostream &out, std::string id, uint32_t t)
|
|||
|
||||
const uint32_t DEFAULT_DUMMY_DELTA = 5;
|
||||
|
||||
NetBinDummy::NetBinDummy(PQInterface *parent, std::string id, uint32_t t)
|
||||
:NetBinInterface(parent, id), type(t), dummyConnected(false),
|
||||
toConnect(false), connectDelta(DEFAULT_DUMMY_DELTA)
|
||||
NetBinDummy::NetBinDummy(PQInterface *parent, const RsPeerId& id, uint32_t t)
|
||||
:NetBinInterface(parent, id), type(t), dummyConnected(false), toConnect(false), connectDelta(DEFAULT_DUMMY_DELTA)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ virtual uint64_t bytecount();
|
|||
class NetBinDummy: public NetBinInterface
|
||||
{
|
||||
public:
|
||||
NetBinDummy(PQInterface *parent, std::string id, uint32_t t);
|
||||
NetBinDummy(PQInterface *parent, const RsPeerId& id, uint32_t t);
|
||||
virtual ~NetBinDummy() { return; }
|
||||
|
||||
// Net Interface
|
||||
|
|
|
@ -122,7 +122,7 @@ int pqihandler::status()
|
|||
// display all interfaces...
|
||||
for(it = mods.begin(); it != mods.end(); it++)
|
||||
{
|
||||
rs_sprintf_append(out, "\tModule [%s] Pointer <%p>", it -> first.c_str(), (void *) ((it -> second) -> pqi));
|
||||
rs_sprintf_append(out, "\tModule [%s] Pointer <%p>", it -> first.toStdString().c_str(), (void *) ((it -> second) -> pqi));
|
||||
}
|
||||
|
||||
pqioutput(PQL_DEBUG_BASIC, pqihandlerzone, out);
|
||||
|
@ -150,7 +150,7 @@ bool pqihandler::AddSearchModule(SearchModule *mod)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (mod->peerid == "")
|
||||
if (mod->peerid.isNull())
|
||||
{
|
||||
// ERROR!
|
||||
pqioutput(PQL_ALERT, pqihandlerzone, "ERROR peerid == NULL");
|
||||
|
@ -261,7 +261,7 @@ int pqihandler::locked_HandleRsItem(RsItem *item, int allowglobal,uint32_t& comp
|
|||
// check security... is output allowed.
|
||||
if(0 < secpolicy_check((it -> second) -> sp, 0, PQI_OUTGOING))
|
||||
{
|
||||
std::string out = "pqihandler::HandleRsItem() sending to chan: " + it -> first;
|
||||
std::string out = "pqihandler::HandleRsItem() sending to chan: " + it -> first.toStdString();
|
||||
pqioutput(PQL_DEBUG_BASIC, pqihandlerzone, out);
|
||||
#ifdef DEBUG_TICK
|
||||
std::cerr << out << std::endl;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#define LOOPBACK_DEBUG 1
|
||||
***/
|
||||
|
||||
pqiloopback::pqiloopback(std::string id)
|
||||
pqiloopback::pqiloopback(const RsPeerId& id)
|
||||
:PQInterface(id)
|
||||
{
|
||||
setMaxRate(true, 0);
|
||||
|
|
|
@ -82,7 +82,7 @@ virtual bool connect_additional_address(uint32_t type, const struct sockaddr_st
|
|||
virtual int getConnectAddress(struct sockaddr_storage &raddr){ return ni->getConnectAddress(raddr); }
|
||||
|
||||
// get the contact from the net side!
|
||||
virtual std::string PeerId()
|
||||
virtual const RsPeerId& PeerId()
|
||||
{
|
||||
if (ni)
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
class pqiQoSstreamer: public pqithreadstreamer, public pqiQoS
|
||||
{
|
||||
public:
|
||||
pqiQoSstreamer(PQInterface *parent, RsSerialiser *rss, std::string peerid, BinInterface *bio_in, int bio_flagsin);
|
||||
pqiQoSstreamer(PQInterface *parent, RsSerialiser *rss, const RsPeerId& peerid, BinInterface *bio_in, int bio_flagsin);
|
||||
|
||||
static const uint32_t PQI_QOS_STREAMER_MAX_LEVELS = 10 ;
|
||||
static const float PQI_QOS_STREAMER_ALPHA = 2.0 ;
|
||||
|
|
|
@ -79,7 +79,7 @@ template<uint32_t ID_SIZE_IN_BYTES,uint32_t UNIQUE_IDENTIFIER> class t_RsGeneric
|
|||
|
||||
inline bool isNull() const
|
||||
{
|
||||
for(int i=0;i<SIZE_IN_BYTES;++i)
|
||||
for(uint32_t i=0;i<SIZE_IN_BYTES;++i)
|
||||
if(bytes[i] != 0)
|
||||
return false ;
|
||||
return true ;
|
||||
|
|
|
@ -250,6 +250,23 @@ bool setRawSha1(void *data,uint32_t size,uint32_t *offset,const Sha1CheckSum& cs
|
|||
|
||||
return true ;
|
||||
}
|
||||
bool getRawPGPId(void *data,uint32_t size,uint32_t *offset,PGPIdType& cs)
|
||||
{
|
||||
uint32_t len = PGPIdType::SIZE_IN_BYTES ; // SSL id type
|
||||
|
||||
/* check there is space for string */
|
||||
if (size < *offset + len)
|
||||
{
|
||||
std::cerr << "getRawPGPId() not enough size" << std::endl;
|
||||
return false;
|
||||
}
|
||||
bool ok = true ;
|
||||
|
||||
cs = PGPIdType(&((uint8_t*)data)[*offset]) ;
|
||||
*offset += len ;
|
||||
|
||||
return ok ;
|
||||
}
|
||||
bool getRawSSLId(void *data,uint32_t size,uint32_t *offset,SSLIdType& cs)
|
||||
{
|
||||
uint32_t len = 16 ; // SSL id type
|
||||
|
@ -267,6 +284,21 @@ bool getRawSSLId(void *data,uint32_t size,uint32_t *offset,SSLIdType& cs)
|
|||
|
||||
return ok ;
|
||||
}
|
||||
bool setRawPGPId(void *data,uint32_t size,uint32_t *offset,const PGPIdType& cs)
|
||||
{
|
||||
uint32_t len = PGPIdType::SIZE_IN_BYTES ; // SHA1 length in bytes
|
||||
|
||||
if (size < *offset + len)
|
||||
{
|
||||
std::cerr << "setRawPGPId() Not enough size" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy((void *) &(((uint8_t *) data)[*offset]), cs.toByteArray(), PGPIdType::SIZE_IN_BYTES);
|
||||
*offset += PGPIdType::SIZE_IN_BYTES ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
bool setRawSSLId(void *data,uint32_t size,uint32_t *offset,const SSLIdType& cs)
|
||||
{
|
||||
uint32_t len = 16 ; // SHA1 length in bytes
|
||||
|
|
|
@ -72,6 +72,9 @@ bool setRawSha1(void *data, uint32_t size, uint32_t *offset, const Sha1CheckSum&
|
|||
bool setRawSSLId(void *data, uint32_t size, uint32_t *offset, const SSLIdType& inStr);
|
||||
bool getRawSSLId(void *data, uint32_t size, uint32_t *offset, SSLIdType& outStr);
|
||||
|
||||
bool setRawPGPId(void *data, uint32_t size, uint32_t *offset, const PGPIdType& inStr);
|
||||
bool getRawPGPId(void *data, uint32_t size, uint32_t *offset, PGPIdType& outStr);
|
||||
|
||||
bool setRawPGPFingerprint(void *data, uint32_t size, uint32_t *offset, const PGPFingerprintType& inStr);
|
||||
bool getRawPGPFingerprint(void *data, uint32_t size, uint32_t *offset, PGPFingerprintType& outStr);
|
||||
|
||||
|
|
|
@ -1342,7 +1342,7 @@ std::ostream& RsPeerServicePermissionItem::print(std::ostream &out, uint16_t ind
|
|||
for(uint32_t i=0;i<pgp_ids.size();++i)
|
||||
{
|
||||
printIndent(out, int_Indent);
|
||||
out << "pgp id: " << pgp_ids[i] << ": " << service_flags[i].toUInt32() << std::endl;
|
||||
out << "pgp id: " << pgp_ids[i].toStdString() << ": " << service_flags[i].toUInt32() << std::endl;
|
||||
}
|
||||
printRsItemEnd(out, "RsPeerServicePermissionItem", indent);
|
||||
return out;
|
||||
|
@ -1355,7 +1355,7 @@ uint32_t RsPeerConfigSerialiser::sizePermissions(RsPeerServicePermissionItem *i)
|
|||
|
||||
for(uint32_t j=0;j<i->pgp_ids.size();++j)
|
||||
{
|
||||
s += GetTlvStringSize(i->pgp_ids[j]) ;
|
||||
s += PGPIdType::SIZE_IN_BYTES ;//GetTlvStringSize(i->pgp_ids[j]) ;
|
||||
s += 4; /* flag */
|
||||
}
|
||||
|
||||
|
@ -1391,7 +1391,7 @@ bool RsPeerConfigSerialiser::serialisePermissions(RsPeerServicePermissionItem *i
|
|||
|
||||
for(uint32_t i=0;i<item->pgp_ids.size();++i)
|
||||
{
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_KEY, item->pgp_ids[i]);
|
||||
ok &= setRawPGPId(data, tlvsize, &offset, item->pgp_ids[i]);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->service_flags[i].toUInt32());
|
||||
}
|
||||
|
||||
|
@ -1446,7 +1446,7 @@ RsPeerServicePermissionItem *RsPeerConfigSerialiser::deserialisePermissions(void
|
|||
for(uint32_t i=0;i<s;++i)
|
||||
{
|
||||
uint32_t flags ;
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_KEY, item->pgp_ids[i]);
|
||||
ok &= getRawPGPId(data, rssize, &offset, item->pgp_ids[i]);
|
||||
ok &= getRawUInt32(data, rssize, &offset, &flags);
|
||||
|
||||
item->service_flags[i] = ServicePermissionFlags(flags) ;
|
||||
|
|
|
@ -109,7 +109,7 @@ class RsPeerServicePermissionItem : public RsItem
|
|||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
/* Mandatory */
|
||||
std::vector<std::string> pgp_ids ;
|
||||
std::vector<PGPIdType> pgp_ids ;
|
||||
std::vector<ServicePermissionFlags> service_flags ;
|
||||
};
|
||||
class RsPeerGroupItem : public RsItem
|
||||
|
@ -131,7 +131,7 @@ public:
|
|||
std::string name;
|
||||
uint32_t flag;
|
||||
|
||||
std::list<std::string> peerIds;
|
||||
std::list<RsPeerId> peerIds;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue