mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Added Virtual Interfaces for p3LinkMgr, p3NetMgr & p3PeerMgr.
Shifted real functionality to p3LinkMgrIMPL, p3NetMgrIMPL p3PeerMgrIMPL This allows us to test most objects with dummy objects (i.e. no need for full AuthSSL/AuthGPG objects) git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-netupgrade@4441 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
85d232ff4f
commit
8d5bde1b50
@ -128,7 +128,7 @@ std::string textPeerConnectState(peerConnectState &state)
|
||||
*/
|
||||
|
||||
|
||||
p3LinkMgr::p3LinkMgr(p3PeerMgr *peerMgr, p3NetMgr *netMgr)
|
||||
p3LinkMgrIMPL::p3LinkMgrIMPL(p3PeerMgrIMPL *peerMgr, p3NetMgrIMPL *netMgr)
|
||||
:mPeerMgr(peerMgr), mNetMgr(netMgr), mLinkMtx("p3LinkMgr"),mStatusChanged(false)
|
||||
{
|
||||
|
||||
@ -158,32 +158,32 @@ p3LinkMgr::p3LinkMgr(p3PeerMgr *peerMgr, p3NetMgr *netMgr)
|
||||
return;
|
||||
}
|
||||
|
||||
void p3LinkMgr::setTunnelConnection(bool b)
|
||||
void p3LinkMgrIMPL::setTunnelConnection(bool b)
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
mAllowTunnelConnection = b;
|
||||
}
|
||||
|
||||
bool p3LinkMgr::getTunnelConnection()
|
||||
bool p3LinkMgrIMPL::getTunnelConnection()
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
return mAllowTunnelConnection;
|
||||
}
|
||||
|
||||
bool p3LinkMgr::setLocalAddress(struct sockaddr_in addr)
|
||||
bool p3LinkMgrIMPL::setLocalAddress(struct sockaddr_in addr)
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
mLocalAddress = addr;
|
||||
}
|
||||
|
||||
struct sockaddr_in p3LinkMgr::getLocalAddress()
|
||||
struct sockaddr_in p3LinkMgrIMPL::getLocalAddress()
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
return mLocalAddress;
|
||||
}
|
||||
|
||||
|
||||
bool p3LinkMgr::isOnline(const std::string &ssl_id)
|
||||
bool p3LinkMgrIMPL::isOnline(const std::string &ssl_id)
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
@ -201,7 +201,7 @@ bool p3LinkMgr::isOnline(const std::string &ssl_id)
|
||||
return false;
|
||||
}
|
||||
|
||||
void p3LinkMgr::getOnlineList(std::list<std::string> &ssl_peers)
|
||||
void p3LinkMgrIMPL::getOnlineList(std::list<std::string> &ssl_peers)
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
@ -216,7 +216,7 @@ void p3LinkMgr::getOnlineList(std::list<std::string> &ssl_peers)
|
||||
return;
|
||||
}
|
||||
|
||||
void p3LinkMgr::getFriendList(std::list<std::string> &ssl_peers)
|
||||
void p3LinkMgrIMPL::getFriendList(std::list<std::string> &ssl_peers)
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
@ -230,7 +230,7 @@ void p3LinkMgr::getFriendList(std::list<std::string> &ssl_peers)
|
||||
|
||||
}
|
||||
|
||||
int p3LinkMgr::getFriendCount()
|
||||
int p3LinkMgrIMPL::getFriendCount()
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
@ -239,7 +239,7 @@ int p3LinkMgr::getFriendCount()
|
||||
|
||||
}
|
||||
|
||||
int p3LinkMgr::getOnlineCount()
|
||||
int p3LinkMgrIMPL::getOnlineCount()
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
@ -258,7 +258,7 @@ int p3LinkMgr::getOnlineCount()
|
||||
|
||||
}
|
||||
|
||||
bool p3LinkMgr::getFriendNetStatus(const std::string &id, peerConnectState &state)
|
||||
bool p3LinkMgrIMPL::getFriendNetStatus(const std::string &id, peerConnectState &state)
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
@ -275,7 +275,7 @@ bool p3LinkMgr::getFriendNetStatus(const std::string &id, peerConnectState &s
|
||||
|
||||
|
||||
|
||||
void p3LinkMgr::setFriendVisibility(const std::string &id, bool isVisible)
|
||||
void p3LinkMgrIMPL::setFriendVisibility(const std::string &id, bool isVisible)
|
||||
{
|
||||
/* set visibility */
|
||||
{
|
||||
@ -288,7 +288,7 @@ void p3LinkMgr::setFriendVisibility(const std::string &id, bool isVisible)
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
/* */
|
||||
std::cerr << "p3LinkMgr::setFriendVisibility() ERROR peer unknown: " << id;
|
||||
std::cerr << "p3LinkMgrIMPL::setFriendVisibility() ERROR peer unknown: " << id;
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
@ -313,24 +313,14 @@ void p3LinkMgr::setFriendVisibility(const std::string &id, bool isVisible)
|
||||
}
|
||||
|
||||
|
||||
void p3LinkMgr::tick()
|
||||
void p3LinkMgrIMPL::tick()
|
||||
{
|
||||
statusTick();
|
||||
tickMonitors();
|
||||
}
|
||||
|
||||
bool p3LinkMgr::shutdown() /* blocking shutdown call */
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::shutdown() NOOP";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void p3LinkMgr::statusTick()
|
||||
void p3LinkMgrIMPL::statusTick()
|
||||
{
|
||||
/* iterate through peers ...
|
||||
* if been available for long time ... remove flag
|
||||
@ -339,7 +329,7 @@ void p3LinkMgr::statusTick()
|
||||
*/
|
||||
|
||||
#ifdef LINKMGR_DEBUG_TICK
|
||||
std::cerr << "p3LinkMgr::statusTick()" << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::statusTick()" << std::endl;
|
||||
#endif
|
||||
std::list<std::string> retryIds;
|
||||
std::list<std::string>::iterator it2;
|
||||
@ -363,7 +353,7 @@ void p3LinkMgr::statusTick()
|
||||
(it->second.lastavailable < oldavail))
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG_TICK
|
||||
std::cerr << "p3LinkMgr::statusTick() ONLINE TIMEOUT for: ";
|
||||
std::cerr << "p3LinkMgrIMPL::statusTick() ONLINE TIMEOUT for: ";
|
||||
std::cerr << it->first;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -382,7 +372,7 @@ void p3LinkMgr::statusTick()
|
||||
for(it2 = retryIds.begin(); it2 != retryIds.end(); it2++)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG_TICK
|
||||
std::cerr << "p3LinkMgr::statusTick() RETRY TIMEOUT for: ";
|
||||
std::cerr << "p3LinkMgrIMPL::statusTick() RETRY TIMEOUT for: ";
|
||||
std::cerr << *it2;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -399,7 +389,7 @@ void p3LinkMgr::statusTick()
|
||||
* Configuration Loading / Saving.
|
||||
*/
|
||||
|
||||
void p3LinkMgr::addMonitor(pqiMonitor *mon)
|
||||
void p3LinkMgrIMPL::addMonitor(pqiMonitor *mon)
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
@ -415,7 +405,7 @@ void p3LinkMgr::addMonitor(pqiMonitor *mon)
|
||||
return;
|
||||
}
|
||||
|
||||
void p3LinkMgr::removeMonitor(pqiMonitor *mon)
|
||||
void p3LinkMgrIMPL::removeMonitor(pqiMonitor *mon)
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
@ -431,7 +421,7 @@ void p3LinkMgr::removeMonitor(pqiMonitor *mon)
|
||||
return;
|
||||
}
|
||||
|
||||
void p3LinkMgr::tickMonitors()
|
||||
void p3LinkMgrIMPL::tickMonitors()
|
||||
{
|
||||
bool doStatusChange = false;
|
||||
std::list<pqipeer> actionList;
|
||||
@ -443,7 +433,7 @@ void p3LinkMgr::tickMonitors()
|
||||
if (mStatusChanged)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG_ACTIONS
|
||||
std::cerr << "p3LinkMgr::tickMonitors() StatusChanged! List:" << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::tickMonitors() StatusChanged! List:" << std::endl;
|
||||
#endif
|
||||
/* assemble list */
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
@ -590,13 +580,13 @@ void p3LinkMgr::tickMonitors()
|
||||
}
|
||||
|
||||
|
||||
const std::string p3LinkMgr::getOwnId()
|
||||
const std::string p3LinkMgrIMPL::getOwnId()
|
||||
{
|
||||
return AuthSSL::getAuthSSL()->OwnId();
|
||||
}
|
||||
|
||||
|
||||
bool p3LinkMgr::connectAttempt(const std::string &id, struct sockaddr_in &addr,
|
||||
bool p3LinkMgrIMPL::connectAttempt(const std::string &id, struct sockaddr_in &addr,
|
||||
uint32_t &delay, uint32_t &period, uint32_t &type)
|
||||
|
||||
{
|
||||
@ -608,7 +598,7 @@ bool p3LinkMgr::connectAttempt(const std::string &id, struct sockaddr_in &addr,
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::connectAttempt() FAILED Not in FriendList! id: " << id << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::connectAttempt() FAILED Not in FriendList! id: " << id << std::endl;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
@ -617,7 +607,7 @@ bool p3LinkMgr::connectAttempt(const std::string &id, struct sockaddr_in &addr,
|
||||
if (it->second.connAddrs.size() < 1)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::connectAttempt() FAILED No ConnectAddresses id: " << id << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::connectAttempt() FAILED No ConnectAddresses id: " << id << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -626,8 +616,8 @@ bool p3LinkMgr::connectAttempt(const std::string &id, struct sockaddr_in &addr,
|
||||
if (it->second.state & RS_PEER_S_CONNECTED)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::connectAttempt() Already FLAGGED as connected!!!!" << std::endl;
|
||||
std::cerr << "p3LinkMgr::connectAttempt() But allowing anyway!!!" << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::connectAttempt() Already FLAGGED as connected!!!!" << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::connectAttempt() But allowing anyway!!!" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -643,13 +633,13 @@ bool p3LinkMgr::connectAttempt(const std::string &id, struct sockaddr_in &addr,
|
||||
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::connectAttempt() found an address: id: " << id << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::connectAttempt() found an address: id: " << id << std::endl;
|
||||
std::cerr << " laddr: " << rs_inet_ntoa(addr.sin_addr) << " lport: " << ntohs(addr.sin_port) << " delay: " << delay << " period: " << period;
|
||||
std::cerr << " type: " << type << std::endl;
|
||||
#endif
|
||||
if (addr.sin_addr.s_addr == 0 || addr.sin_port == 0) {
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::connectAttempt() WARNING: address or port is null" << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::connectAttempt() WARNING: address or port is null" << std::endl;
|
||||
std::cerr << " type: " << type << std::endl;
|
||||
#endif
|
||||
}
|
||||
@ -666,7 +656,7 @@ bool p3LinkMgr::connectAttempt(const std::string &id, struct sockaddr_in &addr,
|
||||
*
|
||||
*/
|
||||
|
||||
bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flags, struct sockaddr_in remote_peer_address)
|
||||
bool p3LinkMgrIMPL::connectResult(const std::string &id, bool success, uint32_t flags, struct sockaddr_in remote_peer_address)
|
||||
{
|
||||
bool doDhtAssist = false ;
|
||||
bool updatePeerAddr = false;
|
||||
@ -675,19 +665,19 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgr::connectResult() called Connect!: id: " + id);
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgrIMPL::connectResult() called Connect!: id: " + id);
|
||||
if (success)
|
||||
{
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgr::connectResult() called with SUCCESS.");
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgrIMPL::connectResult() called with SUCCESS.");
|
||||
} else
|
||||
{
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgr::connectResult() called with FAILED.");
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgrIMPL::connectResult() called with FAILED.");
|
||||
}
|
||||
|
||||
if (id == getOwnId())
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgr::connectResult() Failed, connecting to own id: ");
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgrIMPL::connectResult() Failed, connecting to own id: ");
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -697,7 +687,7 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::connectResult() ERROR, missing Friend " << " id: " << id << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::connectResult() ERROR, missing Friend " << " id: " << id << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -706,16 +696,16 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
||||
{
|
||||
/* update address (should also come through from DISC) */
|
||||
#ifdef LINKMGR_DEBUG_CONNFAIL
|
||||
std::cerr << "p3LinkMgr::connectResult() Connect!: id: " << id << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::connectResult() Connect!: id: " << id << std::endl;
|
||||
std::cerr << " Success: " << success << " flags: " << flags << std::endl;
|
||||
#endif
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::connectResult() Connect!: id: " << id << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::connectResult() Connect!: id: " << id << std::endl;
|
||||
std::cerr << " Success: " << success << " flags: " << flags << std::endl;
|
||||
#endif
|
||||
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgr::connectResult() Success");
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgrIMPL::connectResult() Success");
|
||||
|
||||
/* change state */
|
||||
it->second.state |= RS_PEER_S_CONNECTED;
|
||||
@ -745,7 +735,7 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
||||
{
|
||||
updatePeerAddr = true;
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::connectResult() adding current peer address in list." << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::connectResult() adding current peer address in list." << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -757,17 +747,17 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
||||
else
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG_CONNFAIL
|
||||
std::cerr << "p3LinkMgr::connectResult() Disconnect/Fail: flags: " << flags << " id: " << id;
|
||||
std::cerr << "p3LinkMgrIMPL::connectResult() Disconnect/Fail: flags: " << flags << " id: " << id;
|
||||
std::cerr << std::endl;
|
||||
|
||||
if (it->second.inConnAttempt)
|
||||
{
|
||||
std::cerr << "p3LinkMgr::connectResult() Likely Connect Fail, as inConnAttempt Flag is set";
|
||||
std::cerr << "p3LinkMgrIMPL::connectResult() Likely Connect Fail, as inConnAttempt Flag is set";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
if (it->second.state & RS_PEER_S_CONNECTED)
|
||||
{
|
||||
std::cerr << "p3LinkMgr::connectResult() Likely DISCONNECT, as state set to Connected";
|
||||
std::cerr << "p3LinkMgrIMPL::connectResult() Likely DISCONNECT, as state set to Connected";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
#endif
|
||||
@ -775,7 +765,7 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
||||
it->second.inConnAttempt = false;
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::connectResult() Disconnect/Fail: id: " << id << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::connectResult() Disconnect/Fail: id: " << id << std::endl;
|
||||
std::cerr << " Success: " << success << " flags: " << flags << std::endl;
|
||||
#endif
|
||||
|
||||
@ -810,7 +800,7 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
||||
raddr.mSrc = 0;
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::connectResult() Success and we initiated connection... Updating Address";
|
||||
std::cerr << "p3LinkMgrIMPL::connectResult() Success and we initiated connection... Updating Address";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
mPeerMgr->updateCurrentAddress(id, raddr);
|
||||
@ -825,7 +815,7 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
||||
if (success)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::connectResult() Success switching off DhtAssist for friend: " << id;
|
||||
std::cerr << "p3LinkMgrIMPL::connectResult() Success switching off DhtAssist for friend: " << id;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* always switch it off now */
|
||||
@ -836,7 +826,7 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
||||
if (doDhtAssist)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::connectResult() Fail, Enabling DhtAssist for: " << id;
|
||||
std::cerr << "p3LinkMgrIMPL::connectResult() Fail, Enabling DhtAssist for: " << id;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
mNetMgr->netAssistFriend(id,true) ;
|
||||
@ -844,7 +834,7 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
||||
else
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::connectResult() Fail, No DhtAssist, as No DHT visibility for: " << id;
|
||||
std::cerr << "p3LinkMgrIMPL::connectResult() Fail, No DhtAssist, as No DHT visibility for: " << id;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
@ -858,7 +848,7 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
||||
*/
|
||||
|
||||
|
||||
void p3LinkMgr::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
void p3LinkMgrIMPL::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
uint32_t type, uint32_t flags, uint32_t source)
|
||||
{
|
||||
/* HACKED UP FIX ****/
|
||||
@ -886,7 +876,7 @@ void p3LinkMgr::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3LinkMgr::peerStatus()" << " id: " << id;
|
||||
out << "p3LinkMgrIMPL::peerStatus()" << " id: " << id;
|
||||
out << " type: " << type << " flags: " << flags;
|
||||
out << " source: " << source;
|
||||
out << std::endl;
|
||||
@ -909,17 +899,17 @@ void p3LinkMgr::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
{
|
||||
/* not found - ignore */
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::peerStatus() Peer Not Found - Ignore" << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::peerStatus() Peer Not Found - Ignore" << std::endl;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::peerStatus() Peer is in mOthersList" << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::peerStatus() Peer is in mOthersList" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::peerStatus() Current Peer State:" << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::peerStatus() Current Peer State:" << std::endl;
|
||||
printConnectState(std::cerr, it->second);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -930,7 +920,7 @@ void p3LinkMgr::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
if (source == RS_CB_DHT)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::peerStatus() Update From DHT:";
|
||||
std::cerr << "p3LinkMgrIMPL::peerStatus() Update From DHT:";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* DHT can tell us about
|
||||
@ -948,7 +938,7 @@ void p3LinkMgr::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
else if (source == RS_CB_DISC)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::peerStatus() Update From DISC:";
|
||||
std::cerr << "p3LinkMgrIMPL::peerStatus() Update From DISC:";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* DISC can tell us about
|
||||
@ -976,7 +966,7 @@ void p3LinkMgr::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
* -> update all!
|
||||
*/
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::peerStatus() Update From PERSON:";
|
||||
std::cerr << "p3LinkMgrIMPL::peerStatus() Update From PERSON:";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -1067,11 +1057,11 @@ void p3LinkMgr::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
if (!isFriend)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::peerStatus() NOT FRIEND " << " id: " << id << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::peerStatus() NOT FRIEND " << " id: " << id << std::endl;
|
||||
#endif
|
||||
|
||||
{
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgr::peerStatus() NO CONNECT (not friend)");
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgrIMPL::peerStatus() NO CONNECT (not friend)");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1080,11 +1070,11 @@ void p3LinkMgr::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
if (it->second.state & RS_PEER_S_CONNECTED)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::peerStatus() PEER ONLINE ALREADY " << " id: " << id << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::peerStatus() PEER ONLINE ALREADY " << " id: " << id << std::endl;
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgr::peerStatus() NO CONNECT (already connected!)");
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgrIMPL::peerStatus() NO CONNECT (already connected!)");
|
||||
}
|
||||
|
||||
return;
|
||||
@ -1101,7 +1091,7 @@ void p3LinkMgr::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
}
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::peerStatus()" << " id: " << id;
|
||||
std::cerr << "p3LinkMgrIMPL::peerStatus()" << " id: " << id;
|
||||
std::cerr << " type: " << type << " flags: " << flags;
|
||||
std::cerr << " source: " << source << std::endl;
|
||||
std::cerr << " addrs: " << std::endl;
|
||||
@ -1125,24 +1115,24 @@ void p3LinkMgr::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
#endif // P3CONNMGR_NO_AUTO_CONNECTION
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::peerStatus() Resulting Peer State:" << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::peerStatus() Resulting Peer State:" << std::endl;
|
||||
printConnectState(std::cerr, it->second);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void p3LinkMgr::peerConnectRequest(std::string id, struct sockaddr_in raddr,
|
||||
void p3LinkMgrIMPL::peerConnectRequest(std::string id, struct sockaddr_in raddr,
|
||||
uint32_t source)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::peerConnectRequest() id: " << id << " raddr: " << rs_inet_ntoa(raddr.sin_addr) << ":" << ntohs(raddr.sin_port);
|
||||
std::cerr << "p3LinkMgrIMPL::peerConnectRequest() id: " << id << " raddr: " << rs_inet_ntoa(raddr.sin_addr) << ":" << ntohs(raddr.sin_port);
|
||||
std::cerr << " source: " << source << std::endl;
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3LinkMgr::peerConnectRequest() id: " << id << " raddr: " << rs_inet_ntoa(raddr.sin_addr);
|
||||
out << "p3LinkMgrIMPL::peerConnectRequest() id: " << id << " raddr: " << rs_inet_ntoa(raddr.sin_addr);
|
||||
out << ":" << ntohs(raddr.sin_port) << " source: " << source;
|
||||
rslog(RSL_WARNING, p3connectzone, out.str());
|
||||
}
|
||||
@ -1150,13 +1140,13 @@ void p3LinkMgr::peerConnectRequest(std::string id, struct sockaddr_in raddr,
|
||||
/******************** TCP PART *****************************/
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::peerConnectRequest() Try TCP first" << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::peerConnectRequest() Try TCP first" << std::endl;
|
||||
#endif
|
||||
|
||||
if (source == RS_CB_DHT)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::peerConnectRequest() source DHT ==> retryConnectUDP()";
|
||||
std::cerr << "p3LinkMgrIMPL::peerConnectRequest() source DHT ==> retryConnectUDP()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
retryConnectUDP(id, raddr);
|
||||
@ -1164,7 +1154,7 @@ void p3LinkMgr::peerConnectRequest(std::string id, struct sockaddr_in raddr,
|
||||
}
|
||||
else
|
||||
{ // IS THIS USED???
|
||||
std::cerr << "p3LinkMgr::peerConnectRequest() ERROR source OTHER ==> retryConnect()" << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::peerConnectRequest() ERROR source OTHER ==> retryConnect()" << std::endl;
|
||||
std::cerr << std::endl;
|
||||
|
||||
retryConnect(id);
|
||||
@ -1176,11 +1166,11 @@ void p3LinkMgr::peerConnectRequest(std::string id, struct sockaddr_in raddr,
|
||||
/*******************************************************************/
|
||||
/*******************************************************************/
|
||||
/*************** External Control ****************/
|
||||
bool p3LinkMgr::retryConnect(const std::string &id)
|
||||
bool p3LinkMgrIMPL::retryConnect(const std::string &id)
|
||||
{
|
||||
/* push all available addresses onto the connect addr stack */
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::retryConnect() id: " << id << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::retryConnect() id: " << id << std::endl;
|
||||
#endif
|
||||
|
||||
#ifndef P3CONNMGR_NO_TCP_CONNECTIONS
|
||||
@ -1194,18 +1184,18 @@ bool p3LinkMgr::retryConnect(const std::string &id)
|
||||
|
||||
|
||||
|
||||
bool p3LinkMgr::retryConnectUDP(const std::string &id, struct sockaddr_in &rUdpAddr)
|
||||
bool p3LinkMgrIMPL::retryConnectUDP(const std::string &id, struct sockaddr_in &rUdpAddr)
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* push all available addresses onto the connect addr stack */
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::retryConnectTCP() id: " << id << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::retryConnectTCP() id: " << id << std::endl;
|
||||
#endif
|
||||
|
||||
if (id == getOwnId()) {
|
||||
#ifdef LINKMGR_DEBUG
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgr::retryConnectUDP() Failed, connecting to own id: ");
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgrIMPL::retryConnectUDP() Failed, connecting to own id: ");
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -1215,7 +1205,7 @@ bool p3LinkMgr::retryConnectUDP(const std::string &id, struct sockaddr_in &rUd
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::retryConnectUDP() Peer is not Friend" << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::retryConnectUDP() Peer is not Friend" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -1224,15 +1214,15 @@ bool p3LinkMgr::retryConnectUDP(const std::string &id, struct sockaddr_in &rUd
|
||||
if (it->second.state & RS_PEER_S_CONNECTED)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::retryConnectUDP() Peer Already Connected" << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::retryConnectUDP() Peer Already Connected" << std::endl;
|
||||
#endif
|
||||
if (it->second.connecttype & RS_NET_CONN_TUNNEL) {
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::retryConnectUDP() Peer Connected through a tunnel connection, let's try a normal connection." << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::retryConnectUDP() Peer Connected through a tunnel connection, let's try a normal connection." << std::endl;
|
||||
#endif
|
||||
} else {
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::retryConnectUDP() Peer Connected no more connection attempts" << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::retryConnectUDP() Peer Connected no more connection attempts" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -1265,7 +1255,7 @@ bool p3LinkMgr::retryConnectUDP(const std::string &id, struct sockaddr_in &rUd
|
||||
|
||||
|
||||
|
||||
bool p3LinkMgr::retryConnectTCP(const std::string &id)
|
||||
bool p3LinkMgrIMPL::retryConnectTCP(const std::string &id)
|
||||
{
|
||||
/* Check if we should retry first */
|
||||
{
|
||||
@ -1278,13 +1268,13 @@ bool p3LinkMgr::retryConnectTCP(const std::string &id)
|
||||
*/
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::retryConnectTCP() id: " << id << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::retryConnectTCP() id: " << id << std::endl;
|
||||
#endif
|
||||
|
||||
if (id == getOwnId())
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgr::retryConnectTCP() Failed, connecting to own id: ");
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgrIMPL::retryConnectTCP() Failed, connecting to own id: ");
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -1294,7 +1284,7 @@ bool p3LinkMgr::retryConnectTCP(const std::string &id)
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::retryConnectTCP() Peer is not Friend" << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::retryConnectTCP() Peer is not Friend" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -1303,18 +1293,18 @@ bool p3LinkMgr::retryConnectTCP(const std::string &id)
|
||||
if (it->second.state & RS_PEER_S_CONNECTED)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::retryConnectTCP() Peer Already Connected" << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::retryConnectTCP() Peer Already Connected" << std::endl;
|
||||
#endif
|
||||
if (it->second.connecttype & RS_NET_CONN_TUNNEL)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::retryConnectTCP() Peer Connected through a tunnel connection, let's try a normal connection." << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::retryConnectTCP() Peer Connected through a tunnel connection, let's try a normal connection." << std::endl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::retryConnectTCP() Peer Connected no more connection attempts" << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::retryConnectTCP() Peer Connected no more connection attempts" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -1322,7 +1312,7 @@ bool p3LinkMgr::retryConnectTCP(const std::string &id)
|
||||
} /****** END of LOCKED ******/
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::retryConnectTCP() Getting Address from PeerMgr for : " << id;
|
||||
std::cerr << "p3LinkMgrIMPL::retryConnectTCP() Getting Address from PeerMgr for : " << id;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* If we reach here, must retry .... extract the required info from p3PeerMgr */
|
||||
@ -1358,13 +1348,13 @@ bool p3LinkMgr::retryConnectTCP(const std::string &id)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "p3LinkMgr::retryConnectTCP() ERROR failed to find friend data : " << id;
|
||||
std::cerr << "p3LinkMgrIMPL::retryConnectTCP() ERROR failed to find friend data : " << id;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "p3LinkMgr::retryConnectTCP() ERROR failed to addresses from PeerMgr for: " << id;
|
||||
std::cerr << "p3LinkMgrIMPL::retryConnectTCP() ERROR failed to addresses from PeerMgr for: " << id;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
@ -1375,10 +1365,10 @@ bool p3LinkMgr::retryConnectTCP(const std::string &id)
|
||||
|
||||
#define MAX_TCP_ADDR_AGE (3600 * 24 * 14) // two weeks in seconds.
|
||||
|
||||
bool p3LinkMgr::locked_CheckPotentialAddr(const struct sockaddr_in *addr, time_t age)
|
||||
bool p3LinkMgrIMPL::locked_CheckPotentialAddr(const struct sockaddr_in *addr, time_t age)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::locked_CheckPotentialAddr(";
|
||||
std::cerr << "p3LinkMgrIMPL::locked_CheckPotentialAddr(";
|
||||
std::cerr << rs_inet_ntoa(addr->sin_addr);
|
||||
std::cerr << ":" << ntohs(addr->sin_port);
|
||||
std::cerr << ", " << age << ")";
|
||||
@ -1391,7 +1381,7 @@ bool p3LinkMgr::locked_CheckPotentialAddr(const struct sockaddr_in *addr, time_
|
||||
if (age > MAX_TCP_ADDR_AGE)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::locked_CheckPotentialAddr() REJECTING - TOO OLD";
|
||||
std::cerr << "p3LinkMgrIMPL::locked_CheckPotentialAddr() REJECTING - TOO OLD";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
@ -1406,7 +1396,7 @@ bool p3LinkMgr::locked_CheckPotentialAddr(const struct sockaddr_in *addr, time_
|
||||
if (!isValid)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::locked_CheckPotentialAddr() REJECTING - INVALID";
|
||||
std::cerr << "p3LinkMgrIMPL::locked_CheckPotentialAddr() REJECTING - INVALID";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
@ -1421,7 +1411,7 @@ bool p3LinkMgr::locked_CheckPotentialAddr(const struct sockaddr_in *addr, time_
|
||||
if (it->s_addr == addr->sin_addr.s_addr)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::locked_CheckPotentialAddr() REJECTING - ON BANNED IPLIST";
|
||||
std::cerr << "p3LinkMgrIMPL::locked_CheckPotentialAddr() REJECTING - ON BANNED IPLIST";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
@ -1435,7 +1425,7 @@ bool p3LinkMgr::locked_CheckPotentialAddr(const struct sockaddr_in *addr, time_
|
||||
if (isExternal)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::locked_CheckPotentialAddr() ACCEPTING - EXTERNAL";
|
||||
std::cerr << "p3LinkMgrIMPL::locked_CheckPotentialAddr() ACCEPTING - EXTERNAL";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return true;
|
||||
@ -1447,7 +1437,7 @@ bool p3LinkMgr::locked_CheckPotentialAddr(const struct sockaddr_in *addr, time_
|
||||
- check net against our local address.
|
||||
*/
|
||||
|
||||
std::cerr << "p3LinkMgr::locked_CheckPotentialAddr() Checking sameNet against: ";
|
||||
std::cerr << "p3LinkMgrIMPL::locked_CheckPotentialAddr() Checking sameNet against: ";
|
||||
std::cerr << rs_inet_ntoa(mLocalAddress.sin_addr);
|
||||
std::cerr << ")";
|
||||
std::cerr << std::endl;
|
||||
@ -1455,14 +1445,14 @@ bool p3LinkMgr::locked_CheckPotentialAddr(const struct sockaddr_in *addr, time_
|
||||
if (sameNet(&(mLocalAddress.sin_addr), &(addr->sin_addr)))
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::locked_CheckPotentialAddr() ACCEPTING - PRIVATE & sameNET";
|
||||
std::cerr << "p3LinkMgrIMPL::locked_CheckPotentialAddr() ACCEPTING - PRIVATE & sameNET";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::locked_CheckPotentialAddr() REJECTING - PRIVATE & !sameNET";
|
||||
std::cerr << "p3LinkMgrIMPL::locked_CheckPotentialAddr() REJECTING - PRIVATE & !sameNET";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -1472,10 +1462,10 @@ bool p3LinkMgr::locked_CheckPotentialAddr(const struct sockaddr_in *addr, time_
|
||||
}
|
||||
|
||||
|
||||
void p3LinkMgr::locked_ConnectAttempt_CurrentAddresses(peerConnectState *peer, struct sockaddr_in *localAddr, struct sockaddr_in *serverAddr)
|
||||
void p3LinkMgrIMPL::locked_ConnectAttempt_CurrentAddresses(peerConnectState *peer, struct sockaddr_in *localAddr, struct sockaddr_in *serverAddr)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::locked_ConnectAttempt_CurrentAddresses()";
|
||||
std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_CurrentAddresses()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
// Just push all the addresses onto the stack.
|
||||
@ -1483,7 +1473,7 @@ void p3LinkMgr::locked_ConnectAttempt_CurrentAddresses(peerConnectState *peer,
|
||||
if ((localAddr) && (locked_CheckPotentialAddr(localAddr, 0)))
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::locked_ConnectAttempt_CurrentAddresses() ";
|
||||
std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_CurrentAddresses() ";
|
||||
std::cerr << "Adding tcp connection attempt: ";
|
||||
std::cerr << "Current Local Addr: " << rs_inet_ntoa(localAddr->sin_addr);
|
||||
std::cerr << ":" << ntohs(localAddr->sin_port);
|
||||
@ -1502,7 +1492,7 @@ void p3LinkMgr::locked_ConnectAttempt_CurrentAddresses(peerConnectState *peer,
|
||||
if ((serverAddr) && (locked_CheckPotentialAddr(serverAddr, 0)))
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::locked_ConnectAttempt_CurrentAddresses() ";
|
||||
std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_CurrentAddresses() ";
|
||||
std::cerr << "Adding tcp connection attempt: ";
|
||||
std::cerr << "Current Ext Addr: " << rs_inet_ntoa(serverAddr->sin_addr);
|
||||
std::cerr << ":" << ntohs(serverAddr->sin_port);
|
||||
@ -1520,7 +1510,7 @@ void p3LinkMgr::locked_ConnectAttempt_CurrentAddresses(peerConnectState *peer,
|
||||
}
|
||||
|
||||
|
||||
void p3LinkMgr::locked_ConnectAttempt_HistoricalAddresses(peerConnectState *peer, const pqiIpAddrSet &ipAddrs)
|
||||
void p3LinkMgrIMPL::locked_ConnectAttempt_HistoricalAddresses(peerConnectState *peer, const pqiIpAddrSet &ipAddrs)
|
||||
{
|
||||
/* now try historical addresses */
|
||||
/* try local addresses first */
|
||||
@ -1528,7 +1518,7 @@ void p3LinkMgr::locked_ConnectAttempt_HistoricalAddresses(peerConnectState *pee
|
||||
time_t now = time(NULL);
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::locked_ConnectAttempt_HistoricalAddresses()";
|
||||
std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_HistoricalAddresses()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
for(ait = ipAddrs.mLocal.mAddrs.begin();
|
||||
@ -1538,7 +1528,7 @@ void p3LinkMgr::locked_ConnectAttempt_HistoricalAddresses(peerConnectState *pee
|
||||
{
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::locked_ConnectAttempt_HistoricalAddresses() ";
|
||||
std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_HistoricalAddresses() ";
|
||||
std::cerr << "Adding tcp connection attempt: ";
|
||||
std::cerr << "Local Addr: " << rs_inet_ntoa(ait->mAddr.sin_addr);
|
||||
std::cerr << ":" << ntohs(ait->mAddr.sin_port);
|
||||
@ -1563,7 +1553,7 @@ void p3LinkMgr::locked_ConnectAttempt_HistoricalAddresses(peerConnectState *pee
|
||||
{
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::locked_ConnectAttempt_HistoricalAddresses() ";
|
||||
std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_HistoricalAddresses() ";
|
||||
std::cerr << "Adding tcp connection attempt: ";
|
||||
std::cerr << "Ext Addr: " << rs_inet_ntoa(ait->mAddr.sin_addr);
|
||||
std::cerr << ":" << ntohs(ait->mAddr.sin_port);
|
||||
@ -1582,19 +1572,19 @@ void p3LinkMgr::locked_ConnectAttempt_HistoricalAddresses(peerConnectState *pee
|
||||
}
|
||||
|
||||
|
||||
void p3LinkMgr::locked_ConnectAttempt_AddDynDNS(peerConnectState *peer, std::string dyndns, uint16_t port)
|
||||
void p3LinkMgrIMPL::locked_ConnectAttempt_AddDynDNS(peerConnectState *peer, std::string dyndns, uint16_t port)
|
||||
{
|
||||
/* try dyndns address too */
|
||||
struct in_addr addr;
|
||||
if (!dyndns.empty() && port)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::locked_ConnectAttempt_AddDynDNS() Looking up DynDNS address: " << dyndns << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_AddDynDNS() Looking up DynDNS address: " << dyndns << std::endl;
|
||||
#endif
|
||||
if(mDNSResolver->getIPAddressFromString(dyndns, addr))
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::locked_ConnectAttempt_AddDynDNS() ";
|
||||
std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_AddDynDNS() ";
|
||||
std::cerr << "Adding tcp connection attempt: ";
|
||||
std::cerr << "DynDNS Addr: " << rs_inet_ntoa(addr);
|
||||
std::cerr << ":" << ntohs(port);
|
||||
@ -1619,7 +1609,7 @@ void p3LinkMgr::locked_ConnectAttempt_AddDynDNS(peerConnectState *peer, std::st
|
||||
else
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::locked_ConnectAttempt_AddDynDNS() DNSResolver hasn't found addr yet";
|
||||
std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_AddDynDNS() DNSResolver hasn't found addr yet";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
@ -1627,14 +1617,14 @@ void p3LinkMgr::locked_ConnectAttempt_AddDynDNS(peerConnectState *peer, std::st
|
||||
else
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::locked_ConnectAttempt_AddDynDNS() Address(" << dyndns << ") or Port(" << port << ") NULL ignoring";
|
||||
std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_AddDynDNS() Address(" << dyndns << ") or Port(" << port << ") NULL ignoring";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void p3LinkMgr::locked_ConnectAttempt_AddTunnel(peerConnectState *peer)
|
||||
void p3LinkMgrIMPL::locked_ConnectAttempt_AddTunnel(peerConnectState *peer)
|
||||
{
|
||||
if (!(peer->state & RS_PEER_S_CONNECTED) && mAllowTunnelConnection)
|
||||
{
|
||||
@ -1654,13 +1644,13 @@ void p3LinkMgr::locked_ConnectAttempt_AddTunnel(peerConnectState *peer)
|
||||
}
|
||||
|
||||
|
||||
bool p3LinkMgr::addAddressIfUnique(std::list<peerConnectAddress> &addrList, peerConnectAddress &pca)
|
||||
bool p3LinkMgrIMPL::addAddressIfUnique(std::list<peerConnectAddress> &addrList, peerConnectAddress &pca)
|
||||
{
|
||||
/* iterate through the list, and make sure it isn't already
|
||||
* in the list
|
||||
*/
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::addAddressIfUnique() Checking Address: " << rs_inet_ntoa(pca.addr.sin_addr);
|
||||
std::cerr << "p3LinkMgrIMPL::addAddressIfUnique() Checking Address: " << rs_inet_ntoa(pca.addr.sin_addr);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -1672,7 +1662,7 @@ bool p3LinkMgr::addAddressIfUnique(std::list<peerConnectAddress> &addrList, pee
|
||||
(pca.type == it->type))
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::addAddressIfUnique() Discarding Duplicate Address";
|
||||
std::cerr << "p3LinkMgrIMPL::addAddressIfUnique() Discarding Duplicate Address";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* already */
|
||||
@ -1681,7 +1671,7 @@ bool p3LinkMgr::addAddressIfUnique(std::list<peerConnectAddress> &addrList, pee
|
||||
}
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::addAddressIfUnique() Adding New Address";
|
||||
std::cerr << "p3LinkMgrIMPL::addAddressIfUnique() Adding New Address";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -1692,7 +1682,7 @@ bool p3LinkMgr::addAddressIfUnique(std::list<peerConnectAddress> &addrList, pee
|
||||
|
||||
|
||||
|
||||
bool p3LinkMgr::locked_ConnectAttempt_Complete(peerConnectState *peer)
|
||||
bool p3LinkMgrIMPL::locked_ConnectAttempt_Complete(peerConnectState *peer)
|
||||
{
|
||||
|
||||
/* flag as last attempt to prevent loop */
|
||||
@ -1703,9 +1693,9 @@ bool p3LinkMgr::locked_ConnectAttempt_Complete(peerConnectState *peer)
|
||||
{
|
||||
/* -> it'll automatically use the addresses we added */
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::locked_ConnectAttempt_Complete() Already in CONNECT ATTEMPT";
|
||||
std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_Complete() Already in CONNECT ATTEMPT";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3LinkMgr::locked_ConnectAttempt_Complete() Remaining ConnAddr Count: " << peer->connAddrs.size();
|
||||
std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_Complete() Remaining ConnAddr Count: " << peer->connAddrs.size();
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return true;
|
||||
@ -1716,9 +1706,9 @@ bool p3LinkMgr::locked_ConnectAttempt_Complete(peerConnectState *peer)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::ostringstream out;
|
||||
out << "p3LinkMgr::locked_ConnectAttempt_Complete() Started CONNECT ATTEMPT! " ;
|
||||
out << "p3LinkMgrIMPL::locked_ConnectAttempt_Complete() Started CONNECT ATTEMPT! " ;
|
||||
out << std::endl;
|
||||
out << "p3LinkMgr::locked_ConnectAttempt_Complete() ConnAddr Count: " << peer->connAddrs.size();
|
||||
out << "p3LinkMgrIMPL::locked_ConnectAttempt_Complete() ConnAddr Count: " << peer->connAddrs.size();
|
||||
rslog(RSL_DEBUG_ALERT, p3connectzone, out.str());
|
||||
std::cerr << out.str() << std::endl;
|
||||
|
||||
@ -1732,7 +1722,7 @@ bool p3LinkMgr::locked_ConnectAttempt_Complete(peerConnectState *peer)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::ostringstream out;
|
||||
out << "p3LinkMgr::locked_ConnectAttempt_Complete() No addr in the connect attempt list. Not suitable for CONNECT ATTEMPT! ";
|
||||
out << "p3LinkMgrIMPL::locked_ConnectAttempt_Complete() No addr in the connect attempt list. Not suitable for CONNECT ATTEMPT! ";
|
||||
rslog(RSL_DEBUG_ALERT, p3connectzone, out.str());
|
||||
std::cerr << out.str() << std::endl;
|
||||
#endif
|
||||
@ -1746,13 +1736,13 @@ bool p3LinkMgr::locked_ConnectAttempt_Complete(peerConnectState *peer)
|
||||
************************************* Handling of Friends *************************************************
|
||||
***********************************************************************************************************/
|
||||
|
||||
int p3LinkMgr::addFriend(const std::string &id, bool isVisible)
|
||||
int p3LinkMgrIMPL::addFriend(const std::string &id, bool isVisible)
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::addFriend(" << id << "," << isVisible << ")";
|
||||
std::cerr << "p3LinkMgrIMPL::addFriend(" << id << "," << isVisible << ")";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -1761,7 +1751,7 @@ int p3LinkMgr::addFriend(const std::string &id, bool isVisible)
|
||||
|
||||
if (it != mFriendList.end())
|
||||
{
|
||||
std::cerr << "p3LinkMgr::addFriend() ERROR, friend already exists : " << id;
|
||||
std::cerr << "p3LinkMgrIMPL::addFriend() ERROR, friend already exists : " << id;
|
||||
std::cerr << std::endl;
|
||||
return 0;
|
||||
}
|
||||
@ -1784,13 +1774,13 @@ int p3LinkMgr::addFriend(const std::string &id, bool isVisible)
|
||||
}
|
||||
|
||||
|
||||
int p3LinkMgr::removeFriend(const std::string &id)
|
||||
int p3LinkMgrIMPL::removeFriend(const std::string &id)
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgr::removeFriend(" << id << ")";
|
||||
std::cerr << "p3LinkMgrIMPL::removeFriend(" << id << ")";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -1799,7 +1789,7 @@ int p3LinkMgr::removeFriend(const std::string &id)
|
||||
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
std::cerr << "p3LinkMgr::removeFriend() ERROR, friend not there : " << id;
|
||||
std::cerr << "p3LinkMgrIMPL::removeFriend() ERROR, friend not there : " << id;
|
||||
std::cerr << std::endl;
|
||||
return 0;
|
||||
}
|
||||
@ -1825,12 +1815,12 @@ int p3LinkMgr::removeFriend(const std::string &id)
|
||||
}
|
||||
|
||||
|
||||
void p3LinkMgr::printPeerLists(std::ostream &out)
|
||||
void p3LinkMgrIMPL::printPeerLists(std::ostream &out)
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
out << "p3LinkMgr::printPeerLists() Friend List";
|
||||
out << "p3LinkMgrIMPL::printPeerLists() Friend List";
|
||||
out << std::endl;
|
||||
|
||||
|
||||
@ -1842,7 +1832,7 @@ void p3LinkMgr::printPeerLists(std::ostream &out)
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
out << "p3LinkMgr::printPeerLists() Others List";
|
||||
out << "p3LinkMgrIMPL::printPeerLists() Others List";
|
||||
out << std::endl;
|
||||
for(it = mOthersList.begin(); it != mOthersList.end(); it++)
|
||||
{
|
||||
|
@ -141,102 +141,138 @@ class RsGroupInfo;
|
||||
class p3PeerMgr;
|
||||
class p3NetMgr;
|
||||
|
||||
class p3PeerMgrIMPL;
|
||||
class p3NetMgrIMPL;
|
||||
|
||||
std::string textPeerConnectState(peerConnectState &state);
|
||||
|
||||
/*******
|
||||
* Virtual Interface to allow testing
|
||||
*
|
||||
*/
|
||||
|
||||
class p3LinkMgr: public pqiConnectCb
|
||||
{
|
||||
public:
|
||||
|
||||
p3LinkMgr(p3PeerMgr *peerMgr, p3NetMgr *netMgr);
|
||||
p3LinkMgr() { return; }
|
||||
virtual ~p3LinkMgr() { return; }
|
||||
|
||||
void tick();
|
||||
|
||||
/*************** Setup ***************************/
|
||||
//void addNetAssistConnect(uint32_t type, pqiNetAssistConnect *);
|
||||
//void addNetAssistFirewall(uint32_t type, pqiNetAssistFirewall *);
|
||||
virtual const std::string getOwnId() = 0;
|
||||
virtual bool isOnline(const std::string &ssl_id) = 0;
|
||||
virtual void getOnlineList(std::list<std::string> &ssl_peers) = 0;
|
||||
|
||||
//void addNetListener(pqiNetListener *listener);
|
||||
/**************** handle monitors *****************/
|
||||
virtual void addMonitor(pqiMonitor *mon) = 0;
|
||||
virtual void removeMonitor(pqiMonitor *mon) = 0;
|
||||
|
||||
//bool checkNetAddress(); /* check our address is sensible */
|
||||
/****************** Connections *******************/
|
||||
virtual bool connectAttempt(const std::string &id, struct sockaddr_in &addr,
|
||||
uint32_t &delay, uint32_t &period, uint32_t &type) = 0;
|
||||
virtual bool connectResult(const std::string &id, bool success, uint32_t flags, struct sockaddr_in remote_peer_address) = 0;
|
||||
virtual bool retryConnect(const std::string &id) = 0;
|
||||
|
||||
/*************** External Control ****************/
|
||||
bool shutdown(); /* blocking shutdown call */
|
||||
/* Network Addresses */
|
||||
virtual bool setLocalAddress(struct sockaddr_in addr) = 0;
|
||||
virtual struct sockaddr_in getLocalAddress() = 0;
|
||||
|
||||
bool retryConnect(const std::string &id);
|
||||
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
|
||||
|
||||
void setTunnelConnection(bool b);
|
||||
bool getTunnelConnection();
|
||||
virtual void getFriendList(std::list<std::string> &ssl_peers) = 0; // ONLY used by p3peers.cc USE p3PeerMgr instead.
|
||||
virtual int getOnlineCount() = 0; // ONLY used by p3peers.cc
|
||||
virtual int getFriendCount() = 0; // ONLY used by p3serverconfig.cc & p3peers.cc
|
||||
virtual bool getFriendNetStatus(const std::string &id, peerConnectState &state) = 0; // ONLY used by p3peers.cc
|
||||
|
||||
void setFriendVisibility(const std::string &id, bool isVisible);
|
||||
virtual void setTunnelConnection(bool b) = 0; // ONLY used by p3peermgr.cc & p3peers.cc MOVE => p3PeerMgr
|
||||
virtual bool getTunnelConnection() = 0; // ONLY used by p3peermgr.cc & p3peers.cc MOVE => p3PeerMgr
|
||||
|
||||
//void setOwnNetConfig(uint32_t netMode, uint32_t visState);
|
||||
//bool setLocalAddress(const std::string &id, struct sockaddr_in addr);
|
||||
//bool setExtAddress(const std::string &id, struct sockaddr_in addr);
|
||||
//bool setDynDNS(const std::string &id, const std::string &dyndns);
|
||||
//bool updateAddressList(const std::string& id, const pqiIpAddrSet &addrs);
|
||||
|
||||
//bool setNetworkMode(const std::string &id, uint32_t netMode);
|
||||
//bool setVisState(const std::string &id, uint32_t visState);
|
||||
/******* overloaded from pqiConnectCb *************/
|
||||
// THESE MUSTn't BE specfied HERE - as overloaded from pqiConnectCb.
|
||||
//virtual void peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
// uint32_t type, uint32_t flags, uint32_t source) = 0;
|
||||
//virtual void peerConnectRequest(std::string id,
|
||||
// struct sockaddr_in raddr, uint32_t source) = 0;
|
||||
|
||||
//bool setLocation(const std::string &pid, const std::string &location);//location is shown in the gui to differentiate ssl certs
|
||||
/****************************************************************************/
|
||||
/****************************************************************************/
|
||||
/****************************************************************************/
|
||||
|
||||
/* add/remove friends */
|
||||
int addFriend(const std::string &ssl_id, bool isVisible);
|
||||
int removeFriend(const std::string &ssl_id);
|
||||
void printPeerLists(std::ostream &out);
|
||||
};
|
||||
|
||||
/*************** External Control ****************/
|
||||
|
||||
/* access to network details (called through Monitor) */
|
||||
const std::string getOwnId();
|
||||
bool getOwnNetStatus(peerConnectState &state);
|
||||
|
||||
bool setLocalAddress(struct sockaddr_in addr);
|
||||
struct sockaddr_in getLocalAddress();
|
||||
class p3LinkMgrIMPL: public p3LinkMgr
|
||||
{
|
||||
public:
|
||||
|
||||
bool isOnline(const std::string &ssl_id);
|
||||
bool getFriendNetStatus(const std::string &id, peerConnectState &state);
|
||||
//bool getOthersNetStatus(const std::string &id, peerConnectState &state);
|
||||
/************************************************************************************************/
|
||||
/* EXTERNAL INTERFACE */
|
||||
/************************************************************************************************/
|
||||
|
||||
void getOnlineList(std::list<std::string> &ssl_peers);
|
||||
void getFriendList(std::list<std::string> &ssl_peers);
|
||||
int getOnlineCount();
|
||||
int getFriendCount();
|
||||
virtual const std::string getOwnId();
|
||||
virtual bool isOnline(const std::string &ssl_id);
|
||||
virtual void getOnlineList(std::list<std::string> &ssl_peers);
|
||||
|
||||
|
||||
/**************** handle monitors *****************/
|
||||
void addMonitor(pqiMonitor *mon);
|
||||
void removeMonitor(pqiMonitor *mon);
|
||||
virtual void addMonitor(pqiMonitor *mon);
|
||||
virtual void removeMonitor(pqiMonitor *mon);
|
||||
|
||||
/****************** Connections *******************/
|
||||
virtual bool connectAttempt(const std::string &id, struct sockaddr_in &addr,
|
||||
uint32_t &delay, uint32_t &period, uint32_t &type);
|
||||
virtual bool connectResult(const std::string &id, bool success, uint32_t flags, struct sockaddr_in remote_peer_address);
|
||||
virtual bool retryConnect(const std::string &id);
|
||||
|
||||
/* Network Addresses */
|
||||
virtual bool setLocalAddress(struct sockaddr_in addr);
|
||||
virtual struct sockaddr_in getLocalAddress();
|
||||
|
||||
/******* overloaded from pqiConnectCb *************/
|
||||
virtual void peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
uint32_t type, uint32_t flags, uint32_t source);
|
||||
virtual void peerConnectRequest(std::string id,
|
||||
struct sockaddr_in raddr, uint32_t source);
|
||||
//virtual void stunStatus(std::string id, struct sockaddr_in raddr, uint32_t type, uint32_t flags);
|
||||
|
||||
/****************** Connections *******************/
|
||||
bool connectAttempt(const std::string &id, struct sockaddr_in &addr,
|
||||
uint32_t &delay, uint32_t &period, uint32_t &type);
|
||||
bool connectResult(const std::string &id, bool success, uint32_t flags, struct sockaddr_in remote_peer_address);
|
||||
|
||||
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
|
||||
|
||||
virtual void getFriendList(std::list<std::string> &ssl_peers); // ONLY used by p3peers.cc USE p3PeerMgr instead.
|
||||
virtual int getOnlineCount(); // ONLY used by p3peers.cc
|
||||
virtual int getFriendCount(); // ONLY used by p3serverconfig.cc & p3peers.cc
|
||||
virtual bool getFriendNetStatus(const std::string &id, peerConnectState &state); // ONLY used by p3peers.cc
|
||||
|
||||
virtual void setTunnelConnection(bool b); // ONLY used by p3peermgr.cc & p3peers.cc MOVE => p3PeerMgr
|
||||
virtual bool getTunnelConnection(); // ONLY used by p3peermgr.cc & p3peers.cc MOVE => p3PeerMgr
|
||||
|
||||
/************************************************************************************************/
|
||||
/* Extra IMPL Functions (used by p3PeerMgr, p3NetMgr + Setup) */
|
||||
/************************************************************************************************/
|
||||
|
||||
p3LinkMgrIMPL(p3PeerMgrIMPL *peerMgr, p3NetMgrIMPL *netMgr);
|
||||
|
||||
void tick();
|
||||
|
||||
/* THIS COULD BE ADDED TO INTERFACE */
|
||||
void setFriendVisibility(const std::string &id, bool isVisible);
|
||||
|
||||
/* add/remove friends */
|
||||
int addFriend(const std::string &ssl_id, bool isVisible);
|
||||
int removeFriend(const std::string &ssl_id);
|
||||
|
||||
void printPeerLists(std::ostream &out);
|
||||
|
||||
protected:
|
||||
/* THESE CAN PROBABLY BE REMOVED */
|
||||
//bool shutdown(); /* blocking shutdown call */
|
||||
//bool getOwnNetStatus(peerConnectState &state);
|
||||
|
||||
|
||||
protected:
|
||||
/****************** Internal Interface *******************/
|
||||
|
||||
//virtual bool enableNetAssistConnect(bool on);
|
||||
//virtual bool netAssistConnectEnabled();
|
||||
//virtual bool netAssistConnectActive();
|
||||
//virtual bool netAssistConnectShutdown();
|
||||
//virtual bool netAssistConnectStats(uint32_t &netsize, uint32_t &localnetsize);
|
||||
|
||||
/* Assist Connect */
|
||||
//virtual bool netAssistFriend(std::string id, bool on);
|
||||
//virtual bool netAssistSetAddress( struct sockaddr_in &laddr,
|
||||
// struct sockaddr_in &eaddr,
|
||||
// uint32_t mode);
|
||||
|
||||
|
||||
/* Internal Functions */
|
||||
void statusTick();
|
||||
|
||||
@ -266,8 +302,8 @@ private:
|
||||
//p3tunnel *mP3tunnel;
|
||||
DNSResolver *mDNSResolver ;
|
||||
|
||||
p3PeerMgr *mPeerMgr;
|
||||
p3NetMgr *mNetMgr;
|
||||
p3PeerMgrIMPL *mPeerMgr;
|
||||
p3NetMgrIMPL *mNetMgr;
|
||||
|
||||
RsMutex mLinkMtx; /* protects below */
|
||||
|
||||
|
@ -111,7 +111,7 @@ void pqiNetStatus::print(std::ostream &out)
|
||||
}
|
||||
|
||||
|
||||
p3NetMgr::p3NetMgr()
|
||||
p3NetMgrIMPL::p3NetMgrIMPL()
|
||||
:mPeerMgr(NULL), mLinkMgr(NULL), mNetMtx("p3NetMgr"),
|
||||
mNetStatus(RS_NET_UNKNOWN), mStatusChanged(false)
|
||||
{
|
||||
@ -142,18 +142,18 @@ p3NetMgr::p3NetMgr()
|
||||
return;
|
||||
}
|
||||
|
||||
void p3NetMgr::setManagers(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr)
|
||||
void p3NetMgrIMPL::setManagers(p3PeerMgrIMPL *peerMgr, p3LinkMgrIMPL *linkMgr)
|
||||
{
|
||||
mPeerMgr = peerMgr;
|
||||
mLinkMgr = linkMgr;
|
||||
}
|
||||
|
||||
//void p3NetMgr::setDhtMgr(p3DhtMgr *dhtMgr)
|
||||
//void p3NetMgrIMPL::setDhtMgr(p3DhtMgr *dhtMgr)
|
||||
//{
|
||||
// mDhtMgr = dhtMgr;
|
||||
//}
|
||||
|
||||
void p3NetMgr::setAddrAssist(pqiAddrAssist *dhtStun, pqiAddrAssist *proxyStun)
|
||||
void p3NetMgrIMPL::setAddrAssist(pqiAddrAssist *dhtStun, pqiAddrAssist *proxyStun)
|
||||
{
|
||||
mDhtStunner = dhtStun;
|
||||
mProxyStunner = proxyStun;
|
||||
@ -224,10 +224,10 @@ void p3NetMgr::setAddrAssist(pqiAddrAssist *dhtStun, pqiAddrAssist *proxyStun)
|
||||
* -
|
||||
*/
|
||||
|
||||
void p3NetMgr::netReset()
|
||||
void p3NetMgrIMPL::netReset()
|
||||
{
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgr::netReset() Called" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netReset() Called" << std::endl;
|
||||
#endif
|
||||
|
||||
shutdown(); /* blocking shutdown call */
|
||||
@ -236,19 +236,19 @@ void p3NetMgr::netReset()
|
||||
if (mUseExtAddrFinder)
|
||||
{
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgr::netReset() restarting AddrFinder" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netReset() restarting AddrFinder" << std::endl;
|
||||
#endif
|
||||
mExtAddrFinder->reset() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgr::netReset() ExtAddrFinder Disabled" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netReset() ExtAddrFinder Disabled" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgr::netReset() resetting NetStatus" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netReset() resetting NetStatus" << std::endl;
|
||||
#endif
|
||||
|
||||
/* reset tcp network - if necessary */
|
||||
@ -266,14 +266,14 @@ void p3NetMgr::netReset()
|
||||
struct sockaddr_in iaddr = mLocalAddr;
|
||||
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgr::netReset() resetting listeners" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netReset() resetting listeners" << std::endl;
|
||||
#endif
|
||||
std::list<pqiNetListener *>::const_iterator it;
|
||||
for(it = mNetListeners.begin(); it != mNetListeners.end(); it++)
|
||||
{
|
||||
(*it)->resetListener(iaddr);
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgr::netReset() reset listener" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netReset() reset listener" << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -287,23 +287,23 @@ void p3NetMgr::netReset()
|
||||
updateNetStateBox_reset();
|
||||
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgr::netReset() done" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netReset() done" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void p3NetMgr::netStatusReset_locked()
|
||||
void p3NetMgrIMPL::netStatusReset_locked()
|
||||
{
|
||||
//std::cerr << "p3NetMgr::netStatusReset()" << std::endl;;
|
||||
//std::cerr << "p3NetMgrIMPL::netStatusReset()" << std::endl;;
|
||||
|
||||
mNetFlags = pqiNetStatus();
|
||||
}
|
||||
|
||||
|
||||
bool p3NetMgr::shutdown() /* blocking shutdown call */
|
||||
bool p3NetMgrIMPL::shutdown() /* blocking shutdown call */
|
||||
{
|
||||
#ifdef NETMGR_DEBUG
|
||||
std::cerr << "p3NetMgr::shutdown()";
|
||||
std::cerr << "p3NetMgrIMPL::shutdown()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
@ -326,7 +326,7 @@ bool p3NetMgr::shutdown() /* blocking shutdown call */
|
||||
|
||||
|
||||
|
||||
void p3NetMgr::netStartup()
|
||||
void p3NetMgrIMPL::netStartup()
|
||||
{
|
||||
/* startup stuff */
|
||||
|
||||
@ -334,7 +334,7 @@ void p3NetMgr::netStartup()
|
||||
* This is needed for all systems so startup straight away
|
||||
*/
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgr::netStartup()" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netStartup()" << std::endl;
|
||||
#endif
|
||||
|
||||
netDhtInit();
|
||||
@ -349,7 +349,7 @@ void p3NetMgr::netStartup()
|
||||
netStatusReset_locked();
|
||||
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgr::netStartup() resetting mNetInitTS / Status" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netStartup() resetting mNetInitTS / Status" << std::endl;
|
||||
#endif
|
||||
mNetMode &= ~(RS_NET_MODE_ACTUAL);
|
||||
|
||||
@ -358,7 +358,7 @@ void p3NetMgr::netStartup()
|
||||
|
||||
case RS_NET_MODE_TRY_EXT: /* v similar to UDP */
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgr::netStartup() TRY_EXT mode";
|
||||
std::cerr << "p3NetMgrIMPL::netStartup() TRY_EXT mode";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
mNetMode |= RS_NET_MODE_EXT;
|
||||
@ -367,7 +367,7 @@ void p3NetMgr::netStartup()
|
||||
|
||||
case RS_NET_MODE_TRY_UDP:
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgr::netStartup() TRY_UDP mode";
|
||||
std::cerr << "p3NetMgrIMPL::netStartup() TRY_UDP mode";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
mNetMode |= RS_NET_MODE_UDP;
|
||||
@ -377,13 +377,13 @@ void p3NetMgr::netStartup()
|
||||
default: // Fall through.
|
||||
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgr::netStartup() UNKNOWN mode";
|
||||
std::cerr << "p3NetMgrIMPL::netStartup() UNKNOWN mode";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
case RS_NET_MODE_TRY_UPNP:
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgr::netStartup() TRY_UPNP mode";
|
||||
std::cerr << "p3NetMgrIMPL::netStartup() TRY_UPNP mode";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* Force it here (could be default!) */
|
||||
@ -395,7 +395,7 @@ void p3NetMgr::netStartup()
|
||||
}
|
||||
|
||||
|
||||
void p3NetMgr::tick()
|
||||
void p3NetMgrIMPL::tick()
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
bool doSlowTick = false;
|
||||
@ -415,7 +415,7 @@ void p3NetMgr::tick()
|
||||
}
|
||||
|
||||
|
||||
void p3NetMgr::slowTick()
|
||||
void p3NetMgrIMPL::slowTick()
|
||||
{
|
||||
netTick();
|
||||
netAssistConnectTick();
|
||||
@ -436,11 +436,11 @@ void p3NetMgr::slowTick()
|
||||
#define STARTUP_DELAY 5
|
||||
|
||||
|
||||
void p3NetMgr::netTick()
|
||||
void p3NetMgrIMPL::netTick()
|
||||
{
|
||||
|
||||
#ifdef NETMGR_DEBUG_TICK
|
||||
std::cerr << "p3NetMgr::netTick()" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netTick()" << std::endl;
|
||||
#endif
|
||||
|
||||
// Check whether we are stuck on loopback. This happens if RS starts when
|
||||
@ -464,14 +464,14 @@ void p3NetMgr::netTick()
|
||||
case RS_NET_NEEDS_RESET:
|
||||
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netTick() STATUS: NEEDS_RESET" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netTick() STATUS: NEEDS_RESET" << std::endl;
|
||||
#endif
|
||||
netReset();
|
||||
break;
|
||||
|
||||
case RS_NET_UNKNOWN:
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netTick() STATUS: UNKNOWN" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netTick() STATUS: UNKNOWN" << std::endl;
|
||||
#endif
|
||||
|
||||
/* add a small delay to stop restarting straight after a RESET
|
||||
@ -480,7 +480,7 @@ void p3NetMgr::netTick()
|
||||
if (age < STARTUP_DELAY)
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netTick() Delaying Startup" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netTick() Delaying Startup" << std::endl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@ -492,14 +492,14 @@ void p3NetMgr::netTick()
|
||||
|
||||
case RS_NET_UPNP_INIT:
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netTick() STATUS: UPNP_INIT" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netTick() STATUS: UPNP_INIT" << std::endl;
|
||||
#endif
|
||||
netUpnpInit();
|
||||
break;
|
||||
|
||||
case RS_NET_UPNP_SETUP:
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netTick() STATUS: UPNP_SETUP" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netTick() STATUS: UPNP_SETUP" << std::endl;
|
||||
#endif
|
||||
netUpnpCheck();
|
||||
break;
|
||||
@ -507,14 +507,14 @@ void p3NetMgr::netTick()
|
||||
|
||||
case RS_NET_EXT_SETUP:
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netTick() STATUS: EXT_SETUP" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netTick() STATUS: EXT_SETUP" << std::endl;
|
||||
#endif
|
||||
netExtCheck();
|
||||
break;
|
||||
|
||||
case RS_NET_DONE:
|
||||
#ifdef NETMGR_DEBUG_TICK
|
||||
std::cerr << "p3NetMgr::netTick() STATUS: DONE" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netTick() STATUS: DONE" << std::endl;
|
||||
#endif
|
||||
|
||||
break;
|
||||
@ -523,7 +523,7 @@ void p3NetMgr::netTick()
|
||||
//don't do a shutdown because a client in a computer without local network might be usefull for debug.
|
||||
//shutdown();
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netTick() STATUS: RS_NET_LOOPBACK" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netTick() STATUS: RS_NET_LOOPBACK" << std::endl;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
@ -533,10 +533,10 @@ void p3NetMgr::netTick()
|
||||
}
|
||||
|
||||
|
||||
void p3NetMgr::netDhtInit()
|
||||
void p3NetMgrIMPL::netDhtInit()
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netDhtInit()" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netDhtInit()" << std::endl;
|
||||
#endif
|
||||
|
||||
uint32_t vs = 0;
|
||||
@ -549,10 +549,10 @@ void p3NetMgr::netDhtInit()
|
||||
}
|
||||
|
||||
|
||||
void p3NetMgr::netUpnpInit()
|
||||
void p3NetMgrIMPL::netUpnpInit()
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netUpnpInit()" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netUpnpInit()" << std::endl;
|
||||
#endif
|
||||
uint16_t eport, iport;
|
||||
|
||||
@ -574,7 +574,7 @@ void p3NetMgr::netUpnpInit()
|
||||
enableNetAssistFirewall(true);
|
||||
}
|
||||
|
||||
void p3NetMgr::netUpnpCheck()
|
||||
void p3NetMgrIMPL::netUpnpCheck()
|
||||
{
|
||||
/* grab timestamp */
|
||||
mNetMtx.lock(); /* LOCK MUTEX */
|
||||
@ -582,7 +582,7 @@ void p3NetMgr::netUpnpCheck()
|
||||
time_t delta = time(NULL) - mNetInitTS;
|
||||
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netUpnpCheck() age: " << delta << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netUpnpCheck() age: " << delta << std::endl;
|
||||
#endif
|
||||
|
||||
mNetMtx.unlock(); /* UNLOCK MUTEX */
|
||||
@ -594,7 +594,7 @@ void p3NetMgr::netUpnpCheck()
|
||||
((upnpState > 0) && (delta > (time_t)MAX_UPNP_COMPLETE)))
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netUpnpCheck() ";
|
||||
std::cerr << "p3NetMgrIMPL::netUpnpCheck() ";
|
||||
std::cerr << "Upnp Check failed." << std::endl;
|
||||
#endif
|
||||
/* fallback to UDP startup */
|
||||
@ -609,7 +609,7 @@ void p3NetMgr::netUpnpCheck()
|
||||
else if ((upnpState > 0) && netAssistExtAddress(extAddr))
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netUpnpCheck() ";
|
||||
std::cerr << "p3NetMgrIMPL::netUpnpCheck() ";
|
||||
std::cerr << "Upnp Check success state: " << upnpState << std::endl;
|
||||
#endif
|
||||
/* switch to UDP startup */
|
||||
@ -622,7 +622,7 @@ void p3NetMgr::netUpnpCheck()
|
||||
if (isValidNet(&(extAddr.sin_addr)))
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netUpnpCheck() ";
|
||||
std::cerr << "p3NetMgrIMPL::netUpnpCheck() ";
|
||||
std::cerr << "UpnpAddr: " << rs_inet_ntoa(extAddr.sin_addr);
|
||||
std::cerr << ":" << ntohs(extAddr.sin_port);
|
||||
std::cerr << std::endl;
|
||||
@ -641,7 +641,7 @@ void p3NetMgr::netUpnpCheck()
|
||||
else
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netUpnpCheck() ";
|
||||
std::cerr << "p3NetMgrIMPL::netUpnpCheck() ";
|
||||
std::cerr << "Upnp Check Continues: status: " << upnpState << std::endl;
|
||||
#endif
|
||||
}
|
||||
@ -649,10 +649,10 @@ void p3NetMgr::netUpnpCheck()
|
||||
}
|
||||
|
||||
|
||||
void p3NetMgr::netExtCheck()
|
||||
void p3NetMgrIMPL::netExtCheck()
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netExtCheck()" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck()" << std::endl;
|
||||
#endif
|
||||
bool netSetupDone = false;
|
||||
|
||||
@ -667,14 +667,14 @@ void p3NetMgr::netExtCheck()
|
||||
if (!mNetFlags.mExtAddrOk)
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netExtCheck() Ext Not Ok" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext Not Ok" << std::endl;
|
||||
#endif
|
||||
|
||||
/* net Assist */
|
||||
if (netAssistExtAddress(tmpip))
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netExtCheck() Ext supplied from netAssistExternalAddress()" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext supplied from netAssistExternalAddress()" << std::endl;
|
||||
#endif
|
||||
if (isValidNet(&(tmpip.sin_addr)))
|
||||
{
|
||||
@ -687,7 +687,7 @@ void p3NetMgr::netExtCheck()
|
||||
else
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netExtCheck() Bad Address supplied from netAssistExternalAddress()" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() Bad Address supplied from netAssistExternalAddress()" << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -701,18 +701,18 @@ void p3NetMgr::netExtCheck()
|
||||
if (mUseExtAddrFinder)
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netExtCheck() checking ExtAddrFinder" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() checking ExtAddrFinder" << std::endl;
|
||||
#endif
|
||||
bool extFinderOk = mExtAddrFinder->hasValidIP(&(tmpip.sin_addr));
|
||||
if (extFinderOk)
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netExtCheck() Ext supplied by ExtAddrFinder" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext supplied by ExtAddrFinder" << std::endl;
|
||||
#endif
|
||||
/* best guess at port */
|
||||
tmpip.sin_port = mNetFlags.mLocalAddr.sin_port;
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netExtCheck() ";
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() ";
|
||||
std::cerr << "ExtAddr: " << rs_inet_ntoa(tmpip.sin_addr);
|
||||
std::cerr << ":" << ntohs(tmpip.sin_port);
|
||||
std::cerr << std::endl;
|
||||
@ -737,7 +737,7 @@ void p3NetMgr::netExtCheck()
|
||||
{
|
||||
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netExtCheck() ";
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() ";
|
||||
std::cerr << "ExtAddr: " << rs_inet_ntoa(mNetFlags.mExtAddr.sin_addr);
|
||||
std::cerr << ":" << ntohs(mNetFlags.mExtAddr.sin_port);
|
||||
std::cerr << std::endl;
|
||||
@ -749,7 +749,7 @@ void p3NetMgr::netExtCheck()
|
||||
netSetupDone = true;
|
||||
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netExtCheck() Ext Ok: RS_NET_DONE" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext Ok: RS_NET_DONE" << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
@ -757,9 +757,9 @@ void p3NetMgr::netExtCheck()
|
||||
if (!mNetFlags.mExtAddrStableOk)
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netUdpCheck() UDP Unstable :( ";
|
||||
std::cerr << "p3NetMgrIMPL::netUdpCheck() UDP Unstable :( ";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3NetMgr::netUdpCheck() We are unreachable";
|
||||
std::cerr << "p3NetMgrIMPL::netUdpCheck() We are unreachable";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "netMode => RS_NET_MODE_UNREACHABLE";
|
||||
std::cerr << std::endl;
|
||||
@ -796,14 +796,14 @@ void p3NetMgr::netExtCheck()
|
||||
if (mNetFlags.mExtAddrOk)
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netExtCheck() setting netAssistSetAddress()" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() setting netAssistSetAddress()" << std::endl;
|
||||
#endif
|
||||
netAssistSetAddress(mNetFlags.mLocalAddr, mNetFlags.mExtAddr, mNetMode);
|
||||
}
|
||||
#if 0
|
||||
else
|
||||
{
|
||||
std::cerr << "p3NetMgr::netExtCheck() setting ERR netAssistSetAddress(0)" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() setting ERR netAssistSetAddress(0)" << std::endl;
|
||||
/* mode = 0 for error */
|
||||
netAssistSetAddress(mNetFlags.mLocalAddr, mNetFlags.mExtAddr, mNetMode);
|
||||
}
|
||||
@ -813,7 +813,7 @@ void p3NetMgr::netExtCheck()
|
||||
if ((mNetFlags.mExtAddrOk) && (!mNetFlags.mExtAddrStableOk))
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgr::netExtCheck() Ext Unstable - Unreachable Check" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext Unstable - Unreachable Check" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -833,7 +833,7 @@ void p3NetMgr::netExtCheck()
|
||||
************************************** Interfaces *****************************************
|
||||
**********************************************************************************************/
|
||||
|
||||
bool p3NetMgr::checkNetAddress()
|
||||
bool p3NetMgrIMPL::checkNetAddress()
|
||||
{
|
||||
bool addrChanged = false;
|
||||
bool validAddr = false;
|
||||
@ -847,7 +847,7 @@ bool p3NetMgr::checkNetAddress()
|
||||
if (!validAddr)
|
||||
{
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgr::checkNetAddress() no Valid Network Address, resetting network." << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::checkNetAddress() no Valid Network Address, resetting network." << std::endl;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
netReset();
|
||||
@ -864,7 +864,7 @@ bool p3NetMgr::checkNetAddress()
|
||||
addrChanged = (prefAddr.s_addr != mLocalAddr.sin_addr.s_addr);
|
||||
|
||||
#ifdef NETMGR_DEBUG_TICK
|
||||
std::cerr << "p3NetMgr::checkNetAddress()";
|
||||
std::cerr << "p3NetMgrIMPL::checkNetAddress()";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "Current Local: " << rs_inet_ntoa(mLocalAddr.sin_addr);
|
||||
std::cerr << ":" << ntohs(mLocalAddr.sin_port);
|
||||
@ -876,7 +876,7 @@ bool p3NetMgr::checkNetAddress()
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
if (addrChanged)
|
||||
{
|
||||
std::cerr << "p3NetMgr::checkNetAddress() Address Changed!";
|
||||
std::cerr << "p3NetMgrIMPL::checkNetAddress() Address Changed!";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "Current Local: " << rs_inet_ntoa(mLocalAddr.sin_addr);
|
||||
std::cerr << ":" << ntohs(mLocalAddr.sin_port);
|
||||
@ -893,7 +893,7 @@ bool p3NetMgr::checkNetAddress()
|
||||
if(isLoopbackNet(&(mLocalAddr.sin_addr)))
|
||||
{
|
||||
#ifdef NETMGR_DEBUG
|
||||
std::cerr << "p3NetMgr::checkNetAddress() laddr: Loopback" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::checkNetAddress() laddr: Loopback" << std::endl;
|
||||
#endif
|
||||
mNetFlags.mLocalAddrOk = false;
|
||||
mNetStatus = RS_NET_LOOPBACK;
|
||||
@ -901,14 +901,14 @@ bool p3NetMgr::checkNetAddress()
|
||||
else if (!isValidNet(&mLocalAddr.sin_addr))
|
||||
{
|
||||
#ifdef NETMGR_DEBUG
|
||||
std::cerr << "p3NetMgr::checkNetAddress() laddr: invalid" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::checkNetAddress() laddr: invalid" << std::endl;
|
||||
#endif
|
||||
mNetFlags.mLocalAddrOk = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef NETMGR_DEBUG_TICK
|
||||
std::cerr << "p3NetMgr::checkNetAddress() laddr okay" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::checkNetAddress() laddr okay" << std::endl;
|
||||
#endif
|
||||
mNetFlags.mLocalAddrOk = true;
|
||||
}
|
||||
@ -918,7 +918,7 @@ bool p3NetMgr::checkNetAddress()
|
||||
if ((port < PQI_MIN_PORT) || (port > PQI_MAX_PORT))
|
||||
{
|
||||
#ifdef NETMGR_DEBUG
|
||||
std::cerr << "p3NetMgr::checkNetAddress() Correcting Port to DEFAULT" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::checkNetAddress() Correcting Port to DEFAULT" << std::endl;
|
||||
#endif
|
||||
// Generate a default port from SSL id. The port will always be the
|
||||
// same, but appear random from peer to peer.
|
||||
@ -944,7 +944,7 @@ bool p3NetMgr::checkNetAddress()
|
||||
mExtAddr.sin_family = AF_INET;
|
||||
|
||||
#ifdef NETMGR_DEBUG_TICK
|
||||
std::cerr << "p3NetMgr::checkNetAddress() Final Local Address: " << rs_inet_ntoa(mLocalAddr.sin_addr);
|
||||
std::cerr << "p3NetMgrIMPL::checkNetAddress() Final Local Address: " << rs_inet_ntoa(mLocalAddr.sin_addr);
|
||||
std::cerr << ":" << ntohs(mLocalAddr.sin_port) << std::endl;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -954,7 +954,7 @@ bool p3NetMgr::checkNetAddress()
|
||||
if (addrChanged)
|
||||
{
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgr::checkNetAddress() local address changed, resetting network." << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::checkNetAddress() local address changed, resetting network." << std::endl;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -972,7 +972,7 @@ bool p3NetMgr::checkNetAddress()
|
||||
**********************************************************************************************/
|
||||
|
||||
/* to allow resets of network stuff */
|
||||
void p3NetMgr::addNetListener(pqiNetListener *listener)
|
||||
void p3NetMgrIMPL::addNetListener(pqiNetListener *listener)
|
||||
{
|
||||
RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/
|
||||
mNetListeners.push_back(listener);
|
||||
@ -980,7 +980,7 @@ void p3NetMgr::addNetListener(pqiNetListener *listener)
|
||||
|
||||
|
||||
|
||||
bool p3NetMgr::setLocalAddress(struct sockaddr_in addr)
|
||||
bool p3NetMgrIMPL::setLocalAddress(struct sockaddr_in addr)
|
||||
{
|
||||
bool changed = false;
|
||||
{
|
||||
@ -997,14 +997,14 @@ bool p3NetMgr::setLocalAddress(struct sockaddr_in addr)
|
||||
if (changed)
|
||||
{
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgr::setLocalAddress() Calling NetReset" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::setLocalAddress() Calling NetReset" << std::endl;
|
||||
#endif
|
||||
netReset();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3NetMgr::setExtAddress(struct sockaddr_in addr)
|
||||
bool p3NetMgrIMPL::setExtAddress(struct sockaddr_in addr)
|
||||
{
|
||||
bool changed = false;
|
||||
{
|
||||
@ -1021,14 +1021,14 @@ bool p3NetMgr::setExtAddress(struct sockaddr_in addr)
|
||||
if (changed)
|
||||
{
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgr::setExtAddress() Calling NetReset" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::setExtAddress() Calling NetReset" << std::endl;
|
||||
#endif
|
||||
netReset();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3NetMgr::setNetworkMode(uint32_t netMode)
|
||||
bool p3NetMgrIMPL::setNetworkMode(uint32_t netMode)
|
||||
{
|
||||
uint32_t oldNetMode;
|
||||
{
|
||||
@ -1038,7 +1038,7 @@ bool p3NetMgr::setNetworkMode(uint32_t netMode)
|
||||
oldNetMode = mNetMode;
|
||||
|
||||
#ifdef NETMGR_DEBUG
|
||||
std::cerr << "p3NetMgr::setNetworkMode()";
|
||||
std::cerr << "p3NetMgrIMPL::setNetworkMode()";
|
||||
std::cerr << " Existing netMode: " << mNetMode;
|
||||
std::cerr << " Input netMode: " << netMode;
|
||||
std::cerr << std::endl;
|
||||
@ -1064,7 +1064,7 @@ bool p3NetMgr::setNetworkMode(uint32_t netMode)
|
||||
if ((netMode & RS_NET_MODE_ACTUAL) != (oldNetMode & RS_NET_MODE_ACTUAL))
|
||||
{
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgr::setNetworkMode() Calling NetReset" << std::endl;
|
||||
std::cerr << "p3NetMgrIMPL::setNetworkMode() Calling NetReset" << std::endl;
|
||||
#endif
|
||||
netReset();
|
||||
}
|
||||
@ -1072,7 +1072,7 @@ bool p3NetMgr::setNetworkMode(uint32_t netMode)
|
||||
}
|
||||
|
||||
|
||||
bool p3NetMgr::setVisState(uint32_t visState)
|
||||
bool p3NetMgrIMPL::setVisState(uint32_t visState)
|
||||
{
|
||||
uint32_t netMode;
|
||||
{
|
||||
@ -1093,13 +1093,13 @@ bool p3NetMgr::setVisState(uint32_t visState)
|
||||
************************************** Interfaces *****************************************
|
||||
**********************************************************************************************/
|
||||
|
||||
void p3NetMgr::addNetAssistFirewall(uint32_t id, pqiNetAssistFirewall *fwAgent)
|
||||
void p3NetMgrIMPL::addNetAssistFirewall(uint32_t id, pqiNetAssistFirewall *fwAgent)
|
||||
{
|
||||
mFwAgents[id] = fwAgent;
|
||||
}
|
||||
|
||||
|
||||
bool p3NetMgr::enableNetAssistFirewall(bool on)
|
||||
bool p3NetMgrIMPL::enableNetAssistFirewall(bool on)
|
||||
{
|
||||
std::map<uint32_t, pqiNetAssistFirewall *>::iterator it;
|
||||
for(it = mFwAgents.begin(); it != mFwAgents.end(); it++)
|
||||
@ -1110,7 +1110,7 @@ bool p3NetMgr::enableNetAssistFirewall(bool on)
|
||||
}
|
||||
|
||||
|
||||
bool p3NetMgr::netAssistFirewallEnabled()
|
||||
bool p3NetMgrIMPL::netAssistFirewallEnabled()
|
||||
{
|
||||
std::map<uint32_t, pqiNetAssistFirewall *>::iterator it;
|
||||
for(it = mFwAgents.begin(); it != mFwAgents.end(); it++)
|
||||
@ -1123,7 +1123,7 @@ bool p3NetMgr::netAssistFirewallEnabled()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3NetMgr::netAssistFirewallActive()
|
||||
bool p3NetMgrIMPL::netAssistFirewallActive()
|
||||
{
|
||||
std::map<uint32_t, pqiNetAssistFirewall *>::iterator it;
|
||||
for(it = mFwAgents.begin(); it != mFwAgents.end(); it++)
|
||||
@ -1136,7 +1136,7 @@ bool p3NetMgr::netAssistFirewallActive()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3NetMgr::netAssistFirewallShutdown()
|
||||
bool p3NetMgrIMPL::netAssistFirewallShutdown()
|
||||
{
|
||||
std::map<uint32_t, pqiNetAssistFirewall *>::iterator it;
|
||||
for(it = mFwAgents.begin(); it != mFwAgents.end(); it++)
|
||||
@ -1146,7 +1146,7 @@ bool p3NetMgr::netAssistFirewallShutdown()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3NetMgr::netAssistFirewallPorts(uint16_t iport, uint16_t eport)
|
||||
bool p3NetMgrIMPL::netAssistFirewallPorts(uint16_t iport, uint16_t eport)
|
||||
{
|
||||
std::map<uint32_t, pqiNetAssistFirewall *>::iterator it;
|
||||
for(it = mFwAgents.begin(); it != mFwAgents.end(); it++)
|
||||
@ -1158,7 +1158,7 @@ bool p3NetMgr::netAssistFirewallPorts(uint16_t iport, uint16_t eport)
|
||||
}
|
||||
|
||||
|
||||
bool p3NetMgr::netAssistExtAddress(struct sockaddr_in &extAddr)
|
||||
bool p3NetMgrIMPL::netAssistExtAddress(struct sockaddr_in &extAddr)
|
||||
{
|
||||
std::map<uint32_t, pqiNetAssistFirewall *>::iterator it;
|
||||
for(it = mFwAgents.begin(); it != mFwAgents.end(); it++)
|
||||
@ -1175,16 +1175,16 @@ bool p3NetMgr::netAssistExtAddress(struct sockaddr_in &extAddr)
|
||||
}
|
||||
|
||||
|
||||
void p3NetMgr::addNetAssistConnect(uint32_t id, pqiNetAssistConnect *dht)
|
||||
void p3NetMgrIMPL::addNetAssistConnect(uint32_t id, pqiNetAssistConnect *dht)
|
||||
{
|
||||
mDhts[id] = dht;
|
||||
}
|
||||
|
||||
bool p3NetMgr::enableNetAssistConnect(bool on)
|
||||
bool p3NetMgrIMPL::enableNetAssistConnect(bool on)
|
||||
{
|
||||
|
||||
#ifdef NETMGR_DEBUG
|
||||
std::cerr << "p3NetMgr::enableNetAssistConnect(" << on << ")";
|
||||
std::cerr << "p3NetMgrIMPL::enableNetAssistConnect(" << on << ")";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -1196,7 +1196,7 @@ bool p3NetMgr::enableNetAssistConnect(bool on)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3NetMgr::netAssistConnectEnabled()
|
||||
bool p3NetMgrIMPL::netAssistConnectEnabled()
|
||||
{
|
||||
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
|
||||
for(it = mDhts.begin(); it != mDhts.end(); it++)
|
||||
@ -1204,7 +1204,7 @@ bool p3NetMgr::netAssistConnectEnabled()
|
||||
if ((it->second)->getEnabled())
|
||||
{
|
||||
#ifdef NETMGR_DEBUG
|
||||
std::cerr << "p3NetMgr::netAssistConnectEnabled() YES";
|
||||
std::cerr << "p3NetMgrIMPL::netAssistConnectEnabled() YES";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -1213,14 +1213,14 @@ bool p3NetMgr::netAssistConnectEnabled()
|
||||
}
|
||||
|
||||
#ifdef NETMGR_DEBUG
|
||||
std::cerr << "p3NetMgr::netAssistConnectEnabled() NO";
|
||||
std::cerr << "p3NetMgrIMPL::netAssistConnectEnabled() NO";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3NetMgr::netAssistConnectActive()
|
||||
bool p3NetMgrIMPL::netAssistConnectActive()
|
||||
{
|
||||
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
|
||||
for(it = mDhts.begin(); it != mDhts.end(); it++)
|
||||
@ -1229,7 +1229,7 @@ bool p3NetMgr::netAssistConnectActive()
|
||||
|
||||
{
|
||||
#ifdef NETMGR_DEBUG
|
||||
std::cerr << "p3NetMgr::netAssistConnectActive() ACTIVE";
|
||||
std::cerr << "p3NetMgrIMPL::netAssistConnectActive() ACTIVE";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -1238,14 +1238,14 @@ bool p3NetMgr::netAssistConnectActive()
|
||||
}
|
||||
|
||||
#ifdef NETMGR_DEBUG
|
||||
std::cerr << "p3NetMgr::netAssistConnectActive() INACTIVE";
|
||||
std::cerr << "p3NetMgrIMPL::netAssistConnectActive() INACTIVE";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3NetMgr::netAssistConnectStats(uint32_t &netsize, uint32_t &localnetsize)
|
||||
bool p3NetMgrIMPL::netAssistConnectStats(uint32_t &netsize, uint32_t &localnetsize)
|
||||
{
|
||||
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
|
||||
for(it = mDhts.begin(); it != mDhts.end(); it++)
|
||||
@ -1254,7 +1254,7 @@ bool p3NetMgr::netAssistConnectStats(uint32_t &netsize, uint32_t &localnetsize)
|
||||
|
||||
{
|
||||
#ifdef NETMGR_DEBUG
|
||||
std::cerr << "p3NetMgr::netAssistConnectStats(";
|
||||
std::cerr << "p3NetMgrIMPL::netAssistConnectStats(";
|
||||
std::cerr << netsize << ", " << localnetsize << ")";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -1264,17 +1264,17 @@ bool p3NetMgr::netAssistConnectStats(uint32_t &netsize, uint32_t &localnetsize)
|
||||
}
|
||||
|
||||
#ifdef NETMGR_DEBUG
|
||||
std::cerr << "p3NetMgr::netAssistConnectStats() INACTIVE";
|
||||
std::cerr << "p3NetMgrIMPL::netAssistConnectStats() INACTIVE";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3NetMgr::netAssistConnectShutdown()
|
||||
bool p3NetMgrIMPL::netAssistConnectShutdown()
|
||||
{
|
||||
#ifdef NETMGR_DEBUG
|
||||
std::cerr << "p3NetMgr::netAssistConnectShutdown()";
|
||||
std::cerr << "p3NetMgrIMPL::netAssistConnectShutdown()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -1286,12 +1286,12 @@ bool p3NetMgr::netAssistConnectShutdown()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3NetMgr::netAssistFriend(std::string id, bool on)
|
||||
bool p3NetMgrIMPL::netAssistFriend(std::string id, bool on)
|
||||
{
|
||||
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
|
||||
|
||||
#ifdef NETMGR_DEBUG
|
||||
std::cerr << "p3NetMgr::netAssistFriend(" << id << ", " << on << ")";
|
||||
std::cerr << "p3NetMgrIMPL::netAssistFriend(" << id << ", " << on << ")";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -1306,7 +1306,7 @@ bool p3NetMgr::netAssistFriend(std::string id, bool on)
|
||||
}
|
||||
|
||||
|
||||
bool p3NetMgr::netAssistSetAddress( struct sockaddr_in &laddr,
|
||||
bool p3NetMgrIMPL::netAssistSetAddress( struct sockaddr_in &laddr,
|
||||
struct sockaddr_in &eaddr,
|
||||
uint32_t mode)
|
||||
{
|
||||
@ -1320,7 +1320,7 @@ bool p3NetMgr::netAssistSetAddress( struct sockaddr_in &laddr,
|
||||
return true;
|
||||
}
|
||||
|
||||
void p3NetMgr::netAssistConnectTick()
|
||||
void p3NetMgrIMPL::netAssistConnectTick()
|
||||
{
|
||||
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
|
||||
for(it = mDhts.begin(); it != mDhts.end(); it++)
|
||||
@ -1338,23 +1338,23 @@ void p3NetMgr::netAssistConnectTick()
|
||||
**********************************************************************
|
||||
**********************************************************************/
|
||||
|
||||
bool p3NetMgr::getUPnPState()
|
||||
bool p3NetMgrIMPL::getUPnPState()
|
||||
{
|
||||
return netAssistFirewallActive();
|
||||
}
|
||||
|
||||
bool p3NetMgr::getUPnPEnabled()
|
||||
bool p3NetMgrIMPL::getUPnPEnabled()
|
||||
{
|
||||
return netAssistFirewallEnabled();
|
||||
}
|
||||
|
||||
bool p3NetMgr::getDHTEnabled()
|
||||
bool p3NetMgrIMPL::getDHTEnabled()
|
||||
{
|
||||
return netAssistConnectEnabled();
|
||||
}
|
||||
|
||||
|
||||
void p3NetMgr::getNetStatus(pqiNetStatus &status)
|
||||
void p3NetMgrIMPL::getNetStatus(pqiNetStatus &status)
|
||||
{
|
||||
/* cannot lock local stack, then call DHT... as this can cause lock up */
|
||||
/* must extract data... then update mNetFlags */
|
||||
@ -1385,18 +1385,18 @@ void p3NetMgr::getNetStatus(pqiNetStatus &status)
|
||||
************************************** ExtAddrFinder *****************************************
|
||||
**********************************************************************************************/
|
||||
|
||||
bool p3NetMgr::getIPServersEnabled()
|
||||
bool p3NetMgrIMPL::getIPServersEnabled()
|
||||
{
|
||||
RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/
|
||||
return mUseExtAddrFinder;
|
||||
}
|
||||
|
||||
void p3NetMgr::getIPServersList(std::list<std::string>& ip_servers)
|
||||
void p3NetMgrIMPL::getIPServersList(std::list<std::string>& ip_servers)
|
||||
{
|
||||
mExtAddrFinder->getIPServersList(ip_servers);
|
||||
}
|
||||
|
||||
void p3NetMgr::setIPServersEnabled(bool b)
|
||||
void p3NetMgrIMPL::setIPServersEnabled(bool b)
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/
|
||||
@ -1415,31 +1415,31 @@ void p3NetMgr::setIPServersEnabled(bool b)
|
||||
************************************** NetStateBox ******************************************
|
||||
**********************************************************************************************/
|
||||
|
||||
uint32_t p3NetMgr::getNetStateMode()
|
||||
uint32_t p3NetMgrIMPL::getNetStateMode()
|
||||
{
|
||||
RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/
|
||||
return mNetStateBox.getNetStateMode();
|
||||
}
|
||||
|
||||
uint32_t p3NetMgr::getNetworkMode()
|
||||
uint32_t p3NetMgrIMPL::getNetworkMode()
|
||||
{
|
||||
RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/
|
||||
return mNetStateBox.getNetworkMode();
|
||||
}
|
||||
|
||||
uint32_t p3NetMgr::getNatTypeMode()
|
||||
uint32_t p3NetMgrIMPL::getNatTypeMode()
|
||||
{
|
||||
RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/
|
||||
return mNetStateBox.getNatTypeMode();
|
||||
}
|
||||
|
||||
uint32_t p3NetMgr::getNatHoleMode()
|
||||
uint32_t p3NetMgrIMPL::getNatHoleMode()
|
||||
{
|
||||
RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/
|
||||
return mNetStateBox.getNatHoleMode();
|
||||
}
|
||||
|
||||
uint32_t p3NetMgr::getConnectModes()
|
||||
uint32_t p3NetMgrIMPL::getConnectModes()
|
||||
{
|
||||
RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/
|
||||
return mNetStateBox.getConnectModes();
|
||||
@ -1447,10 +1447,10 @@ uint32_t p3NetMgr::getConnectModes()
|
||||
|
||||
|
||||
/* These are the regular updates from Dht / Stunners */
|
||||
void p3NetMgr::updateNetStateBox_temporal()
|
||||
void p3NetMgrIMPL::updateNetStateBox_temporal()
|
||||
{
|
||||
#ifdef NETMGR_DEBUG_STATEBOX
|
||||
std::cerr << "p3NetMgr::updateNetStateBox_temporal() ";
|
||||
std::cerr << "p3NetMgrIMPL::updateNetStateBox_temporal() ";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -1468,7 +1468,7 @@ void p3NetMgr::updateNetStateBox_temporal()
|
||||
mNetStateBox.setAddressStunDht(&tmpaddr, isstable);
|
||||
|
||||
#ifdef NETMGR_DEBUG_STATEBOX
|
||||
std::cerr << "p3NetMgr::updateNetStateBox_temporal() DhtStunner: ";
|
||||
std::cerr << "p3NetMgrIMPL::updateNetStateBox_temporal() DhtStunner: ";
|
||||
std::cerr << rs_inet_ntoa(tmpaddr.sin_addr) << ":" << htons(tmpaddr.sin_port);
|
||||
std::cerr << " Stable: " << (uint32_t) isstable;
|
||||
std::cerr << std::endl;
|
||||
@ -1487,7 +1487,7 @@ void p3NetMgr::updateNetStateBox_temporal()
|
||||
mNetStateBox.setAddressStunProxy(&tmpaddr, isstable);
|
||||
|
||||
#ifdef NETMGR_DEBUG_STATEBOX
|
||||
std::cerr << "p3NetMgr::updateNetStateBox_temporal() ProxyStunner: ";
|
||||
std::cerr << "p3NetMgrIMPL::updateNetStateBox_temporal() ProxyStunner: ";
|
||||
std::cerr << rs_inet_ntoa(tmpaddr.sin_addr) << ":" << htons(tmpaddr.sin_port);
|
||||
std::cerr << " Stable: " << (uint32_t) isstable;
|
||||
std::cerr << std::endl;
|
||||
@ -1525,7 +1525,7 @@ void p3NetMgr::updateNetStateBox_temporal()
|
||||
std::string netmodestr = NetStateNetworkModeString(netMode);
|
||||
|
||||
#ifdef NETMGR_DEBUG_STATEBOX
|
||||
std::cerr << "p3NetMgr::updateNetStateBox_temporal() NetStateBox Thinking";
|
||||
std::cerr << "p3NetMgrIMPL::updateNetStateBox_temporal() NetStateBox Thinking";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "\tNetState: " << netstatestr;
|
||||
std::cerr << std::endl;
|
||||
@ -1549,7 +1549,7 @@ void p3NetMgr::updateNetStateBox_temporal()
|
||||
#define NET_STUNNER_PERIOD_FAST (-1) // default of Stunner.
|
||||
#define NET_STUNNER_PERIOD_SLOW (180) // 3 minutes.
|
||||
|
||||
void p3NetMgr::updateNatSetting()
|
||||
void p3NetMgrIMPL::updateNatSetting()
|
||||
{
|
||||
bool updateRefreshRate = false;
|
||||
uint32_t natType = RSNET_NATTYPE_UNKNOWN;
|
||||
@ -1566,7 +1566,7 @@ void p3NetMgr::updateNatSetting()
|
||||
updateRefreshRate = true;
|
||||
|
||||
#ifdef NETMGR_DEBUG_STATEBOX
|
||||
std::cerr << "p3NetMgr::updateNetStateBox_temporal() NatType Change!";
|
||||
std::cerr << "p3NetMgrIMPL::updateNetStateBox_temporal() NatType Change!";
|
||||
std::cerr << "\tNatType: " << NetStateNatTypeString(natType);
|
||||
std::cerr << "\tNatHole: " << NetStateNatHoleString(natHole);
|
||||
|
||||
@ -1582,7 +1582,7 @@ void p3NetMgr::updateNatSetting()
|
||||
if (updateRefreshRate)
|
||||
{
|
||||
#ifdef NETMGR_DEBUG_STATEBOX
|
||||
std::cerr << "p3NetMgr::updateNetStateBox_temporal() Updating Refresh Rate, based on changed NatType";
|
||||
std::cerr << "p3NetMgrIMPL::updateNetStateBox_temporal() Updating Refresh Rate, based on changed NatType";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -1615,10 +1615,10 @@ void p3NetMgr::updateNatSetting()
|
||||
|
||||
|
||||
|
||||
void p3NetMgr::updateNetStateBox_startup()
|
||||
void p3NetMgrIMPL::updateNetStateBox_startup()
|
||||
{
|
||||
#ifdef NETMGR_DEBUG_STATEBOX
|
||||
std::cerr << "p3NetMgr::updateNetStateBox_startup() ";
|
||||
std::cerr << "p3NetMgrIMPL::updateNetStateBox_startup() ";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
@ -1632,7 +1632,7 @@ void p3NetMgr::updateNetStateBox_startup()
|
||||
{
|
||||
|
||||
#ifdef NETMGR_DEBUG_STATEBOX
|
||||
std::cerr << "p3NetMgr::updateNetStateBox_startup() ";
|
||||
std::cerr << "p3NetMgrIMPL::updateNetStateBox_startup() ";
|
||||
std::cerr << "Ext supplied from netAssistExternalAddress()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -1640,7 +1640,7 @@ void p3NetMgr::updateNetStateBox_startup()
|
||||
if (isValidNet(&(tmpip.sin_addr)))
|
||||
{
|
||||
#ifdef NETMGR_DEBUG_STATEBOX
|
||||
std::cerr << "p3NetMgr::updateNetStateBox_startup() ";
|
||||
std::cerr << "p3NetMgrIMPL::updateNetStateBox_startup() ";
|
||||
std::cerr << "netAssist Returned: " << rs_inet_ntoa(tmpip.sin_addr);
|
||||
std::cerr << ":" << ntohs(tmpip.sin_port);
|
||||
std::cerr << std::endl;
|
||||
@ -1651,7 +1651,7 @@ void p3NetMgr::updateNetStateBox_startup()
|
||||
{
|
||||
mNetStateBox.setAddressUPnP(false, &tmpip);
|
||||
#ifdef NETMGR_DEBUG_STATEBOX
|
||||
std::cerr << "p3NetMgr::updateNetStateBox_startup() ";
|
||||
std::cerr << "p3NetMgrIMPL::updateNetStateBox_startup() ";
|
||||
std::cerr << "ERROR Bad Address supplied from netAssistExternalAddress()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -1660,7 +1660,7 @@ void p3NetMgr::updateNetStateBox_startup()
|
||||
else
|
||||
{
|
||||
#ifdef NETMGR_DEBUG_STATEBOX
|
||||
std::cerr << "p3NetMgr::updateNetStateBox_startup() ";
|
||||
std::cerr << "p3NetMgrIMPL::updateNetStateBox_startup() ";
|
||||
std::cerr << " netAssistExtAddress() is not active";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -1678,7 +1678,7 @@ void p3NetMgr::updateNetStateBox_startup()
|
||||
tmpip.sin_port = mNetFlags.mLocalAddr.sin_port;
|
||||
|
||||
#ifdef NETMGR_DEBUG_STATEBOX
|
||||
std::cerr << "p3NetMgr::updateNetStateBox_startup() ";
|
||||
std::cerr << "p3NetMgrIMPL::updateNetStateBox_startup() ";
|
||||
std::cerr << "ExtAddrFinder Returned: " << rs_inet_ntoa(tmpip.sin_addr);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -1689,7 +1689,7 @@ void p3NetMgr::updateNetStateBox_startup()
|
||||
{
|
||||
mNetStateBox.setAddressWebIP(false, &tmpip);
|
||||
#ifdef NETMGR_DEBUG_STATEBOX
|
||||
std::cerr << "p3NetMgr::updateNetStateBox_startup() ";
|
||||
std::cerr << "p3NetMgrIMPL::updateNetStateBox_startup() ";
|
||||
std::cerr << " ExtAddrFinder hasn't found an address yet";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -1698,7 +1698,7 @@ void p3NetMgr::updateNetStateBox_startup()
|
||||
else
|
||||
{
|
||||
#ifdef NETMGR_DEBUG_STATEBOX
|
||||
std::cerr << "p3NetMgr::updateNetStateBox_startup() ";
|
||||
std::cerr << "p3NetMgrIMPL::updateNetStateBox_startup() ";
|
||||
std::cerr << " ExtAddrFinder is not active";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -1707,7 +1707,7 @@ void p3NetMgr::updateNetStateBox_startup()
|
||||
}
|
||||
}
|
||||
|
||||
void p3NetMgr::updateNetStateBox_reset()
|
||||
void p3NetMgrIMPL::updateNetStateBox_reset()
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
@ -84,23 +84,128 @@ class pqiNetStatus
|
||||
class p3PeerMgr;
|
||||
class p3LinkMgr;
|
||||
|
||||
class p3PeerMgrIMPL;
|
||||
class p3LinkMgrIMPL;
|
||||
|
||||
class rsUdpStack;
|
||||
class UdpStunner;
|
||||
class p3BitDht;
|
||||
class UdpRelayReceiver;
|
||||
|
||||
|
||||
|
||||
/**********
|
||||
* p3NetMgr Interface....
|
||||
* This allows a drop-in replacement for testing.
|
||||
*/
|
||||
|
||||
class p3NetMgr
|
||||
{
|
||||
public:
|
||||
|
||||
p3NetMgr();
|
||||
p3NetMgr() { return; }
|
||||
virtual ~p3NetMgr() { return; }
|
||||
|
||||
void setManagers(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr);
|
||||
|
||||
/*************** External Control ****************/
|
||||
|
||||
// Setup Network State.
|
||||
virtual bool setNetworkMode(uint32_t netMode) = 0;
|
||||
virtual bool setVisState(uint32_t visState) = 0;
|
||||
|
||||
// Switch DHT On/Off.
|
||||
virtual bool netAssistFriend(std::string id, bool on) = 0;
|
||||
|
||||
/* Get Network State */
|
||||
virtual uint32_t getNetStateMode() = 0;
|
||||
virtual uint32_t getNetworkMode() = 0;
|
||||
virtual uint32_t getNatTypeMode() = 0;
|
||||
virtual uint32_t getNatHoleMode() = 0;
|
||||
virtual uint32_t getConnectModes() = 0;
|
||||
|
||||
/* Shut It Down! */
|
||||
virtual bool shutdown() = 0; /* blocking shutdown call */
|
||||
|
||||
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
|
||||
|
||||
// THESE SHOULD BE MOVED TO p3PeerMgr (as it controls the config).
|
||||
// The functional object should be transformed into a NetAssistFirewall object.
|
||||
// ONLY USED by p3peers.cc & p3peermgr.cc
|
||||
virtual bool getIPServersEnabled() = 0;
|
||||
virtual void setIPServersEnabled(bool b) = 0;
|
||||
virtual void getIPServersList(std::list<std::string>& ip_servers) = 0;
|
||||
|
||||
// ONLY USED by p3face-config.cc WHICH WILL BE REMOVED.
|
||||
virtual void getNetStatus(pqiNetStatus &status) = 0;
|
||||
virtual bool getUPnPState() = 0;
|
||||
virtual bool getUPnPEnabled() = 0;
|
||||
virtual bool getDHTEnabled() = 0;
|
||||
|
||||
|
||||
/************************************************************************************************/
|
||||
/************************************************************************************************/
|
||||
/************************************************************************************************/
|
||||
/************************************************************************************************/
|
||||
|
||||
};
|
||||
|
||||
|
||||
class p3NetMgrIMPL: public p3NetMgr
|
||||
{
|
||||
public:
|
||||
|
||||
p3NetMgrIMPL();
|
||||
|
||||
/************************************************************************************************/
|
||||
/* EXTERNAL INTERFACE */
|
||||
/************************************************************************************************/
|
||||
|
||||
/*************** External Control ****************/
|
||||
|
||||
// Setup Network State.
|
||||
virtual bool setNetworkMode(uint32_t netMode);
|
||||
virtual bool setVisState(uint32_t visState);
|
||||
|
||||
// Switch DHT On/Off.
|
||||
virtual bool netAssistFriend(std::string id, bool on);
|
||||
|
||||
/* Get Network State */
|
||||
virtual uint32_t getNetStateMode();
|
||||
virtual uint32_t getNetworkMode();
|
||||
virtual uint32_t getNatTypeMode();
|
||||
virtual uint32_t getNatHoleMode();
|
||||
virtual uint32_t getConnectModes();
|
||||
|
||||
/* Shut It Down! */
|
||||
virtual bool shutdown(); /* blocking shutdown call */
|
||||
|
||||
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
|
||||
|
||||
// THESE SHOULD BE MOVED TO p3PeerMgr (as it controls the config).
|
||||
// The functional object should be transformed into a NetAssistFirewall object.
|
||||
// ONLY USED by p3peers.cc & p3peermgr.cc
|
||||
virtual bool getIPServersEnabled();
|
||||
virtual void setIPServersEnabled(bool b);
|
||||
virtual void getIPServersList(std::list<std::string>& ip_servers);
|
||||
|
||||
// ONLY USED by p3face-config.cc WHICH WILL BE REMOVED.
|
||||
virtual void getNetStatus(pqiNetStatus &status);
|
||||
virtual bool getUPnPState();
|
||||
virtual bool getUPnPEnabled();
|
||||
virtual bool getDHTEnabled();
|
||||
|
||||
/************************************************************************************************/
|
||||
/* Extra IMPL Functions (used by p3PeerMgr, p3NetMgr + Setup) */
|
||||
/************************************************************************************************/
|
||||
|
||||
void setManagers(p3PeerMgrIMPL *peerMgr, p3LinkMgrIMPL *linkMgr);
|
||||
void setAddrAssist(pqiAddrAssist *dhtStun, pqiAddrAssist *proxyStun);
|
||||
|
||||
void tick();
|
||||
void slowTick();
|
||||
|
||||
// THESE MIGHT BE ADDED TO INTERFACE.
|
||||
bool setLocalAddress(struct sockaddr_in addr);
|
||||
bool setExtAddress(struct sockaddr_in addr);
|
||||
|
||||
/*************** Setup ***************************/
|
||||
void addNetAssistConnect(uint32_t type, pqiNetAssistConnect *);
|
||||
@ -108,65 +213,41 @@ void addNetAssistFirewall(uint32_t type, pqiNetAssistFirewall *);
|
||||
|
||||
void addNetListener(pqiNetListener *listener);
|
||||
|
||||
// SHOULD MAKE THIS PROTECTED.
|
||||
bool checkNetAddress(); /* check our address is sensible */
|
||||
|
||||
/*************** External Control ****************/
|
||||
bool shutdown(); /* blocking shutdown call */
|
||||
|
||||
/* a nice simple network configuration */
|
||||
uint32_t getNetStateMode();
|
||||
uint32_t getNetworkMode();
|
||||
uint32_t getNatTypeMode();
|
||||
uint32_t getNatHoleMode();
|
||||
uint32_t getConnectModes();
|
||||
protected:
|
||||
|
||||
void slowTick();
|
||||
|
||||
/* THESE FUNCTIONS ARE ON_LONGER EXTERNAL - CAN THEY BE REMOVED? */
|
||||
//bool getDHTStats(uint32_t &netsize, uint32_t &localnetsize);
|
||||
|
||||
//bool getNetStatusLocalOk();
|
||||
//bool getNetStatusUpnpOk();
|
||||
//bool getNetStatusDhtOk();
|
||||
//bool getNetStatusStunOk();
|
||||
//bool getNetStatusExtraAddressCheckOk();
|
||||
|
||||
bool getUPnPState();
|
||||
bool getUPnPEnabled();
|
||||
bool getDHTEnabled();
|
||||
bool getDHTStats(uint32_t &netsize, uint32_t &localnetsize);
|
||||
//bool getUpnpExtAddress(struct sockaddr_in &addr);
|
||||
//bool getExtFinderAddress(struct sockaddr_in &addr);
|
||||
|
||||
bool getIPServersEnabled();
|
||||
void setIPServersEnabled(bool b) ;
|
||||
void getIPServersList(std::list<std::string>& ip_servers) ;
|
||||
//void setOwnNetConfig(uint32_t netMode, uint32_t visState);
|
||||
|
||||
bool getNetStatusLocalOk();
|
||||
bool getNetStatusUpnpOk();
|
||||
bool getNetStatusDhtOk();
|
||||
bool getNetStatusStunOk();
|
||||
bool getNetStatusExtraAddressCheckOk();
|
||||
|
||||
bool getUpnpExtAddress(struct sockaddr_in &addr);
|
||||
bool getExtFinderAddress(struct sockaddr_in &addr);
|
||||
void getNetStatus(pqiNetStatus &status);
|
||||
|
||||
void setOwnNetConfig(uint32_t netMode, uint32_t visState);
|
||||
bool setLocalAddress(struct sockaddr_in addr);
|
||||
bool setExtAddress(struct sockaddr_in addr);
|
||||
bool setNetworkMode(uint32_t netMode);
|
||||
bool setVisState(uint32_t visState);
|
||||
|
||||
|
||||
virtual bool netAssistFriend(std::string id, bool on);
|
||||
|
||||
/*************** External Control ****************/
|
||||
|
||||
/* access to network details (called through Monitor) */
|
||||
|
||||
protected:
|
||||
/****************** Internal Interface *******************/
|
||||
virtual bool enableNetAssistFirewall(bool on);
|
||||
virtual bool netAssistFirewallEnabled();
|
||||
virtual bool netAssistFirewallActive();
|
||||
virtual bool netAssistFirewallShutdown();
|
||||
bool enableNetAssistFirewall(bool on);
|
||||
bool netAssistFirewallEnabled();
|
||||
bool netAssistFirewallActive();
|
||||
bool netAssistFirewallShutdown();
|
||||
|
||||
virtual bool enableNetAssistConnect(bool on);
|
||||
virtual bool netAssistConnectEnabled();
|
||||
virtual bool netAssistConnectActive();
|
||||
virtual bool netAssistConnectShutdown();
|
||||
virtual bool netAssistConnectStats(uint32_t &netsize, uint32_t &localnetsize);
|
||||
bool enableNetAssistConnect(bool on);
|
||||
bool netAssistConnectEnabled();
|
||||
bool netAssistConnectActive();
|
||||
bool netAssistConnectShutdown();
|
||||
bool netAssistConnectStats(uint32_t &netsize, uint32_t &localnetsize);
|
||||
void netAssistConnectTick();
|
||||
|
||||
/* Assist Firewall */
|
||||
@ -174,8 +255,8 @@ bool netAssistExtAddress(struct sockaddr_in &extAddr);
|
||||
bool netAssistFirewallPorts(uint16_t iport, uint16_t eport);
|
||||
|
||||
/* Assist Connect */
|
||||
//virtual bool netAssistFriend(std::string id, bool on);
|
||||
virtual bool netAssistSetAddress( struct sockaddr_in &laddr,
|
||||
//virtual bool netAssistFriend(std::string id, bool on); (PUBLIC)
|
||||
bool netAssistSetAddress( struct sockaddr_in &laddr,
|
||||
struct sockaddr_in &eaddr,
|
||||
uint32_t mode);
|
||||
|
||||
@ -221,8 +302,8 @@ private:
|
||||
|
||||
std::list<pqiNetListener *> mNetListeners;
|
||||
|
||||
p3PeerMgr *mPeerMgr;
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3PeerMgrIMPL *mPeerMgr;
|
||||
p3LinkMgrIMPL *mLinkMgr;
|
||||
|
||||
//p3BitDht *mBitDht;
|
||||
pqiAddrAssist *mDhtStunner;
|
||||
|
@ -97,7 +97,7 @@ std::string textPeerConnectState(peerState &state)
|
||||
}
|
||||
|
||||
|
||||
p3PeerMgr::p3PeerMgr()
|
||||
p3PeerMgrIMPL::p3PeerMgrIMPL()
|
||||
:p3Config(CONFIG_TYPE_PEERS), mPeerMtx("p3PeerMgr"), mStatusChanged(false)
|
||||
{
|
||||
|
||||
@ -126,19 +126,19 @@ p3PeerMgr::p3PeerMgr()
|
||||
return;
|
||||
}
|
||||
|
||||
void p3PeerMgr::setManagers(p3LinkMgr *linkMgr, p3NetMgr *netMgr)
|
||||
void p3PeerMgrIMPL::setManagers(p3LinkMgrIMPL *linkMgr, p3NetMgrIMPL *netMgr)
|
||||
{
|
||||
mLinkMgr = linkMgr;
|
||||
mNetMgr = netMgr;
|
||||
}
|
||||
|
||||
void p3PeerMgr::setOwnNetworkMode(uint32_t netMode)
|
||||
void p3PeerMgrIMPL::setOwnNetworkMode(uint32_t netMode)
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::setOwnNetworkMode() :";
|
||||
std::cerr << "p3PeerMgrIMPL::setOwnNetworkMode() :";
|
||||
std::cerr << " Existing netMode: " << mOwnState.netMode;
|
||||
std::cerr << " Input netMode: " << netMode;
|
||||
std::cerr << std::endl;
|
||||
@ -153,13 +153,13 @@ void p3PeerMgr::setOwnNetworkMode(uint32_t netMode)
|
||||
mNetMgr->setNetworkMode((netMode & RS_NET_MODE_ACTUAL));
|
||||
}
|
||||
|
||||
void p3PeerMgr::setOwnVisState(uint32_t visState)
|
||||
void p3PeerMgrIMPL::setOwnVisState(uint32_t visState)
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::setOwnVisState()";
|
||||
std::cerr << "p3PeerMgrIMPL::setOwnVisState()";
|
||||
std::cerr << "Existing vis: " << mOwnState.visState;
|
||||
std::cerr << "Input vis: " << visState;
|
||||
std::cerr << std::endl;
|
||||
@ -175,8 +175,7 @@ void p3PeerMgr::setOwnVisState(uint32_t visState)
|
||||
}
|
||||
|
||||
|
||||
|
||||
void p3PeerMgr::tick()
|
||||
void p3PeerMgrIMPL::tick()
|
||||
{
|
||||
|
||||
static time_t last_friends_check = time(NULL) ;
|
||||
@ -186,7 +185,7 @@ void p3PeerMgr::tick()
|
||||
|
||||
if(now > last_friends_check + INTERVAL_BETWEEN_LOCATION_CLEANING && rsPeers != NULL)
|
||||
{
|
||||
std::cerr << "p3PeerMgr::tick(): cleaning unused locations." << std::endl ;
|
||||
std::cerr << "p3PeerMgrIMPL::tick(): cleaning unused locations." << std::endl ;
|
||||
|
||||
rsPeers->cleanUnusedLocations() ;
|
||||
last_friends_check = now ;
|
||||
@ -199,35 +198,34 @@ void p3PeerMgr::tick()
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const std::string p3PeerMgr::getOwnId()
|
||||
const std::string p3PeerMgrIMPL::getOwnId()
|
||||
{
|
||||
return AuthSSL::getAuthSSL()->OwnId();
|
||||
}
|
||||
|
||||
|
||||
bool p3PeerMgr::getOwnNetStatus(peerState &state)
|
||||
bool p3PeerMgrIMPL::getOwnNetStatus(peerState &state)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
state = mOwnState;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3PeerMgr::isFriend(const std::string &id)
|
||||
bool p3PeerMgrIMPL::isFriend(const std::string &id)
|
||||
{
|
||||
#ifdef PEER_DEBUG_COMMON
|
||||
std::cerr << "p3PeerMgr::isFriend(" << id << ") called" << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::isFriend(" << id << ") called" << std::endl;
|
||||
#endif
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
bool ret = (mFriendList.end() != mFriendList.find(id));
|
||||
#ifdef PEER_DEBUG_COMMON
|
||||
std::cerr << "p3PeerMgr::isFriend(" << id << ") returning : " << ret << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::isFriend(" << id << ") returning : " << ret << std::endl;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool p3PeerMgr::getFriendNetStatus(const std::string &id, peerState &state)
|
||||
bool p3PeerMgrIMPL::getFriendNetStatus(const std::string &id, peerState &state)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
@ -244,7 +242,7 @@ bool p3PeerMgr::getFriendNetStatus(const std::string &id, peerState &state)
|
||||
}
|
||||
|
||||
|
||||
bool p3PeerMgr::getOthersNetStatus(const std::string &id, peerState &state)
|
||||
bool p3PeerMgrIMPL::getOthersNetStatus(const std::string &id, peerState &state)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
@ -260,8 +258,9 @@ bool p3PeerMgr::getOthersNetStatus(const std::string &id, peerState &state)
|
||||
return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
void p3PeerMgr::getFriendList(std::list<std::string> &peers)
|
||||
void p3PeerMgrIMPL::getFriendList(std::list<std::string> &peers)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
@ -274,9 +273,10 @@ void p3PeerMgr::getFriendList(std::list<std::string> &peers)
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
void p3PeerMgr::getOthersList(std::list<std::string> &peers)
|
||||
void p3PeerMgrIMPL::getOthersList(std::list<std::string> &peers)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
@ -292,7 +292,7 @@ void p3PeerMgr::getOthersList(std::list<std::string> &peers)
|
||||
|
||||
|
||||
|
||||
int p3PeerMgr::getConnectAddresses(const std::string &id,
|
||||
int p3PeerMgrIMPL::getConnectAddresses(const std::string &id,
|
||||
struct sockaddr_in &lAddr, struct sockaddr_in &eAddr,
|
||||
pqiIpAddrSet &histAddrs, std::string &dyndns)
|
||||
{
|
||||
@ -305,7 +305,7 @@ int p3PeerMgr::getConnectAddresses(const std::string &id,
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
/* ERROR */
|
||||
std::cerr << "p3PeerMgr::getConnectAddresses() ERROR unknown Peer";
|
||||
std::cerr << "p3PeerMgrIMPL::getConnectAddresses() ERROR unknown Peer";
|
||||
std::cerr << std::endl;
|
||||
return 0;
|
||||
}
|
||||
@ -320,7 +320,7 @@ int p3PeerMgr::getConnectAddresses(const std::string &id,
|
||||
|
||||
|
||||
|
||||
bool p3PeerMgr::haveOnceConnected()
|
||||
bool p3PeerMgrIMPL::haveOnceConnected()
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
@ -331,7 +331,7 @@ bool p3PeerMgr::haveOnceConnected()
|
||||
if (it->second.lastcontact > 0)
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::haveOnceConnected() lastcontact: ";
|
||||
std::cerr << "p3PeerMgrIMPL::haveOnceConnected() lastcontact: ";
|
||||
std::cerr << time(NULL) - it->second.lastcontact << " for id: " << it->first;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -341,7 +341,7 @@ bool p3PeerMgr::haveOnceConnected()
|
||||
}
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::haveOnceConnected() all Last Contacts = 0";
|
||||
std::cerr << "p3PeerMgrIMPL::haveOnceConnected() all Last Contacts = 0";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -353,7 +353,7 @@ bool p3PeerMgr::haveOnceConnected()
|
||||
/*******************************************************************/
|
||||
/*******************************************************************/
|
||||
|
||||
bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint32_t netMode, uint32_t visState, time_t lastContact)
|
||||
bool p3PeerMgrIMPL::addFriend(const std::string &id, const std::string &gpg_id, uint32_t netMode, uint32_t visState, time_t lastContact)
|
||||
{
|
||||
bool notifyLinkMgr = false;
|
||||
{
|
||||
@ -362,7 +362,7 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint
|
||||
|
||||
if (id == AuthSSL::getAuthSSL()->OwnId()) {
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::addFriend() cannot add own id as a friend." << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::addFriend() cannot add own id as a friend." << std::endl;
|
||||
#endif
|
||||
/* (1) already exists */
|
||||
return false;
|
||||
@ -374,14 +374,14 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint
|
||||
*/
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::addFriend() " << id << "; gpg_id : " << gpg_id << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::addFriend() " << id << "; gpg_id : " << gpg_id << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::string, peerState>::iterator it;
|
||||
if (mFriendList.end() != mFriendList.find(id))
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::addFriend() Already Exists" << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::addFriend() Already Exists" << std::endl;
|
||||
#endif
|
||||
/* (1) already exists */
|
||||
return true;
|
||||
@ -392,7 +392,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())
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::addFriend() gpg is not accepted" << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::addFriend() gpg is not accepted" << std::endl;
|
||||
#endif
|
||||
/* no auth */
|
||||
return false;
|
||||
@ -404,7 +404,7 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint
|
||||
{
|
||||
/* (2) in mOthersList -> move over */
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::addFriend() Move from Others" << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::addFriend() Move from Others" << std::endl;
|
||||
#endif
|
||||
|
||||
mFriendList[id] = it->second;
|
||||
@ -426,7 +426,7 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint
|
||||
else
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::addFriend() Creating New Entry" << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::addFriend() Creating New Entry" << std::endl;
|
||||
#endif
|
||||
|
||||
/* create a new entry */
|
||||
@ -466,12 +466,12 @@ bool p3PeerMgr::addFriend(const std::string &id, const std::string &gpg_id, uint
|
||||
}
|
||||
|
||||
|
||||
bool p3PeerMgr::removeFriend(const std::string &id)
|
||||
bool p3PeerMgrIMPL::removeFriend(const std::string &id)
|
||||
{
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::removeFriend() for id : " << id << std::endl;
|
||||
std::cerr << "p3PeerMgr::removeFriend() mFriendList.size() : " << mFriendList.size() << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::removeFriend() for id : " << id << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::removeFriend() mFriendList.size() : " << mFriendList.size() << std::endl;
|
||||
#endif
|
||||
|
||||
std::list<std::string> toRemove; // This is a list of SSLIds.
|
||||
@ -487,7 +487,7 @@ bool p3PeerMgr::removeFriend(const std::string &id)
|
||||
{
|
||||
if (it->second.id == id || it->second.gpg_id == id) {
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::removeFriend() friend found in the list." << id << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::removeFriend() friend found in the list." << id << std::endl;
|
||||
#endif
|
||||
peerState peer = it->second;
|
||||
|
||||
@ -510,7 +510,7 @@ bool p3PeerMgr::removeFriend(const std::string &id)
|
||||
}
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::removeFriend() new mFriendList.size() : " << mFriendList.size() << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::removeFriend() new mFriendList.size() : " << mFriendList.size() << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -537,12 +537,12 @@ bool p3PeerMgr::removeFriend(const std::string &id)
|
||||
}
|
||||
|
||||
|
||||
void p3PeerMgr::printPeerLists(std::ostream &out)
|
||||
void p3PeerMgrIMPL::printPeerLists(std::ostream &out)
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
out << "p3PeerMgr::printPeerLists() Friend List";
|
||||
out << "p3PeerMgrIMPL::printPeerLists() Friend List";
|
||||
out << std::endl;
|
||||
|
||||
|
||||
@ -554,7 +554,7 @@ void p3PeerMgr::printPeerLists(std::ostream &out)
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
out << "p3PeerMgr::printPeerLists() Others List";
|
||||
out << "p3PeerMgrIMPL::printPeerLists() Others List";
|
||||
out << std::endl;
|
||||
for(it = mOthersList.begin(); it != mOthersList.end(); it++)
|
||||
{
|
||||
@ -570,11 +570,11 @@ void p3PeerMgr::printPeerLists(std::ostream &out)
|
||||
|
||||
|
||||
#if 0
|
||||
bool p3PeerMgr::addNeighbour(std::string id)
|
||||
bool p3PeerMgrIMPL::addNeighbour(std::string id)
|
||||
{
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::addNeighbour() not implemented anymore." << id << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::addNeighbour() not implemented anymore." << id << std::endl;
|
||||
#endif
|
||||
|
||||
/* so three possibilities
|
||||
@ -643,7 +643,7 @@ bool p3PeerMgr::addNeighbour(std::string id)
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
bool p3PeerMgr::setLocalAddress(const std::string &id, struct sockaddr_in addr)
|
||||
bool p3PeerMgrIMPL::setLocalAddress(const std::string &id, struct sockaddr_in addr)
|
||||
{
|
||||
if (id == AuthSSL::getAuthSSL()->OwnId())
|
||||
{
|
||||
@ -677,7 +677,7 @@ bool p3PeerMgr::setLocalAddress(const std::string &id, struct sockaddr_in add
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::setLocalAddress() cannot add addres info : peer id not found in friend list id: " << id << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres info : peer id not found in friend list id: " << id << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -699,7 +699,7 @@ bool p3PeerMgr::setLocalAddress(const std::string &id, struct sockaddr_in add
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3PeerMgr::setExtAddress(const std::string &id, struct sockaddr_in addr)
|
||||
bool p3PeerMgrIMPL::setExtAddress(const std::string &id, struct sockaddr_in addr)
|
||||
{
|
||||
if (id == AuthSSL::getAuthSSL()->OwnId())
|
||||
{
|
||||
@ -721,7 +721,7 @@ bool p3PeerMgr::setExtAddress(const std::string &id, struct sockaddr_in addr)
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::setLocalAddress() cannot add addres info : peer id not found in friend list id: " << id << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres info : peer id not found in friend list id: " << id << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -744,7 +744,7 @@ bool p3PeerMgr::setExtAddress(const std::string &id, struct sockaddr_in addr)
|
||||
}
|
||||
|
||||
|
||||
bool p3PeerMgr::setDynDNS(const std::string &id, const std::string &dyndns)
|
||||
bool p3PeerMgrIMPL::setDynDNS(const std::string &id, const std::string &dyndns)
|
||||
{
|
||||
if (id == AuthSSL::getAuthSSL()->OwnId())
|
||||
{
|
||||
@ -761,7 +761,7 @@ bool p3PeerMgr::setDynDNS(const std::string &id, const std::string &dyndns)
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
{
|
||||
#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 << "p3PeerMgrIMPL::setDynDNS() cannot add dyn dns info : peer id not found in friend list id: " << id << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -775,10 +775,10 @@ bool p3PeerMgr::setDynDNS(const std::string &id, const std::string &dyndns)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3PeerMgr::updateAddressList(const std::string& id, const pqiIpAddrSet &addrs)
|
||||
bool p3PeerMgrIMPL::updateAddressList(const std::string& id, const pqiIpAddrSet &addrs)
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::setAddressList() called for id : " << id << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::setAddressList() called for id : " << id << std::endl;
|
||||
#endif
|
||||
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
@ -797,7 +797,7 @@ bool p3PeerMgr::updateAddressList(const std::string& id, const pqiIpAddrSet &
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::setLocalAddress() cannot add addres info : peer id not found in friend list. id: " << id << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres info : peer id not found in friend list. id: " << id << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -806,7 +806,7 @@ bool p3PeerMgr::updateAddressList(const std::string& id, const pqiIpAddrSet &
|
||||
/* "it" points to peer */
|
||||
it->second.ipAddrs.updateAddrs(addrs);
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::setLocalAddress() Updated Address for: " << id;
|
||||
std::cerr << "p3PeerMgrIMPL::setLocalAddress() Updated Address for: " << id;
|
||||
std::cerr << std::endl;
|
||||
it->second.ipAddrs.printAddrs(std::cerr);
|
||||
std::cerr << std::endl;
|
||||
@ -818,10 +818,10 @@ bool p3PeerMgr::updateAddressList(const std::string& id, const pqiIpAddrSet &
|
||||
}
|
||||
|
||||
|
||||
bool p3PeerMgr::updateCurrentAddress(const std::string& id, const pqiIpAddress &addr)
|
||||
bool p3PeerMgrIMPL::updateCurrentAddress(const std::string& id, const pqiIpAddress &addr)
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::updateCurrentAddress() called for id : " << id << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::updateCurrentAddress() called for id : " << id << std::endl;
|
||||
#endif
|
||||
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
@ -834,7 +834,7 @@ bool p3PeerMgr::updateCurrentAddress(const std::string& id, const pqiIpAddres
|
||||
{
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
{
|
||||
std::cerr << "p3PeerMgr::updateCurrentAddress() ERROR peer id not found: " << id << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::updateCurrentAddress() ERROR peer id not found: " << id << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -851,7 +851,7 @@ bool p3PeerMgr::updateCurrentAddress(const std::string& id, const pqiIpAddres
|
||||
}
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::updatedCurrentAddress() Updated Address for: " << id;
|
||||
std::cerr << "p3PeerMgrIMPL::updatedCurrentAddress() Updated Address for: " << id;
|
||||
std::cerr << std::endl;
|
||||
it->second.ipAddrs.printAddrs(std::cerr);
|
||||
std::cerr << std::endl;
|
||||
@ -863,10 +863,10 @@ bool p3PeerMgr::updateCurrentAddress(const std::string& id, const pqiIpAddres
|
||||
}
|
||||
|
||||
|
||||
bool p3PeerMgr::updateLastContact(const std::string& id)
|
||||
bool p3PeerMgrIMPL::updateLastContact(const std::string& id)
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::updateLastContact() called for id : " << id << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::updateLastContact() called for id : " << id << std::endl;
|
||||
#endif
|
||||
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
@ -879,7 +879,7 @@ bool p3PeerMgr::updateLastContact(const std::string& id)
|
||||
{
|
||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
{
|
||||
std::cerr << "p3PeerMgr::updateLastContact() ERROR peer id not found: " << id << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::updateLastContact() ERROR peer id not found: " << id << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -894,7 +894,7 @@ bool p3PeerMgr::updateLastContact(const std::string& id)
|
||||
|
||||
|
||||
|
||||
bool p3PeerMgr::setNetworkMode(const std::string &id, uint32_t netMode)
|
||||
bool p3PeerMgrIMPL::setNetworkMode(const std::string &id, uint32_t netMode)
|
||||
{
|
||||
if (id == AuthSSL::getAuthSSL()->OwnId())
|
||||
{
|
||||
@ -920,12 +920,12 @@ bool p3PeerMgr::setNetworkMode(const std::string &id, uint32_t netMode)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3PeerMgr::setLocation(const std::string &id, const std::string &location)
|
||||
bool p3PeerMgrIMPL::setLocation(const std::string &id, const std::string &location)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::setLocation() called for id : " << id << "; with location " << location << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::setLocation() called for id : " << id << "; with location " << location << std::endl;
|
||||
#endif
|
||||
if (id == AuthSSL::getAuthSSL()->OwnId())
|
||||
{
|
||||
@ -943,7 +943,7 @@ bool p3PeerMgr::setLocation(const std::string &id, const std::string &locatio
|
||||
}
|
||||
}
|
||||
|
||||
bool p3PeerMgr::setVisState(const std::string &id, uint32_t visState)
|
||||
bool p3PeerMgrIMPL::setVisState(const std::string &id, uint32_t visState)
|
||||
{
|
||||
if (id == AuthSSL::getAuthSSL()->OwnId())
|
||||
{
|
||||
@ -1007,7 +1007,7 @@ bool p3PeerMgr::setVisState(const std::string &id, uint32_t visState)
|
||||
|
||||
/* Key Functions to be overloaded for Full Configuration */
|
||||
|
||||
RsSerialiser *p3PeerMgr::setupSerialiser()
|
||||
RsSerialiser *p3PeerMgrIMPL::setupSerialiser()
|
||||
{
|
||||
RsSerialiser *rss = new RsSerialiser();
|
||||
rss->addSerialType(new RsPeerConfigSerialiser());
|
||||
@ -1017,7 +1017,7 @@ RsSerialiser *p3PeerMgr::setupSerialiser()
|
||||
}
|
||||
|
||||
|
||||
bool p3PeerMgr::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
||||
bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
||||
{
|
||||
/* create a list of current peers */
|
||||
cleanup = false;
|
||||
@ -1055,7 +1055,7 @@ bool p3PeerMgr::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
||||
mOwnState.ipAddrs.mExt.loadTlv(item->extAddrList);
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::saveList() Own Config Item:" << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::saveList() Own Config Item:" << std::endl;
|
||||
item->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -1085,7 +1085,7 @@ bool p3PeerMgr::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
||||
saveData.push_back(item);
|
||||
saveCleanupList.push_back(item);
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::saveList() Peer Config Item:" << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::saveList() Peer Config Item:" << std::endl;
|
||||
item->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -1131,7 +1131,7 @@ bool p3PeerMgr::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
||||
return true;
|
||||
}
|
||||
|
||||
void p3PeerMgr::saveDone()
|
||||
void p3PeerMgrIMPL::saveDone()
|
||||
{
|
||||
/* clean up the save List */
|
||||
std::list<RsItem *>::iterator it;
|
||||
@ -1146,7 +1146,7 @@ void p3PeerMgr::saveDone()
|
||||
mPeerMtx.unlock(); /****** MUTEX UNLOCKED *******/
|
||||
}
|
||||
|
||||
bool p3PeerMgr::loadList(std::list<RsItem *>& load)
|
||||
bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
||||
{
|
||||
|
||||
// DEFAULTS.
|
||||
@ -1154,12 +1154,12 @@ bool p3PeerMgr::loadList(std::list<RsItem *>& load)
|
||||
bool allowTunnelConnection = true;
|
||||
|
||||
if (load.size() == 0) {
|
||||
std::cerr << "p3PeerMgr::loadList() list is empty, it may be a configuration problem." << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() list is empty, it may be a configuration problem." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::loadList() Item Count: " << load.size() << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() Item Count: " << load.size() << std::endl;
|
||||
#endif
|
||||
|
||||
std::string ownId = getOwnId();
|
||||
@ -1174,7 +1174,7 @@ bool p3PeerMgr::loadList(std::list<RsItem *>& load)
|
||||
if (pitem->pid == ownId)
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::loadList() Own Config Item:" << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() Own Config Item:" << std::endl;
|
||||
pitem->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -1188,7 +1188,7 @@ bool p3PeerMgr::loadList(std::list<RsItem *>& load)
|
||||
else
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::loadList() Peer Config Item:" << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() Peer Config Item:" << std::endl;
|
||||
pitem->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -1219,7 +1219,7 @@ bool p3PeerMgr::loadList(std::list<RsItem *>& load)
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::loadList() General Variable Config Item:" << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() General Variable Config Item:" << std::endl;
|
||||
vitem->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -1245,7 +1245,7 @@ bool p3PeerMgr::loadList(std::list<RsItem *>& load)
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::loadList() Peer group item:" << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() Peer group item:" << std::endl;
|
||||
gitem->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -1357,7 +1357,7 @@ void printConnectState(std::ostream &out, peerState &peer)
|
||||
**********************************************************************
|
||||
**********************************************************************/
|
||||
|
||||
bool p3PeerMgr::addGroup(RsGroupInfo &groupInfo)
|
||||
bool p3PeerMgrIMPL::addGroup(RsGroupInfo &groupInfo)
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
@ -1384,7 +1384,7 @@ bool p3PeerMgr::addGroup(RsGroupInfo &groupInfo)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3PeerMgr::editGroup(const std::string &groupId, RsGroupInfo &groupInfo)
|
||||
bool p3PeerMgrIMPL::editGroup(const std::string &groupId, RsGroupInfo &groupInfo)
|
||||
{
|
||||
if (groupId.empty()) {
|
||||
return false;
|
||||
@ -1421,7 +1421,7 @@ bool p3PeerMgr::editGroup(const std::string &groupId, RsGroupInfo &groupInfo)
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool p3PeerMgr::removeGroup(const std::string &groupId)
|
||||
bool p3PeerMgrIMPL::removeGroup(const std::string &groupId)
|
||||
{
|
||||
if (groupId.empty()) {
|
||||
return false;
|
||||
@ -1459,7 +1459,7 @@ bool p3PeerMgr::removeGroup(const std::string &groupId)
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool p3PeerMgr::getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo)
|
||||
bool p3PeerMgrIMPL::getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo)
|
||||
{
|
||||
if (groupId.empty()) {
|
||||
return false;
|
||||
@ -1479,7 +1479,7 @@ bool p3PeerMgr::getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3PeerMgr::getGroupInfoList(std::list<RsGroupInfo> &groupInfoList)
|
||||
bool p3PeerMgrIMPL::getGroupInfoList(std::list<RsGroupInfo> &groupInfoList)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
@ -1494,7 +1494,7 @@ bool p3PeerMgr::getGroupInfoList(std::list<RsGroupInfo> &groupInfoList)
|
||||
}
|
||||
|
||||
// groupId == "" && assign == false -> remove from all groups
|
||||
bool p3PeerMgr::assignPeersToGroup(const std::string &groupId, const std::list<std::string> &peerIds, bool assign)
|
||||
bool p3PeerMgrIMPL::assignPeersToGroup(const std::string &groupId, const std::list<std::string> &peerIds, bool assign)
|
||||
{
|
||||
if (groupId.empty() && assign == true) {
|
||||
return false;
|
||||
|
@ -111,82 +111,173 @@ std::string textPeerState(peerState &state);
|
||||
class p3LinkMgr;
|
||||
class p3NetMgr;
|
||||
|
||||
class p3LinkMgrIMPL;
|
||||
class p3NetMgrIMPL;
|
||||
|
||||
class p3PeerMgr: public p3Config
|
||||
class p3PeerMgr
|
||||
{
|
||||
public:
|
||||
|
||||
p3PeerMgr();
|
||||
p3PeerMgr() { return; }
|
||||
virtual ~p3PeerMgr() { return; }
|
||||
|
||||
void setManagers(p3LinkMgr *linkMgr, p3NetMgr *netMgr);
|
||||
virtual bool addFriend(const std::string &ssl_id, const std::string &gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
|
||||
uint32_t visState = RS_VIS_STATE_STD , time_t lastContact = 0) = 0;
|
||||
virtual bool removeFriend(const std::string &ssl_id) = 0;
|
||||
|
||||
virtual bool isFriend(const std::string &ssl_id) = 0;
|
||||
|
||||
|
||||
|
||||
/******************** Groups **********************/
|
||||
/* This is solely used by p3peers - makes sense */
|
||||
|
||||
virtual bool addGroup(RsGroupInfo &groupInfo) = 0;
|
||||
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
||||
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<std::string> &peerIds, bool assign) = 0;
|
||||
|
||||
|
||||
/**************** Set Net Info ****************/
|
||||
/*
|
||||
* These functions are used by:
|
||||
* 1) p3linkmgr
|
||||
* 2) p3peers - reasonable
|
||||
* 3) p3disc - reasonable
|
||||
*/
|
||||
|
||||
virtual bool setLocalAddress(const std::string &id, struct sockaddr_in addr) = 0;
|
||||
virtual bool setExtAddress(const std::string &id, struct sockaddr_in addr) = 0;
|
||||
virtual bool setDynDNS(const std::string &id, const std::string &dyndns) = 0;
|
||||
|
||||
virtual bool setNetworkMode(const std::string &id, uint32_t netMode) = 0;
|
||||
virtual bool setVisState(const std::string &id, uint32_t visState) = 0;
|
||||
|
||||
virtual bool setLocation(const std::string &pid, const std::string &location) = 0;
|
||||
|
||||
virtual bool updateCurrentAddress(const std::string& id, const pqiIpAddress &addr) = 0;
|
||||
virtual bool updateLastContact(const std::string& id) = 0;
|
||||
virtual bool updateAddressList(const std::string& id, const pqiIpAddrSet &addrs) = 0;
|
||||
|
||||
/**************** Net Status Info ****************/
|
||||
/*
|
||||
* MUST RATIONALISE THE DATA FROM THESE FUNCTIONS
|
||||
* These functions are used by:
|
||||
* 1) p3face-config ... to remove!
|
||||
* 2) p3peers - reasonable
|
||||
* 3) p3disc - reasonable
|
||||
*/
|
||||
|
||||
virtual bool getOwnNetStatus(peerState &state) = 0;
|
||||
virtual bool getFriendNetStatus(const std::string &id, peerState &state) = 0;
|
||||
virtual bool getOthersNetStatus(const std::string &id, peerState &state) = 0;
|
||||
|
||||
|
||||
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
|
||||
|
||||
// Single Use Function... shouldn't be here. used by p3serverconfig.cc
|
||||
virtual bool haveOnceConnected() = 0;
|
||||
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*************************************************************************************************/
|
||||
/*************************************************************************************************/
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
class p3PeerMgrIMPL: public p3PeerMgr, public p3Config
|
||||
{
|
||||
public:
|
||||
|
||||
/************************************************************************************************/
|
||||
/* EXTERNAL INTERFACE */
|
||||
/************************************************************************************************/
|
||||
|
||||
virtual bool addFriend(const std::string &ssl_id, const std::string &gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
|
||||
uint32_t visState = RS_VIS_STATE_STD , time_t lastContact = 0);
|
||||
virtual bool removeFriend(const std::string &ssl_id);
|
||||
|
||||
virtual bool isFriend(const std::string &ssl_id);
|
||||
|
||||
|
||||
/******************** Groups **********************/
|
||||
/* This is solely used by p3peers - makes sense */
|
||||
|
||||
virtual bool addGroup(RsGroupInfo &groupInfo);
|
||||
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);
|
||||
|
||||
|
||||
/**************** Set Net Info ****************/
|
||||
/*
|
||||
* These functions are used by:
|
||||
* 1) p3linkmgr
|
||||
* 2) p3peers - reasonable
|
||||
* 3) p3disc - reasonable
|
||||
*/
|
||||
|
||||
virtual bool setLocalAddress(const std::string &id, struct sockaddr_in addr);
|
||||
virtual bool setExtAddress(const std::string &id, struct sockaddr_in addr);
|
||||
virtual bool setDynDNS(const std::string &id, const std::string &dyndns);
|
||||
|
||||
virtual bool setNetworkMode(const std::string &id, uint32_t netMode);
|
||||
virtual bool setVisState(const std::string &id, uint32_t visState);
|
||||
|
||||
virtual bool setLocation(const std::string &pid, const std::string &location);
|
||||
|
||||
virtual bool updateCurrentAddress(const std::string& id, const pqiIpAddress &addr);
|
||||
virtual bool updateLastContact(const std::string& id);
|
||||
virtual bool updateAddressList(const std::string& id, const pqiIpAddrSet &addrs);
|
||||
|
||||
/**************** Net Status Info ****************/
|
||||
/*
|
||||
* MUST RATIONALISE THE DATA FROM THESE FUNCTIONS
|
||||
* These functions are used by:
|
||||
* 1) p3face-config ... to remove!
|
||||
* 2) p3peers - reasonable
|
||||
* 3) p3disc - reasonable
|
||||
*/
|
||||
|
||||
virtual bool getOwnNetStatus(peerState &state);
|
||||
virtual bool getFriendNetStatus(const std::string &id, peerState &state);
|
||||
virtual bool getOthersNetStatus(const std::string &id, peerState &state);
|
||||
|
||||
|
||||
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
|
||||
|
||||
// Single Use Function... shouldn't be here. used by p3serverconfig.cc
|
||||
virtual bool haveOnceConnected();
|
||||
|
||||
|
||||
/************************************************************************************************/
|
||||
/* Extra IMPL Functions (used by p3LinkMgr, p3NetMgr + Setup) */
|
||||
/************************************************************************************************/
|
||||
|
||||
p3PeerMgrIMPL();
|
||||
|
||||
void setManagers(p3LinkMgrIMPL *linkMgr, p3NetMgrIMPL *netMgr);
|
||||
|
||||
void tick();
|
||||
|
||||
/*************** External Control ****************/
|
||||
bool shutdown(); /* blocking shutdown call */
|
||||
|
||||
const std::string getOwnId();
|
||||
void setOwnNetworkMode(uint32_t netMode);
|
||||
void setOwnVisState(uint32_t visState);
|
||||
|
||||
bool setLocalAddress(const std::string &id, struct sockaddr_in addr);
|
||||
bool setExtAddress(const std::string &id, struct sockaddr_in addr);
|
||||
bool setDynDNS(const std::string &id, const std::string &dyndns);
|
||||
|
||||
bool updateAddressList(const std::string& id, const pqiIpAddrSet &addrs);
|
||||
bool updateCurrentAddress(const std::string& id, const pqiIpAddress &addr);
|
||||
bool updateLastContact(const std::string& id);
|
||||
|
||||
bool setNetworkMode(const std::string &id, uint32_t netMode);
|
||||
bool setVisState(const std::string &id, uint32_t visState);
|
||||
|
||||
bool setLocation(const std::string &pid, const std::string &location);//location is shown in the gui to differentiate ssl certs
|
||||
|
||||
/* add/remove friends */
|
||||
bool addFriend(const std::string &ssl_id, const std::string &gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
|
||||
uint32_t visState = RS_VIS_STATE_STD , time_t lastContact = 0);
|
||||
|
||||
bool removeFriend(const std::string &ssl_id);
|
||||
bool addNeighbour(const std::string&);
|
||||
void printPeerLists(std::ostream &out);
|
||||
|
||||
/*************** External Control ****************/
|
||||
|
||||
/* access to network details (called through Monitor) */
|
||||
const std::string getOwnId();
|
||||
bool getOwnNetStatus(peerState &state);
|
||||
|
||||
bool isFriend(const std::string &ssl_id);
|
||||
bool isOnline(const std::string &ssl_id);
|
||||
bool getFriendNetStatus(const std::string &id, peerState &state);
|
||||
bool getOthersNetStatus(const std::string &id, peerState &state);
|
||||
|
||||
void getOnlineList(std::list<std::string> &ssl_peers);
|
||||
void getFriendList(std::list<std::string> &ssl_peers);
|
||||
//void getOthersList(std::list<std::string> &peers); /deprecated
|
||||
bool getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineCount, bool ssl);
|
||||
|
||||
int getConnectAddresses(const std::string &id,
|
||||
struct sockaddr_in &lAddr, struct sockaddr_in &eAddr,
|
||||
pqiIpAddrSet &histAddrs, std::string &dyndns);
|
||||
|
||||
bool haveOnceConnected();
|
||||
|
||||
/**************** handle monitors *****************/
|
||||
void addMonitor(pqiMonitor *mon);
|
||||
void removeMonitor(pqiMonitor *mon);
|
||||
|
||||
/******************** Groups **********************/
|
||||
bool addGroup(RsGroupInfo &groupInfo);
|
||||
bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo);
|
||||
bool removeGroup(const std::string &groupId);
|
||||
bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo);
|
||||
bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
|
||||
bool assignPeersToGroup(const std::string &groupId, const std::list<std::string> &peerIds, bool assign);
|
||||
|
||||
|
||||
protected:
|
||||
/* Internal Functions */
|
||||
void printPeerLists(std::ostream &out);
|
||||
|
||||
protected:
|
||||
/*****************************************************************/
|
||||
@ -200,8 +291,8 @@ protected:
|
||||
|
||||
/* other important managers */
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3NetMgr *mNetMgr;
|
||||
p3LinkMgrIMPL *mLinkMgr;
|
||||
p3NetMgrIMPL *mNetMgr;
|
||||
|
||||
|
||||
private:
|
||||
|
@ -45,9 +45,9 @@
|
||||
#include "services/p3channels.h"
|
||||
#include "services/p3forums.h"
|
||||
|
||||
class p3PeerMgr;
|
||||
class p3LinkMgr;
|
||||
class p3NetMgr;
|
||||
class p3PeerMgrIMPL;
|
||||
class p3LinkMgrIMPL;
|
||||
class p3NetMgrIMPL;
|
||||
|
||||
|
||||
/* The Main Interface Class - for controlling the server */
|
||||
@ -154,9 +154,9 @@ class RsServer: public RsControl, public RsThread
|
||||
//filedexserver *server;
|
||||
ftServer *ftserver;
|
||||
|
||||
p3PeerMgr *mPeerMgr;
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3NetMgr *mNetMgr;
|
||||
p3PeerMgrIMPL *mPeerMgr;
|
||||
p3LinkMgrIMPL *mLinkMgr;
|
||||
p3NetMgrIMPL *mNetMgr;
|
||||
|
||||
pqipersongrp *pqih;
|
||||
|
||||
|
@ -1834,9 +1834,9 @@ int RsServer::StartupRetroShare()
|
||||
/* Setup Notify Early - So we can use it. */
|
||||
rsNotify = new p3Notify();
|
||||
|
||||
mPeerMgr = new p3PeerMgr();
|
||||
mNetMgr = new p3NetMgr();
|
||||
mLinkMgr = new p3LinkMgr(mPeerMgr, mNetMgr);
|
||||
mPeerMgr = new p3PeerMgrIMPL();
|
||||
mNetMgr = new p3NetMgrIMPL();
|
||||
mLinkMgr = new p3LinkMgrIMPL(mPeerMgr, mNetMgr);
|
||||
|
||||
mPeerMgr->setManagers(mLinkMgr, mNetMgr);
|
||||
mNetMgr->setManagers(mPeerMgr, mLinkMgr);
|
||||
|
@ -225,7 +225,7 @@ int p3MsgService::checkOutgoingMessages()
|
||||
peerConnectState pstate;
|
||||
bool toSend = false;
|
||||
|
||||
if (mLinkMgr->getFriendNetStatus(pid, pstate))
|
||||
if (mLinkMgr->isOnline(pid))
|
||||
{
|
||||
if (pstate.state & RS_PEER_S_CONNECTED)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user