From 91e10f1590fc881949edcc7c9233fe9bf0848209 Mon Sep 17 00:00:00 2001 From: drbob Date: Sat, 30 Jul 2011 12:18:56 +0000 Subject: [PATCH] * Fixed up network configuration. - p3peermgr now uses RS_NET_MODE_XXXX instead of RS_NET_MODE_TRY_XXXX - p3netmgr maintains both TRY and ACTUAL mode. - actual mode is not visible through old interface (TO FIX). - added default to UPNP mode. * Added debug to show changes to peer->VisState. - It seems that this is never updated by p3disc. BUG, (TO FIX). * disabled extra debug in rsdiscitems. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4498 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/p3netmgr.cc | 5 +++ libretroshare/src/pqi/p3peermgr.cc | 36 +++++++++++++++++++-- libretroshare/src/serialiser/rsdiscitems.cc | 4 +-- libretroshare/src/services/p3disc.cc | 6 ++-- 4 files changed, 44 insertions(+), 7 deletions(-) diff --git a/libretroshare/src/pqi/p3netmgr.cc b/libretroshare/src/pqi/p3netmgr.cc index 89fc7b7af..5fecf59be 100644 --- a/libretroshare/src/pqi/p3netmgr.cc +++ b/libretroshare/src/pqi/p3netmgr.cc @@ -441,6 +441,11 @@ void p3NetMgrIMPL::netTick() #ifdef NETMGR_DEBUG_TICK std::cerr << "p3NetMgrIMPL::netTick()" << std::endl; + + std::cerr << "p3NetMgrIMPL::netTick() mNetMode: " << std::hex << mNetMode; + std::cerr << " ACTUALMODE: " << (mNetMode & RS_NET_MODE_ACTUAL); + std::cerr << " TRYMODE: " << (mNetMode & RS_NET_MODE_TRYMODE); + std::cerr << std::endl; #endif // Check whether we are stuck on loopback. This happens if RS starts when diff --git a/libretroshare/src/pqi/p3peermgr.cc b/libretroshare/src/pqi/p3peermgr.cc index e800de3e2..40cb71df6 100644 --- a/libretroshare/src/pqi/p3peermgr.cc +++ b/libretroshare/src/pqi/p3peermgr.cc @@ -109,9 +109,7 @@ p3PeerMgrIMPL::p3PeerMgrIMPL() mOwnState.gpg_id = AuthGPG::getAuthGPG()->getGPGOwnId(); mOwnState.name = AuthGPG::getAuthGPG()->getGPGOwnName(); mOwnState.location = AuthSSL::getAuthSSL()->getOwnLocation(); - mOwnState.netMode = RS_NET_MODE_UDP; - // user decided. - //mOwnState.netMode |= RS_NET_MODE_TRY_UPNP; + mOwnState.netMode = RS_NET_MODE_UPNP; // Default to UPNP. lastGroupId = 1; @@ -973,17 +971,46 @@ bool p3PeerMgrIMPL::setVisState(const std::string &id, uint32_t visState) /* "it" points to peer */ it->second.visState = visState; dht_state = it->second.visState & RS_VIS_STATE_NODHT ; + + std::cerr << "p3PeerMgrIMPL::setVisState(" << id << ", " << std::hex << visState << std::dec << ") "; + std::cerr << " NAME: " << it->second.name; + + if (it->second.visState & RS_VIS_STATE_NODHT) + { + std::cerr << " NO-DHT "; + } + else + { + std::cerr << " DHT-OK "; + } + if (it->second.visState & RS_VIS_STATE_NODISC) + { + std::cerr << " NO-DISC "; + } + else + { + std::cerr << " DISC-OK "; + } + std::cerr << std::endl; + } if(isFriend) { /* toggle DHT state */ if(dht_state) { + + std::cerr << "p3PeerMgrIMPL::setVisState() setFriendVisibility => false"; + std::cerr << std::endl; + /* hidden from DHT world */ mLinkMgr->setFriendVisibility(id, false); } else { + std::cerr << "p3PeerMgrIMPL::setVisState() setFriendVisibility => true"; + std::cerr << std::endl; + mLinkMgr->setFriendVisibility(id, true); } } @@ -1032,6 +1059,7 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list& saveData) item->pid = getOwnId(); item->gpg_id = mOwnState.gpg_id; item->location = mOwnState.location; +#if 0 if (mOwnState.netMode & RS_NET_MODE_TRY_EXT) { item->netMode = RS_NET_MODE_EXT; @@ -1044,6 +1072,8 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list& saveData) { item->netMode = RS_NET_MODE_UDP; } +#endif + item->netMode = mOwnState.netMode; item->visState = mOwnState.visState; item->lastContact = mOwnState.lastcontact; diff --git a/libretroshare/src/serialiser/rsdiscitems.cc b/libretroshare/src/serialiser/rsdiscitems.cc index 2de903554..7f83ad4c7 100644 --- a/libretroshare/src/serialiser/rsdiscitems.cc +++ b/libretroshare/src/serialiser/rsdiscitems.cc @@ -324,7 +324,7 @@ uint32_t RsDiscSerialiser::sizeReply(RsDiscReply *item) for (std::list::iterator it = item->rsPeerList.begin(); it != item->rsPeerList.end(); it++) { s += rss.size(&(*it)) ; -#ifdef RSSERIAL_ERROR_DEBUG +#ifdef RSSERIAL_DEBUG std::cerr << "RsDiscSerialiser::sizeReply() +RsPeerNetItem Size: " << s << std::endl; #endif } @@ -392,7 +392,7 @@ bool RsDiscSerialiser::serialiseReply(RsDiscReply *item, void *data, uint32_ // The size has been updated to its exact value. offset += size; -#ifdef RSSERIAL_ERROR_DEBUG +#ifdef RSSERIAL_DEBUG std::cerr << "RsDiscSerialiser::serialiseReply() RsPeerNetItem ok?: " << ok << std::endl; std::cerr << "RsDiscSerialiser::serialiseReply() Offset After RsPeerNetItem: " << offset << std::endl; #endif diff --git a/libretroshare/src/services/p3disc.cc b/libretroshare/src/services/p3disc.cc index 42f898cc3..dc6e8c1fa 100644 --- a/libretroshare/src/services/p3disc.cc +++ b/libretroshare/src/services/p3disc.cc @@ -675,11 +675,13 @@ void p3disc::recvPeerDetails(RsDiscReply *item, const std::string &certGpgId) // if (item->PeerId() == pitem->pid) { -#ifdef P3DISC_DEBUG std::cerr << "Info sent by the peer itself -> updating self info:" << std::endl; std::cerr << " -> current local addr = " << pitem->currentlocaladdr << std::endl; std::cerr << " -> current remote addr = " << pitem->currentremoteaddr << std::endl; - std::cerr << " -> clearing NODISC flag " << std::endl; + //std::cerr << " -> clearing NODISC flag " << std::endl; + std::cerr << " -> visState = " << std::hex << pitem->visState << std::dec; + std::cerr << std::endl; +#ifdef P3DISC_DEBUG #endif // When the peer sends his own list of IPs, the info replaces the existing info, because the