#define HAVE_BOOST 1
#define HAVE_MBEDTLS2 1
EOF
-mkdir -p $DIRNAME/ext/rapidjson/include/rapidjson/internal
-cp -a ../ext/rapidjson/include/rapidjson/*.h $DIRNAME/ext/rapidjson/include/rapidjson/
-cp -a ../ext/rapidjson/include/rapidjson/internal/*.h $DIRNAME/ext/rapidjson/include/rapidjson/internal
mkdir -p $DIRNAME/ext/mbedtls/include/mbedtls
cp -a ../ext/mbedtls/include/mbedtls/{config.h,check_config.h,aes.h,ripemd160.h,sha1.h,md.h,md5.h,sha256.h,sha512.h,ecp.h,ecdsa.h,md_internal.h} ../ext/mbedtls/include/mbedtls/base64.h ../ext/mbedtls/include/mbedtls/platform.h ../ext/mbedtls/include/mbedtls/version.h $DIRNAME/ext/mbedtls/include/mbedtls
cp -a ../ext/mbedtls/include/mbedtls/{entropy.h,ctr_drbg.h,hmac_drbg.h,rsa.h,ecp.h,bignum.h,oid.h,asn1.h,asn1write.h,pk.h,ecdsa.h,cipher.h,x509.h} $DIRNAME/ext/mbedtls/include/mbedtls
SYSCONFDIR=/etc/powerdns/
LOCALSTATEDIR=/var/run/
OPTFLAGS?=-O3
-CXXFLAGS:= $(CXXFLAGS) -Iext/rapidjson/include -I$(CURDIR)/ext/mbedtls/include -I$(CURDIR)/ext/json11 -Wall @CF_PIE@ @CF_FORTIFY@ @CF_STACK@ $(OPTFLAGS) $(PROFILEFLAGS) $(ARCHFLAGS) -pthread -Iext/yahttp -DHAVE_CONFIG_H
+CXXFLAGS:= $(CXXFLAGS) -I$(CURDIR)/ext/mbedtls/include -I$(CURDIR)/ext/json11 -Wall @CF_PIE@ @CF_FORTIFY@ @CF_STACK@ $(OPTFLAGS) $(PROFILEFLAGS) $(ARCHFLAGS) -pthread -Iext/yahttp -DHAVE_CONFIG_H
CFLAGS:=$(CFLAGS) -Wall $(OPTFLAGS) @CF_PIE@ @CF_FORTIFY@ @CF_STACK@ $(PROFILEFLAGS) $(ARCHFLAGS) -I$(CURDIR)/ext/mbedtls/include -pthread -DHAVE_CONFIG_H
LDFLAGS:=$(LDFLAGS) $(ARCHFLAGS) -pthread @LD_RELRO@ @CF_STACK@ @LD_PIE@
STRIP_BINARIES?=1
AM_CPPFLAGS += \
-I$(top_srcdir)/ext/json11 \
- -I$(top_srcdir)/ext/rapidjson/include \
$(YAHTTP_CFLAGS) \
$(MBEDTLS_CFLAGS)
#include "namespaces.hh"
#include "misc.hh"
-#include "rapidjson/document.h"
-#include "rapidjson/stringbuffer.h"
-#include "rapidjson/writer.h"
-
-using namespace rapidjson;
using json11::Json;
-int intFromJson(const Value& container, const char* key)
-{
- if (!container.IsObject()) {
- throw JsonException("Container was not an object.");
- }
- const Value& val = container[key];
- if (val.IsInt()) {
- return val.GetInt();
- } else if (val.IsString()) {
- return std::stoi(val.GetString());
- } else {
- throw JsonException("Key '" + string(key) + "' not an Integer or not present");
- }
-}
-
-int intFromJson(const Value& container, const char* key, const int default_value)
-{
- if (!container.IsObject()) {
- throw JsonException("Container was not an object.");
- }
- const Value& val = container[key];
- if (val.IsInt()) {
- return val.GetInt();
- } else if (val.IsString()) {
- return std::stoi(val.GetString());
- } else {
- // TODO: check if value really isn't present
- return default_value;
- }
-}
-
int intFromJson(const Json container, const std::string& key)
{
auto val = container[key];
}
}
-string stringFromJson(const Value& container, const char* key)
-{
- if (!container.IsObject()) {
- throw JsonException("Container was not an object.");
- }
- const Value& val = container[key];
- if (val.IsString()) {
- return val.GetString();
- } else {
- throw JsonException("Key '" + string(key) + "' not present or not a String");
- }
-}
-
string stringFromJson(const Json container, const std::string &key)
{
const Json val = container[key];
}
}
-string stringFromJson(const Value& container, const char* key, const string& default_value)
-{
- if (!container.IsObject()) {
- throw JsonException("Container was not an object.");
- }
- const Value& val = container[key];
- if (val.IsString()) {
- return val.GetString();
- } else {
- // TODO: check if value really isn't present
- return default_value;
- }
-}
-
-bool boolFromJson(const rapidjson::Value& container, const char* key)
-{
- if (!container.IsObject()) {
- throw JsonException("Container was not an object.");
- }
- const Value& val = container[key];
- if (val.IsBool()) {
- return val.GetBool();
- } else {
- throw JsonException("Key '" + string(key) + "' not present or not a Bool");
- }
-}
-
-bool boolFromJson(const rapidjson::Value& container, const char* key, const bool default_value)
-{
- if (!container.IsObject()) {
- throw JsonException("Container was not an object.");
- }
- const Value& val = container[key];
- if (val.IsBool()) {
- return val.GetBool();
- } else {
- return default_value;
- }
-}
-
-bool boolFromJson(const json11::Json container, const std::string& key)
+bool boolFromJson(const Json container, const std::string& key)
{
auto val = container[key];
if (val.is_bool()) {
}
}
-bool boolFromJson(const json11::Json container, const std::string& key, const bool default_value)
+bool boolFromJson(const Json container, const std::string& key, const bool default_value)
{
auto val = container[key];
if (val.is_bool()) {
return default_value;
}
}
-
-string makeStringFromDocument(const Document& doc)
-{
- StringBuffer output;
- Writer<StringBuffer> w(output);
- doc.Accept(w);
- return string(output.GetString(), output.Size());
-}
#pragma once // it is 2012, deal with it
#include <string>
-#include <map>
#include <stdexcept>
-#include "rapidjson/document.h"
#include "json11.hpp"
-std::string makeStringFromDocument(const rapidjson::Document& doc);
-int intFromJson(const rapidjson::Value& container, const char* key);
-int intFromJson(const rapidjson::Value& container, const char* key, const int default_value);
int intFromJson(const json11::Json container, const std::string& key);
int intFromJson(const json11::Json container, const std::string& key, const int default_value);
-std::string stringFromJson(const rapidjson::Value& container, const char* key);
-std::string stringFromJson(const rapidjson::Value& container, const char* key, const std::string& default_value);
std::string stringFromJson(const json11::Json container, const std::string &key);
-bool boolFromJson(const rapidjson::Value& container, const char* key);
-bool boolFromJson(const rapidjson::Value& container, const char* key, const bool default_value);
bool boolFromJson(const json11::Json container, const std::string& key);
bool boolFromJson(const json11::Json container, const std::string& key, const bool default_value);
Socket* client;
};
-void HttpRequest::json(rapidjson::Document& document)
-{
- if(this->body.empty()) {
- L<<Logger::Debug<<"HTTP: JSON document expected in request body, but body was empty" << endl;
- throw HttpBadRequestException();
- }
- if(document.Parse<0>(this->body.c_str()).HasParseError()) {
- L<<Logger::Debug<<"HTTP: parsing of JSON document failed" << endl;
- throw HttpBadRequestException();
- }
-}
-
json11::Json HttpRequest::json()
{
string err;
}
-void HttpResponse::setBody(rapidjson::Document& document)
-{
- this->body = makeStringFromDocument(document);
-}
-
void HttpResponse::setBody(const json11::Json& document)
{
document.dump(this->body);
#include <list>
#include <boost/utility.hpp>
#include <yahttp/yahttp.hpp>
-#include "rapidjson/document.h"
-#include "rapidjson/stringbuffer.h"
-#include "rapidjson/writer.h"
#include "json11.hpp"
#include "namespaces.hh"
#include "sstuff.hh"
bool accept_json;
bool accept_html;
bool complete;
- void json(rapidjson::Document& document);
json11::Json json();
// checks password _only_.
HttpResponse() : YaHTTP::Response() { };
HttpResponse(const YaHTTP::Response &resp) : YaHTTP::Response(resp) { };
- void setBody(rapidjson::Document& document);
void setBody(const json11::Json& document);
void setErrorResult(const std::string& message, const int status);
void setSuccessResult(const std::string& message, const int status = 200);
#include <boost/format.hpp>
#include "namespaces.hh"
-#include "rapidjson/document.h"
-#include "rapidjson/stringbuffer.h"
-#include "rapidjson/writer.h"
#include "ws-api.hh"
#include "version.hh"
#include "dnsseckeeper.hh"
#include "common_startup.hh"
-using namespace rapidjson;
using json11::Json;
extern StatBag S;
#include "misc.hh"
#include "syncres.hh"
#include "dnsparser.hh"
-#include "rapidjson/document.h"
-#include "rapidjson/stringbuffer.h"
-#include "rapidjson/writer.h"
#include "json11.hpp"
#include "webserver.hh"
#include "ws-api.hh"
extern __thread FDMultiplexer* t_fdm;
-using namespace rapidjson;
using json11::Json;
void productServerStatisticsFetch(map<string,string>& out)