mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-11 15:50:38 -04:00
merge of branch v0.6-idclean 7180
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7187 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
7815efb16f
commit
0f29d28b1b
397 changed files with 6503 additions and 5702 deletions
|
@ -83,9 +83,7 @@ static const std::string kConfigKeyProxyServerPort = "PROXY_SERVER_PORT";
|
|||
void printConnectState(std::ostream &out, peerState &peer);
|
||||
|
||||
peerState::peerState()
|
||||
:id("unknown"),
|
||||
gpg_id("unknown"),
|
||||
netMode(RS_NET_MODE_UNKNOWN), vs_disc(RS_VS_DISC_FULL), vs_dht(RS_VS_DHT_FULL), lastcontact(0),
|
||||
:netMode(RS_NET_MODE_UNKNOWN), vs_disc(RS_VS_DISC_FULL), vs_dht(RS_VS_DHT_FULL), lastcontact(0),
|
||||
hiddenNode(false), hiddenPort(0)
|
||||
{
|
||||
sockaddr_storage_clear(localaddr);
|
||||
|
@ -96,7 +94,7 @@ peerState::peerState()
|
|||
|
||||
std::string textPeerConnectState(peerState &state)
|
||||
{
|
||||
std::string out = "Id: " + state.id + "\n";
|
||||
std::string out = "Id: " + state.id.toStdString() + "\n";
|
||||
rs_sprintf_append(out, "NetMode: %lu\n", state.netMode);
|
||||
rs_sprintf_append(out, "VisState: Disc: %u Dht: %u\n", state.vs_disc, state.vs_dht);
|
||||
|
||||
|
@ -110,10 +108,7 @@ std::string textPeerConnectState(peerState &state)
|
|||
}
|
||||
|
||||
|
||||
p3PeerMgrIMPL::p3PeerMgrIMPL(const std::string& ssl_own_id,
|
||||
const std::string& gpg_own_id,
|
||||
const std::string& gpg_own_name,
|
||||
const std::string& ssl_own_location)
|
||||
p3PeerMgrIMPL::p3PeerMgrIMPL(const RsPeerId& ssl_own_id, const RsPgpId& gpg_own_id, const std::string& gpg_own_name, const std::string& ssl_own_location)
|
||||
:p3Config(CONFIG_TYPE_PEERS), mPeerMtx("p3PeerMgr"), mStatusChanged(false)
|
||||
{
|
||||
|
||||
|
@ -297,7 +292,7 @@ void p3PeerMgrIMPL::tick()
|
|||
*/
|
||||
|
||||
|
||||
const std::string p3PeerMgrIMPL::getOwnId()
|
||||
const RsPeerId& p3PeerMgrIMPL::getOwnId()
|
||||
{
|
||||
return AuthSSL::getAuthSSL()->OwnId();
|
||||
}
|
||||
|
@ -310,7 +305,7 @@ bool p3PeerMgrIMPL::getOwnNetStatus(peerState &state)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::isFriend(const std::string &id)
|
||||
bool p3PeerMgrIMPL::isFriend(const RsPeerId& id)
|
||||
{
|
||||
#ifdef PEER_DEBUG_COMMON
|
||||
std::cerr << "p3PeerMgrIMPL::isFriend(" << id << ") called" << std::endl;
|
||||
|
@ -323,12 +318,12 @@ bool p3PeerMgrIMPL::isFriend(const std::string &id)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::getPeerName(const std::string &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<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
it = mFriendList.find(ssl_id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -339,12 +334,12 @@ bool p3PeerMgrIMPL::getPeerName(const std::string &ssl_id, std::string &name)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::getGpgId(const std::string &ssl_id, std::string &gpgId)
|
||||
bool p3PeerMgrIMPL::getGpgId(const RsPeerId &ssl_id, RsPgpId &gpgId)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check for existing */
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
it = mFriendList.find(ssl_id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -364,12 +359,12 @@ bool p3PeerMgrIMPL::isHidden()
|
|||
}
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::isHiddenPeer(const std::string &ssl_id)
|
||||
bool p3PeerMgrIMPL::isHiddenPeer(const RsPeerId &ssl_id)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check for existing */
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
it = mFriendList.find(ssl_id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -384,7 +379,7 @@ bool p3PeerMgrIMPL::isHiddenPeer(const std::string &ssl_id)
|
|||
return (it->second).hiddenNode;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::setHiddenDomainPort(const std::string &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 *******/
|
||||
|
||||
|
@ -417,7 +412,7 @@ bool p3PeerMgrIMPL::setHiddenDomainPort(const std::string &ssl_id, const std::st
|
|||
}
|
||||
|
||||
/* check for existing */
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
it = mFriendList.find(ssl_id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -456,12 +451,12 @@ bool p3PeerMgrIMPL::getProxyServerAddress(struct sockaddr_storage &proxy_addr)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::getProxyAddress(const std::string &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<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
it = mFriendList.find(ssl_id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -481,7 +476,7 @@ bool p3PeerMgrIMPL::getProxyAddress(const std::string &ssl_id, struct sockaddr_s
|
|||
}
|
||||
|
||||
// Placeholder until we implement this functionality.
|
||||
uint32_t p3PeerMgrIMPL::getConnectionType(const std::string &/*sslId*/)
|
||||
uint32_t p3PeerMgrIMPL::getConnectionType(const RsPeerId &/*sslId*/)
|
||||
{
|
||||
return RS_NET_CONN_TYPE_FRIEND;
|
||||
}
|
||||
|
@ -490,15 +485,15 @@ int p3PeerMgrIMPL::getFriendCount(bool ssl, bool online)
|
|||
{
|
||||
if (online) {
|
||||
// count only online id's
|
||||
std::list<std::string> onlineIds;
|
||||
std::list<RsPeerId> onlineIds;
|
||||
mLinkMgr->getOnlineList(onlineIds);
|
||||
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::set<std::string> gpgIds;
|
||||
std::set<RsPgpId> gpgIds;
|
||||
int count = 0;
|
||||
|
||||
std::map<std::string, 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;
|
||||
|
@ -522,22 +517,22 @@ int p3PeerMgrIMPL::getFriendCount(bool ssl, bool online)
|
|||
}
|
||||
|
||||
// count all gpg id's
|
||||
std::list<std::string> gpgIds;
|
||||
std::list<RsPgpId> gpgIds;
|
||||
AuthGPG::getAuthGPG()->getGPGAcceptedList(gpgIds);
|
||||
|
||||
// add own gpg id, if we have more than one location
|
||||
std::list<std::string> ownSslIds;
|
||||
std::list<RsPeerId> ownSslIds;
|
||||
getAssociatedPeers(AuthGPG::getAuthGPG()->getGPGOwnId(), ownSslIds);
|
||||
|
||||
return gpgIds.size() + ((ownSslIds.size() > 0) ? 1 : 0);
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::getFriendNetStatus(const std::string &id, peerState &state)
|
||||
bool p3PeerMgrIMPL::getFriendNetStatus(const RsPeerId &id, peerState &state)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check for existing */
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
it = mFriendList.find(id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -549,12 +544,12 @@ bool p3PeerMgrIMPL::getFriendNetStatus(const std::string &id, peerState &state)
|
|||
}
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::getOthersNetStatus(const std::string &id, peerState &state)
|
||||
bool p3PeerMgrIMPL::getOthersNetStatus(const RsPeerId &id, peerState &state)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check for existing */
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
it = mOthersList.find(id);
|
||||
if (it == mOthersList.end())
|
||||
{
|
||||
|
@ -565,41 +560,7 @@ bool p3PeerMgrIMPL::getOthersNetStatus(const std::string &id, peerState &state)
|
|||
return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
void p3PeerMgrIMPL::getFriendList(std::list<std::string> &peers)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check for existing */
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
{
|
||||
peers.push_back(it->first);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
void p3PeerMgrIMPL::getOthersList(std::list<std::string> &peers)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check for existing */
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
for(it = mOthersList.begin(); it != mOthersList.end(); it++)
|
||||
{
|
||||
peers.push_back(it->first);
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
int p3PeerMgrIMPL::getConnectAddresses(const std::string &id,
|
||||
int p3PeerMgrIMPL::getConnectAddresses(const RsPeerId &id,
|
||||
struct sockaddr_storage &lAddr, struct sockaddr_storage &eAddr,
|
||||
pqiIpAddrSet &histAddrs, std::string &dyndns)
|
||||
{
|
||||
|
@ -607,7 +568,7 @@ int p3PeerMgrIMPL::getConnectAddresses(const std::string &id,
|
|||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check for existing */
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
it = mFriendList.find(id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
|
@ -632,7 +593,7 @@ bool p3PeerMgrIMPL::haveOnceConnected()
|
|||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check for existing */
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
{
|
||||
if (it->second.lastcontact > 0)
|
||||
|
@ -660,23 +621,13 @@ bool p3PeerMgrIMPL::haveOnceConnected()
|
|||
/*******************************************************************/
|
||||
/*******************************************************************/
|
||||
|
||||
bool p3PeerMgrIMPL::addFriend(const std::string& input_id, const std::string& 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 RsPgpId& input_gpg_id, uint32_t netMode, uint16_t vs_disc, uint16_t vs_dht, time_t lastContact,ServicePermissionFlags service_flags)
|
||||
{
|
||||
bool notifyLinkMgr = false;
|
||||
std::string id = input_id ;
|
||||
std::string gpg_id = input_gpg_id ;
|
||||
RsPeerId id = input_id ;
|
||||
RsPgpId gpg_id = input_gpg_id ;
|
||||
|
||||
rslog(RSL_WARNING, p3peermgrzone, "p3PeerMgr::addFriend() id: " + id);
|
||||
|
||||
// For safety, make sure ssl_id is lower case and GPG id is upper case.
|
||||
//
|
||||
for(uint32_t i=0;i<id.length();++i)
|
||||
if(id[i] >= 'A' && id[i] <= 'F')
|
||||
id[i] += 'a' - 'A' ;
|
||||
|
||||
for(uint32_t i=0;i<gpg_id.length();++i)
|
||||
if(gpg_id[i] >= 'a' && gpg_id[i] <= 'f')
|
||||
gpg_id[i] += 'A' - 'a' ;
|
||||
rslog(RSL_WARNING, p3peermgrzone, "p3PeerMgr::addFriend() id: " + id.toStdString());
|
||||
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
@ -700,7 +651,7 @@ bool p3PeerMgrIMPL::addFriend(const std::string& input_id, const std::string& in
|
|||
std::cerr << "p3PeerMgrIMPL::addFriend() " << id << "; gpg_id : " << gpg_id << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() != mFriendList.find(id))
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
|
@ -794,8 +745,79 @@ bool p3PeerMgrIMPL::addFriend(const std::string& input_id, const std::string& in
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::removeFriend(const RsPgpId &id)
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::removeFriend() for id : " << id << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::removeFriend() mFriendList.size() : " << mFriendList.size() << std::endl;
|
||||
#endif
|
||||
|
||||
bool p3PeerMgrIMPL::removeFriend(const std::string &id, bool removePgpId)
|
||||
rslog(RSL_WARNING, p3peermgrzone, "p3PeerMgr::removeFriend() id: " + id.toStdString());
|
||||
|
||||
std::list<RsPeerId> sslid_toRemove; // This is a list of SSLIds.
|
||||
rsPeers->getAssociatedSSLIds(id,sslid_toRemove) ;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* move to othersList */
|
||||
bool success = false;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
//remove ssl and gpg_ids
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
{
|
||||
if (find(sslid_toRemove.begin(),sslid_toRemove.end(),it->second.id) != sslid_toRemove.end())
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::removeFriend() friend found in the list." << id << std::endl;
|
||||
#endif
|
||||
peerState peer = it->second;
|
||||
|
||||
sslid_toRemove.push_back(it->second.id);
|
||||
|
||||
mOthersList[it->second.id] = peer;
|
||||
mStatusChanged = true;
|
||||
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
for(std::list<RsPeerId>::iterator rit = sslid_toRemove.begin(); rit != sslid_toRemove.end(); rit++)
|
||||
if (mFriendList.end() != (it = mFriendList.find(*rit)))
|
||||
mFriendList.erase(it);
|
||||
|
||||
std::map<RsPgpId,ServicePermissionFlags>::iterator it2 = mFriendsPermissionFlags.find(id) ;
|
||||
|
||||
if(it2 != mFriendsPermissionFlags.end())
|
||||
mFriendsPermissionFlags.erase(it2);
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::removeFriend() new mFriendList.size() : " << mFriendList.size() << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
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<RsPgpId> ids ;
|
||||
ids.push_back(id) ;
|
||||
assignPeersToGroup("", ids, false);
|
||||
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
printPeerLists(std::cerr);
|
||||
mLinkMgr->printPeerLists(std::cerr);
|
||||
#endif
|
||||
|
||||
return !sslid_toRemove.empty();
|
||||
}
|
||||
bool p3PeerMgrIMPL::removeFriend(const RsPeerId &id, bool removePgpId)
|
||||
{
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
|
@ -803,21 +825,22 @@ bool p3PeerMgrIMPL::removeFriend(const std::string &id, bool removePgpId)
|
|||
std::cerr << "p3PeerMgrIMPL::removeFriend() mFriendList.size() : " << mFriendList.size() << std::endl;
|
||||
#endif
|
||||
|
||||
rslog(RSL_WARNING, p3peermgrzone, "p3PeerMgr::removeFriend() id: " + id);
|
||||
rslog(RSL_WARNING, p3peermgrzone, "p3PeerMgr::removeFriend() id: " + id.toStdString());
|
||||
|
||||
std::list<std::string> sslid_toRemove; // This is a list of SSLIds.
|
||||
std::list<std::string> pgpid_toRemove; // This is a list of SSLIds.
|
||||
std::list<RsPeerId> sslid_toRemove; // This is a list of SSLIds.
|
||||
std::list<RsPgpId> pgpid_toRemove; // This is a list of SSLIds.
|
||||
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* move to othersList */
|
||||
bool success = false;
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
//remove ssl and gpg_ids
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
{
|
||||
if (it->second.id == id || it->second.gpg_id == id) {
|
||||
if (it->second.id == id)
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::removeFriend() friend found in the list." << id << std::endl;
|
||||
#endif
|
||||
|
@ -834,14 +857,13 @@ bool p3PeerMgrIMPL::removeFriend(const std::string &id, bool removePgpId)
|
|||
}
|
||||
}
|
||||
|
||||
std::list<std::string>::iterator rit;
|
||||
for(rit = sslid_toRemove.begin(); rit != sslid_toRemove.end(); rit++)
|
||||
for(std::list<RsPeerId>::iterator rit = sslid_toRemove.begin(); rit != sslid_toRemove.end(); rit++)
|
||||
if (mFriendList.end() != (it = mFriendList.find(*rit)))
|
||||
mFriendList.erase(it);
|
||||
|
||||
std::map<std::string,ServicePermissionFlags>::iterator it2 ;
|
||||
std::map<RsPgpId,ServicePermissionFlags>::iterator it2 ;
|
||||
|
||||
for(rit = pgpid_toRemove.begin(); rit != pgpid_toRemove.end(); rit++)
|
||||
for(std::list<RsPgpId>::iterator rit = pgpid_toRemove.begin(); rit != pgpid_toRemove.end(); rit++)
|
||||
if (mFriendsPermissionFlags.end() != (it2 = mFriendsPermissionFlags.find(*rit)))
|
||||
mFriendsPermissionFlags.erase(it2);
|
||||
|
||||
|
@ -850,17 +872,15 @@ bool p3PeerMgrIMPL::removeFriend(const std::string &id, bool removePgpId)
|
|||
#endif
|
||||
}
|
||||
|
||||
std::list<std::string>::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<std::string> peerIds;
|
||||
peerIds.push_back(id);
|
||||
|
||||
assignPeersToGroup("", peerIds, false);
|
||||
assignPeersToGroup("", pgpid_toRemove, false);
|
||||
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
|
||||
|
@ -882,7 +902,7 @@ void p3PeerMgrIMPL::printPeerLists(std::ostream &out)
|
|||
out << std::endl;
|
||||
|
||||
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
{
|
||||
out << "\t SSL ID: " << it->second.id;
|
||||
|
@ -905,69 +925,6 @@ void p3PeerMgrIMPL::printPeerLists(std::ostream &out)
|
|||
|
||||
|
||||
|
||||
#if 0
|
||||
bool p3PeerMgrIMPL::addNeighbour(std::string id)
|
||||
{
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::addNeighbour() not implemented anymore." << id << std::endl;
|
||||
#endif
|
||||
|
||||
/* so three possibilities
|
||||
* (1) already exists as friend -> do nothing.
|
||||
* (2) already in others list -> do nothing.
|
||||
* (3) is non-existant -> create new one.
|
||||
*/
|
||||
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
if (mFriendList.end() == mFriendList.find(id))
|
||||
{
|
||||
/* (1) already exists */
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mOthersList.end() == mOthersList.find(id))
|
||||
{
|
||||
/* (2) already exists */
|
||||
return true;
|
||||
}
|
||||
|
||||
/* check with the AuthMgr if its valid */
|
||||
if (!AuthSSL::getAuthSSL()->isAuthenticated(id))
|
||||
{
|
||||
/* no auth */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* get details from AuthMgr */
|
||||
sslcert detail;
|
||||
if (!AuthSSL::getAuthSSL()->getCertDetails(id, detail))
|
||||
{
|
||||
/* no details */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* create a new entry */
|
||||
peerState pstate;
|
||||
|
||||
pstate.id = id;
|
||||
pstate.name = detail.name;
|
||||
|
||||
pstate.state = 0;
|
||||
pstate.actions = 0; //RS_PEER_NEW;
|
||||
pstate.visState = RS_VIS_STATE_STD;
|
||||
pstate.netMode = RS_NET_MODE_UNKNOWN;
|
||||
|
||||
/* addr & timestamps -> auto cleared */
|
||||
mOthersList[id] = pstate;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*******************************************************************/
|
||||
/*******************************************************************/
|
||||
|
||||
|
@ -1058,7 +1015,7 @@ bool p3PeerMgrIMPL::UpdateOwnAddress(const struct sockaddr_storage &localAddr,
|
|||
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::setLocalAddress(const std::string &id, const struct sockaddr_storage &addr)
|
||||
bool p3PeerMgrIMPL::setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
|
@ -1085,7 +1042,7 @@ bool p3PeerMgrIMPL::setLocalAddress(const std::string &id, const struct socka
|
|||
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
/* check if it is a friend */
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
|
@ -1119,7 +1076,7 @@ bool p3PeerMgrIMPL::setLocalAddress(const std::string &id, const struct socka
|
|||
return changed;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::setExtAddress(const std::string &id, const struct sockaddr_storage &addr)
|
||||
bool p3PeerMgrIMPL::setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
|
@ -1141,7 +1098,7 @@ bool p3PeerMgrIMPL::setExtAddress(const std::string &id, const struct sockadd
|
|||
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
/* check if it is a friend */
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
|
@ -1176,7 +1133,7 @@ bool p3PeerMgrIMPL::setExtAddress(const std::string &id, const struct sockadd
|
|||
}
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::setDynDNS(const std::string &id, const std::string &dyndns)
|
||||
bool p3PeerMgrIMPL::setDynDNS(const RsPeerId &id, const std::string &dyndns)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
|
@ -1194,7 +1151,7 @@ bool p3PeerMgrIMPL::setDynDNS(const std::string &id, const std::string &dyndns)
|
|||
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
/* check if it is a friend */
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
|
@ -1216,7 +1173,7 @@ bool p3PeerMgrIMPL::setDynDNS(const std::string &id, const std::string &dyndns)
|
|||
return changed;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::updateAddressList(const std::string& 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;
|
||||
|
@ -1232,7 +1189,7 @@ bool p3PeerMgrIMPL::updateAddressList(const std::string& id, const pqiIpAddrS
|
|||
}
|
||||
|
||||
/* check if it is a friend */
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
|
@ -1261,7 +1218,7 @@ bool p3PeerMgrIMPL::updateAddressList(const std::string& id, const pqiIpAddrS
|
|||
}
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::updateCurrentAddress(const std::string& 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;
|
||||
|
@ -1272,7 +1229,7 @@ bool p3PeerMgrIMPL::updateCurrentAddress(const std::string& id, const pqiIpAd
|
|||
/* cannot be own id */
|
||||
|
||||
/* check if it is a friend */
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
|
@ -1308,7 +1265,7 @@ bool p3PeerMgrIMPL::updateCurrentAddress(const std::string& id, const pqiIpAd
|
|||
}
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::updateLastContact(const std::string& id)
|
||||
bool p3PeerMgrIMPL::updateLastContact(const RsPeerId& id)
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::updateLastContact() called for id : " << id << std::endl;
|
||||
|
@ -1319,7 +1276,7 @@ bool p3PeerMgrIMPL::updateLastContact(const std::string& id)
|
|||
/* cannot be own id */
|
||||
|
||||
/* check if it is a friend */
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
|
@ -1336,7 +1293,7 @@ bool p3PeerMgrIMPL::updateLastContact(const std::string& id)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::setNetworkMode(const std::string &id, uint32_t netMode)
|
||||
bool p3PeerMgrIMPL::setNetworkMode(const RsPeerId &id, uint32_t netMode)
|
||||
{
|
||||
if (id == AuthSSL::getAuthSSL()->OwnId())
|
||||
{
|
||||
|
@ -1345,7 +1302,7 @@ bool p3PeerMgrIMPL::setNetworkMode(const std::string &id, uint32_t netMode)
|
|||
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
/* check if it is a friend */
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
|
@ -1367,7 +1324,7 @@ bool p3PeerMgrIMPL::setNetworkMode(const std::string &id, uint32_t netMode)
|
|||
return changed;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::setLocation(const std::string &id, const std::string &location)
|
||||
bool p3PeerMgrIMPL::setLocation(const RsPeerId &id, const std::string &location)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
|
@ -1386,7 +1343,7 @@ bool p3PeerMgrIMPL::setLocation(const std::string &id, const std::string &loc
|
|||
}
|
||||
|
||||
/* check if it is a friend */
|
||||
std::map<std::string, 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;
|
||||
|
@ -1396,11 +1353,11 @@ bool p3PeerMgrIMPL::setLocation(const std::string &id, const std::string &loc
|
|||
return changed;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::setVisState(const std::string &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;
|
||||
rs_sprintf(out, "p3PeerMgr::setVisState(%s, %u, %u)", id.c_str(), vs_disc, vs_dht);
|
||||
rs_sprintf(out, "p3PeerMgr::setVisState(%s, %u, %u)", id.toStdString().c_str(), vs_disc, vs_dht);
|
||||
rslog(RSL_WARNING, p3peermgrzone, out);
|
||||
}
|
||||
|
||||
|
@ -1415,7 +1372,7 @@ bool p3PeerMgrIMPL::setVisState(const std::string &id, uint16_t vs_disc, uint
|
|||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check if it is a friend */
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
|
@ -1518,9 +1475,9 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||
RsPeerNetItem *item = new RsPeerNetItem();
|
||||
item->clear();
|
||||
|
||||
item->pid = getOwnId();
|
||||
item->gpg_id = mOwnState.gpg_id;
|
||||
item->location = mOwnState.location;
|
||||
item->pid = getOwnId().toStdString();
|
||||
item->gpg_id = mOwnState.gpg_id.toStdString();
|
||||
item->location = mOwnState.location;
|
||||
#if 0
|
||||
if (mOwnState.netMode & RS_NET_MODE_TRY_EXT)
|
||||
{
|
||||
|
@ -1563,14 +1520,14 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||
saveCleanupList.push_back(item);
|
||||
|
||||
/* iterate through all friends and save */
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
{
|
||||
item = new RsPeerNetItem();
|
||||
item->clear();
|
||||
|
||||
item->pid = it->first;
|
||||
item->gpg_id = (it->second).gpg_id;
|
||||
item->pid = it->first.toStdString();
|
||||
item->gpg_id = (it->second).gpg_id.toStdString();
|
||||
item->location = (it->second).location;
|
||||
item->netMode = (it->second).netMode;
|
||||
item->vs_disc = (it->second).vs_disc;
|
||||
|
@ -1602,7 +1559,7 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||
|
||||
RsPeerServicePermissionItem *sitem = new RsPeerServicePermissionItem ;
|
||||
|
||||
for(std::map<std::string,ServicePermissionFlags>::const_iterator it(mFriendsPermissionFlags.begin());it!=mFriendsPermissionFlags.end();++it)
|
||||
for(std::map<RsPgpId,ServicePermissionFlags>::const_iterator it(mFriendsPermissionFlags.begin());it!=mFriendsPermissionFlags.end();++it)
|
||||
{
|
||||
sitem->pgp_ids.push_back(it->first) ;
|
||||
sitem->service_flags.push_back(it->second) ;
|
||||
|
@ -1677,7 +1634,7 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
|||
std::cerr << "p3PeerMgrIMPL::loadList() Item Count: " << load.size() << std::endl;
|
||||
#endif
|
||||
|
||||
std::string ownId = getOwnId();
|
||||
RsPeerId ownId = getOwnId();
|
||||
|
||||
/* load the list of peers */
|
||||
std::list<RsItem *>::iterator it;
|
||||
|
@ -1686,7 +1643,10 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
|||
RsPeerNetItem *pitem = dynamic_cast<RsPeerNetItem *>(*it);
|
||||
if (pitem)
|
||||
{
|
||||
if (pitem->pid == ownId)
|
||||
RsPeerId peer_id(pitem->pid) ;
|
||||
RsPgpId peer_pgp_id(pitem->gpg_id) ;
|
||||
|
||||
if (peer_id == ownId)
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() Own Config Item:" << std::endl;
|
||||
|
@ -1708,29 +1668,29 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* ************* */
|
||||
addFriend(pitem->pid, pitem->gpg_id, pitem->netMode, pitem->vs_disc, pitem->vs_dht, pitem->lastContact, RS_SERVICE_PERM_ALL);
|
||||
setLocation(pitem->pid, pitem->location);
|
||||
addFriend(peer_id, peer_pgp_id, pitem->netMode, pitem->vs_disc, pitem->vs_dht, pitem->lastContact, RS_SERVICE_PERM_ALL);
|
||||
setLocation(RsPeerId(pitem->pid), pitem->location);
|
||||
}
|
||||
|
||||
if (pitem->netMode == RS_NET_MODE_HIDDEN)
|
||||
{
|
||||
/* set only the hidden stuff & localAddress */
|
||||
setLocalAddress(pitem->pid, pitem->localAddrV4.addr);
|
||||
setHiddenDomainPort(pitem->pid, pitem->domain_addr, pitem->domain_port);
|
||||
setLocalAddress(peer_id, pitem->localAddrV4.addr);
|
||||
setHiddenDomainPort(peer_id, pitem->domain_addr, pitem->domain_port);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
setLocalAddress(pitem->pid, pitem->localAddrV4.addr);
|
||||
setExtAddress(pitem->pid, pitem->extAddrV4.addr);
|
||||
setDynDNS (pitem->pid, pitem->dyndns);
|
||||
setLocalAddress(peer_id, pitem->localAddrV4.addr);
|
||||
setExtAddress(peer_id, pitem->extAddrV4.addr);
|
||||
setDynDNS (peer_id, pitem->dyndns);
|
||||
|
||||
/* convert addresses */
|
||||
pqiIpAddrSet addrs;
|
||||
addrs.mLocal.extractFromTlv(pitem->localAddrList);
|
||||
addrs.mExt.extractFromTlv(pitem->extAddrList);
|
||||
|
||||
updateAddressList(pitem->pid, addrs);
|
||||
updateAddressList(peer_id, addrs);
|
||||
}
|
||||
|
||||
delete(*it);
|
||||
|
@ -2062,7 +2022,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<std::string> &peerIds, bool assign)
|
||||
bool p3PeerMgrIMPL::assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign)
|
||||
{
|
||||
if (groupId.empty() && assign == true) {
|
||||
return false;
|
||||
|
@ -2082,9 +2042,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<RsPgpId>::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<RsPgpId>::iterator peerIt1 = std::find(groupItem->peerIds.begin(), groupItem->peerIds.end(), *peerIt);
|
||||
if (assign) {
|
||||
if (peerIt1 == groupItem->peerIds.end()) {
|
||||
groupItem->peerIds.push_back(*peerIt);
|
||||
|
@ -2121,19 +2081,14 @@ bool p3PeerMgrIMPL::assignPeersToGroup(const std::string &groupId, const std::li
|
|||
**********************************************************************
|
||||
**********************************************************************/
|
||||
|
||||
ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags_sslid(const std::string& ssl_id)
|
||||
ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags(const RsPeerId& ssl_id)
|
||||
{
|
||||
std::string gpg_id ;
|
||||
RsPgpId 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<std::string, 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 ;
|
||||
|
@ -2145,19 +2100,12 @@ ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags_sslid(const std::st
|
|||
}
|
||||
|
||||
|
||||
ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags(const std::string& pgp_id)
|
||||
ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags(const RsPgpId& 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 *******/
|
||||
|
||||
std::map<std::string,ServicePermissionFlags>::const_iterator it = mFriendsPermissionFlags.find( pgp_id ) ;
|
||||
std::map<RsPgpId,ServicePermissionFlags>::const_iterator it = mFriendsPermissionFlags.find( pgp_id ) ;
|
||||
|
||||
if(it == mFriendsPermissionFlags.end())
|
||||
return RS_SERVICE_PERM_ALL ;
|
||||
|
@ -2165,18 +2113,13 @@ ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags(const std::string&
|
|||
return it->second ;
|
||||
}
|
||||
}
|
||||
void p3PeerMgrIMPL::setServicePermissionFlags(const std::string& pgp_id, const ServicePermissionFlags& flags)
|
||||
void p3PeerMgrIMPL::setServicePermissionFlags(const RsPgpId& pgp_id, const ServicePermissionFlags& flags)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
// 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! *****/
|
||||
|
@ -2188,15 +2131,15 @@ void p3PeerMgrIMPL::setServicePermissionFlags(const std::string& pgp_id, const S
|
|||
**********************************************************************
|
||||
**********************************************************************/
|
||||
|
||||
bool p3PeerMgrIMPL::removeAllFriendLocations(const std::string &gpgid)
|
||||
bool p3PeerMgrIMPL::removeAllFriendLocations(const RsPgpId &gpgid)
|
||||
{
|
||||
std::list<std::string> sslIds;
|
||||
std::list<RsPeerId> sslIds;
|
||||
if (!getAssociatedPeers(gpgid, sslIds))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::list<std::string>::iterator it;
|
||||
std::list<RsPeerId>::iterator it;
|
||||
for(it = sslIds.begin(); it != sslIds.end(); it++)
|
||||
{
|
||||
removeFriend(*it, true);
|
||||
|
@ -2206,7 +2149,7 @@ bool p3PeerMgrIMPL::removeAllFriendLocations(const std::string &gpgid)
|
|||
}
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::getAssociatedPeers(const std::string &gpg_id, std::list<std::string> &ids)
|
||||
bool p3PeerMgrIMPL::getAssociatedPeers(const RsPgpId &gpg_id, std::list<RsPeerId> &ids)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
|
@ -2215,7 +2158,7 @@ bool p3PeerMgrIMPL::getAssociatedPeers(const std::string &gpg_id, std::list<std:
|
|||
#endif
|
||||
|
||||
int count = 0;
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
{
|
||||
if (it->second.gpg_id == gpg_id)
|
||||
|
@ -2236,20 +2179,20 @@ bool p3PeerMgrIMPL::getAssociatedPeers(const std::string &gpg_id, std::list<std:
|
|||
|
||||
|
||||
|
||||
/* 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(std::string 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<std::string> toRemove;
|
||||
std::list<RsPeerId> toRemove;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
@ -2260,7 +2203,7 @@ bool p3PeerMgrIMPL::removeUnusedLocations()
|
|||
|
||||
time_t now = time(NULL);
|
||||
|
||||
std::map<std::string, 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)
|
||||
|
@ -2273,19 +2216,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<std::string>::iterator it;
|
||||
std::list<RsPeerId>::iterator it;
|
||||
|
||||
for(it = toRemove.begin(); it != toRemove.end(); it++)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue