Merge branch 'pulls/159'
This commit is contained in:
commit
7744cb16a2
8 changed files with 57 additions and 54 deletions
2
.gitmodules
vendored
2
.gitmodules
vendored
|
@ -1,6 +1,6 @@
|
|||
[submodule "beast"]
|
||||
path = beast
|
||||
url = https://github.com/vinniefalco/Beast.git
|
||||
url = https://github.com/boostorg/beast.git
|
||||
[submodule "miniupnp"]
|
||||
path = miniupnp
|
||||
url = https://github.com/miniupnp/miniupnp.git
|
||||
|
|
2
beast
2
beast
|
@ -1 +1 @@
|
|||
Subproject commit 663c275fc16c2b5e075b96bbe91467f83256df5c
|
||||
Subproject commit c7b830f37f8adc0df63d41ff4d31395ab704516b
|
2
cryptopp
2
cryptopp
|
@ -1 +1 @@
|
|||
Subproject commit 32f715f1d723e2bbb78b44fa9e167da64214e2e6
|
||||
Subproject commit ed4c345ce86aad98c38fac120569eb9406fbfc37
|
2
miniupnp
2
miniupnp
|
@ -1 +1 @@
|
|||
Subproject commit 5923d5de6ffd7960b9362f46735cbb0a6b738adf
|
||||
Subproject commit e24d7eca28022b959b331b08e6918b58b303c1cf
|
|
@ -3,8 +3,7 @@
|
|||
#include <rai/node/testing.hpp>
|
||||
#include <rai/node/rpc.hpp>
|
||||
|
||||
#include <beast/http.hpp>
|
||||
#include <beast/http/string_body.hpp>
|
||||
#include <boost/beast.hpp>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
@ -25,17 +24,17 @@ public:
|
|||
{
|
||||
std::stringstream ostream;
|
||||
boost::property_tree::write_json (ostream, request);
|
||||
req.method ("POST");
|
||||
req.method (boost::beast::http::verb::post);
|
||||
req.target ("/");
|
||||
req.version = 11;
|
||||
ostream.flush ();
|
||||
req.body = ostream.str ();
|
||||
beast::http::prepare(req);
|
||||
beast::http::async_write (sock, req, [this] (boost::system::error_code & ec)
|
||||
req.prepare_payload ();
|
||||
boost::beast::http::async_write (sock, req, [this] (boost::system::error_code const & ec)
|
||||
{
|
||||
if (!ec)
|
||||
{
|
||||
beast::http::async_read(sock, sb, resp, [this] (boost::system::error_code & ec)
|
||||
boost::beast::http::async_read(sock, sb, resp, [this] (boost::system::error_code const & ec)
|
||||
{
|
||||
if (!ec)
|
||||
{
|
||||
|
@ -71,9 +70,9 @@ public:
|
|||
boost::property_tree::ptree const & request;
|
||||
boost::asio::ip::tcp::socket sock;
|
||||
boost::property_tree::ptree json;
|
||||
beast::flat_buffer sb;
|
||||
beast::http::request<beast::http::string_body> req;
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::beast::flat_buffer sb;
|
||||
boost::beast::http::request<boost::beast::http::string_body> req;
|
||||
boost::beast::http::response<boost::beast::http::string_body> resp;
|
||||
int status;
|
||||
};
|
||||
|
||||
|
@ -1361,10 +1360,9 @@ TEST (rpc, version)
|
|||
ASSERT_EQ (200, response1.status);
|
||||
ASSERT_EQ ("8", response1.json.get <std::string> ("store_version"));
|
||||
ASSERT_EQ (boost::str (boost::format ("RaiBlocks %1%.%2%.%3%") % RAIBLOCKS_VERSION_MAJOR % RAIBLOCKS_VERSION_MINOR % RAIBLOCKS_VERSION_PATCH), response1.json.get <std::string> ("node_vendor"));
|
||||
auto & headers (response1.resp.fields);
|
||||
auto access_control (std::find_if (headers.begin (), headers.end (), [] (decltype (*headers.begin ()) & header_a) { return boost::iequals (header_a.first, "Access-Control-Allow-Origin"); }));
|
||||
ASSERT_NE (headers.end (), access_control);
|
||||
ASSERT_EQ ("*", access_control->second);
|
||||
auto headers (response1.resp.find ("Access-Control-Allow-Origin"));
|
||||
ASSERT_NE (response1.resp.end (), headers);
|
||||
ASSERT_EQ ("*", headers->value ());
|
||||
}
|
||||
|
||||
TEST (rpc, work_generate)
|
||||
|
|
|
@ -1119,31 +1119,33 @@ warmed_up (0)
|
|||
{
|
||||
if (!ec)
|
||||
{
|
||||
auto req (std::make_shared <beast::http::request<beast::http::string_body>> ());
|
||||
req->method ("POST");
|
||||
auto req (std::make_shared <boost::beast::http::request<boost::beast::http::string_body>> ());
|
||||
req->method (boost::beast::http::verb::post);
|
||||
req->target (*target);
|
||||
req->version = 11;
|
||||
req->fields.replace("Host", address);
|
||||
req->insert(boost::beast::http::field::host, address);
|
||||
req->body = *body;
|
||||
beast::http::prepare (*req);
|
||||
beast::http::async_write (*sock, *req, [node_l, sock, address, port, req] (boost::system::error_code & ec)
|
||||
//req->prepare (*req);
|
||||
//boost::beast::http::prepare(req);
|
||||
req->prepare_payload();
|
||||
boost::beast::http::async_write (*sock, *req, [node_l, sock, address, port, req] (boost::system::error_code const & ec)
|
||||
{
|
||||
if (!ec)
|
||||
{
|
||||
auto sb (std::make_shared <beast::flat_buffer> ());
|
||||
auto resp (std::make_shared <beast::http::response <beast::http::string_body>> ());
|
||||
beast::http::async_read (*sock, *sb, *resp, [node_l, sb, resp, sock, address, port] (boost::system::error_code & ec)
|
||||
auto sb (std::make_shared <boost::beast::flat_buffer> ());
|
||||
auto resp (std::make_shared <boost::beast::http::response <boost::beast::http::string_body>> ());
|
||||
boost::beast::http::async_read (*sock, *sb, *resp, [node_l, sb, resp, sock, address, port] (boost::system::error_code const & ec)
|
||||
{
|
||||
if (!ec)
|
||||
{
|
||||
if (resp->status == 200)
|
||||
if (resp->result() == boost::beast::http::status::ok)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (node_l->config.logging.callback_logging ())
|
||||
{
|
||||
BOOST_LOG (node_l->log) << boost::str (boost::format ("Callback to %1%:%2% failed with status: %3%") % address % port % resp->status);
|
||||
BOOST_LOG (node_l->log) << boost::str (boost::format ("Callback to %1%:%2% failed with status: %3%") % address % port % resp->result());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1837,8 +1839,8 @@ socket (service_a)
|
|||
}
|
||||
boost::asio::ip::address address;
|
||||
uint16_t port;
|
||||
beast::flat_buffer buffer;
|
||||
beast::http::response <beast::http::string_body> response;
|
||||
boost::beast::flat_buffer buffer;
|
||||
boost::beast::http::response <boost::beast::http::string_body> response;
|
||||
boost::asio::ip::tcp::socket socket;
|
||||
};
|
||||
class distributed_work : public std::enable_shared_from_this <distributed_work>
|
||||
|
@ -1881,21 +1883,21 @@ void start ()
|
|||
boost::property_tree::write_json (ostream, request);
|
||||
request_string = ostream.str ();
|
||||
}
|
||||
beast::http::request <beast::http::string_body> request;
|
||||
request.method ("POST");
|
||||
request.target ("/");
|
||||
request.version = 11;
|
||||
request.body = request_string;
|
||||
beast::http::prepare (request);
|
||||
beast::http::async_write (connection->socket, request, [this_l, connection] (boost::system::error_code const & ec)
|
||||
auto request (std::make_shared <boost::beast::http::request <boost::beast::http::string_body>> ());
|
||||
request->method (boost::beast::http::verb::post);
|
||||
request->target ("/");
|
||||
request->version = 11;
|
||||
request->body = request_string;
|
||||
request->prepare_payload ();
|
||||
boost::beast::http::async_write (connection->socket, *request, [this_l, connection, request] (boost::system::error_code const & ec)
|
||||
{
|
||||
if (!ec)
|
||||
{
|
||||
beast::http::async_read (connection->socket, connection->buffer, connection->response, [this_l, connection] (boost::system::error_code const & ec)
|
||||
boost::beast::http::async_read (connection->socket, connection->buffer, connection->response, [this_l, connection] (boost::system::error_code const & ec)
|
||||
{
|
||||
if (!ec)
|
||||
{
|
||||
if (connection->response.status == 200)
|
||||
if (connection->response.result() == boost::beast::http::status::ok)
|
||||
{
|
||||
this_l->success (connection->response.body, connection->address);
|
||||
}
|
||||
|
@ -1952,14 +1954,15 @@ void stop ()
|
|||
boost::property_tree::write_json (ostream, request);
|
||||
request_string = ostream.str ();
|
||||
}
|
||||
beast::http::request <beast::http::string_body> request;
|
||||
request.method ("POST");
|
||||
boost::beast::http::request <boost::beast::http::string_body> request;
|
||||
request.method (boost::beast::http::verb::post);
|
||||
request.target ("/");
|
||||
request.version = 11;
|
||||
request.body = request_string;
|
||||
beast::http::prepare (request);
|
||||
//boost::beast::http::prepare (request);
|
||||
request.prepare_payload();
|
||||
auto socket (std::make_shared <boost::asio::ip::tcp::socket> (this_l->node->network.service));
|
||||
beast::http::async_write (*socket, request, [socket] (boost::system::error_code const & ec)
|
||||
boost::beast::http::async_write (*socket, request, [socket] (boost::system::error_code const & ec)
|
||||
{
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3093,7 +3093,7 @@ socket (node_a.network.service)
|
|||
void rai::rpc_connection::parse_connection ()
|
||||
{
|
||||
auto this_l (shared_from_this ());
|
||||
beast::http::async_read (socket, buffer, request, [this_l] (boost::system::error_code const & ec)
|
||||
boost::beast::http::async_read (socket, buffer, request, [this_l] (boost::system::error_code const & ec)
|
||||
{
|
||||
if (!ec)
|
||||
{
|
||||
|
@ -3107,13 +3107,14 @@ void rai::rpc_connection::parse_connection ()
|
|||
boost::property_tree::write_json (ostream, tree_a);
|
||||
ostream.flush ();
|
||||
auto body (ostream.str ());
|
||||
this_l->res.fields.insert ("content-type", "application/json");
|
||||
this_l->res.fields.insert ("Access-Control-Allow-Origin", "*");
|
||||
this_l->res.status = 200;
|
||||
this_l->res.set ("content-type", "application/json");
|
||||
this_l->res.set ("Access-Control-Allow-Origin", "*");
|
||||
this_l->res.result(boost::beast::http::status::ok);
|
||||
this_l->res.body = body;
|
||||
this_l->res.version = version;
|
||||
beast::http::prepare (this_l->res);
|
||||
beast::http::async_write (this_l->socket, this_l->res, [this_l] (boost::system::error_code const & ec)
|
||||
this_l->res.prepare_payload();
|
||||
//boost::beast::http::prepare (this_l->res);
|
||||
boost::beast::http::async_write (this_l->socket, this_l->res, [this_l] (boost::system::error_code const & ec)
|
||||
{
|
||||
});
|
||||
if (this_l->node->config.logging.log_rpc ())
|
||||
|
@ -3121,7 +3122,7 @@ void rai::rpc_connection::parse_connection ()
|
|||
BOOST_LOG (this_l->node->log) << boost::str (boost::format ("RPC request %2% completed in: %1% microseconds") % std::chrono::duration_cast <std::chrono::microseconds> (std::chrono::system_clock::now () - start).count () % boost::io::group (std::hex, std::showbase, reinterpret_cast <uintptr_t> (this_l.get ())));
|
||||
}
|
||||
});
|
||||
if (this_l->request.method () == "POST")
|
||||
if (this_l->request.method () == boost::beast::http::verb::post)
|
||||
{
|
||||
auto handler (std::make_shared <rai::rpc_handler> (*this_l->node, this_l->rpc, this_l->request.body, response_handler));
|
||||
handler->process_request ();
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
#include <rai/utility.hpp>
|
||||
|
||||
#include <beast/http.hpp>
|
||||
#include <beast/core/flat_buffer.hpp>
|
||||
//#include <boost/beast/http.hpp>
|
||||
//#include <boost/beast/core/flat_buffer.hpp>
|
||||
#include <boost/beast.hpp>
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
|
@ -63,9 +64,9 @@ public:
|
|||
std::shared_ptr <rai::node> node;
|
||||
rai::rpc & rpc;
|
||||
boost::asio::ip::tcp::socket socket;
|
||||
beast::flat_buffer buffer;
|
||||
beast::http::request <beast::http::string_body> request;
|
||||
beast::http::response <beast::http::string_body> res;
|
||||
boost::beast::flat_buffer buffer;
|
||||
boost::beast::http::request <boost::beast::http::string_body> request;
|
||||
boost::beast::http::response <boost::beast::http::string_body> res;
|
||||
};
|
||||
class payment_observer : public std::enable_shared_from_this <rai::payment_observer>
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue