mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 16:10:33 +03:00
Fixes for I2PControl.
This commit is contained in:
parent
1f90b08445
commit
996c36b93d
@ -27,15 +27,18 @@ std::string I2PControlSession::Response::toJsonString() const
|
|||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "{\"id\":" << id << ",\"result\":{";
|
oss << "{\"id\":" << id << ",\"result\":{";
|
||||||
|
for(auto it = parameters.begin(); it != parameters.end(); ++it) {
|
||||||
|
if(it != parameters.begin())
|
||||||
|
oss << ',';
|
||||||
|
oss << '"' << it->first << "\":" << it->second;
|
||||||
|
}
|
||||||
oss << "},\"jsonrpc\":\"" << version << "\"}";
|
oss << "},\"jsonrpc\":\"" << version << "\"}";
|
||||||
for(auto& pair : parameters)
|
|
||||||
oss << '"' << pair.first << "\":" << pair.second << ", ";
|
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2PControlSession::Response::setParam(const std::string& param, const std::string& value)
|
void I2PControlSession::Response::setParam(const std::string& param, const std::string& value)
|
||||||
{
|
{
|
||||||
parameters[param] = value.empty() ? "\"" + value + "\"" : "null";
|
parameters[param] = value.empty() ? "null" : "\"" + value + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2PControlSession::Response::setParam(const std::string& param, int value)
|
void I2PControlSession::Response::setParam(const std::string& param, int value)
|
||||||
@ -130,26 +133,27 @@ void I2PControlSession::handleI2PControl(const PropertyTree& pt, Response& respo
|
|||||||
void I2PControlSession::handleRouterInfo(const PropertyTree& pt, Response& response)
|
void I2PControlSession::handleRouterInfo(const PropertyTree& pt, Response& response)
|
||||||
{
|
{
|
||||||
LogPrint(eLogDebug, "I2PControl RouterInfo");
|
LogPrint(eLogDebug, "I2PControl RouterInfo");
|
||||||
for(auto pair : pt) {
|
for(const auto& pair : pt) {
|
||||||
LogPrint(eLogDebug, pair.first);
|
LogPrint(eLogDebug, pair.first);
|
||||||
auto it = routerInfoHandlers.find(pair.first);
|
auto it = routerInfoHandlers.find(pair.first);
|
||||||
|
LogPrint(eLogDebug, "Still going");
|
||||||
if(it != routerInfoHandlers.end())
|
if(it != routerInfoHandlers.end())
|
||||||
(this->*(it->second))(response);
|
(this->*(it->second))(response);
|
||||||
else
|
else
|
||||||
LogPrint(eLogError, "I2PControl RouterInfo unknown request ", it->first);
|
LogPrint(eLogError, "I2PControl RouterInfo unknown request ", pair.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2PControlSession::handleRouterManager(const PropertyTree& pt, Response& response)
|
void I2PControlSession::handleRouterManager(const PropertyTree& pt, Response& response)
|
||||||
{
|
{
|
||||||
LogPrint(eLogDebug, "I2PControl RouterManager");
|
LogPrint(eLogDebug, "I2PControl RouterManager");
|
||||||
for(auto pair : pt) {
|
for(const auto& pair : pt) {
|
||||||
LogPrint(eLogDebug, pair.first);
|
LogPrint(eLogDebug, pair.first);
|
||||||
auto it = routerManagerHandlers.find(pair.first);
|
auto it = routerManagerHandlers.find(pair.first);
|
||||||
if(it != routerManagerHandlers.end())
|
if(it != routerManagerHandlers.end())
|
||||||
(this->*(it->second))(response);
|
(this->*(it->second))(response);
|
||||||
else
|
else
|
||||||
LogPrint(eLogError, "I2PControl RouterManager unknown request ", it->first);
|
LogPrint(eLogError, "I2PControl RouterManager unknown request ", pair.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user