mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fixed up Adding / Removing Peers.
* added OthersList to p3linkmgr. this is important so we can send ACTIONS for removed Peers. * added missing mStatusChanged when adding Friend. * added printPeerLists to PeerMgr and LinkMgr. * tweaked debugging. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-netupgrade@4427 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
1cf790990f
commit
d643f168a0
@ -53,9 +53,12 @@ const int p3connectzone = 3431;
|
|||||||
/****
|
/****
|
||||||
* #define LINKMGR_DEBUG 1
|
* #define LINKMGR_DEBUG 1
|
||||||
* #define LINKMGR_DEBUG_CONNFAIL 1
|
* #define LINKMGR_DEBUG_CONNFAIL 1
|
||||||
|
* #define LINKMGR_DEBUG_ACTIONS 1
|
||||||
***/
|
***/
|
||||||
|
|
||||||
#define LINKMGR_DEBUG_CONNFAIL 1
|
#define LINKMGR_DEBUG_CONNFAIL 1
|
||||||
|
#define LINKMGR_DEBUG_ACTIONS 1
|
||||||
|
|
||||||
|
|
||||||
/****
|
/****
|
||||||
* #define P3CONNMGR_NO_TCP_CONNECTIONS 1
|
* #define P3CONNMGR_NO_TCP_CONNECTIONS 1
|
||||||
@ -442,7 +445,7 @@ void p3LinkMgr::tickMonitors()
|
|||||||
|
|
||||||
if (mStatusChanged)
|
if (mStatusChanged)
|
||||||
{
|
{
|
||||||
#ifdef LINKMGR_DEBUG
|
#ifdef LINKMGR_DEBUG_ACTIONS
|
||||||
std::cerr << "p3LinkMgr::tickMonitors() StatusChanged! List:" << std::endl;
|
std::cerr << "p3LinkMgr::tickMonitors() StatusChanged! List:" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
/* assemble list */
|
/* assemble list */
|
||||||
@ -462,7 +465,7 @@ void p3LinkMgr::tickMonitors()
|
|||||||
|
|
||||||
actionList.push_back(peer);
|
actionList.push_back(peer);
|
||||||
|
|
||||||
#ifdef LINKMGR_DEBUG
|
#ifdef LINKMGR_DEBUG_ACTIONS
|
||||||
std::cerr << "Friend: " << peer.name << " Id: " << peer.id << " State: " << peer.state;
|
std::cerr << "Friend: " << peer.name << " Id: " << peer.id << " State: " << peer.state;
|
||||||
if (peer.state & RS_PEER_S_FRIEND)
|
if (peer.state & RS_PEER_S_FRIEND)
|
||||||
std::cerr << " S:RS_PEER_S_FRIEND";
|
std::cerr << " S:RS_PEER_S_FRIEND";
|
||||||
@ -497,6 +500,7 @@ void p3LinkMgr::tickMonitors()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* do the Others as well! */
|
/* do the Others as well! */
|
||||||
for(it = mOthersList.begin(); it != mOthersList.end(); it++)
|
for(it = mOthersList.begin(); it != mOthersList.end(); it++)
|
||||||
{
|
{
|
||||||
@ -512,7 +516,7 @@ void p3LinkMgr::tickMonitors()
|
|||||||
/* reset action */
|
/* reset action */
|
||||||
it->second.actions = 0;
|
it->second.actions = 0;
|
||||||
|
|
||||||
#ifdef LINKMGR_DEBUG
|
#ifdef LINKMGR_DEBUG_ACTIONS
|
||||||
std::cerr << "Other: " << peer.name << " Id: " << peer.id << " State: " << peer.state;
|
std::cerr << "Other: " << peer.name << " Id: " << peer.id << " State: " << peer.state;
|
||||||
if (peer.state & RS_PEER_S_FRIEND)
|
if (peer.state & RS_PEER_S_FRIEND)
|
||||||
std::cerr << " S:RS_PEER_S_FRIEND";
|
std::cerr << " S:RS_PEER_S_FRIEND";
|
||||||
@ -554,7 +558,7 @@ void p3LinkMgr::tickMonitors()
|
|||||||
|
|
||||||
if (doStatusChange)
|
if (doStatusChange)
|
||||||
{
|
{
|
||||||
#ifdef LINKMGR_DEBUG
|
#ifdef LINKMGR_DEBUG_ACTIONS
|
||||||
std::cerr << "Sending to " << clients.size() << " monitorClients" << std::endl;
|
std::cerr << "Sending to " << clients.size() << " monitorClients" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -578,6 +582,14 @@ void p3LinkMgr::tickMonitors()
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
{
|
||||||
|
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
|
/* Now Cleanup OthersList (served its purpose (MOVE Action)) */
|
||||||
|
mOthersList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1760,11 +1772,13 @@ int p3LinkMgr::addFriend(const std::string &id, bool isVisible)
|
|||||||
peerConnectState pcs;
|
peerConnectState pcs;
|
||||||
pcs.dhtVisible = isVisible;
|
pcs.dhtVisible = isVisible;
|
||||||
pcs.id = id;
|
pcs.id = id;
|
||||||
pcs.name = "Dummy Id Name";
|
pcs.name = "NoName";
|
||||||
pcs.state = RS_PEER_S_FRIEND;
|
pcs.state = RS_PEER_S_FRIEND;
|
||||||
pcs.actions = RS_PEER_NEW;
|
pcs.actions = RS_PEER_NEW;
|
||||||
|
|
||||||
mFriendList[id] = pcs;
|
mFriendList[id] = pcs;
|
||||||
|
|
||||||
|
mStatusChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
mNetMgr->netAssistFriend(id, isVisible);
|
mNetMgr->netAssistFriend(id, isVisible);
|
||||||
@ -1774,6 +1788,7 @@ int p3LinkMgr::addFriend(const std::string &id, bool isVisible)
|
|||||||
|
|
||||||
|
|
||||||
int p3LinkMgr::removeFriend(const std::string &id)
|
int p3LinkMgr::removeFriend(const std::string &id)
|
||||||
|
{
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
@ -1792,11 +1807,55 @@ int p3LinkMgr::removeFriend(const std::string &id)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Move to OthersList (so remove can be handled via the action) */
|
||||||
|
peerConnectState peer = it->second;
|
||||||
|
|
||||||
|
peer.state &= (~RS_PEER_S_FRIEND);
|
||||||
|
peer.state &= (~RS_PEER_S_CONNECTED);
|
||||||
|
peer.state &= (~RS_PEER_S_ONLINE);
|
||||||
|
peer.actions = RS_PEER_MOVED;
|
||||||
|
peer.inConnAttempt = false;
|
||||||
|
mOthersList[id] = peer;
|
||||||
|
|
||||||
|
mStatusChanged = true;
|
||||||
|
|
||||||
mFriendList.erase(it);
|
mFriendList.erase(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
mNetMgr->netAssistFriend(id, false);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void p3LinkMgr::printPeerLists(std::ostream &out)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
|
out << "p3LinkMgr::printPeerLists() Friend List";
|
||||||
|
out << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
std::map<std::string, peerConnectState>::iterator it;
|
||||||
|
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||||
|
{
|
||||||
|
out << "\t SSL ID: " << it->second.id;
|
||||||
|
out << "\t State: " << it->second.state;
|
||||||
|
out << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
out << "p3LinkMgr::printPeerLists() Others List";
|
||||||
|
out << std::endl;
|
||||||
|
for(it = mOthersList.begin(); it != mOthersList.end(); it++)
|
||||||
|
{
|
||||||
|
out << "\t SSL ID: " << it->second.id;
|
||||||
|
out << "\t State: " << it->second.state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void printConnectState(std::ostream &out, peerConnectState &peer)
|
void printConnectState(std::ostream &out, peerConnectState &peer)
|
||||||
|
@ -184,6 +184,7 @@ void setFriendVisibility(const std::string &id, bool isVisible);
|
|||||||
/* add/remove friends */
|
/* add/remove friends */
|
||||||
int addFriend(const std::string &ssl_id, bool isVisible);
|
int addFriend(const std::string &ssl_id, bool isVisible);
|
||||||
int removeFriend(const std::string &ssl_id);
|
int removeFriend(const std::string &ssl_id);
|
||||||
|
void printPeerLists(std::ostream &out);
|
||||||
|
|
||||||
/*************** External Control ****************/
|
/*************** External Control ****************/
|
||||||
|
|
||||||
|
@ -62,11 +62,11 @@ const uint32_t MIN_TIME_BETWEEN_NET_RESET = 5;
|
|||||||
const uint32_t PEER_IP_CONNECT_STATE_MAX_LIST_SIZE = 4;
|
const uint32_t PEER_IP_CONNECT_STATE_MAX_LIST_SIZE = 4;
|
||||||
|
|
||||||
/****
|
/****
|
||||||
* #define CONN_DEBUG 1
|
* #define PEER_DEBUG 1
|
||||||
* #define CONN_DEBUG_RESET 1
|
|
||||||
* #define CONN_DEBUG_TICK 1
|
|
||||||
***/
|
***/
|
||||||
|
|
||||||
|
#define PEER_DEBUG 1
|
||||||
|
|
||||||
#define MAX_AVAIL_PERIOD 230 //times a peer stay in available state when not connected
|
#define MAX_AVAIL_PERIOD 230 //times a peer stay in available state when not connected
|
||||||
#define MIN_RETRY_PERIOD 140
|
#define MIN_RETRY_PERIOD 140
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ p3PeerMgr::p3PeerMgr()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr() Startup" << std::endl;
|
std::cerr << "p3PeerMgr() Startup" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ void p3PeerMgr::setOwnNetworkMode(uint32_t netMode)
|
|||||||
{
|
{
|
||||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::setOwnNetworkMode() :";
|
std::cerr << "p3PeerMgr::setOwnNetworkMode() :";
|
||||||
std::cerr << " Existing netMode: " << mOwnState.netMode;
|
std::cerr << " Existing netMode: " << mOwnState.netMode;
|
||||||
std::cerr << " Input netMode: " << netMode;
|
std::cerr << " Input netMode: " << netMode;
|
||||||
@ -160,7 +160,7 @@ void p3PeerMgr::setOwnVisState(uint32_t visState)
|
|||||||
{
|
{
|
||||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::setOwnVisState()";
|
std::cerr << "p3PeerMgr::setOwnVisState()";
|
||||||
std::cerr << "Existing vis: " << mOwnState.visState;
|
std::cerr << "Existing vis: " << mOwnState.visState;
|
||||||
std::cerr << "Input vis: " << visState;
|
std::cerr << "Input vis: " << visState;
|
||||||
@ -217,12 +217,12 @@ bool p3PeerMgr::getOwnNetStatus(peerState &state)
|
|||||||
|
|
||||||
bool p3PeerMgr::isFriend(const std::string &id)
|
bool p3PeerMgr::isFriend(const std::string &id)
|
||||||
{
|
{
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG_COMMON
|
||||||
std::cerr << "p3PeerMgr::isFriend(" << id << ") called" << std::endl;
|
std::cerr << "p3PeerMgr::isFriend(" << id << ") called" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
bool ret = (mFriendList.end() != mFriendList.find(id));
|
bool ret = (mFriendList.end() != mFriendList.find(id));
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG_COMMON
|
||||||
std::cerr << "p3PeerMgr::isFriend(" << id << ") returning : " << ret << std::endl;
|
std::cerr << "p3PeerMgr::isFriend(" << id << ") returning : " << ret << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
@ -345,7 +345,7 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint
|
|||||||
|
|
||||||
|
|
||||||
if (id == AuthSSL::getAuthSSL()->OwnId()) {
|
if (id == AuthSSL::getAuthSSL()->OwnId()) {
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::addFriend() cannot add own id as a friend." << std::endl;
|
std::cerr << "p3PeerMgr::addFriend() cannot add own id as a friend." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
/* (1) already exists */
|
/* (1) already exists */
|
||||||
@ -357,14 +357,14 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint
|
|||||||
* (3) is non-existant -> create new one.
|
* (3) is non-existant -> create new one.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::addFriend() " << id << "; gpg_id : " << gpg_id << std::endl;
|
std::cerr << "p3PeerMgr::addFriend() " << id << "; gpg_id : " << gpg_id << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::map<std::string, peerState>::iterator it;
|
std::map<std::string, peerState>::iterator it;
|
||||||
if (mFriendList.end() != mFriendList.find(id))
|
if (mFriendList.end() != mFriendList.find(id))
|
||||||
{
|
{
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::addFriend() Already Exists" << std::endl;
|
std::cerr << "p3PeerMgr::addFriend() Already Exists" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
/* (1) already exists */
|
/* (1) already exists */
|
||||||
@ -375,7 +375,7 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint
|
|||||||
//
|
//
|
||||||
if (!AuthGPG::getAuthGPG()->isGPGAccepted(gpg_id) && gpg_id != AuthGPG::getAuthGPG()->getGPGOwnId())
|
if (!AuthGPG::getAuthGPG()->isGPGAccepted(gpg_id) && gpg_id != AuthGPG::getAuthGPG()->getGPGOwnId())
|
||||||
{
|
{
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::addFriend() gpg is not accepted" << std::endl;
|
std::cerr << "p3PeerMgr::addFriend() gpg is not accepted" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
/* no auth */
|
/* no auth */
|
||||||
@ -387,7 +387,7 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint
|
|||||||
if (mOthersList.end() != (it = mOthersList.find(id)))
|
if (mOthersList.end() != (it = mOthersList.find(id)))
|
||||||
{
|
{
|
||||||
/* (2) in mOthersList -> move over */
|
/* (2) in mOthersList -> move over */
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::addFriend() Move from Others" << std::endl;
|
std::cerr << "p3PeerMgr::addFriend() Move from Others" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -409,7 +409,7 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::addFriend() Creating New Entry" << std::endl;
|
std::cerr << "p3PeerMgr::addFriend() Creating New Entry" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -441,6 +441,11 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint
|
|||||||
mLinkMgr->addFriend(id, !(visState & RS_VIS_STATE_NODHT));
|
mLinkMgr->addFriend(id, !(visState & RS_VIS_STATE_NODHT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PEER_DEBUG
|
||||||
|
printPeerLists(std::cerr);
|
||||||
|
mLinkMgr->printPeerLists(std::cerr);
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,14 +453,12 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint
|
|||||||
bool p3PeerMgr::removeFriend(const std::string &id)
|
bool p3PeerMgr::removeFriend(const std::string &id)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::removeFriend() for id : " << id << std::endl;
|
std::cerr << "p3PeerMgr::removeFriend() for id : " << id << std::endl;
|
||||||
std::cerr << "p3PeerMgr::removeFriend() mFriendList.size() : " << mFriendList.size() << std::endl;
|
std::cerr << "p3PeerMgr::removeFriend() mFriendList.size() : " << mFriendList.size() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mLinkMgr->removeFriend(id);
|
std::list<std::string> toRemove; // This is a list of SSLIds.
|
||||||
|
|
||||||
std::list<std::string> toRemove;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
@ -467,7 +470,7 @@ bool p3PeerMgr::removeFriend(const std::string &id)
|
|||||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||||
{
|
{
|
||||||
if (it->second.id == id || it->second.gpg_id == id) {
|
if (it->second.id == id || it->second.gpg_id == id) {
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::removeFriend() friend found in the list." << id << std::endl;
|
std::cerr << "p3PeerMgr::removeFriend() friend found in the list." << id << std::endl;
|
||||||
#endif
|
#endif
|
||||||
peerState peer = it->second;
|
peerState peer = it->second;
|
||||||
@ -481,18 +484,26 @@ bool p3PeerMgr::removeFriend(const std::string &id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<std::string>::iterator toRemoveIt;
|
std::list<std::string>::iterator rit;
|
||||||
for(toRemoveIt = toRemove.begin(); toRemoveIt != toRemove.end(); toRemoveIt++) {
|
for(rit = toRemove.begin(); rit != toRemove.end(); rit++)
|
||||||
if (mFriendList.end() != (it = mFriendList.find(*toRemoveIt))) {
|
{
|
||||||
|
if (mFriendList.end() != (it = mFriendList.find(*rit)))
|
||||||
|
{
|
||||||
mFriendList.erase(it);
|
mFriendList.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::removeFriend() new mFriendList.size() : " << mFriendList.size() << std::endl;
|
std::cerr << "p3PeerMgr::removeFriend() new mFriendList.size() : " << mFriendList.size() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::list<std::string>::iterator rit;
|
||||||
|
for(rit = toRemove.begin(); rit != toRemove.end(); rit++)
|
||||||
|
{
|
||||||
|
mLinkMgr->removeFriend(*rit);
|
||||||
|
}
|
||||||
|
|
||||||
/* remove id from all groups */
|
/* remove id from all groups */
|
||||||
std::list<std::string> peerIds;
|
std::list<std::string> peerIds;
|
||||||
peerIds.push_back(id);
|
peerIds.push_back(id);
|
||||||
@ -501,16 +512,52 @@ bool p3PeerMgr::removeFriend(const std::string &id)
|
|||||||
|
|
||||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||||
|
|
||||||
|
#ifdef PEER_DEBUG
|
||||||
|
printPeerLists(std::cerr);
|
||||||
|
mLinkMgr->printPeerLists(std::cerr);
|
||||||
|
#endif
|
||||||
|
|
||||||
return !toRemove.empty();
|
return !toRemove.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void p3PeerMgr::printPeerLists(std::ostream &out)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
|
out << "p3PeerMgr::printPeerLists() Friend List";
|
||||||
|
out << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
std::map<std::string, peerState>::iterator it;
|
||||||
|
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||||
|
{
|
||||||
|
out << "\t SSL ID: " << it->second.id;
|
||||||
|
out << "\t GPG ID: " << it->second.gpg_id;
|
||||||
|
out << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
out << "p3PeerMgr::printPeerLists() Others List";
|
||||||
|
out << std::endl;
|
||||||
|
for(it = mOthersList.begin(); it != mOthersList.end(); it++)
|
||||||
|
{
|
||||||
|
out << "\t SSL ID: " << it->second.id;
|
||||||
|
out << "\t GPG ID: " << it->second.gpg_id;
|
||||||
|
out << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
bool p3PeerMgr::addNeighbour(std::string id)
|
bool p3PeerMgr::addNeighbour(std::string id)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::addNeighbour() not implemented anymore." << id << std::endl;
|
std::cerr << "p3PeerMgr::addNeighbour() not implemented anymore." << id << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -602,10 +649,6 @@ bool p3PeerMgr::setLocalAddress(const std::string &id, struct sockaddr_in add
|
|||||||
|
|
||||||
mNetMgr->setLocalAddress(addr);
|
mNetMgr->setLocalAddress(addr);
|
||||||
mLinkMgr->setLocalAddress(addr);
|
mLinkMgr->setLocalAddress(addr);
|
||||||
|
|
||||||
#ifdef CONN_DEBUG_RESET
|
|
||||||
std::cerr << "p3PeerMgr::setLocalAddress() Calling NetReset" << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -617,7 +660,7 @@ bool p3PeerMgr::setLocalAddress(const std::string &id, struct sockaddr_in add
|
|||||||
{
|
{
|
||||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||||
{
|
{
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::setLocalAddress() cannot add addres info : peer id not found in friend list id: " << id << std::endl;
|
std::cerr << "p3PeerMgr::setLocalAddress() cannot add addres info : peer id not found in friend list id: " << id << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
@ -661,7 +704,7 @@ bool p3PeerMgr::setExtAddress(const std::string &id, struct sockaddr_in addr)
|
|||||||
{
|
{
|
||||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||||
{
|
{
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::setLocalAddress() cannot add addres info : peer id not found in friend list id: " << id << std::endl;
|
std::cerr << "p3PeerMgr::setLocalAddress() cannot add addres info : peer id not found in friend list id: " << id << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
@ -701,7 +744,7 @@ bool p3PeerMgr::setDynDNS(const std::string &id, const std::string &dyndns)
|
|||||||
{
|
{
|
||||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||||
{
|
{
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::setDynDNS() cannot add dyn dns info : peer id not found in friend list id: " << id << std::endl;
|
std::cerr << "p3PeerMgr::setDynDNS() cannot add dyn dns info : peer id not found in friend list id: " << id << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
@ -718,7 +761,7 @@ bool p3PeerMgr::setDynDNS(const std::string &id, const std::string &dyndns)
|
|||||||
|
|
||||||
bool p3PeerMgr::updateAddressList(const std::string& id, const pqiIpAddrSet &addrs)
|
bool p3PeerMgr::updateAddressList(const std::string& id, const pqiIpAddrSet &addrs)
|
||||||
{
|
{
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::setAddressList() called for id : " << id << std::endl;
|
std::cerr << "p3PeerMgr::setAddressList() called for id : " << id << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -737,7 +780,7 @@ bool p3PeerMgr::updateAddressList(const std::string& id, const pqiIpAddrSet &
|
|||||||
{
|
{
|
||||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||||
{
|
{
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::setLocalAddress() cannot add addres info : peer id not found in friend list. id: " << id << std::endl;
|
std::cerr << "p3PeerMgr::setLocalAddress() cannot add addres info : peer id not found in friend list. id: " << id << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
@ -746,7 +789,7 @@ bool p3PeerMgr::updateAddressList(const std::string& id, const pqiIpAddrSet &
|
|||||||
|
|
||||||
/* "it" points to peer */
|
/* "it" points to peer */
|
||||||
it->second.ipAddrs.updateAddrs(addrs);
|
it->second.ipAddrs.updateAddrs(addrs);
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::setLocalAddress() Updated Address for: " << id;
|
std::cerr << "p3PeerMgr::setLocalAddress() Updated Address for: " << id;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
it->second.ipAddrs.printAddrs(std::cerr);
|
it->second.ipAddrs.printAddrs(std::cerr);
|
||||||
@ -761,7 +804,7 @@ bool p3PeerMgr::updateAddressList(const std::string& id, const pqiIpAddrSet &
|
|||||||
|
|
||||||
bool p3PeerMgr::updateCurrentAddress(const std::string& id, const pqiIpAddress &addr)
|
bool p3PeerMgr::updateCurrentAddress(const std::string& id, const pqiIpAddress &addr)
|
||||||
{
|
{
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::updateCurrentAddress() called for id : " << id << std::endl;
|
std::cerr << "p3PeerMgr::updateCurrentAddress() called for id : " << id << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -791,7 +834,7 @@ bool p3PeerMgr::updateCurrentAddress(const std::string& id, const pqiIpAddres
|
|||||||
it->second.serveraddr = addr.mAddr;
|
it->second.serveraddr = addr.mAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::updatedCurrentAddress() Updated Address for: " << id;
|
std::cerr << "p3PeerMgr::updatedCurrentAddress() Updated Address for: " << id;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
it->second.ipAddrs.printAddrs(std::cerr);
|
it->second.ipAddrs.printAddrs(std::cerr);
|
||||||
@ -806,7 +849,7 @@ bool p3PeerMgr::updateCurrentAddress(const std::string& id, const pqiIpAddres
|
|||||||
|
|
||||||
bool p3PeerMgr::updateLastContact(const std::string& id)
|
bool p3PeerMgr::updateLastContact(const std::string& id)
|
||||||
{
|
{
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::updateLastContact() called for id : " << id << std::endl;
|
std::cerr << "p3PeerMgr::updateLastContact() called for id : " << id << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -865,7 +908,7 @@ bool p3PeerMgr::setLocation(const std::string &id, const std::string &locatio
|
|||||||
{
|
{
|
||||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::setLocation() called for id : " << id << "; with location " << location << std::endl;
|
std::cerr << "p3PeerMgr::setLocation() called for id : " << id << "; with location " << location << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (id == AuthSSL::getAuthSSL()->OwnId())
|
if (id == AuthSSL::getAuthSSL()->OwnId())
|
||||||
@ -995,7 +1038,7 @@ bool p3PeerMgr::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||||||
mOwnState.ipAddrs.mLocal.loadTlv(item->localAddrList);
|
mOwnState.ipAddrs.mLocal.loadTlv(item->localAddrList);
|
||||||
mOwnState.ipAddrs.mExt.loadTlv(item->extAddrList);
|
mOwnState.ipAddrs.mExt.loadTlv(item->extAddrList);
|
||||||
|
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::saveList() Own Config Item:" << std::endl;
|
std::cerr << "p3PeerMgr::saveList() Own Config Item:" << std::endl;
|
||||||
item->print(std::cerr, 10);
|
item->print(std::cerr, 10);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -1025,7 +1068,7 @@ bool p3PeerMgr::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||||||
|
|
||||||
saveData.push_back(item);
|
saveData.push_back(item);
|
||||||
saveCleanupList.push_back(item);
|
saveCleanupList.push_back(item);
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::saveList() Peer Config Item:" << std::endl;
|
std::cerr << "p3PeerMgr::saveList() Peer Config Item:" << std::endl;
|
||||||
item->print(std::cerr, 10);
|
item->print(std::cerr, 10);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -1041,8 +1084,8 @@ bool p3PeerMgr::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||||||
kv.value = (useExtAddrFinder)?"TRUE":"FALSE" ;
|
kv.value = (useExtAddrFinder)?"TRUE":"FALSE" ;
|
||||||
vitem->tlvkvs.pairs.push_back(kv) ;
|
vitem->tlvkvs.pairs.push_back(kv) ;
|
||||||
|
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cout << "Pushing item for use_extr_addr_finder = " << mUseExtAddrFinder << std::endl ;
|
std::cout << "Pushing item for use_extr_addr_finder = " << useExtAddrFinder << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
saveData.push_back(vitem);
|
saveData.push_back(vitem);
|
||||||
saveCleanupList.push_back(vitem);
|
saveCleanupList.push_back(vitem);
|
||||||
@ -1056,8 +1099,8 @@ bool p3PeerMgr::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||||||
kv2.value = (allowTunnelConnection)?"TRUE":"FALSE" ;
|
kv2.value = (allowTunnelConnection)?"TRUE":"FALSE" ;
|
||||||
vitem2->tlvkvs.pairs.push_back(kv2) ;
|
vitem2->tlvkvs.pairs.push_back(kv2) ;
|
||||||
|
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cout << "Pushing item for allow_tunnel_connection = " << mAllowTunnelConnection << std::endl ;
|
std::cout << "Pushing item for allow_tunnel_connection = " << allowTunnelConnection << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
saveData.push_back(vitem2);
|
saveData.push_back(vitem2);
|
||||||
saveCleanupList.push_back(vitem2);
|
saveCleanupList.push_back(vitem2);
|
||||||
@ -1099,7 +1142,7 @@ bool p3PeerMgr::loadList(std::list<RsItem *>& load)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::loadList() Item Count: " << load.size() << std::endl;
|
std::cerr << "p3PeerMgr::loadList() Item Count: " << load.size() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1114,7 +1157,7 @@ bool p3PeerMgr::loadList(std::list<RsItem *>& load)
|
|||||||
{
|
{
|
||||||
if (pitem->pid == ownId)
|
if (pitem->pid == ownId)
|
||||||
{
|
{
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::loadList() Own Config Item:" << std::endl;
|
std::cerr << "p3PeerMgr::loadList() Own Config Item:" << std::endl;
|
||||||
pitem->print(std::cerr, 10);
|
pitem->print(std::cerr, 10);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -1128,7 +1171,7 @@ bool p3PeerMgr::loadList(std::list<RsItem *>& load)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::loadList() Peer Config Item:" << std::endl;
|
std::cerr << "p3PeerMgr::loadList() Peer Config Item:" << std::endl;
|
||||||
pitem->print(std::cerr, 10);
|
pitem->print(std::cerr, 10);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -1159,7 +1202,7 @@ bool p3PeerMgr::loadList(std::list<RsItem *>& load)
|
|||||||
{
|
{
|
||||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::loadList() General Variable Config Item:" << std::endl;
|
std::cerr << "p3PeerMgr::loadList() General Variable Config Item:" << std::endl;
|
||||||
vitem->print(std::cerr, 10);
|
vitem->print(std::cerr, 10);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -1185,7 +1228,7 @@ bool p3PeerMgr::loadList(std::list<RsItem *>& load)
|
|||||||
{
|
{
|
||||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
#ifdef CONN_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::loadList() Peer group item:" << std::endl;
|
std::cerr << "p3PeerMgr::loadList() Peer group item:" << std::endl;
|
||||||
gitem->print(std::cerr, 10);
|
gitem->print(std::cerr, 10);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
@ -148,6 +148,7 @@ bool addFriend(const std::string &ssl_id, const std::string &gpg_id, uint32_t n
|
|||||||
|
|
||||||
bool removeFriend(const std::string &ssl_id);
|
bool removeFriend(const std::string &ssl_id);
|
||||||
bool addNeighbour(const std::string&);
|
bool addNeighbour(const std::string&);
|
||||||
|
void printPeerLists(std::ostream &out);
|
||||||
|
|
||||||
/*************** External Control ****************/
|
/*************** External Control ****************/
|
||||||
|
|
||||||
|
@ -268,7 +268,8 @@ int pqiperson::notifyEvent(NetInterface *ni, int newState)
|
|||||||
"CONNECT_FAILED->marking so!");
|
"CONNECT_FAILED->marking so!");
|
||||||
active = false;
|
active = false;
|
||||||
activepqi = NULL;
|
activepqi = NULL;
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
pqioutput(PQL_WARNING, pqipersonzone,
|
pqioutput(PQL_WARNING, pqipersonzone,
|
||||||
"CONNECT_FAILED-> from an unactive connection, don't flag the peer as not connected, just try next attempt !");
|
"CONNECT_FAILED-> from an unactive connection, don't flag the peer as not connected, just try next attempt !");
|
||||||
}
|
}
|
||||||
@ -279,7 +280,7 @@ int pqiperson::notifyEvent(NetInterface *ni, int newState)
|
|||||||
"CONNECT_FAILED+NOT active -> try connect again");
|
"CONNECT_FAILED+NOT active -> try connect again");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* notify up (But not if we are actually active: rtn -1 case above) */
|
/* notify up */
|
||||||
if (pqipg)
|
if (pqipg)
|
||||||
{
|
{
|
||||||
struct sockaddr_in raddr;
|
struct sockaddr_in raddr;
|
||||||
|
@ -381,9 +381,9 @@ int pqipersongrp::addPeer(std::string id)
|
|||||||
pqioutput(PQL_DEBUG_BASIC, pqipersongrpzone, out.str());
|
pqioutput(PQL_DEBUG_BASIC, pqipersongrpzone, out.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PGRP_DEBUG
|
|
||||||
std::cerr << "pqipersongrp::addPeer() id: " << id;
|
std::cerr << "pqipersongrp::addPeer() id: " << id;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#ifdef PGRP_DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SearchModule *sm = NULL;
|
SearchModule *sm = NULL;
|
||||||
@ -394,6 +394,10 @@ int pqipersongrp::addPeer(std::string id)
|
|||||||
{
|
{
|
||||||
pqioutput(PQL_DEBUG_BASIC, pqipersongrpzone,
|
pqioutput(PQL_DEBUG_BASIC, pqipersongrpzone,
|
||||||
"pqipersongrp::addPeer() Peer already in Use!");
|
"pqipersongrp::addPeer() Peer already in Use!");
|
||||||
|
|
||||||
|
std::cerr << " pqipersongrp::addPeer() ERROR Peer already in use! id: " << id;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,9 +423,9 @@ int pqipersongrp::removePeer(std::string id)
|
|||||||
std::map<std::string, SearchModule *>::iterator it;
|
std::map<std::string, SearchModule *>::iterator it;
|
||||||
|
|
||||||
#ifdef PGRP_DEBUG
|
#ifdef PGRP_DEBUG
|
||||||
|
#endif
|
||||||
std::cerr << "pqipersongrp::removePeer() id: " << id;
|
std::cerr << "pqipersongrp::removePeer() id: " << id;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
|
||||||
|
|
||||||
RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/
|
RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/
|
||||||
|
|
||||||
@ -438,6 +442,11 @@ int pqipersongrp::removePeer(std::string id)
|
|||||||
delete p;
|
delete p;
|
||||||
mods.erase(it);
|
mods.erase(it);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << " pqipersongrp::removePeer() ERROR doesn't exist! id: " << id;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user