mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Added Address update from p3NetMgr => p3PeerMgr, when external address has been determined.
* extract external address from DhtStunner if possible. * added p3PeerMgr::UpdateOwnAddress(), which should only be called by p3netmgr. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4512 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
7e6c58dd10
commit
3ef08fead5
@ -699,6 +699,37 @@ void p3NetMgrIMPL::netExtCheck()
|
||||
|
||||
}
|
||||
|
||||
/* Next ask the DhtStunner */
|
||||
if (!mNetFlags.mExtAddrOk)
|
||||
{
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() Ext Not Ok, Checking DhtStunner" << std::endl;
|
||||
#endif
|
||||
uint8_t isstable = 0;
|
||||
struct sockaddr_in tmpaddr;
|
||||
sockaddr_clear(&tmpaddr);
|
||||
|
||||
if (mDhtStunner)
|
||||
{
|
||||
/* input network bits */
|
||||
if (mDhtStunner->getExternalAddr(tmpaddr, isstable))
|
||||
{
|
||||
// must be stable???
|
||||
isStable = (isstable == 1);
|
||||
mNetFlags.mExtAddr = tmpaddr;
|
||||
mNetFlags.mExtAddrOk = true;
|
||||
mNetFlags.mExtAddrStableOk = isStable;
|
||||
|
||||
#ifdef NETMGR_DEBUG_STATEBOX
|
||||
std::cerr << "p3NetMgrIMPL::netExtCheck() From DhtStunner: ";
|
||||
std::cerr << rs_inet_ntoa(tmpaddr.sin_addr) << ":" << htons(tmpaddr.sin_port);
|
||||
std::cerr << " Stable: " << (uint32_t) isstable;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* otherwise ask ExtAddrFinder */
|
||||
if (!mNetFlags.mExtAddrOk)
|
||||
{
|
||||
@ -769,12 +800,16 @@ void p3NetMgrIMPL::netExtCheck()
|
||||
std::cerr << "netMode => RS_NET_MODE_UNREACHABLE";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
mNetMode &= ~(RS_NET_MODE_ACTUAL);
|
||||
mNetMode |= RS_NET_MODE_UNREACHABLE;
|
||||
|
||||
// Due to the new UDP connections - we can still connect some of the time!
|
||||
// So limit warning!
|
||||
|
||||
//mNetMode &= ~(RS_NET_MODE_ACTUAL);
|
||||
//mNetMode |= RS_NET_MODE_UNREACHABLE;
|
||||
|
||||
/* send a system warning message */
|
||||
pqiNotify *notify = getPqiNotify();
|
||||
if (notify)
|
||||
//pqiNotify *notify = getPqiNotify();
|
||||
//if (notify)
|
||||
{
|
||||
std::string title =
|
||||
"Warning: Bad Firewall Configuration";
|
||||
@ -784,14 +819,16 @@ void p3NetMgrIMPL::netExtCheck()
|
||||
msg += "Retroshare has detected that you are behind";
|
||||
msg += " a restrictive Firewall\n";
|
||||
msg += "\n";
|
||||
msg += "You cannot connect to other firewalled peers\n";
|
||||
msg += "You will have limited connectivity to other firewalled peers\n";
|
||||
msg += "\n";
|
||||
msg += "You can fix this by:\n";
|
||||
msg += " (1) opening an External Port\n";
|
||||
msg += " (2) enabling UPnP, or\n";
|
||||
msg += " (3) get a new (approved) Firewall/Router\n";
|
||||
|
||||
notify->AddSysMessage(0, RS_SYS_WARNING, title, msg);
|
||||
//notify->AddSysMessage(0, RS_SYS_WARNING, title, msg);
|
||||
|
||||
std::cerr << msg << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
@ -830,6 +867,9 @@ void p3NetMgrIMPL::netExtCheck()
|
||||
{
|
||||
/* Setup NetStateBox with this info */
|
||||
updateNetStateBox_startup();
|
||||
|
||||
/* update PeerMgr with correct info */
|
||||
mPeerMgr->UpdateOwnAddress(mLocalAddr, mExtAddr);
|
||||
}
|
||||
|
||||
}
|
||||
@ -963,7 +1003,7 @@ bool p3NetMgrIMPL::checkNetAddress()
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
//mPeerMgr->UpdateOwnAddress(mLocalAddr, mExtAddr);
|
||||
mPeerMgr->UpdateOwnAddress(mLocalAddr, mExtAddr);
|
||||
|
||||
netReset();
|
||||
}
|
||||
|
@ -641,6 +641,52 @@ bool p3PeerMgrIMPL::addNeighbour(std::string id)
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
/* This function should only be called from NetMgr,
|
||||
* as it doesn't call back to there.
|
||||
*/
|
||||
|
||||
bool p3PeerMgrIMPL::UpdateOwnAddress(const struct sockaddr_in &localAddr, const struct sockaddr_in &extAddr)
|
||||
{
|
||||
std::cerr << "p3PeerMgrIMPL::UpdateOwnAddress(";
|
||||
std::cerr << rs_inet_ntoa(localAddr.sin_addr) << ":" << htons(localAddr.sin_port);
|
||||
std::cerr << ", ";
|
||||
std::cerr << rs_inet_ntoa(extAddr.sin_addr) << ":" << htons(extAddr.sin_port);
|
||||
std::cerr << ")" << std::endl;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
//update ip address list
|
||||
pqiIpAddress ipAddressTimed;
|
||||
ipAddressTimed.mAddr = localAddr;
|
||||
ipAddressTimed.mSeenTime = time(NULL);
|
||||
mOwnState.ipAddrs.updateLocalAddrs(ipAddressTimed);
|
||||
|
||||
mOwnState.localaddr = localAddr;
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
//update ip address list
|
||||
pqiIpAddress ipAddressTimed;
|
||||
ipAddressTimed.mAddr = extAddr;
|
||||
ipAddressTimed.mSeenTime = time(NULL);
|
||||
mOwnState.ipAddrs.updateExtAddrs(ipAddressTimed);
|
||||
|
||||
mOwnState.serveraddr = extAddr;
|
||||
}
|
||||
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
mLinkMgr->setLocalAddress(localAddr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::setLocalAddress(const std::string &id, struct sockaddr_in addr)
|
||||
{
|
||||
if (id == AuthSSL::getAuthSSL()->OwnId())
|
||||
|
@ -161,6 +161,10 @@ virtual bool updateCurrentAddress(const std::string& id, const pqiIpAddress &
|
||||
virtual bool updateLastContact(const std::string& id) = 0;
|
||||
virtual bool updateAddressList(const std::string& id, const pqiIpAddrSet &addrs) = 0;
|
||||
|
||||
|
||||
// THIS MUST ONLY BE CALLED BY NETMGR!!!!
|
||||
virtual bool UpdateOwnAddress(const struct sockaddr_in &mLocalAddr, const struct sockaddr_in &mExtAddr) = 0;
|
||||
|
||||
/**************** Net Status Info ****************/
|
||||
/*
|
||||
* MUST RATIONALISE THE DATA FROM THESE FUNCTIONS
|
||||
@ -237,6 +241,9 @@ virtual bool updateCurrentAddress(const std::string& id, const pqiIpAddress &
|
||||
virtual bool updateLastContact(const std::string& id);
|
||||
virtual bool updateAddressList(const std::string& id, const pqiIpAddrSet &addrs);
|
||||
|
||||
|
||||
// THIS MUST ONLY BE CALLED BY NETMGR!!!!
|
||||
virtual bool UpdateOwnAddress(const struct sockaddr_in &mLocalAddr, const struct sockaddr_in &mExtAddr);
|
||||
/**************** Net Status Info ****************/
|
||||
/*
|
||||
* MUST RATIONALISE THE DATA FROM THESE FUNCTIONS
|
||||
|
Loading…
Reference in New Issue
Block a user