mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-17 19:09:29 -04:00
BugFix: DHT was not turning on.
also updated the ServerDialog with more info on exact network state. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@753 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
95d5f38222
commit
bc98b9ea7d
12 changed files with 330 additions and 122 deletions
|
@ -64,6 +64,7 @@ const uint32_t MAX_UPNP_INIT = 10; /* seconds UPnP timeout */
|
|||
***/
|
||||
|
||||
#define CONN_DEBUG 1
|
||||
|
||||
const uint32_t P3CONNMGR_TCP_DEFAULT_DELAY = 2; /* 2 Seconds? is it be enough! */
|
||||
const uint32_t P3CONNMGR_UDP_DHT_DELAY = DHT_NOTIFY_PERIOD + 60; /* + 1 minute for DHT POST */
|
||||
const uint32_t P3CONNMGR_UDP_PROXY_DELAY = 30; /* 30 seconds (NOT IMPLEMENTED YET!) */
|
||||
|
@ -169,7 +170,7 @@ void p3ConnectMgr::setOwnNetConfig(uint32_t netMode, uint32_t visState)
|
|||
/* if we've started up - then tweak Dht On/Off */
|
||||
if (mNetStatus != RS_NET_UNKNOWN)
|
||||
{
|
||||
enableNetAssistFirewall(!(ownState.visState & RS_VIS_STATE_NODHT));
|
||||
enableNetAssistConnect(!(ownState.visState & RS_VIS_STATE_NODHT));
|
||||
}
|
||||
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
|
@ -231,6 +232,17 @@ void p3ConnectMgr::setOwnNetConfig(uint32_t netMode, uint32_t visState)
|
|||
*
|
||||
*/
|
||||
|
||||
void p3ConnectMgr::netStatusReset()
|
||||
{
|
||||
netFlagOk = true;
|
||||
netFlagUpnpOk = false;
|
||||
netFlagDhtOk = false;
|
||||
netFlagExtOk = false;
|
||||
netFlagUdpOk = false;
|
||||
netFlagTcpOk = false;
|
||||
netFlagResetReq = false;
|
||||
}
|
||||
|
||||
void p3ConnectMgr::netStartup()
|
||||
{
|
||||
/* startup stuff */
|
||||
|
@ -246,6 +258,7 @@ void p3ConnectMgr::netStartup()
|
|||
netDhtInit();
|
||||
netUdpInit();
|
||||
netStunInit();
|
||||
netStatusReset();
|
||||
|
||||
/* decide which net setup mode we're going into
|
||||
*/
|
||||
|
@ -469,7 +482,7 @@ void p3ConnectMgr::netDhtInit()
|
|||
|
||||
connMtx.unlock(); /* UNLOCK MUTEX */
|
||||
|
||||
enableNetAssistFirewall(!(vs & RS_VIS_STATE_NODHT));
|
||||
enableNetAssistConnect(!(vs & RS_VIS_STATE_NODHT));
|
||||
}
|
||||
|
||||
|
||||
|
@ -532,6 +545,14 @@ void p3ConnectMgr::netUpnpCheck()
|
|||
/* switch to UDP startup */
|
||||
connMtx.lock(); /* LOCK MUTEX */
|
||||
|
||||
/* Set Net Status flags ....
|
||||
* we now have external upnp address. Golden!
|
||||
* don't set netOk flag until have seen some traffic.
|
||||
*/
|
||||
|
||||
netFlagUpnpOk = true;
|
||||
netFlagExtOk = true;
|
||||
|
||||
mUpnpAddrValid = true;
|
||||
mUpnpExtAddr = extAddr;
|
||||
mNetStatus = RS_NET_UDP_SETUP;
|
||||
|
@ -778,6 +799,15 @@ bool p3ConnectMgr::udpExtAddressCheck()
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* update net Status flags ....
|
||||
* we've got stun information via udp...
|
||||
* so up is okay, and ext address is known stable or not.
|
||||
*/
|
||||
|
||||
if (mStunAddrStable)
|
||||
netFlagExtOk = true;
|
||||
netFlagUdpOk = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1552,6 +1582,11 @@ void p3ConnectMgr::peerStatus(std::string id,
|
|||
/* If we get a info -> then they are online */
|
||||
it->second.state |= RS_PEER_S_ONLINE;
|
||||
it->second.lastavailable = now;
|
||||
|
||||
/* if we are recieving these - the dht is definitely up.
|
||||
*/
|
||||
|
||||
netFlagDhtOk = true;
|
||||
}
|
||||
else if (source == RS_CB_DISC)
|
||||
{
|
||||
|
@ -3257,5 +3292,40 @@ bool p3ConnectMgr::getDHTEnabled()
|
|||
|
||||
|
||||
|
||||
bool p3ConnectMgr::getNetStatusOk()
|
||||
{
|
||||
return netFlagOk;
|
||||
}
|
||||
|
||||
bool p3ConnectMgr::getNetStatusUpnpOk()
|
||||
{
|
||||
return netFlagUpnpOk;
|
||||
}
|
||||
|
||||
bool p3ConnectMgr::getNetStatusDhtOk()
|
||||
{
|
||||
return netFlagDhtOk;
|
||||
}
|
||||
|
||||
bool p3ConnectMgr::getNetStatusExtOk()
|
||||
{
|
||||
return netFlagExtOk;
|
||||
}
|
||||
|
||||
bool p3ConnectMgr::getNetStatusUdpOk()
|
||||
{
|
||||
return netFlagUdpOk;
|
||||
}
|
||||
|
||||
bool p3ConnectMgr::getNetStatusTcpOk()
|
||||
{
|
||||
return netFlagTcpOk;
|
||||
}
|
||||
|
||||
bool p3ConnectMgr::getNetResetReq()
|
||||
{
|
||||
return netFlagResetReq;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -81,6 +81,13 @@ const uint32_t RS_NET_CONN_UDP_ALL = 0x00f0;
|
|||
const uint32_t RS_NET_CONN_TCP_LOCAL = 0x0001;
|
||||
const uint32_t RS_NET_CONN_TCP_EXTERNAL = 0x0002;
|
||||
const uint32_t RS_NET_CONN_UDP_DHT_SYNC = 0x0010;
|
||||
const uint32_t RS_NET_CONN_UDP_PEER_SYNC = 0x0020; /* coming soon */
|
||||
|
||||
/* extra flags */
|
||||
// not sure if needed yet.
|
||||
//const uint32_t RS_NET_CONN_PEERAGE = 0x0f00;
|
||||
//const uint32_t RS_NET_CONN_SERVER = 0x0100; /* TCP only */
|
||||
//const uint32_t RS_NET_CONN_PEER = 0x0200; /* all UDP */
|
||||
|
||||
|
||||
/* flags of peerStatus */
|
||||
|
@ -176,6 +183,14 @@ bool getUPnPState();
|
|||
bool getUPnPEnabled();
|
||||
bool getDHTEnabled();
|
||||
|
||||
bool getNetStatusOk();
|
||||
bool getNetStatusUpnpOk();
|
||||
bool getNetStatusDhtOk();
|
||||
bool getNetStatusExtOk();
|
||||
bool getNetStatusUdpOk();
|
||||
bool getNetStatusTcpOk();
|
||||
bool getNetResetReq();
|
||||
|
||||
void setOwnNetConfig(uint32_t netMode, uint32_t visState);
|
||||
bool setLocalAddress(std::string id, struct sockaddr_in addr);
|
||||
bool setExtAddress(std::string id, struct sockaddr_in addr);
|
||||
|
@ -260,7 +275,7 @@ void netDhtInit();
|
|||
void netUdpInit();
|
||||
void netStunInit();
|
||||
|
||||
|
||||
void netStatusReset();
|
||||
|
||||
|
||||
void netInit();
|
||||
|
@ -338,6 +353,15 @@ private:
|
|||
struct sockaddr_in mUpnpExtAddr;
|
||||
struct sockaddr_in mStunExtAddr;
|
||||
|
||||
/* network status flags (read by rsiface) */
|
||||
bool netFlagOk;
|
||||
bool netFlagUpnpOk;
|
||||
bool netFlagDhtOk;
|
||||
bool netFlagExtOk;
|
||||
bool netFlagUdpOk;
|
||||
bool netFlagTcpOk;
|
||||
bool netFlagResetReq;
|
||||
|
||||
|
||||
/* these are protected for testing */
|
||||
protected:
|
||||
|
|
|
@ -48,6 +48,8 @@ const int p3dhtzone = 3892;
|
|||
*
|
||||
*/
|
||||
|
||||
#define DHT_DEBUG 1
|
||||
|
||||
/**** DHT State Variables ****/
|
||||
|
||||
#define DHT_STATE_OFF 0
|
||||
|
|
|
@ -137,11 +137,21 @@ class RsConfig
|
|||
|
||||
int promptAtBoot; /* popup the password prompt */
|
||||
|
||||
/* older data types */
|
||||
bool DHTActive;
|
||||
bool uPnPActive;
|
||||
|
||||
int uPnPState;
|
||||
int DHTPeers;
|
||||
|
||||
/* Flags for Network Status */
|
||||
bool netOk; /* That we've talked to someone! */
|
||||
bool netUpnpOk; /* upnp is enabled and active */
|
||||
bool netDhtOk; /* response from dht */
|
||||
bool netExtOk; /* know our external address */
|
||||
bool netUdpOk; /* recvd stun / udp packets */
|
||||
bool netTcpOk; /* recvd incoming tcp */
|
||||
bool netResetReq;
|
||||
};
|
||||
|
||||
/********************** For Search Interface *****************/
|
||||
|
|
|
@ -124,6 +124,15 @@ int RsServer::UpdateAllConfig()
|
|||
config.maxIndivDataRate = (int) pqih -> getMaxIndivRate(true);/* kb */
|
||||
config.promptAtBoot = true; /* popup the password prompt */
|
||||
|
||||
/* update network configuration */
|
||||
|
||||
config.netOk = mConnMgr->getNetStatusOk();
|
||||
config.netUpnpOk = mConnMgr->getNetStatusUpnpOk();
|
||||
config.netDhtOk = mConnMgr->getNetStatusDhtOk();
|
||||
config.netExtOk = mConnMgr->getNetStatusExtOk();
|
||||
config.netUdpOk = mConnMgr->getNetStatusUdpOk();
|
||||
config.netTcpOk = mConnMgr->getNetStatusTcpOk();
|
||||
|
||||
/* update DHT/UPnP config */
|
||||
|
||||
config.uPnPState = mConnMgr->getUPnPState();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue