mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-30 09:13:40 -05:00
rework a little the netCheckConsistency
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1886 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
908a6e1891
commit
2b52db6c47
@ -567,10 +567,6 @@ void p3ConnectMgr::netTick()
|
|||||||
#ifdef CONN_DEBUG
|
#ifdef CONN_DEBUG
|
||||||
//std::cerr << "p3ConnectMgr::netTick() STATUS: DONE" << std::endl;
|
//std::cerr << "p3ConnectMgr::netTick() STATUS: DONE" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
stunCheck(); /* Keep on stunning */
|
|
||||||
if (!netFlagStunOk) {
|
|
||||||
netExtFinderAddressCheck();
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -743,13 +739,6 @@ void p3ConnectMgr::networkConsistencyCheck()
|
|||||||
|
|
||||||
if (!doNetReset) {//set an external address. if ip adresses are different, let's use the stun address, then the extaddrfinder and then the upnp address.
|
if (!doNetReset) {//set an external address. if ip adresses are different, let's use the stun address, then the extaddrfinder and then the upnp address.
|
||||||
struct sockaddr_in extAddr;
|
struct sockaddr_in extAddr;
|
||||||
if (getStunExtAddress(extAddr)) {
|
|
||||||
#ifdef CONN_DEBUG
|
|
||||||
std::cerr << "p3ConnectMgr::networkConsistencyCheck() using STUN for ownState.serveraddr." << std::endl;
|
|
||||||
#endif
|
|
||||||
ownState.currentserveraddr = extAddr;
|
|
||||||
} else {
|
|
||||||
//call the extrafinder address
|
|
||||||
if (getUpnpExtAddress(extAddr)) {
|
if (getUpnpExtAddress(extAddr)) {
|
||||||
#ifdef CONN_DEBUG
|
#ifdef CONN_DEBUG
|
||||||
std::cerr << "p3ConnectMgr::networkConsistencyCheck() using getUpnpExtAddress for ownState.serveraddr." << std::endl;
|
std::cerr << "p3ConnectMgr::networkConsistencyCheck() using getUpnpExtAddress for ownState.serveraddr." << std::endl;
|
||||||
@ -762,11 +751,22 @@ void p3ConnectMgr::networkConsistencyCheck()
|
|||||||
#endif
|
#endif
|
||||||
ownState.currentserveraddr = extAddr;
|
ownState.currentserveraddr = extAddr;
|
||||||
} else {
|
} else {
|
||||||
#ifdef CONN_DEBUG
|
//check if a peer is connected, if yes don't do a net reset
|
||||||
std::cerr << "p3ConnectMgr::networkConsistencyCheck() no external ip address." << std::endl;
|
bool is_connected = false;
|
||||||
#endif
|
std::map<std::string, peerConnectState>::iterator it;
|
||||||
doNetReset = true;
|
for(it = mFriendList.begin(); it != mFriendList.end() && !is_connected; it++)
|
||||||
|
{
|
||||||
|
/* get last contact detail */
|
||||||
|
is_connected = it->second.state & RS_PEER_S_CONNECTED;
|
||||||
}
|
}
|
||||||
|
#ifdef CONN_DEBUG
|
||||||
|
if (is_connected) {
|
||||||
|
std::cerr << "p3ConnectMgr::networkConsistencyCheck() not doing a net reset because a peer is connected." << std::endl;
|
||||||
|
} else {
|
||||||
|
std::cerr << "p3ConnectMgr::networkConsistencyCheck() no peer is connected." << std::endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
doNetReset = !is_connected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
connMtx.unlock(); /* UNLOCK MUTEX */
|
connMtx.unlock(); /* UNLOCK MUTEX */
|
||||||
@ -779,25 +779,6 @@ void p3ConnectMgr::networkConsistencyCheck()
|
|||||||
ownState.updateIpAddressList(ipAddressTimed);
|
ownState.updateIpAddressList(ipAddressTimed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doNetReset) {
|
|
||||||
//check if a peer is connected, then don't do a net reset
|
|
||||||
bool is_connected = false;
|
|
||||||
std::map<std::string, peerConnectState>::iterator it;
|
|
||||||
for(it = mFriendList.begin(); it != mFriendList.end() && !is_connected; it++)
|
|
||||||
{
|
|
||||||
/* get last contact detail */
|
|
||||||
is_connected = it->second.state & RS_PEER_S_CONNECTED;
|
|
||||||
}
|
|
||||||
doNetReset = !is_connected;
|
|
||||||
#ifdef CONN_DEBUG
|
|
||||||
if (is_connected) {
|
|
||||||
std::cerr << "p3ConnectMgr::networkConsistencyCheck() not doing a net reset because a peer is connected." << std::endl;
|
|
||||||
} else {
|
|
||||||
std::cerr << "p3ConnectMgr::networkConsistencyCheck() no peer is connected." << std::endl;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//let's do a net reset
|
//let's do a net reset
|
||||||
if (doNetReset) {
|
if (doNetReset) {
|
||||||
//don't do a reset it if the network init is not finished
|
//don't do a reset it if the network init is not finished
|
||||||
@ -2492,10 +2473,13 @@ bool p3ConnectMgr::setAddressList(std::string id, std::list<IpAddressTimed> I
|
|||||||
{
|
{
|
||||||
/* check if it is our own ip */
|
/* check if it is our own ip */
|
||||||
if (id == getOwnId()) {
|
if (id == getOwnId()) {
|
||||||
|
struct sockaddr_in extAddr;
|
||||||
|
if (getUpnpExtAddress(extAddr) || getExtFinderExtAddress(extAddr)) {
|
||||||
#ifdef CONN_DEBUG
|
#ifdef CONN_DEBUG
|
||||||
std::cerr << "p3ConnectMgr::setAddressList() received own ip address list." << std::endl;
|
std::cerr << "p3ConnectMgr::setAddressList() received own ip address list, but already got an external address with upnp or extaddrfinder." << std::endl;
|
||||||
peerConnectState::printIpAddressList(IpAddressTimedList);
|
|
||||||
#endif
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//extract first address that is not the same as local address
|
//extract first address that is not the same as local address
|
||||||
//check if the ip list contains the current remote address of the connected peer
|
//check if the ip list contains the current remote address of the connected peer
|
||||||
IpAddressTimed foundAddress;
|
IpAddressTimed foundAddress;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user