improved stun check

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1767 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2009-10-30 00:40:31 +00:00
parent 06c1c0f59f
commit cf157422f5

View File

@ -1043,18 +1043,23 @@ bool p3ConnectMgr::stunCheck()
if (0 < tou_extaddr((struct sockaddr *) &raddr, &rlen, &stable)) if (0 < tou_extaddr((struct sockaddr *) &raddr, &rlen, &stable))
{ {
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
mStunAddrStable = (stable != 0);
if ((mStunExtAddr.sin_addr.s_addr != raddr.sin_addr.s_addr) || if ((mStunExtAddr.sin_addr.s_addr != raddr.sin_addr.s_addr) ||
(mStunAddrStable != stable)) (mStunAddrStable != true))
{ {
#ifdef CONN_DEBUG #ifdef CONN_DEBUG
std::cerr << "Ext Address Changed -> netReset" << std::endl; std::cerr << "mStunExtAddr.sin_addr.s_addr : " << inet_ntoa(mStunExtAddr.sin_addr) << std::endl;
std::cerr << "raddr.sin_addr.s_addr : " << inet_ntoa(raddr.sin_addr) << std::endl;
std::cerr << "mStunAddrStable : " << mStunAddrStable << std::endl;
#endif #endif
doNetReset = true; doNetReset = true;
} }
else else
{ {
netFlagUdpOk = true;
#ifdef CONN_DEBUG #ifdef CONN_DEBUG
std::cerr << "Ext Address Same: ok!" << std::endl; std::cerr << "Ext Address Same: ok!" << std::endl;
#endif #endif
@ -1070,6 +1075,7 @@ bool p3ConnectMgr::stunCheck()
if (upnpExtAdress) { if (upnpExtAdress) {
//don't do a reset //don't do a reset
mStunExtAddr = extAddr; mStunExtAddr = extAddr;
netFlagUdpOk = false;
#ifdef CONN_DEBUG #ifdef CONN_DEBUG
std::cerr << "Found upnp Ext Address. don't do a reset." << std::endl; std::cerr << "Found upnp Ext Address. don't do a reset." << std::endl;
#endif #endif