|
|
@ -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 <sstream> |
|
|
|
#include <boost/lexical_cast.hpp> |
|
|
|
#include <boost/lexical_cast.hpp> |
|
|
|
#include <boost/date_time/local_time/local_time.hpp> |
|
|
|
#include <boost/date_time/local_time/local_time.hpp> |
|
|
|
#include <boost/date_time/posix_time/posix_time.hpp> |
|
|
|
#include <boost/date_time/posix_time/posix_time.hpp> |
|
|
|
#include <boost/property_tree/ptree.hpp> |
|
|
|
#include <boost/property_tree/ptree.hpp> |
|
|
|
|
|
|
|
#if !GCC47_BOOST149 |
|
|
|
#include <boost/property_tree/json_parser.hpp> |
|
|
|
#include <boost/property_tree/json_parser.hpp> |
|
|
|
|
|
|
|
#endif |
|
|
|
#include "Log.h" |
|
|
|
#include "Log.h" |
|
|
|
#include "NetDb.h" |
|
|
|
#include "NetDb.h" |
|
|
|
#include "RouterContext.h" |
|
|
|
#include "RouterContext.h" |
|
|
@ -111,7 +115,12 @@ namespace client |
|
|
|
void I2PControlService::ReadRequest (std::shared_ptr<boost::asio::ip::tcp::socket> socket) |
|
|
|
void I2PControlService::ReadRequest (std::shared_ptr<boost::asio::ip::tcp::socket> socket) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto request = std::make_shared<I2PControlBuffer>(); |
|
|
|
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::bind(&I2PControlService::HandleRequestReceived, this, |
|
|
|
std::placeholders::_1, std::placeholders::_2, socket, request)); |
|
|
|
std::placeholders::_1, std::placeholders::_2, socket, request)); |
|
|
|
} |
|
|
|
} |
|
|
@ -142,8 +151,12 @@ namespace client |
|
|
|
return; // TODO:
|
|
|
|
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::ptree pt; |
|
|
|
boost::property_tree::read_json (ss, pt); |
|
|
|
boost::property_tree::read_json (ss, pt); |
|
|
|
|
|
|
|
|
|
|
|
std::string method = pt.get<std::string>(I2P_CONTROL_PROPERTY_METHOD); |
|
|
|
std::string method = pt.get<std::string>(I2P_CONTROL_PROPERTY_METHOD); |
|
|
|
auto it = m_MethodHandlers.find (method); |
|
|
|
auto it = m_MethodHandlers.find (method); |
|
|
|
if (it != m_MethodHandlers.end ()) |
|
|
|
if (it != m_MethodHandlers.end ()) |
|
|
@ -161,6 +174,7 @@ namespace client |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
LogPrint (eLogWarning, "Unknown I2PControl method ", method); |
|
|
|
LogPrint (eLogWarning, "Unknown I2PControl method ", method); |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
catch (std::exception& ex) |
|
|
|
catch (std::exception& ex) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -187,7 +201,11 @@ namespace client |
|
|
|
pt.put ("jsonrpc", "2.0"); |
|
|
|
pt.put ("jsonrpc", "2.0"); |
|
|
|
|
|
|
|
|
|
|
|
std::ostringstream ss; |
|
|
|
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); |
|
|
|
boost::property_tree::write_json (ss, pt, false); |
|
|
|
|
|
|
|
#endif |
|
|
|
size_t len = ss.str ().length (), offset = 0; |
|
|
|
size_t len = ss.str ().length (), offset = 0; |
|
|
|
if (isHtml) |
|
|
|
if (isHtml) |
|
|
|
{ |
|
|
|
{ |
|
|
|