Merge branch 'master' into android

This commit is contained in:
Gio 2016-10-26 13:43:24 +02:00
commit ea42d822c2
257 changed files with 11438 additions and 22401 deletions

View file

@ -15,6 +15,7 @@
#include "ApiPluginHandler.h"
#include "ChannelsHandler.h"
#include "StatsHandler.h"
/*
data types in json http://json.org/
@ -234,7 +235,8 @@ public:
mTransfersHandler(sts, ifaces.mFiles),
mChatHandler(sts, ifaces.mNotify, ifaces.mMsgs, ifaces.mPeers, ifaces.mIdentity, &mPeersHandler),
mApiPluginHandler(sts, ifaces),
mChannelsHandler(ifaces.mGxsChannels)
mChannelsHandler(ifaces.mGxsChannels),
mStatsHandler()
{
// the dynamic cast is to not confuse the addResourceHandler template like this:
// addResourceHandler(derived class, parent class)
@ -258,6 +260,8 @@ public:
&ChatHandler::handleRequest);
router.addResourceHandler("channels", dynamic_cast<ResourceRouter*>(&mChannelsHandler),
&ChannelsHandler::handleRequest);
router.addResourceHandler("stats", dynamic_cast<ResourceRouter*>(&mStatsHandler),
&StatsHandler::handleRequest);
}
PeersHandler mPeersHandler;
@ -269,6 +273,7 @@ public:
ChatHandler mChatHandler;
ApiPluginHandler mApiPluginHandler;
ChannelsHandler mChannelsHandler;
StatsHandler mStatsHandler;
};
ApiServer::ApiServer():

View file

@ -173,8 +173,8 @@ void FileSearchHandler::handleCreateSearch(Request &req, Response &resp)
return;
}
NameExpression exprs(ContainsAllStrings,words,true) ;
LinearizedExpression lin_exp ;
RsRegularExpression::NameExpression exprs(RsRegularExpression::ContainsAllStrings,words,true) ;
RsRegularExpression::LinearizedExpression lin_exp ;
exprs.linearize(lin_exp) ;
uint32_t search_id = RSRandom::random_u32();

View file

@ -29,7 +29,7 @@ private:
std::vector<RsGxsId> mIds;
StateToken mStateToken;
protected:
virtual void gxsDoWork(Request &req, Response &resp)
virtual void gxsDoWork(Request& /*req*/, Response &resp)
{
resp.mDataStream.getStreamToMember();
for(std::vector<RsGxsId>::iterator vit = mIds.begin(); vit != mIds.end(); ++vit)

View file

@ -0,0 +1,50 @@
#include "StatsHandler.h"
#include "Operators.h"
#include <retroshare/rsconfig.h>
#include <retroshare/rspeers.h>
#include <pqi/authssl.h>
namespace resource_api
{
StatsHandler::StatsHandler()
{
addResourceHandler("*", this, &StatsHandler::handleStatsRequest);
}
void StatsHandler::handleStatsRequest(Request &/*req*/, Response &resp)
{
StreamBase& itemStream = resp.mDataStream.getStreamToMember();
// location info
itemStream << makeKeyValue("name", rsPeers->getGPGName(rsPeers->getGPGOwnId()));
itemStream << makeKeyValue("location", AuthSSL::getAuthSSL()->getOwnLocation());
// peer info
unsigned int all, online;
rsPeers->getPeerCount(&all, &online, false);
itemStream << makeKeyValue("peers_all", all);
itemStream << makeKeyValue("peers_connected", online);
// bandwidth info
float downKb, upKb;
rsConfig->GetCurrentDataRates(downKb, upKb);
itemStream << makeKeyValue("bandwidth_up_kb", (double)upKb);
itemStream << makeKeyValue("bandwidth_down_kb", (double)downKb);
// DHT/NAT info
RsConfigNetStatus config;
rsConfig->getConfigNetStatus(config);
itemStream << makeKeyValue("dht_active", config.DHTActive);
itemStream << makeKeyValue("dht_ok", config.netDhtOk);
itemStream << makeKeyValue("dht_size_all", config.netDhtNetSize);
itemStream << makeKeyValue("dht_size_rs", config.netDhtRsNetSize);
uint32_t netState = rsConfig -> getNetState();
itemStream << makeKeyValue("nat_state", netState);
// ok
resp.setOk();
}
} // namespace resource_api

View file

@ -0,0 +1,25 @@
#ifndef STATSHANDLER_H
#define STATSHANDLER_H
/*
* simple class to output some basic stats about RS
* like bandwidth, connected peers, ...
*/
#include "ResourceRouter.h"
namespace resource_api
{
class StatsHandler : public ResourceRouter
{
public:
StatsHandler();
private:
void handleStatsRequest(Request& req, Response& resp);
};
} // namespace resource_api
#endif // STATSHANDLER_H

View file

@ -824,7 +824,6 @@ static Value DeserializeValue(std::string& str, bool* had_error, std::stack<Stac
std::string temp_val;
size_t i = 0;
bool found_digit = false;
bool found_first_valid_char = false;
for (; i < str.length(); i++)
{
@ -894,7 +893,6 @@ static Value DeserializeValue(std::string& str, bool* had_error, std::stack<Stac
if (std::isdigit(str[i]))
found_digit = true;
found_first_valid_char = true;
temp_val += str[i];
}
}