Merge pull request #309 from majestrate/staging

Staging
pull/310/head
Jeff 5 years ago committed by GitHub
commit a204d7c42e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,10 +1,10 @@
FROM debian:stable
RUN apt update && \
apt install -y build-essential cmake git libcap-dev curl rapidjson-dev
apt install -y build-essential cmake git libcap-dev curl rapidjson-dev ninja-build
WORKDIR /src/
COPY . /src/
RUN make -j 8 JSONRPC=ON && make install
RUN make NINJA=ninja JSONRPC=ON && make install NINJA=ninja

@ -1,10 +1,10 @@
FROM ubuntu:latest
RUN apt update && \
apt install -y build-essential cmake git libcap-dev curl rapidjson-dev
apt install -y build-essential cmake git libcap-dev curl rapidjson-dev ninja-build
WORKDIR /src/
COPY . /src/
RUN make -j 8 JSONRPC=ON
RUN make NINJA=ninja JSONRPC=ON

@ -3,17 +3,79 @@
#include <memory>
#include <rapidjson/document.h>
#include <rapidjson/prettywriter.h>
#include <rapidjson/ostreamwrapper.h>
#include <rapidjson/writer.h>
#include <iostream>
namespace abyss
{
namespace json
{
/// add this because debian stable doesn't have it
template < typename StreamType >
class BasicOStreamWrapper
{
public:
typedef typename StreamType::char_type Ch;
BasicOStreamWrapper(StreamType& stream) : stream_(stream)
{
}
void
Put(Ch c)
{
stream_.put(c);
}
void
Flush()
{
stream_.flush();
}
// Not implemented
char
Peek() const
{
RAPIDJSON_ASSERT(false);
return 0;
}
char
Take()
{
RAPIDJSON_ASSERT(false);
return 0;
}
size_t
Tell() const
{
RAPIDJSON_ASSERT(false);
return 0;
}
char*
PutBegin()
{
RAPIDJSON_ASSERT(false);
return 0;
}
size_t
PutEnd(char*)
{
RAPIDJSON_ASSERT(false);
return 0;
}
private:
BasicOStreamWrapper(const BasicOStreamWrapper&);
BasicOStreamWrapper&
operator=(const BasicOStreamWrapper&);
StreamType& stream_;
};
using Document = rapidjson::Document;
using Value = rapidjson::Value;
using Writer = rapidjson::Writer< rapidjson::OStreamWrapper >;
using Stream = BasicOStreamWrapper< std::ostream >;
using Writer = rapidjson::Writer< Stream >;
} // namespace json
#if __cplusplus >= 201703L
@ -40,18 +102,18 @@ namespace abyss
/// feed data to parser return true if successful
virtual bool
FeedData(const char *buf, size_t sz) = 0;
FeedData(const char* buf, size_t sz) = 0;
/// parse internal buffer
virtual Result
Parse(Document &obj) const = 0;
Parse(Document& obj) const = 0;
};
/// create new parser
IParser *
IParser*
MakeParser(size_t contentSize);
void
ToString(const json::Document &obj, std::ostream &out);
ToString(const json::Document& obj, std::ostream& out);
} // namespace json
} // namespace abyss

@ -1,6 +1,4 @@
#include <abyss/json.hpp>
#include <rapidjson/ostreamwrapper.h>
#include <rapidjson/writer.h>
#include <util/string_view.hpp>
#include <cstring>
@ -52,8 +50,8 @@ namespace abyss
void
ToString(const json::Document& val, std::ostream& out)
{
rapidjson::OStreamWrapper s(out);
rapidjson::Writer< rapidjson::OStreamWrapper > writer(s);
Stream s(out);
rapidjson::Writer< Stream > writer(s);
val.Accept(writer);
}

@ -25,7 +25,7 @@ namespace abyss
std::unique_ptr< abyss::json::IParser > m_BodyParser;
json::Document m_Request;
std::stringstream m_ResponseBuffer;
rapidjson::OStreamWrapper m_ResponseStream;
abyss::json::Stream m_ResponseStream;
abyss::json::Writer m_Response;
enum HTTPState

@ -1737,7 +1737,7 @@ namespace llarp
++itr;
}
// send control message if we look too quiet
if(now - lastGoodSend > 60000)
if(now - lastGoodSend > (sendTimeout / 2))
{
Encrypted< 64 > tmp;
tmp.Randomize();

Loading…
Cancel
Save