|
|
|
@ -1,11 +1,15 @@
|
|
|
|
|
#include "I2PControl.h"
|
|
|
|
|
// There is bug in boost 1.49 with gcc 4.7 coming with Debian Wheezy
|
|
|
|
|
#define GCC47_BOOST149 ((BOOST_VERSION == 104900) && (__GNUC__ != 4) && (__GNUC_MINOR__ != 7))
|
|
|
|
|
|
|
|
|
|
#include "I2PControl.h"
|
|
|
|
|
#include <sstream>
|
|
|
|
|
#include <boost/lexical_cast.hpp>
|
|
|
|
|
#include <boost/date_time/local_time/local_time.hpp>
|
|
|
|
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
|
|
|
|
#include <boost/property_tree/ptree.hpp>
|
|
|
|
|
#if !GCC47_BOOST149
|
|
|
|
|
#include <boost/property_tree/json_parser.hpp>
|
|
|
|
|
#endif
|
|
|
|
|
#include "Log.h"
|
|
|
|
|
#include "NetDb.h"
|
|
|
|
|
#include "RouterContext.h"
|
|
|
|
@ -111,7 +115,12 @@ namespace client
|
|
|
|
|
void I2PControlService::ReadRequest (std::shared_ptr<boost::asio::ip::tcp::socket> socket)
|
|
|
|
|
{
|
|
|
|
|
auto request = std::make_shared<I2PControlBuffer>();
|
|
|
|
|
socket->async_read_some (boost::asio::buffer (*request),
|
|
|
|
|
socket->async_read_some (
|
|
|
|
|
#if BOOST_VERSION >= 104900
|
|
|
|
|
boost::asio::buffer (*request),
|
|
|
|
|
#else
|
|
|
|
|
boost::asio::buffer (request->data (), request->size ()),
|
|
|
|
|
#endif
|
|
|
|
|
std::bind(&I2PControlService::HandleRequestReceived, this,
|
|
|
|
|
std::placeholders::_1, std::placeholders::_2, socket, request));
|
|
|
|
|
}
|
|
|
|
@ -142,8 +151,12 @@ namespace client
|
|
|
|
|
return; // TODO:
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#if GCC47_BOOST149
|
|
|
|
|
LogPrint (eLogError, "json_read is not supported due bug in boost 1.49 with gcc 4.7");
|
|
|
|
|
#else
|
|
|
|
|
boost::property_tree::ptree pt;
|
|
|
|
|
boost::property_tree::read_json (ss, pt);
|
|
|
|
|
|
|
|
|
|
std::string method = pt.get<std::string>(I2P_CONTROL_PROPERTY_METHOD);
|
|
|
|
|
auto it = m_MethodHandlers.find (method);
|
|
|
|
|
if (it != m_MethodHandlers.end ())
|
|
|
|
@ -161,6 +174,7 @@ namespace client
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
LogPrint (eLogWarning, "Unknown I2PControl method ", method);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
catch (std::exception& ex)
|
|
|
|
|
{
|
|
|
|
@ -187,7 +201,11 @@ namespace client
|
|
|
|
|
pt.put ("jsonrpc", "2.0");
|
|
|
|
|
|
|
|
|
|
std::ostringstream ss;
|
|
|
|
|
#if GCC47_BOOST149
|
|
|
|
|
LogPrint (eLogError, "json_write is not supported due bug in boost 1.49 with gcc 4.7");
|
|
|
|
|
#else
|
|
|
|
|
boost::property_tree::write_json (ss, pt, false);
|
|
|
|
|
#endif
|
|
|
|
|
size_t len = ss.str ().length (), offset = 0;
|
|
|
|
|
if (isHtml)
|
|
|
|
|
{
|
|
|
|
|