From 9b67e93e01ee00d6a27e7b8b0a98a1d1ec2cfdeb Mon Sep 17 00:00:00 2001 From: Konrad Date: Sun, 21 May 2017 19:51:52 +0200 Subject: [PATCH 01/13] Added: Network configuration to libresapi. --- libresapi/src/api/PeersHandler.cpp | 195 +++++++++++++++++++++++++++++ libresapi/src/api/PeersHandler.h | 3 + 2 files changed, 198 insertions(+) diff --git a/libresapi/src/api/PeersHandler.cpp b/libresapi/src/api/PeersHandler.cpp index d7f13fd6e..30179508f 100644 --- a/libresapi/src/api/PeersHandler.cpp +++ b/libresapi/src/api/PeersHandler.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include @@ -198,6 +199,8 @@ PeersHandler::PeersHandler(StateTokenServer* sts, RsNotify* notify, RsPeers *pee addResourceHandler("set_state_string", this, &PeersHandler::handleSetStateString); addResourceHandler("get_custom_state_string", this, &PeersHandler::handleGetCustomStateString); addResourceHandler("set_custom_state_string", this, &PeersHandler::handleSetCustomStateString); + addResourceHandler("get_network_options", this, &PeersHandler::handleGetNetworkOptions); + addResourceHandler("set_network_options", this, &PeersHandler::handleSetNetworkOptions); addResourceHandler("get_pgp_options", this, &PeersHandler::handleGetPGPOptions); addResourceHandler("set_pgp_options", this, &PeersHandler::handleSetPGPOptions); addResourceHandler("get_node_options", this, &PeersHandler::handleGetNodeOptions); @@ -618,6 +621,198 @@ void PeersHandler::handleExamineCert(Request &req, Response &resp) } } +void PeersHandler::handleGetNetworkOptions(Request& req, Response& resp) +{ + RsPeerDetails detail; + if (!mRsPeers->getPeerDetails(mRsPeers->getOwnId(), detail)) + return; + + resp.mDataStream << makeKeyValue("local_address", detail.localAddr); + resp.mDataStream << makeKeyValue("local_port", (int)detail.localPort); + resp.mDataStream << makeKeyValue("external_address", detail.extAddr); + resp.mDataStream << makeKeyValue("external_port", (int)detail.extPort); + resp.mDataStream << makeKeyValue("dyn_dns", detail.dyndns); + + int netIndex = 0; + switch(detail.netMode) + { + case RS_NETMODE_EXT: + netIndex = 2; + break; + case RS_NETMODE_UDP: + netIndex = 1; + break; + case RS_NETMODE_UPNP: + netIndex = 0; + break; + } + + resp.mDataStream << makeKeyValue("nat_mode", netIndex); + + int discoveryIndex = 3; // NONE. + if(detail.vs_dht != RS_VS_DHT_OFF) + { + if(detail.vs_disc != RS_VS_DISC_OFF) + discoveryIndex = 0; // PUBLIC + else + discoveryIndex = 2; // INVERTED + } + else + { + if(detail.vs_disc != RS_VS_DISC_OFF) + discoveryIndex = 1; // PRIVATE + else + discoveryIndex = 3; // NONE + } + + resp.mDataStream << makeKeyValue("discovery_mode", discoveryIndex); + + int dlrate = 0; + int ulrate = 0; + rsConfig->GetMaxDataRates(dlrate, ulrate); + resp.mDataStream << makeKeyValue("download_limit", dlrate); + resp.mDataStream << makeKeyValue("upload_limit", ulrate); + + bool checkIP = mRsPeers->getAllowServerIPDetermination(); + resp.mDataStream << makeKeyValue("check_ip", checkIP); + + StreamBase& previousIPsStream = resp.mDataStream.getStreamToMember("previous_ips"); + previousIPsStream.getStreamToMember(); + for(std::list::const_iterator it = detail.ipAddressList.begin(); it != detail.ipAddressList.end(); ++it) + previousIPsStream.getStreamToMember() << makeKeyValue("ip_address", *it); + + std::list ip_servers; + mRsPeers->getIPServersList(ip_servers); + + StreamBase& websitesStream = resp.mDataStream.getStreamToMember("websites"); + websitesStream.getStreamToMember(); + + for(std::list::const_iterator it = ip_servers.begin(); it != ip_servers.end(); ++it) + websitesStream.getStreamToMember() << makeKeyValue("website", *it); + + std::string proxyaddr; + uint16_t proxyport; + uint32_t status ; + // Tor + mRsPeers->getProxyServer(RS_HIDDEN_TYPE_TOR, proxyaddr, proxyport, status); + resp.mDataStream << makeKeyValue("tor_address", proxyaddr); + resp.mDataStream << makeKeyValue("tor_port", (int)proxyport); + + // I2P + mRsPeers->getProxyServer(RS_HIDDEN_TYPE_I2P, proxyaddr, proxyport, status); + resp.mDataStream << makeKeyValue("i2p_address", proxyaddr); + resp.mDataStream << makeKeyValue("i2p_port", (int)proxyport); + + resp.setOk(); +} + +void PeersHandler::handleSetNetworkOptions(Request& req, Response& resp) +{ + RsPeerDetails detail; + if (!mRsPeers->getPeerDetails(mRsPeers->getOwnId(), detail)) + return; + + int netIndex = 0; + uint32_t natMode = 0; + req.mStream << makeKeyValueReference("nat_mode", netIndex); + + switch(netIndex) + { + case 3: + natMode = RS_NETMODE_HIDDEN; + break; + case 2: + natMode = RS_NETMODE_EXT; + break; + case 1: + natMode = RS_NETMODE_UDP; + break; + default: + case 0: + natMode = RS_NETMODE_UPNP; + break; + } + + if (detail.netMode != natMode) + mRsPeers->setNetworkMode(mRsPeers->getOwnId(), natMode); + + int discoveryIndex; + uint16_t vs_disc = 0; + uint16_t vs_dht = 0; + req.mStream << makeKeyValueReference("discovery_mode", discoveryIndex); + + switch(discoveryIndex) + { + case 0: + vs_disc = RS_VS_DISC_FULL; + vs_dht = RS_VS_DHT_FULL; + break; + case 1: + vs_disc = RS_VS_DISC_FULL; + vs_dht = RS_VS_DHT_OFF; + break; + case 2: + vs_disc = RS_VS_DISC_OFF; + vs_dht = RS_VS_DHT_FULL; + break; + case 3: + default: + vs_disc = RS_VS_DISC_OFF; + vs_dht = RS_VS_DHT_OFF; + break; + } + + if ((vs_disc != detail.vs_disc) || (vs_dht != detail.vs_dht)) + mRsPeers->setVisState(mRsPeers->getOwnId(), vs_disc, vs_dht); + + if (0 != netIndex) + { + std::string localAddr; + int localPort; + std::string extAddr; + int extPort; + + req.mStream << makeKeyValueReference("local_address", localAddr); + req.mStream << makeKeyValueReference("local_port", localPort); + req.mStream << makeKeyValueReference("external_address", extAddr); + req.mStream << makeKeyValueReference("external_port", extPort); + + mRsPeers->setLocalAddress(mRsPeers->getOwnId(), localAddr, (uint16_t)localPort); + mRsPeers->setExtAddress(mRsPeers->getOwnId(), extAddr, (uint16_t)extPort); + } + + std::string dynDNS; + req.mStream << makeKeyValueReference("dyn_dns", dynDNS); + mRsPeers->setDynDNS(mRsPeers->getOwnId(), dynDNS); + + int dlrate = 0; + int ulrate = 0; + req.mStream << makeKeyValueReference("download_limit", dlrate); + req.mStream << makeKeyValueReference("upload_limit", ulrate); + rsConfig->SetMaxDataRates(dlrate, ulrate); + + bool checkIP; + req.mStream << makeKeyValueReference("check_ip", checkIP); + rsPeers->allowServerIPDetermination(checkIP) ; + + // Tor + std::string toraddr; + int torport; + req.mStream << makeKeyValueReference("tor_address", toraddr); + req.mStream << makeKeyValueReference("tor_port", torport); + mRsPeers->setProxyServer(RS_HIDDEN_TYPE_TOR, toraddr, (uint16_t)torport); + + // I2P + std::string i2paddr; + int i2pport; + req.mStream << makeKeyValueReference("i2p_address", i2paddr); + req.mStream << makeKeyValueReference("i2p_port", i2pport); + mRsPeers->setProxyServer(RS_HIDDEN_TYPE_I2P, i2paddr, (uint16_t)i2pport); + + resp.mStateToken = getCurrentStateToken(); + resp.setOk(); +} + void PeersHandler::handleGetPGPOptions(Request& req, Response& resp) { std::string pgp_id; diff --git a/libresapi/src/api/PeersHandler.h b/libresapi/src/api/PeersHandler.h index c4e0ddc3d..9ed60f263 100644 --- a/libresapi/src/api/PeersHandler.h +++ b/libresapi/src/api/PeersHandler.h @@ -42,6 +42,9 @@ private: void handleGetCustomStateString(Request& req, Response& resp); void handleSetCustomStateString(Request& req, Response& resp); + void handleGetNetworkOptions(Request& req, Response& resp); + void handleSetNetworkOptions(Request& req, Response& resp); + void handleGetPGPOptions(Request& req, Response& resp); void handleSetPGPOptions(Request& req, Response& resp); From 7fb0419c75e5c6ef13675d1e8318187bb36aae1c Mon Sep 17 00:00:00 2001 From: BabushkaRetroShare Date: Sun, 4 Jun 2017 20:34:10 +0200 Subject: [PATCH 02/13] Typo fixes --- libretroshare/src/gxstunnel/p3gxstunnel.cc | 2 +- libretroshare/src/pqi/p3peermgr.cc | 2 +- libretroshare/src/tests/network_simulator/README.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libretroshare/src/gxstunnel/p3gxstunnel.cc b/libretroshare/src/gxstunnel/p3gxstunnel.cc index 90e601ed3..46d9179b1 100644 --- a/libretroshare/src/gxstunnel/p3gxstunnel.cc +++ b/libretroshare/src/gxstunnel/p3gxstunnel.cc @@ -211,7 +211,7 @@ void p3GxsTunnelService::flush() if(it->second.last_contact+20+GXS_TUNNEL_KEEP_ALIVE_TIMEOUT < now && it->second.status == RS_GXS_TUNNEL_STATUS_CAN_TALK) { #ifdef DEBUG_GXS_TUNNEL - std::cerr << "(II) GxsTunnelService:: connexion interrupted with peer." << std::endl; + std::cerr << "(II) GxsTunnelService:: connection interrupted with peer." << std::endl; #endif it->second.status = RS_GXS_TUNNEL_STATUS_TUNNEL_DN ; diff --git a/libretroshare/src/pqi/p3peermgr.cc b/libretroshare/src/pqi/p3peermgr.cc index cad91f30b..ece94650e 100644 --- a/libretroshare/src/pqi/p3peermgr.cc +++ b/libretroshare/src/pqi/p3peermgr.cc @@ -1528,7 +1528,7 @@ bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, cons if((!rsBanList->isAddressAccepted(addr_filtered,RSBANLIST_CHECKING_FLAGS_WHITELIST)) && (!sockaddr_storage_sameip(own_addr,addr_filtered))) { - std::cerr << " Peer " << from << " reports a connexion address (" << sockaddr_storage_iptostring(addr_filtered) <<") that is not your current external address (" << sockaddr_storage_iptostring(own_addr) << "). This is weird." << std::endl; + std::cerr << " Peer " << from << " reports a connection address (" << sockaddr_storage_iptostring(addr_filtered) <<") that is not your current external address (" << sockaddr_storage_iptostring(own_addr) << "). This is weird." << std::endl; RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED, from.toStdString(), sockaddr_storage_iptostring(own_addr), sockaddr_storage_iptostring(addr)); } diff --git a/libretroshare/src/tests/network_simulator/README.txt b/libretroshare/src/tests/network_simulator/README.txt index cf5838545..2a669d3c3 100644 --- a/libretroshare/src/tests/network_simulator/README.txt +++ b/libretroshare/src/tests/network_simulator/README.txt @@ -51,7 +51,7 @@ together. The routers will talk to a fake link manager, which reports the peers Required components: =================== - NetworkGraph: a set of friends, with connexions. Should be able to be saved to a file for debugging. + NetworkGraph: a set of friends, with connections. Should be able to be saved to a file for debugging. GraphNode: a RS peer, represented by a random SSL id, a link manager, and possibly components such as file transfer, etc. From ca1dc9d64f62959479e92a0ffdebdca664f6af3e Mon Sep 17 00:00:00 2001 From: Konrad Date: Sun, 4 Jun 2017 22:10:41 +0200 Subject: [PATCH 03/13] Changed: Unified socket path across systems. --- retroshare-android-service/src/service.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/retroshare-android-service/src/service.cpp b/retroshare-android-service/src/service.cpp index d67ca1bef..6729768cc 100644 --- a/retroshare-android-service/src/service.cpp +++ b/retroshare-android-service/src/service.cpp @@ -45,16 +45,11 @@ int main(int argc, char *argv[]) dynamic_cast(&ctrl_mod), &resource_api::RsControlModule::handleRequest); -#if defined(Q_OS_WIN) && defined(QT_DEBUG) - QString sockPath = "RS/"; -#elif defined(Q_OS_WIN) - QString sockPath = QCoreApplication::applicationDirPath(); -#else - QString sockPath = QDir::homePath() + "/.retroshare"; -#endif + QString sockPath = QDir::homePath() + "/.retroshare"; sockPath.append("/libresapi.sock"); qDebug() << "Listening on:" << sockPath; + ApiServerLocal apiServerLocal(&api, sockPath); (void) apiServerLocal; while (!ctrl_mod.processShouldExit()) From 2d8fd0764b70dcffa5748ecbecc36326c6562088 Mon Sep 17 00:00:00 2001 From: RetroPooh Date: Mon, 5 Jun 2017 14:25:09 +0300 Subject: [PATCH 04/13] stats tunnels rearranged columns for better readablilty --- retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp b/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp index a76b5b5c3..8f35f6d57 100644 --- a/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp +++ b/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp @@ -142,7 +142,7 @@ void TurtleRouterDialog::updateTunnelRequests( const std::vector [" + QString::fromUtf8(tunnels_info[i][1].c_str()) + "]\t\t " + tr("last transfer") + ": " + QString::fromStdString(tunnels_info[i][4]) + " " + "\t " + tr("Speed") + ": " + QString::fromStdString(tmp) ; + QString str = tr("Tunnel id") + ": " + QString::fromUtf8(tunnels_info[i][0].c_str()) + "\t" + tr("Speed") + ": " + QString::fromStdString(tmp) + "\t " + tr("last transfer") + ": " + QString::fromStdString(tunnels_info[i][4])+ "\t" + QString::fromUtf8(tunnels_info[i][2].c_str()) + " -> " + QString::fromUtf8(tunnels_info[i][1].c_str()); stl.clear() ; stl.push_back(str) ; QTreeWidgetItem *item = new QTreeWidgetItem(stl); From e726bd1061bd819ee51027190fc6e354282f0a6e Mon Sep 17 00:00:00 2001 From: cyril soler Date: Wed, 7 Jun 2017 13:37:38 +0200 Subject: [PATCH 05/13] attempt to fix the crash in DataStore by not calling deleteMsgs directly --- libretroshare/src/gxstrans/p3gxstrans.cc | 11 +++++++++-- libretroshare/src/gxstrans/p3gxstrans.h | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/gxstrans/p3gxstrans.cc b/libretroshare/src/gxstrans/p3gxstrans.cc index 41a100e4c..057e0fc64 100644 --- a/libretroshare/src/gxstrans/p3gxstrans.cc +++ b/libretroshare/src/gxstrans/p3gxstrans.cc @@ -354,8 +354,14 @@ void p3GxsTrans::GxsTransIntegrityCleanupThread::run() RS_STACK_MUTEX(mMtx) ; mMsgToDel = msgsToDel ; + mDone = true; } +bool p3GxsTrans::GxsTransIntegrityCleanupThread::isDone() +{ + RS_STACK_MUTEX(mMtx) ; + return mDone ; +} void p3GxsTrans::service_tick() { GxsTokenQueue::checkRequests(); @@ -381,7 +387,7 @@ void p3GxsTrans::service_tick() // now grab collected messages to delete - if(mCleanupThread != NULL && !mCleanupThread->isRunning()) + if(mCleanupThread != NULL && !mCleanupThread->isDone()) { GxsMsgReq msgToDel ; @@ -390,7 +396,8 @@ void p3GxsTrans::service_tick() if(!msgToDel.empty()) { std::cerr << "p3GxsTrans::service_tick(): deleting messages." << std::endl; - getDataStore()->removeMsgs(msgToDel); + uint32_t token ; + deleteMsgs(token,msgToDel); } } diff --git a/libretroshare/src/gxstrans/p3gxstrans.h b/libretroshare/src/gxstrans/p3gxstrans.h index fb205409d..d068827cd 100644 --- a/libretroshare/src/gxstrans/p3gxstrans.h +++ b/libretroshare/src/gxstrans/p3gxstrans.h @@ -159,7 +159,7 @@ private: * Two weeks seems fair ATM. */ static const uint32_t GXS_STORAGE_PERIOD = 0x127500; - static const uint32_t MAX_DELAY_BETWEEN_CLEANUPS = 1203; // every 20 mins. Could be less. + static const uint32_t MAX_DELAY_BETWEEN_CLEANUPS = 1203; // every 20 mins. Could be less. time_t mLastMsgCleanup ; @@ -282,7 +282,7 @@ private: enum CheckState { CheckStart, CheckChecking }; public: - GxsTransIntegrityCleanupThread(RsGeneralDataService *const dataService): mDs(dataService),mMtx("GxsTransIntegrityCheck") {} + GxsTransIntegrityCleanupThread(RsGeneralDataService *const dataService): mDs(dataService),mMtx("GxsTransIntegrityCheck") { mDone=false;} bool isDone(); void run(); @@ -296,6 +296,7 @@ private: RsMutex mMtx ; GxsMsgReq mMsgToDel ; + bool mDone ; }; GxsTransIntegrityCleanupThread *mCleanupThread ; From 23156ab4b1bd122b5257e541fff72e388c796dbc Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 3 Jun 2017 10:30:02 +0200 Subject: [PATCH 06/13] fixed malloc problem when chat avatar is missing --- libretroshare/src/chat/p3chatservice.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libretroshare/src/chat/p3chatservice.cc b/libretroshare/src/chat/p3chatservice.cc index 851b2983d..64c4e9534 100644 --- a/libretroshare/src/chat/p3chatservice.cc +++ b/libretroshare/src/chat/p3chatservice.cc @@ -169,6 +169,12 @@ class p3ChatService::AvatarInfo void toUnsignedChar(unsigned char *& data,uint32_t& size) const { + if(_image_size == 0) + { + size = 0 ; + data = NULL ; + return ; + } data = (unsigned char *)rs_malloc(_image_size) ; size = _image_size ; memcpy(data,_image_data,size*sizeof(unsigned char)) ; From 318ea310f8473c63aeb87791a5636607e2bd8bbb Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 3 Jun 2017 10:30:22 +0200 Subject: [PATCH 07/13] fixed layout of GxsTrans stats --- .../gui/statistics/GxsTransportStatistics.ui | 96 ++++++++++--------- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.ui b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.ui index 2fe43f576..78653b5ae 100644 --- a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.ui +++ b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.ui @@ -13,51 +13,8 @@ Router Statistics - - - - - Gxs Transport Groups: - - - - - - Qt::Vertical - - - - - Group ID / Author - - - - - Number of messages / Publish TS - - - - - Total size of messages - - - - - Subscribed - - - - - Popularity - - - - - - - - - + + GroupBox @@ -65,6 +22,12 @@ + + + 0 + 0 + + Qt::CustomContextMenu @@ -114,6 +77,49 @@ + + + + Gxs Transport Groups: + + + + + + Qt::Vertical + + + + + Group ID / Author + + + + + Number of messages / Publish TS + + + + + Total size of messages + + + + + Subscribed + + + + + Popularity + + + + + + + + From 4cb7522feb0ef261d0e053a218cafcccdf2c0bbc Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 7 Jun 2017 21:41:00 +0200 Subject: [PATCH 08/13] added deleted gxs messages to the reject list of GxsNetService to avoid re-downloading them right away --- libretroshare/src/gxs/rsgenexchange.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index 5845a2887..32ddaa7e6 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -1752,8 +1752,18 @@ void RsGenExchange::deleteGroup(uint32_t& token, const RsGxsGroupId& grpId) } void RsGenExchange::deleteMsgs(uint32_t& token, const GxsMsgReq& msgs) { + RS_STACK_MUTEX(mGenMtx) ; + token = mDataAccess->generatePublicToken(); mMsgDeletePublish.push_back(MsgDeletePublish(msgs, token)); + + // This code below will suspend any requests of the deleted messages for 24 hrs. This of course only works + // if all friend nodes consistently delete the messages in the mean time. + + if(mNetService != NULL) + for(GxsMsgReq::const_iterator it(msgs.begin());it!=msgs.end();++it) + for(uint32_t i=0;isecond.size();++i) + mNetService->rejectMessage(it->second[i]) ; } void RsGenExchange::publishMsg(uint32_t& token, RsGxsMsgItem *msgItem) From 7691a8ef2f861e1c82891f96e7ec0e373e239f6c Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 7 Jun 2017 21:41:20 +0200 Subject: [PATCH 09/13] removed debug info --- retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index 2c0e1af84..46a3943e5 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -185,8 +185,9 @@ bool GxsChannelPostItem::setGroup(const RsGxsChannelGroup &group, bool doFill) mGroup = group; // if not publisher, hide the edit button. Without the publish key, there's no way to edit a message. - +#ifdef DEBUG_ITEM std::cerr << "Group subscribe flags = " << std::hex << mGroup.mMeta.mSubscribeFlags << std::dec << std::endl; +#endif if(!IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) ui->editButton->hide(); From 9853b53f8b749c07124f94f47e915d6a6a93ad15 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 7 Jun 2017 23:10:24 +0200 Subject: [PATCH 10/13] fixed debug output in GxsNetService --- libretroshare/src/gxs/rsgxsnetservice.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index 789a77441..91a915f40 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -268,7 +268,7 @@ static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_GXS_KEY_MISSING = 0x05 ; static const RsPeerId peer_to_print = RsPeerId(std::string("")) ; static const RsGxsGroupId group_id_to_print = RsGxsGroupId(std::string("")) ; // use this to allow to this group id only, or "" for all IDs -static const uint32_t service_to_print = 0x215 ; // use this to allow to this service id only, or 0 for all services +static const uint32_t service_to_print = RS_SERVICE_TYPE_GXS_TRANS ; // use this to allow to this service id only, or 0 for all services // warning. Numbers should be SERVICE IDS (see serialiser/rsserviceids.h. E.g. 0x0215 for forums) class nullstream: public std::ostream {}; @@ -447,6 +447,9 @@ void RsGxsNetService::rejectMessage(const RsGxsMessageId& msg_id) { RS_STACK_MUTEX(mNxsMutex) ; +#ifdef NXS_NET_DEBUG_0 + GXSNETDEBUG___ << "adding message " << msg_id << " to rejection list for 24hrs." << std::endl; +#endif mRejectedMessages[msg_id] = time(NULL) ; } void RsGxsNetService::cleanRejectedMessages() @@ -595,9 +598,9 @@ void RsGxsNetService::syncWithPeers() #ifdef NXS_NET_DEBUG_0 GXSNETDEBUG_PG(peerId,grpId) << " peer can send messages for group " << grpId ; if(!encrypt_to_this_circle_id.isNull()) - std::cerr << " request should be encrypted for circle ID " << encrypt_to_this_circle_id << std::endl; + GXSNETDEBUG_PG(peerId,grpId) << " request should be encrypted for circle ID " << encrypt_to_this_circle_id << std::endl; else - std::cerr << " request should be sent in clear." << std::endl; + GXSNETDEBUG_PG(peerId,grpId) << " request should be sent in clear." << std::endl; #endif // On default, the info has never been received so the TS is 0, meaning the peer has sent that it had no information. @@ -1839,7 +1842,7 @@ void RsGxsNetService::debugDump() GXSNETDEBUG_PG(it->first,it2->first) << " group " << it2->first << " - last updated at peer (secs ago): " << nice_time_stamp(time(NULL),it2->second.time_stamp) << ". Message count=" << it2->second.message_count << std::endl; } - GXSNETDEBUG___<< " List of rejected message ids: " << mRejectedMessages.size() << std::endl; + GXSNETDEBUG___<< " List of rejected message ids: " << std::dec << mRejectedMessages.size() << std::endl; #endif } From 1766087f7124d571cd5dc1d2dfa692051e5551af Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 7 Jun 2017 23:10:59 +0200 Subject: [PATCH 11/13] fixed update notification and display in GxsTransStatistics --- libretroshare/src/gxstrans/p3gxstrans.cc | 3 ++- .../gui/statistics/GxsTransportStatistics.cpp | 20 +++++++++---------- .../gui/statistics/GxsTransportStatistics.h | 6 +++--- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/libretroshare/src/gxstrans/p3gxstrans.cc b/libretroshare/src/gxstrans/p3gxstrans.cc index 057e0fc64..3fde5beb7 100644 --- a/libretroshare/src/gxstrans/p3gxstrans.cc +++ b/libretroshare/src/gxstrans/p3gxstrans.cc @@ -387,7 +387,7 @@ void p3GxsTrans::service_tick() // now grab collected messages to delete - if(mCleanupThread != NULL && !mCleanupThread->isDone()) + if(mCleanupThread != NULL && mCleanupThread->isDone()) { GxsMsgReq msgToDel ; @@ -543,6 +543,7 @@ void p3GxsTrans::notifyChanges(std::vector& changes) } } } + RsGxsIfaceHelper::receiveChanges(changes); } uint32_t p3GxsTrans::AuthenPolicy() diff --git a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp index 39c6b1c84..7233b6981 100644 --- a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp @@ -73,7 +73,7 @@ static const int GXSTRANS_STATISTICS_DELAY_BETWEEN_GROUP_REQ = 30 ; // never req #define DEBUG_GXSTRANS_STATS 1 GxsTransportStatistics::GxsTransportStatistics(QWidget *parent) - : RsAutoUpdatePage(2000,parent) + : RsGxsUpdateBroadcastPage(rsGxsTrans,parent) { setupUi(this) ; @@ -93,6 +93,7 @@ GxsTransportStatistics::GxsTransportStatistics(QWidget *parent) // load settings processSettings(true); + updateDisplay(true); } GxsTransportStatistics::~GxsTransportStatistics() @@ -139,19 +140,14 @@ void GxsTransportStatistics::CustomPopupMenu( QPoint ) contextMnu.exec(QCursor::pos()); } -void GxsTransportStatistics::updateDisplay() +void GxsTransportStatistics::updateDisplay(bool) { - time_t now = time(NULL) ; + time_t now = time(NULL) ; - if(mLastGroupReqTS + GXSTRANS_STATISTICS_DELAY_BETWEEN_GROUP_REQ < now) - { - requestGroupMeta(); - mLastGroupReqTS = now ; - } + std::cerr << "GxsTransportStatistics::updateDisplay()" << std::endl; - //_tst_CW->updateContent() ; - - updateContent(); + requestGroupMeta(); + mLastGroupReqTS = now ; } QString GxsTransportStatistics::getPeerName(const RsPeerId &peer_id) @@ -319,6 +315,8 @@ void GxsTransportStatistics::loadRequest(const TokenQueue *queue, const TokenReq std::cerr << std::endl; break; } + + updateContent(); } void GxsTransportStatistics::requestGroupMeta() diff --git a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.h b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.h index 576aadd26..c57d63c11 100644 --- a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.h +++ b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.h @@ -30,6 +30,7 @@ #include "util/TokenQueue.h" #include "RsAutoUpdatePage.h" #include "ui_GxsTransportStatistics.h" +#include "gui/gxs/RsGxsUpdateBroadcastPage.h" class GxsTransportStatisticsWidget ; class UIStateHelper; @@ -45,7 +46,7 @@ public: std::vector messages_metas ; }; -class GxsTransportStatistics: public RsAutoUpdatePage, public TokenResponse, public Ui::GxsTransportStatistics +class GxsTransportStatistics: public RsGxsUpdateBroadcastPage, public TokenResponse, public Ui::GxsTransportStatistics { Q_OBJECT @@ -66,6 +67,7 @@ private slots: void personDetails(); private: + void updateDisplay(bool complete) ; void loadGroupMeta(const uint32_t& token); void loadGroupStat(const uint32_t& token); void loadMsgMeta(const uint32_t& token); @@ -77,8 +79,6 @@ private: void processSettings(bool bLoad); bool m_bProcessSettings; - virtual void updateDisplay() ; - GxsTransportStatisticsWidget *_tst_CW ; TokenQueue *mTransQueue ; UIStateHelper *mStateHelper; From 80ec9b73218e04dde129c64ddd9da8008840d5bc Mon Sep 17 00:00:00 2001 From: Jeetu Golani Date: Mon, 12 Jun 2017 15:51:26 +0530 Subject: [PATCH 12/13] Included QStringList header in ApiServerLocal.cpp [Issue 879] --- libresapi/src/api/ApiServerLocal.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libresapi/src/api/ApiServerLocal.cpp b/libresapi/src/api/ApiServerLocal.cpp index 5d89ed2d0..ec1812af7 100644 --- a/libresapi/src/api/ApiServerLocal.cpp +++ b/libresapi/src/api/ApiServerLocal.cpp @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include #include "ApiServerLocal.h" #include "JsonStream.h" From 79825eb2e2a5fb73fdd3193bf73fe3d0b6a5b39b Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 12 Jun 2017 20:36:02 +0200 Subject: [PATCH 13/13] fixed thread issue in RsGxsCleanupThread that caused random crashes --- libretroshare/src/gxs/rsgenexchange.cc | 84 +++++++++++++------------- libretroshare/src/gxs/rsgxsutil.cc | 84 ++++++++++++++------------ libretroshare/src/util/rsthreads.cc | 1 + 3 files changed, 88 insertions(+), 81 deletions(-) diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index 32ddaa7e6..e6a1b3d30 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -190,52 +190,54 @@ void RsGenExchange::tick() now = time(NULL); if(mChecking || (mLastCheck + INTEGRITY_CHECK_PERIOD < now)) { - if(mIntegrityCheck) + mLastCheck = time(NULL); + { - if(mIntegrityCheck->isDone()) + RS_STACK_MUTEX(mGenMtx) ; + + if(!mIntegrityCheck) { - std::list grpIds; - std::map > msgIds; - mIntegrityCheck->getDeletedIds(grpIds, msgIds); - - if (!grpIds.empty()) - { - RS_STACK_MUTEX(mGenMtx) ; - - RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PROCESSED, false); - gc->mGrpIdList = grpIds; -#ifdef GEN_EXCH_DEBUG - std::cerr << " adding the following grp ids to notification: " << std::endl; - for(std::list::const_iterator it(grpIds.begin());it!=grpIds.end();++it) - std::cerr << " " << *it << std::endl; -#endif - mNotifications.push_back(gc); - - // also notify the network exchange service that these groups no longer exist. - - if(mNetService) - mNetService->removeGroups(grpIds) ; - } - - if (!msgIds.empty()) { - RS_STACK_MUTEX(mGenMtx) ; - - RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, false); - c->msgChangeMap = msgIds; - mNotifications.push_back(c); - } - - delete mIntegrityCheck; - mIntegrityCheck = NULL; - mLastCheck = time(NULL); - mChecking = false; + mIntegrityCheck = new RsGxsIntegrityCheck(mDataStore,this,mGixs); + mIntegrityCheck->start("gxs integrity"); + mChecking = true; } } - else + + if(mIntegrityCheck->isDone()) { - mIntegrityCheck = new RsGxsIntegrityCheck(mDataStore,this,mGixs); - mIntegrityCheck->start("gxs integrity"); - mChecking = true; + RS_STACK_MUTEX(mGenMtx) ; + + std::list grpIds; + std::map > msgIds; + mIntegrityCheck->getDeletedIds(grpIds, msgIds); + + if (!grpIds.empty()) + { + RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PROCESSED, false); + gc->mGrpIdList = grpIds; +#ifdef GEN_EXCH_DEBUG + std::cerr << " adding the following grp ids to notification: " << std::endl; + for(std::list::const_iterator it(grpIds.begin());it!=grpIds.end();++it) + std::cerr << " " << *it << std::endl; +#endif + mNotifications.push_back(gc); + + // also notify the network exchange service that these groups no longer exist. + + if(mNetService) + mNetService->removeGroups(grpIds) ; + } + + if (!msgIds.empty()) + { + RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, false); + c->msgChangeMap = msgIds; + mNotifications.push_back(c); + } + + delete mIntegrityCheck; + mIntegrityCheck = NULL; + mChecking = false; } } } diff --git a/libretroshare/src/gxs/rsgxsutil.cc b/libretroshare/src/gxs/rsgxsutil.cc index 21d7d3d3e..8a853e789 100644 --- a/libretroshare/src/gxs/rsgxsutil.cc +++ b/libretroshare/src/gxs/rsgxsutil.cc @@ -136,6 +136,9 @@ RsGxsIntegrityCheck::RsGxsIntegrityCheck(RsGeneralDataService* const dataService void RsGxsIntegrityCheck::run() { check(); + + RsStackMutex stack(mIntegrityMutex); + mDone = true; } bool RsGxsIntegrityCheck::check() @@ -286,71 +289,72 @@ bool RsGxsIntegrityCheck::check() mDs->removeMsgs(msgsToDel); - RsStackMutex stack(mIntegrityMutex); - mDone = true; + { + RsStackMutex stack(mIntegrityMutex); - std::vector::iterator grpIt; - for(grpIt = grpsToDel.begin(); grpIt != grpsToDel.end(); ++grpIt) - { - mDeletedGrps.push_back(*grpIt); - } - mDeletedMsgs = msgsToDel; + std::vector::iterator grpIt; + for(grpIt = grpsToDel.begin(); grpIt != grpsToDel.end(); ++grpIt) + { + mDeletedGrps.push_back(*grpIt); + } + mDeletedMsgs = msgsToDel; #ifdef DEBUG_GXSUTIL - GXSUTIL_DEBUG() << "At end of pass, this is the list used GXS ids: " << std::endl; - GXSUTIL_DEBUG() << " requesting them to GXS identity service to enforce loading." << std::endl; + GXSUTIL_DEBUG() << "At end of pass, this is the list used GXS ids: " << std::endl; + GXSUTIL_DEBUG() << " requesting them to GXS identity service to enforce loading." << std::endl; #endif - std::list connected_friends ; - rsPeers->getOnlineList(connected_friends) ; + std::list connected_friends ; + rsPeers->getOnlineList(connected_friends) ; - std::vector > gxs_ids ; + std::vector > gxs_ids ; - for(std::map::const_iterator it(used_gxs_ids.begin());it!=used_gxs_ids.end();++it) - { - gxs_ids.push_back(*it) ; + for(std::map::const_iterator it(used_gxs_ids.begin());it!=used_gxs_ids.end();++it) + { + gxs_ids.push_back(*it) ; #ifdef DEBUG_GXSUTIL - GXSUTIL_DEBUG() << " " << *it << std::endl; + GXSUTIL_DEBUG() << " " << *it << std::endl; #endif - } - uint32_t nb_requested_not_in_cache = 0; + } + uint32_t nb_requested_not_in_cache = 0; #ifdef DEBUG_GXSUTIL - GXSUTIL_DEBUG() << " issuing random get on friends for non existing IDs" << std::endl; + GXSUTIL_DEBUG() << " issuing random get on friends for non existing IDs" << std::endl; #endif - // now request a cache update for them, which triggers downloading from friends, if missing. + // now request a cache update for them, which triggers downloading from friends, if missing. - for(;nb_requested_not_in_cachehaveKey(gxs_ids[n].first)) // checks if we have it already in the cache (conservative way to ensure that we atually have it) - { - mGixs->requestKey(gxs_ids[n].first,connected_friends,gxs_ids[n].second); + if(!mGixs->haveKey(gxs_ids[n].first)) // checks if we have it already in the cache (conservative way to ensure that we atually have it) + { + mGixs->requestKey(gxs_ids[n].first,connected_friends,gxs_ids[n].second); - ++nb_requested_not_in_cache ; + ++nb_requested_not_in_cache ; #ifdef DEBUG_GXSUTIL - GXSUTIL_DEBUG() << " ... from cache/net" << std::endl; + GXSUTIL_DEBUG() << " ... from cache/net" << std::endl; #endif - } - else - { + } + else + { #ifdef DEBUG_GXSUTIL - GXSUTIL_DEBUG() << " ... already in cache" << std::endl; + GXSUTIL_DEBUG() << " ... already in cache" << std::endl; #endif - } - mGixs->timeStampKey(gxs_ids[n].first,gxs_ids[n].second); + } + mGixs->timeStampKey(gxs_ids[n].first,gxs_ids[n].second); - gxs_ids[n] = gxs_ids[gxs_ids.size()-1] ; - gxs_ids.pop_back() ; - } + gxs_ids[n] = gxs_ids[gxs_ids.size()-1] ; + gxs_ids.pop_back() ; + } #ifdef DEBUG_GXSUTIL - GXSUTIL_DEBUG() << " total actual cache requests: "<< nb_requested_not_in_cache << std::endl; + GXSUTIL_DEBUG() << " total actual cache requests: "<< nb_requested_not_in_cache << std::endl; #endif + } return true; } diff --git a/libretroshare/src/util/rsthreads.cc b/libretroshare/src/util/rsthreads.cc index 1db86f17e..8899ee01c 100644 --- a/libretroshare/src/util/rsthreads.cc +++ b/libretroshare/src/util/rsthreads.cc @@ -179,6 +179,7 @@ void RsThread::start(const std::string &threadName) THREAD_DEBUG << "pqithreadstreamer::start() initing should_stop=0" << std::endl; #endif mShouldStopSemaphore.set(0) ; + mHasStoppedSemaphore.set(0) ; int err ;