mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-15 09:36:23 -04:00
ID cleaning. Unfinished yet.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-IdCleaning@7096 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c4c8414a79
commit
effbf8f683
18 changed files with 166 additions and 157 deletions
|
@ -348,7 +348,7 @@ bool p3BitDht::dropPeer(std::string pid)
|
|||
|
||||
|
||||
/* extract current peer status */
|
||||
bool p3BitDht::getPeerStatus(std::string id,
|
||||
bool p3BitDht::getPeerStatus(const RsPeerId& id,
|
||||
struct sockaddr_storage &/*laddr*/, struct sockaddr_storage &/*raddr*/,
|
||||
uint32_t &/*type*/, uint32_t &/*mode*/)
|
||||
{
|
||||
|
|
|
@ -66,7 +66,7 @@ int p3BitDht::getDhtPeers(int lvl, std::list<RsDhtPeer> &peers)
|
|||
return (int_peers.entries.size() > 0);
|
||||
}
|
||||
|
||||
int p3BitDht::getNetPeerList(std::list<std::string> &peerIds)
|
||||
int p3BitDht::getNetPeerList(std::list<RsPeerId> &peerIds)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /*********** LOCKED **********/
|
||||
std::map<bdNodeId, DhtPeerDetails>::iterator it;
|
||||
|
@ -78,7 +78,7 @@ int p3BitDht::getNetPeerList(std::list<std::string> &peerIds)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int p3BitDht::getNetPeerStatus(std::string peerId, RsDhtNetPeer &status)
|
||||
int p3BitDht::getNetPeerStatus(const RsPeerId& peerId, RsDhtNetPeer &status)
|
||||
{
|
||||
|
||||
RsStackMutex stack(dhtMtx); /*********** LOCKED **********/
|
||||
|
|
|
@ -143,7 +143,7 @@ int p3BitDht::NodeCallback(const bdId *id, uint32_t peerflags)
|
|||
bdStdPrintId(std::cerr, id);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
mProxyStunner->addStunPeer(id->addr, "");
|
||||
mProxyStunner->addStunPeer(id->addr, NULL);
|
||||
}
|
||||
/* else */ // removed else until we have lots of peers.
|
||||
|
||||
|
@ -154,7 +154,7 @@ int p3BitDht::NodeCallback(const bdId *id, uint32_t peerflags)
|
|||
bdStdPrintId(std::cerr, id);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
mDhtStunner->addStunPeer(id->addr, "");
|
||||
mDhtStunner->addStunPeer(id->addr, NULL);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
@ -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 */
|
||||
RsPeerId pid;
|
||||
std::string 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 */
|
||||
RsPeerId pid;
|
||||
std::string pid;
|
||||
bdStdPrintNodeId(pid, &(action.mDestId.id), false);
|
||||
|
||||
|
||||
|
@ -2382,7 +2382,7 @@ void p3BitDht::ReleaseProxyExclusiveMode_locked(DhtPeerDetails *dpd, bool addrCh
|
|||
std::cerr << std::endl;
|
||||
|
||||
/* translate id into string for exclusive mode */
|
||||
RsPeerId pid;
|
||||
std::string pid;
|
||||
bdStdPrintNodeId(pid, &(dpd->mDhtId.id), false);
|
||||
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
#define USE_OLD_DHT_INTERFACE 1
|
||||
|
||||
|
||||
bool p3BitDht::findPeer(std::string pid)
|
||||
bool p3BitDht::findPeer(const RsPeerId& pid)
|
||||
{
|
||||
#ifdef DEBUG_BITDHT
|
||||
std::cerr << "p3BitDht::findPeer(" << pid << ")";
|
||||
|
@ -133,7 +133,7 @@ bool p3BitDht::findPeer(std::string pid)
|
|||
return true ;
|
||||
}
|
||||
|
||||
bool p3BitDht::dropPeer(std::string pid)
|
||||
bool p3BitDht::dropPeer(const RsPeerId& pid)
|
||||
{
|
||||
#ifdef DEBUG_BITDHT
|
||||
std::cerr << "p3BitDht::dropPeer(" << pid << ")";
|
||||
|
@ -216,7 +216,7 @@ int p3BitDht::addBadPeer(const struct sockaddr_storage &addr, uint32_t /*reason*
|
|||
}
|
||||
|
||||
|
||||
int p3BitDht::addKnownPeer(const std::string &pid, const struct sockaddr_storage &addr, uint32_t flags)
|
||||
int p3BitDht::addKnownPeer(const RsPeerId &pid, const struct sockaddr_storage &addr, uint32_t flags)
|
||||
{
|
||||
struct sockaddr_in addrv4;
|
||||
|
||||
|
@ -389,7 +389,7 @@ int p3BitDht::addOther(const std::string pid)
|
|||
#endif
|
||||
|
||||
|
||||
int p3BitDht::removePeer(const std::string pid)
|
||||
int p3BitDht::removePeer(const RsPeerId& pid)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /********* LOCKED *********/
|
||||
|
||||
|
@ -401,7 +401,7 @@ int p3BitDht::removePeer(const std::string pid)
|
|||
********************************* Basic Peer Details *************************************
|
||||
******************************************************************************************/
|
||||
|
||||
DhtPeerDetails *p3BitDht::addInternalPeer_locked(const std::string pid, uint32_t type)
|
||||
DhtPeerDetails *p3BitDht::addInternalPeer_locked(const RsPeerId& pid, uint32_t type)
|
||||
{
|
||||
/* create the data structure */
|
||||
if (!havePeerTranslation_locked(pid))
|
||||
|
@ -435,7 +435,7 @@ DhtPeerDetails *p3BitDht::addInternalPeer_locked(const std::string pid, uint32_t
|
|||
}
|
||||
|
||||
|
||||
int p3BitDht::removeInternalPeer_locked(const std::string pid)
|
||||
int p3BitDht::removeInternalPeer_locked(const RsPeerId& pid)
|
||||
{
|
||||
bdNodeId id;
|
||||
if (!lookupNodeId_locked(pid, &id))
|
||||
|
@ -478,7 +478,7 @@ DhtPeerDetails *p3BitDht::findInternalDhtPeer_locked(const bdNodeId *id, uint32_
|
|||
|
||||
|
||||
/* interface to get with alt id */
|
||||
DhtPeerDetails *p3BitDht::findInternalRsPeer_locked(const std::string &pid)
|
||||
DhtPeerDetails *p3BitDht::findInternalRsPeer_locked(const RsPeerId &pid)
|
||||
{
|
||||
/* create the data structure */
|
||||
if (!havePeerTranslation_locked(pid))
|
||||
|
@ -502,14 +502,14 @@ DhtPeerDetails *p3BitDht::findInternalRsPeer_locked(const std::string &pid)
|
|||
*************************** Fundamental Node Translation *********************************
|
||||
******************************************************************************************/
|
||||
|
||||
bool p3BitDht::havePeerTranslation_locked(const std::string &pid)
|
||||
bool p3BitDht::havePeerTranslation_locked(const RsPeerId &pid)
|
||||
{
|
||||
#ifdef DEBUG_BITDHT_TRANSLATE
|
||||
std::cerr << "p3BitDht::havePeerTranslation_locked() for : " << pid;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::string, bdNodeId>::iterator it;
|
||||
std::map<RsPeerId, bdNodeId>::iterator it;
|
||||
it = mTransToNodeId.find(pid);
|
||||
if (it == mTransToNodeId.end())
|
||||
{
|
||||
|
@ -531,14 +531,14 @@ bool p3BitDht::havePeerTranslation_locked(const std::string &pid)
|
|||
}
|
||||
|
||||
|
||||
int p3BitDht::lookupNodeId_locked(const std::string pid, bdNodeId *id)
|
||||
int p3BitDht::lookupNodeId_locked(const RsPeerId& pid, bdNodeId *id)
|
||||
{
|
||||
#ifdef DEBUG_BITDHT_TRANSLATE
|
||||
std::cerr << "p3BitDht::lookupNodeId_locked() for : " << pid;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::string, bdNodeId>::iterator it;
|
||||
std::map<RsPeerId, bdNodeId>::iterator it;
|
||||
it = mTransToNodeId.find(pid);
|
||||
if (it == mTransToNodeId.end())
|
||||
{
|
||||
|
@ -562,7 +562,7 @@ int p3BitDht::lookupNodeId_locked(const std::string pid, bdNodeId *id)
|
|||
}
|
||||
|
||||
|
||||
int p3BitDht::lookupRsId_locked(const bdNodeId *id, std::string &pid)
|
||||
int p3BitDht::lookupRsId_locked(const bdNodeId *id, RsPeerId&pid)
|
||||
{
|
||||
#ifdef DEBUG_BITDHT_TRANSLATE
|
||||
std::cerr << "p3BitDht::lookupRsId_locked() for : ";
|
||||
|
@ -570,7 +570,7 @@ int p3BitDht::lookupRsId_locked(const bdNodeId *id, std::string &pid)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<bdNodeId, std::string>::iterator nit;
|
||||
std::map<bdNodeId, RsPeerId>::iterator nit;
|
||||
nit = mTransToRsId.find(*id);
|
||||
if (nit == mTransToRsId.end())
|
||||
{
|
||||
|
@ -592,7 +592,7 @@ int p3BitDht::lookupRsId_locked(const bdNodeId *id, std::string &pid)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int p3BitDht::storeTranslation_locked(const std::string pid)
|
||||
int p3BitDht::storeTranslation_locked(const RsPeerId& pid)
|
||||
{
|
||||
#ifdef DEBUG_BITDHT_TRANSLATE
|
||||
std::cerr << "p3BitDht::storeTranslation_locked(" << pid << ")";
|
||||
|
@ -619,7 +619,7 @@ int p3BitDht::storeTranslation_locked(const std::string pid)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int p3BitDht::removeTranslation_locked(const std::string pid)
|
||||
int p3BitDht::removeTranslation_locked(const RsPeerId& pid)
|
||||
{
|
||||
|
||||
#ifdef DEBUG_BITDHT_TRANSLATE
|
||||
|
@ -627,7 +627,7 @@ int p3BitDht::removeTranslation_locked(const std::string pid)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::string, bdNodeId>::iterator it = mTransToNodeId.find(pid);
|
||||
std::map<RsPeerId, bdNodeId>::iterator it = mTransToNodeId.find(pid);
|
||||
it = mTransToNodeId.find(pid);
|
||||
if (it == mTransToNodeId.end())
|
||||
{
|
||||
|
@ -646,7 +646,7 @@ int p3BitDht::removeTranslation_locked(const std::string pid)
|
|||
#endif
|
||||
|
||||
|
||||
std::map<bdNodeId, std::string>::iterator nit;
|
||||
std::map<bdNodeId, RsPeerId>::iterator nit;
|
||||
nit = mTransToRsId.find(nid);
|
||||
if (nit == mTransToRsId.end())
|
||||
{
|
||||
|
@ -676,7 +676,7 @@ const uint8_t RS_DHT_VERSION_LEN = 17;
|
|||
const uint8_t rs_dht_version_data[RS_DHT_VERSION_LEN] = "RS_VERSION_0.5.1";
|
||||
|
||||
/******************** Conversion Functions **************************/
|
||||
int p3BitDht::calculateNodeId(const std::string pid, bdNodeId *id)
|
||||
int p3BitDht::calculateNodeId(const RsPeerId& pid, bdNodeId *id)
|
||||
{
|
||||
/* generate node id from pid */
|
||||
#ifdef DEBUG_BITDHT_TRANSLATE
|
||||
|
@ -691,7 +691,7 @@ int p3BitDht::calculateNodeId(const std::string pid, bdNodeId *id)
|
|||
SHA1_Init(sha_ctx);
|
||||
|
||||
SHA1_Update(sha_ctx, rs_dht_version_data, RS_DHT_VERSION_LEN);
|
||||
SHA1_Update(sha_ctx, pid.c_str(), pid.length());
|
||||
SHA1_Update(sha_ctx, pid.toByteArray(), RsPeerId::SIZE_IN_BYTES);
|
||||
SHA1_Final(sha_hash, sha_ctx);
|
||||
|
||||
for(int i = 0; i < SHA_DIGEST_LENGTH && (i < BITDHT_KEY_LEN); i++)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue