mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-25 15:35:49 -04:00
* Switched on Dht "Attach" Mode if RS is firewalled. (and not nice firewall).
* Added interfaces to enable AttachMode switch. * Added further tcponudp tests. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4484 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f6002b3981
commit
b56ddfeb5b
10 changed files with 445 additions and 11 deletions
|
@ -1304,6 +1304,23 @@ bool p3NetMgrIMPL::netAssistFriend(std::string id, bool on)
|
|||
}
|
||||
|
||||
|
||||
bool p3NetMgrIMPL::netAssistAttach(bool on)
|
||||
{
|
||||
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
|
||||
|
||||
#ifdef NETMGR_DEBUG
|
||||
std::cerr << "p3NetMgrIMPL::netAssistAttach(" << on << ")";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
for(it = mDhts.begin(); it != mDhts.end(); it++)
|
||||
{
|
||||
(it->second)->setAttachMode(on);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool p3NetMgrIMPL::netAssistStatusUpdate(std::string id, int state)
|
||||
{
|
||||
|
@ -1622,12 +1639,45 @@ void p3NetMgrIMPL::updateNatSetting()
|
|||
case RSNET_NATTYPE_NONE:
|
||||
case RSNET_NATTYPE_UNKNOWN:
|
||||
case RSNET_NATTYPE_SYMMETRIC:
|
||||
case RSNET_NATTYPE_DETERM_SYM:
|
||||
case RSNET_NATTYPE_FULL_CONE:
|
||||
case RSNET_NATTYPE_OTHER:
|
||||
|
||||
mProxyStunner->setRefreshPeriod(NET_STUNNER_PERIOD_SLOW);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* This controls the Attach mode of the DHT...
|
||||
* which effectively makes the DHT "attach" to Open Nodes.
|
||||
* So that messages can get through.
|
||||
* We only want to be attached - if we don't have a stable DHT port.
|
||||
*/
|
||||
if ((natHole == RSNET_NATHOLE_NONE) || (natHole == RSNET_NATHOLE_UNKNOWN))
|
||||
{
|
||||
switch(natType)
|
||||
{
|
||||
/* switch to attach mode if we have a bad firewall */
|
||||
case RSNET_NATTYPE_UNKNOWN:
|
||||
case RSNET_NATTYPE_SYMMETRIC:
|
||||
case RSNET_NATTYPE_RESTRICTED_CONE:
|
||||
case RSNET_NATTYPE_DETERM_SYM:
|
||||
case RSNET_NATTYPE_OTHER:
|
||||
netAssistAttach(true);
|
||||
|
||||
break;
|
||||
/* switch off attach mode if we have a nice firewall */
|
||||
case RSNET_NATTYPE_NONE:
|
||||
case RSNET_NATTYPE_FULL_CONE:
|
||||
netAssistAttach(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Switch off Firewall Mode (Attach)
|
||||
netAssistAttach(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -254,7 +254,6 @@ bool netAssistConnectActive();
|
|||
bool netAssistConnectShutdown();
|
||||
bool netAssistConnectStats(uint32_t &netsize, uint32_t &localnetsize);
|
||||
void netAssistConnectTick();
|
||||
|
||||
/* Assist Firewall */
|
||||
bool netAssistExtAddress(struct sockaddr_in &extAddr);
|
||||
bool netAssistFirewallPorts(uint16_t iport, uint16_t eport);
|
||||
|
@ -265,6 +264,8 @@ bool netAssistSetAddress( struct sockaddr_in &laddr,
|
|||
struct sockaddr_in &eaddr,
|
||||
uint32_t mode);
|
||||
|
||||
bool netAssistAttach(bool on);
|
||||
|
||||
|
||||
/* Internal Functions */
|
||||
void netReset();
|
||||
|
|
|
@ -132,6 +132,9 @@ virtual bool getPeerStatus(std::string id,
|
|||
struct sockaddr_in &laddr, struct sockaddr_in &raddr,
|
||||
uint32_t &type, uint32_t &mode) = 0;
|
||||
|
||||
virtual bool setAttachMode(bool on) = 0;
|
||||
|
||||
|
||||
//virtual bool getExternalInterface(struct sockaddr_in &raddr,
|
||||
// uint32_t &mode) = 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue