mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
Bugfixes for ExclusiveProxy Mode.
* changed PeerConnectStateBox::getNetState() to calcNetState() to provide up-to-date info (internal mNetState can be stale!) * Added "bool addrChangeLikely" parameter to ReleaseProxyExclusiveLock() - this parameter is determined by whether we actually started a UDP connection. * disabled ForceRestun in UdpStunner if addrChange is unlikely. * Reduced Stunner Period Slow from 3 minutes to 2 minutes - exact value will only be known after real-world testing. * More debugging. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-netupgrade@4458 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
181ad06e33
commit
c33b415ef4
7 changed files with 73 additions and 26 deletions
|
@ -71,6 +71,7 @@ UdpStunner::UdpStunner(UdpPublisher *pub)
|
|||
|
||||
mExclusiveMode = false;
|
||||
mExclusiveModeTS = 0;
|
||||
mForceRestun = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -150,7 +151,7 @@ int UdpStunner::grabExclusiveMode() /* returns seconds since last send/recv */
|
|||
return commsage;
|
||||
}
|
||||
|
||||
int UdpStunner::releaseExclusiveMode()
|
||||
int UdpStunner::releaseExclusiveMode(bool forceStun)
|
||||
{
|
||||
RsStackMutex stack(stunMtx); /********** LOCK MUTEX *********/
|
||||
|
||||
|
@ -165,16 +166,18 @@ int UdpStunner::releaseExclusiveMode()
|
|||
|
||||
time_t now = time(NULL);
|
||||
mExclusiveMode = false;
|
||||
|
||||
if (forceStun)
|
||||
{
|
||||
mForceRestun = true;
|
||||
}
|
||||
|
||||
#ifdef UDPSTUN_ALLOW_LOCALNET
|
||||
/* if we are simulating an exclusive NAT, then immediately after we release - it'll become unstable.
|
||||
* This is even harser than reality... so better test.
|
||||
*
|
||||
/* if we are simulating an exclusive NAT, then immediately after we release - it'll become unstable.
|
||||
* In reality, it will only become unstable if we have tried a UDP connection.
|
||||
* so we use the forceStun parameter (which is true when a UDP connection has been tried).
|
||||
*/
|
||||
|
||||
if (mSimExclusiveNat)
|
||||
if ((mSimExclusiveNat) && (forceStun))
|
||||
{
|
||||
mSimUnstableExt = true;
|
||||
}
|
||||
|
@ -360,6 +363,14 @@ bool UdpStunner::externalAddr(struct sockaddr_in &external, uint8_t &stable)
|
|||
eaddrKnown = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Force Restun is triggered after an Exclusive Mode... as Ext Address is likely to have changed
|
||||
* Until the Restun has got an address - we act as if we don't have an external address
|
||||
*/
|
||||
if (mForceRestun)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
external = eaddr;
|
||||
|
||||
|
@ -669,6 +680,12 @@ bool UdpStunner::checkStunDesired()
|
|||
{
|
||||
return false; /* no pings in exclusive mode */
|
||||
}
|
||||
|
||||
if (mForceRestun)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (!eaddrKnown)
|
||||
{
|
||||
|
@ -856,6 +873,12 @@ bool UdpStunner::locked_recvdStun(const struct sockaddr_in &remote, const str
|
|||
}
|
||||
}
|
||||
|
||||
/* We've received a Stun, so the ForceStun can be cancelled */
|
||||
if (found)
|
||||
{
|
||||
mForceRestun = false;
|
||||
}
|
||||
|
||||
/* if not found.. should we add it back in? */
|
||||
|
||||
/* How do we calculate the success rate?
|
||||
|
|
|
@ -89,7 +89,7 @@ virtual ~UdpStunner() { return; }
|
|||
#endif
|
||||
|
||||
int grabExclusiveMode(); /* returns seconds since last send/recv */
|
||||
int releaseExclusiveMode();
|
||||
int releaseExclusiveMode(bool forceStun);
|
||||
|
||||
|
||||
void setTargetStunPeriod(int32_t sec_per_stun);
|
||||
|
@ -156,6 +156,7 @@ bool locked_checkExternalAddress();
|
|||
|
||||
bool mExclusiveMode; /* when this is switched on, the stunner stays silent (and extAddr is maintained) */
|
||||
time_t mExclusiveModeTS;
|
||||
bool mForceRestun;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue