mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-26 16:24:17 +00:00
Add more information to webui.
This commit is contained in:
parent
7e066f7f69
commit
9890bf98e4
@ -114,10 +114,12 @@ namespace client
|
|||||||
// I2P Control
|
// I2P Control
|
||||||
int i2pcontrolPort = i2p::util::config::GetArg("-i2pcontrolport", 0);
|
int i2pcontrolPort = i2p::util::config::GetArg("-i2pcontrolport", 0);
|
||||||
if(i2pcontrolPort) {
|
if(i2pcontrolPort) {
|
||||||
m_I2PControlService = new I2PControlService(
|
m_I2PControlService = new i2pcontrol::I2PControlService(
|
||||||
i2p::util::config::GetArg("-i2pcontroladdress", "127.0.0.1"),
|
i2p::util::config::GetArg("-i2pcontroladdress", "127.0.0.1"),
|
||||||
i2pcontrolPort,
|
i2pcontrolPort,
|
||||||
i2p::util::config::GetArg("-i2pcontrolpassword", I2P_CONTROL_DEFAULT_PASSWORD)
|
i2p::util::config::GetArg(
|
||||||
|
"-i2pcontrolpassword", i2pcontrol::constants::DEFAULT_PASSWORD
|
||||||
|
)
|
||||||
);
|
);
|
||||||
m_I2PControlService->Start();
|
m_I2PControlService->Start();
|
||||||
LogPrint("I2PControl started");
|
LogPrint("I2PControl started");
|
||||||
|
@ -72,7 +72,7 @@ namespace client
|
|||||||
std::map<i2p::data::IdentHash, std::unique_ptr<I2PServerTunnel> > m_ServerTunnels; // destination->tunnel
|
std::map<i2p::data::IdentHash, std::unique_ptr<I2PServerTunnel> > m_ServerTunnels; // destination->tunnel
|
||||||
SAMBridge * m_SamBridge;
|
SAMBridge * m_SamBridge;
|
||||||
BOBCommandChannel * m_BOBCommandChannel;
|
BOBCommandChannel * m_BOBCommandChannel;
|
||||||
I2PControlService * m_I2PControlService;
|
i2pcontrol::I2PControlService * m_I2PControlService;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// for HTTP
|
// for HTTP
|
||||||
|
@ -36,7 +36,7 @@ const char HTTP_COMMAND_SAM_SESSION[] = "sam_session";
|
|||||||
const char HTTP_PARAM_SAM_SESSION_ID[] = "id";
|
const char HTTP_PARAM_SAM_SESSION_ID[] = "id";
|
||||||
|
|
||||||
HTTPConnection::HTTPConnection(boost::asio::ip::tcp::socket* socket,
|
HTTPConnection::HTTPConnection(boost::asio::ip::tcp::socket* socket,
|
||||||
std::shared_ptr<i2p::client::I2PControlSession> session)
|
std::shared_ptr<client::i2pcontrol::I2PControlSession> session)
|
||||||
: m_Socket(socket), m_Timer(socket->get_io_service()),
|
: m_Socket(socket), m_Timer(socket->get_io_service()),
|
||||||
m_BufferLen(0), m_Session(session)
|
m_BufferLen(0), m_Session(session)
|
||||||
{
|
{
|
||||||
@ -159,7 +159,7 @@ void HTTPConnection::HandleRequest()
|
|||||||
void HTTPConnection::HandleI2PControlRequest()
|
void HTTPConnection::HandleI2PControlRequest()
|
||||||
{
|
{
|
||||||
std::stringstream ss(m_Request.getContent());
|
std::stringstream ss(m_Request.getContent());
|
||||||
const client::I2PControlSession::Response rsp = m_Session->handleRequest(ss);
|
const client::i2pcontrol::I2PControlSession::Response rsp = m_Session->handleRequest(ss);
|
||||||
m_Reply = i2p::util::http::Response(200, rsp.toJsonString());
|
m_Reply = i2p::util::http::Response(200, rsp.toJsonString());
|
||||||
m_Reply.setHeader("Content-Type", "application/json");
|
m_Reply.setHeader("Content-Type", "application/json");
|
||||||
SendReply();
|
SendReply();
|
||||||
@ -197,7 +197,7 @@ HTTPServer::HTTPServer(const std::string& address, int port):
|
|||||||
boost::asio::ip::address::from_string(address), port)
|
boost::asio::ip::address::from_string(address), port)
|
||||||
),
|
),
|
||||||
m_NewSocket(nullptr),
|
m_NewSocket(nullptr),
|
||||||
m_Session(std::make_shared<i2p::client::I2PControlSession>(m_Service))
|
m_Session(std::make_shared<client::i2pcontrol::I2PControlSession>(m_Service))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ class HTTPConnection: public std::enable_shared_from_this<HTTPConnection> {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
HTTPConnection(boost::asio::ip::tcp::socket* socket,
|
HTTPConnection(boost::asio::ip::tcp::socket* socket,
|
||||||
std::shared_ptr<i2p::client::I2PControlSession> session);
|
std::shared_ptr<i2p::client::i2pcontrol::I2PControlSession> session);
|
||||||
|
|
||||||
~HTTPConnection() { delete m_Socket; }
|
~HTTPConnection() { delete m_Socket; }
|
||||||
void Receive();
|
void Receive();
|
||||||
@ -44,7 +44,7 @@ private:
|
|||||||
size_t m_BufferLen;
|
size_t m_BufferLen;
|
||||||
util::http::Request m_Request;
|
util::http::Request m_Request;
|
||||||
util::http::Response m_Reply;
|
util::http::Response m_Reply;
|
||||||
std::shared_ptr<i2p::client::I2PControlSession> m_Session;
|
std::shared_ptr<i2p::client::i2pcontrol::I2PControlSession> m_Session;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HTTPServer {
|
class HTTPServer {
|
||||||
@ -69,7 +69,7 @@ private:
|
|||||||
boost::asio::io_service::work m_Work;
|
boost::asio::io_service::work m_Work;
|
||||||
boost::asio::ip::tcp::acceptor m_Acceptor;
|
boost::asio::ip::tcp::acceptor m_Acceptor;
|
||||||
boost::asio::ip::tcp::socket * m_NewSocket;
|
boost::asio::ip::tcp::socket * m_NewSocket;
|
||||||
std::shared_ptr<i2p::client::I2PControlSession> m_Session;
|
std::shared_ptr<i2p::client::i2pcontrol::I2PControlSession> m_Session;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void CreateConnection(boost::asio::ip::tcp::socket* m_NewSocket);
|
void CreateConnection(boost::asio::ip::tcp::socket* m_NewSocket);
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <cryptopp/filters.h>
|
#include <cryptopp/filters.h>
|
||||||
|
|
||||||
#include <boost/property_tree/json_parser.hpp>
|
#include <boost/property_tree/json_parser.hpp>
|
||||||
|
#include "util/util.h"
|
||||||
#include "util/Log.h"
|
#include "util/Log.h"
|
||||||
#include "util/Timestamp.h"
|
#include "util/Timestamp.h"
|
||||||
#include "transport/Transports.h"
|
#include "transport/Transports.h"
|
||||||
@ -21,6 +22,7 @@
|
|||||||
|
|
||||||
namespace i2p {
|
namespace i2p {
|
||||||
namespace client {
|
namespace client {
|
||||||
|
namespace i2pcontrol {
|
||||||
|
|
||||||
I2PControlSession::Response::Response(const std::string& version)
|
I2PControlSession::Response::Response(const std::string& version)
|
||||||
: id(), version(version), error(ErrorCode::None), parameters()
|
: id(), version(version), error(ErrorCode::None), parameters()
|
||||||
@ -104,28 +106,33 @@ I2PControlSession::I2PControlSession(boost::asio::io_service& ios, const std::st
|
|||||||
: password(pass), tokens(), tokensMutex(),
|
: password(pass), tokens(), tokensMutex(),
|
||||||
service(ios), shutdownTimer(ios), expireTokensTimer(ios)
|
service(ios), shutdownTimer(ios), expireTokensTimer(ios)
|
||||||
{
|
{
|
||||||
|
using namespace i2p::client::i2pcontrol::constants;
|
||||||
// Method handlers
|
// Method handlers
|
||||||
methodHandlers[I2P_CONTROL_METHOD_AUTHENTICATE] = &I2PControlSession::handleAuthenticate;
|
methodHandlers[METHOD_AUTHENTICATE] = &I2PControlSession::handleAuthenticate;
|
||||||
methodHandlers[I2P_CONTROL_METHOD_ECHO] = &I2PControlSession::handleEcho;
|
methodHandlers[METHOD_ECHO] = &I2PControlSession::handleEcho;
|
||||||
methodHandlers[I2P_CONTROL_METHOD_I2PCONTROL] = &I2PControlSession::handleI2PControl;
|
methodHandlers[METHOD_I2PCONTROL] = &I2PControlSession::handleI2PControl;
|
||||||
methodHandlers[I2P_CONTROL_METHOD_ROUTER_INFO] = &I2PControlSession::handleRouterInfo;
|
methodHandlers[METHOD_ROUTER_INFO] = &I2PControlSession::handleRouterInfo;
|
||||||
methodHandlers[I2P_CONTROL_METHOD_ROUTER_MANAGER] = &I2PControlSession::handleRouterManager;
|
methodHandlers[METHOD_ROUTER_MANAGER] = &I2PControlSession::handleRouterManager;
|
||||||
methodHandlers[I2P_CONTROL_METHOD_NETWORK_SETTING] = &I2PControlSession::handleNetworkSetting;
|
methodHandlers[METHOD_NETWORK_SETTING] = &I2PControlSession::handleNetworkSetting;
|
||||||
// RouterInfo handlers
|
// RouterInfo handlers
|
||||||
routerInfoHandlers[I2P_CONTROL_ROUTER_INFO_UPTIME] = &I2PControlSession::handleUptime;
|
routerInfoHandlers[ROUTER_INFO_UPTIME] = &I2PControlSession::handleUptime;
|
||||||
routerInfoHandlers[I2P_CONTROL_ROUTER_INFO_VERSION] = &I2PControlSession::handleVersion;
|
routerInfoHandlers[ROUTER_INFO_VERSION] = &I2PControlSession::handleVersion;
|
||||||
routerInfoHandlers[I2P_CONTROL_ROUTER_INFO_STATUS] = &I2PControlSession::handleStatus;
|
routerInfoHandlers[ROUTER_INFO_STATUS] = &I2PControlSession::handleStatus;
|
||||||
routerInfoHandlers[I2P_CONTROL_ROUTER_INFO_NETDB_KNOWNPEERS]= &I2PControlSession::handleNetDbKnownPeers;
|
routerInfoHandlers[ROUTER_INFO_DATAPATH] = &I2PControlSession::handleDatapath;
|
||||||
routerInfoHandlers[I2P_CONTROL_ROUTER_INFO_NETDB_ACTIVEPEERS] = &I2PControlSession::handleNetDbActivePeers;
|
routerInfoHandlers[ROUTER_INFO_NETDB_KNOWNPEERS]= &I2PControlSession::handleNetDbKnownPeers;
|
||||||
routerInfoHandlers[I2P_CONTROL_ROUTER_INFO_NET_STATUS] = &I2PControlSession::handleNetStatus;
|
routerInfoHandlers[ROUTER_INFO_NETDB_ACTIVEPEERS] = &I2PControlSession::handleNetDbActivePeers;
|
||||||
routerInfoHandlers[I2P_CONTROL_ROUTER_INFO_TUNNELS_PARTICIPATING] = &I2PControlSession::handleTunnelsParticipating;
|
routerInfoHandlers[ROUTER_INFO_NETDB_LEASESETS] = &I2PControlSession::handleNetDbLeaseSets;
|
||||||
routerInfoHandlers[I2P_CONTROL_ROUTER_INFO_BW_IB_1S] = &I2PControlSession::handleInBandwidth1S;
|
routerInfoHandlers[ROUTER_INFO_NETDB_FLOODFILLS] = &I2PControlSession::handleNetDbFloodfills;
|
||||||
routerInfoHandlers[I2P_CONTROL_ROUTER_INFO_BW_OB_1S] = &I2PControlSession::handleOutBandwidth1S;
|
routerInfoHandlers[ROUTER_INFO_NET_STATUS] = &I2PControlSession::handleNetStatus;
|
||||||
|
routerInfoHandlers[ROUTER_INFO_TUNNELS_PARTICIPATING] = &I2PControlSession::handleTunnelsParticipating;
|
||||||
|
routerInfoHandlers[ROUTER_INFO_TUNNELS_CREATION_SUCCESS] = &I2PControlSession::handleTunnelsCreationSuccess;
|
||||||
|
routerInfoHandlers[ROUTER_INFO_BW_IB_1S] = &I2PControlSession::handleInBandwidth1S;
|
||||||
|
routerInfoHandlers[ROUTER_INFO_BW_OB_1S] = &I2PControlSession::handleOutBandwidth1S;
|
||||||
|
|
||||||
// RouterManager handlers
|
// RouterManager handlers
|
||||||
routerManagerHandlers[I2P_CONTROL_ROUTER_MANAGER_SHUTDOWN] = &I2PControlSession::handleShutdown;
|
routerManagerHandlers[ROUTER_MANAGER_SHUTDOWN] = &I2PControlSession::handleShutdown;
|
||||||
routerManagerHandlers[I2P_CONTROL_ROUTER_MANAGER_SHUTDOWN_GRACEFUL] = &I2PControlSession::handleShutdownGraceful;
|
routerManagerHandlers[ROUTER_MANAGER_SHUTDOWN_GRACEFUL] = &I2PControlSession::handleShutdownGraceful;
|
||||||
routerManagerHandlers[I2P_CONTROL_ROUTER_MANAGER_RESEED] = &I2PControlSession::handleReseed;
|
routerManagerHandlers[ROUTER_MANAGER_RESEED] = &I2PControlSession::handleReseed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2PControlSession::start()
|
void I2PControlSession::start()
|
||||||
@ -147,9 +154,9 @@ I2PControlSession::Response I2PControlSession::handleRequest(std::stringstream&
|
|||||||
|
|
||||||
Response response;
|
Response response;
|
||||||
try {
|
try {
|
||||||
response.setId(pt.get<std::string>(I2P_CONTROL_PROPERTY_ID));
|
response.setId(pt.get<std::string>(constants::PROPERTY_ID));
|
||||||
|
|
||||||
std::string method = pt.get<std::string>(I2P_CONTROL_PROPERTY_METHOD);
|
std::string method = pt.get<std::string>(constants::PROPERTY_METHOD);
|
||||||
auto it = methodHandlers.find(method);
|
auto it = methodHandlers.find(method);
|
||||||
if(it == methodHandlers.end()) { // Not found
|
if(it == methodHandlers.end()) { // Not found
|
||||||
LogPrint(eLogWarning, "Unknown I2PControl method ", method);
|
LogPrint(eLogWarning, "Unknown I2PControl method ", method);
|
||||||
@ -157,8 +164,8 @@ I2PControlSession::Response I2PControlSession::handleRequest(std::stringstream&
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyTree params = pt.get_child(I2P_CONTROL_PROPERTY_PARAMS);
|
PropertyTree params = pt.get_child(constants::PROPERTY_PARAMS);
|
||||||
if(method != I2P_CONTROL_METHOD_AUTHENTICATE && !authenticate(params, response)) {
|
if(method != constants::METHOD_AUTHENTICATE && !authenticate(params, response)) {
|
||||||
LogPrint(eLogWarning, "I2PControl invalid token presented");
|
LogPrint(eLogWarning, "I2PControl invalid token presented");
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -177,14 +184,14 @@ I2PControlSession::Response I2PControlSession::handleRequest(std::stringstream&
|
|||||||
bool I2PControlSession::authenticate(const PropertyTree& pt, Response& response)
|
bool I2PControlSession::authenticate(const PropertyTree& pt, Response& response)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
std::string token = pt.get<std::string>(I2P_CONTROL_PARAM_TOKEN);
|
std::string token = pt.get<std::string>(constants::PARAM_TOKEN);
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(tokensMutex);
|
std::lock_guard<std::mutex> lock(tokensMutex);
|
||||||
auto it = tokens.find(token);
|
auto it = tokens.find(token);
|
||||||
if(it == tokens.end()) {
|
if(it == tokens.end()) {
|
||||||
response.setError(ErrorCode::NonexistentToken);
|
response.setError(ErrorCode::NonexistentToken);
|
||||||
return false;
|
return false;
|
||||||
} else if(util::GetSecondsSinceEpoch() - it->second > I2P_CONTROL_TOKEN_LIFETIME) {
|
} else if(util::GetSecondsSinceEpoch() - it->second > constants::TOKEN_LIFETIME) {
|
||||||
response.setError(ErrorCode::ExpiredToken);
|
response.setError(ErrorCode::ExpiredToken);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -199,12 +206,12 @@ bool I2PControlSession::authenticate(const PropertyTree& pt, Response& response)
|
|||||||
|
|
||||||
std::string I2PControlSession::generateToken() const
|
std::string I2PControlSession::generateToken() const
|
||||||
{
|
{
|
||||||
byte random_data[I2P_CONTROL_TOKEN_SIZE] = {};
|
byte random_data[constants::TOKEN_SIZE] = {};
|
||||||
CryptoPP::AutoSeededRandomPool rng;
|
CryptoPP::AutoSeededRandomPool rng;
|
||||||
rng.GenerateBlock(random_data, I2P_CONTROL_TOKEN_SIZE);
|
rng.GenerateBlock(random_data, constants::TOKEN_SIZE);
|
||||||
std::string token;
|
std::string token;
|
||||||
CryptoPP::StringSource ss(
|
CryptoPP::StringSource ss(
|
||||||
random_data, I2P_CONTROL_TOKEN_SIZE, true,
|
random_data, constants::TOKEN_SIZE, true,
|
||||||
new CryptoPP::HexEncoder(new CryptoPP::StringSink(token))
|
new CryptoPP::HexEncoder(new CryptoPP::StringSink(token))
|
||||||
);
|
);
|
||||||
return token;
|
return token;
|
||||||
@ -212,8 +219,8 @@ std::string I2PControlSession::generateToken() const
|
|||||||
|
|
||||||
void I2PControlSession::handleAuthenticate(const PropertyTree& pt, Response& response)
|
void I2PControlSession::handleAuthenticate(const PropertyTree& pt, Response& response)
|
||||||
{
|
{
|
||||||
const int api = pt.get<int>(I2P_CONTROL_PARAM_API);
|
const int api = pt.get<int>(constants::PARAM_API);
|
||||||
const std::string given_pass = pt.get<std::string>(I2P_CONTROL_PARAM_PASSWORD);
|
const std::string given_pass = pt.get<std::string>(constants::PARAM_PASSWORD);
|
||||||
LogPrint(eLogDebug, "I2PControl Authenticate API = ", api, " Password = ", given_pass);
|
LogPrint(eLogDebug, "I2PControl Authenticate API = ", api, " Password = ", given_pass);
|
||||||
if(given_pass != password) {
|
if(given_pass != password) {
|
||||||
LogPrint(
|
LogPrint(
|
||||||
@ -224,8 +231,8 @@ void I2PControlSession::handleAuthenticate(const PropertyTree& pt, Response& res
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const std::string token = generateToken();
|
const std::string token = generateToken();
|
||||||
response.setParam(I2P_CONTROL_PARAM_API, api);
|
response.setParam(constants::PARAM_API, api);
|
||||||
response.setParam(I2P_CONTROL_PARAM_TOKEN, token);
|
response.setParam(constants::PARAM_TOKEN, token);
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(tokensMutex);
|
std::lock_guard<std::mutex> lock(tokensMutex);
|
||||||
tokens.insert(std::make_pair(token, util::GetSecondsSinceEpoch()));
|
tokens.insert(std::make_pair(token, util::GetSecondsSinceEpoch()));
|
||||||
@ -233,9 +240,9 @@ void I2PControlSession::handleAuthenticate(const PropertyTree& pt, Response& res
|
|||||||
|
|
||||||
void I2PControlSession::handleEcho(const PropertyTree& pt, Response& response)
|
void I2PControlSession::handleEcho(const PropertyTree& pt, Response& response)
|
||||||
{
|
{
|
||||||
const std::string echo = pt.get<std::string>(I2P_CONTROL_PARAM_ECHO);
|
const std::string echo = pt.get<std::string>(constants::PARAM_ECHO);
|
||||||
LogPrint(eLogDebug, "I2PControl Echo Echo = ", echo);
|
LogPrint(eLogDebug, "I2PControl Echo Echo = ", echo);
|
||||||
response.setParam(I2P_CONTROL_PARAM_RESULT, echo);
|
response.setParam(constants::PARAM_RESULT, echo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2PControlSession::handleI2PControl(const PropertyTree&, Response&)
|
void I2PControlSession::handleI2PControl(const PropertyTree&, Response&)
|
||||||
@ -249,7 +256,7 @@ void I2PControlSession::handleRouterInfo(const PropertyTree& pt, Response& respo
|
|||||||
{
|
{
|
||||||
LogPrint(eLogDebug, "I2PControl RouterInfo");
|
LogPrint(eLogDebug, "I2PControl RouterInfo");
|
||||||
for(const auto& pair : pt) {
|
for(const auto& pair : pt) {
|
||||||
if(pair.first == I2P_CONTROL_PARAM_TOKEN)
|
if(pair.first == constants::PARAM_TOKEN)
|
||||||
continue;
|
continue;
|
||||||
LogPrint(eLogDebug, pair.first);
|
LogPrint(eLogDebug, pair.first);
|
||||||
auto it = routerInfoHandlers.find(pair.first);
|
auto it = routerInfoHandlers.find(pair.first);
|
||||||
@ -266,7 +273,7 @@ void I2PControlSession::handleRouterManager(const PropertyTree& pt, Response& re
|
|||||||
{
|
{
|
||||||
LogPrint(eLogDebug, "I2PControl RouterManager");
|
LogPrint(eLogDebug, "I2PControl RouterManager");
|
||||||
for(const auto& pair : pt) {
|
for(const auto& pair : pt) {
|
||||||
if(pair.first == I2P_CONTROL_PARAM_TOKEN)
|
if(pair.first == constants::PARAM_TOKEN)
|
||||||
continue;
|
continue;
|
||||||
LogPrint(eLogDebug, pair.first);
|
LogPrint(eLogDebug, pair.first);
|
||||||
auto it = routerManagerHandlers.find(pair.first);
|
auto it = routerManagerHandlers.find(pair.first);
|
||||||
@ -286,53 +293,85 @@ void I2PControlSession::handleNetworkSetting(const PropertyTree&, Response&)
|
|||||||
|
|
||||||
void I2PControlSession::handleUptime(Response& response)
|
void I2PControlSession::handleUptime(Response& response)
|
||||||
{
|
{
|
||||||
response.setParam(I2P_CONTROL_ROUTER_INFO_UPTIME, (int)i2p::context.GetUptime()*1000);
|
response.setParam(constants::ROUTER_INFO_UPTIME, (int)i2p::context.GetUptime()*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2PControlSession::handleVersion(Response& response)
|
void I2PControlSession::handleVersion(Response& response)
|
||||||
{
|
{
|
||||||
response.setParam(I2P_CONTROL_ROUTER_INFO_VERSION, VERSION);
|
response.setParam(constants::ROUTER_INFO_VERSION, VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2PControlSession::handleStatus(Response& response)
|
void I2PControlSession::handleStatus(Response& response)
|
||||||
{
|
{
|
||||||
response.setParam(I2P_CONTROL_ROUTER_INFO_STATUS, "???"); // TODO:
|
response.setParam(constants::ROUTER_INFO_STATUS, "???"); // TODO:
|
||||||
|
}
|
||||||
|
|
||||||
|
void I2PControlSession::handleDatapath(Response& response)
|
||||||
|
{
|
||||||
|
response.setParam(
|
||||||
|
constants::ROUTER_INFO_DATAPATH,
|
||||||
|
i2p::util::filesystem::GetDefaultDataDir().string()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2PControlSession::handleNetDbKnownPeers(Response& response)
|
void I2PControlSession::handleNetDbKnownPeers(Response& response)
|
||||||
{
|
{
|
||||||
response.setParam(
|
response.setParam(
|
||||||
I2P_CONTROL_ROUTER_INFO_NETDB_KNOWNPEERS, i2p::data::netdb.GetNumRouters()
|
constants::ROUTER_INFO_NETDB_KNOWNPEERS, i2p::data::netdb.GetNumRouters()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2PControlSession::handleNetDbActivePeers(Response& response)
|
void I2PControlSession::handleNetDbActivePeers(Response& response)
|
||||||
{
|
{
|
||||||
response.setParam(
|
response.setParam(
|
||||||
I2P_CONTROL_ROUTER_INFO_NETDB_ACTIVEPEERS,
|
constants::ROUTER_INFO_NETDB_ACTIVEPEERS,
|
||||||
(int)i2p::transport::transports.GetPeers().size()
|
(int)i2p::transport::transports.GetPeers().size()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void I2PControlSession::handleNetDbFloodfills(Response& response)
|
||||||
|
{
|
||||||
|
response.setParam(
|
||||||
|
constants::ROUTER_INFO_NETDB_FLOODFILLS,
|
||||||
|
(int)i2p::data::netdb.GetNumFloodfills()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void I2PControlSession::handleNetDbLeaseSets(Response& response)
|
||||||
|
{
|
||||||
|
response.setParam(
|
||||||
|
constants::ROUTER_INFO_NETDB_LEASESETS,
|
||||||
|
(int)i2p::data::netdb.GetNumLeaseSets()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void I2PControlSession::handleNetStatus(Response& response)
|
void I2PControlSession::handleNetStatus(Response& response)
|
||||||
{
|
{
|
||||||
response.setParam(
|
response.setParam(
|
||||||
I2P_CONTROL_ROUTER_INFO_NET_STATUS, (int)i2p::context.GetStatus()
|
constants::ROUTER_INFO_NET_STATUS, (int)i2p::context.GetStatus()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2PControlSession::handleTunnelsParticipating(Response& response)
|
void I2PControlSession::handleTunnelsParticipating(Response& response)
|
||||||
{
|
{
|
||||||
response.setParam(
|
response.setParam(
|
||||||
I2P_CONTROL_ROUTER_INFO_TUNNELS_PARTICIPATING,
|
constants::ROUTER_INFO_TUNNELS_PARTICIPATING,
|
||||||
(int)i2p::tunnel::tunnels.GetTransitTunnels().size()
|
(int)i2p::tunnel::tunnels.GetTransitTunnels().size()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void I2PControlSession::handleTunnelsCreationSuccess(Response& response)
|
||||||
|
{
|
||||||
|
response.setParam(
|
||||||
|
constants::ROUTER_INFO_TUNNELS_CREATION_SUCCESS,
|
||||||
|
i2p::tunnel::tunnels.GetTunnelCreationSuccessRate()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void I2PControlSession::handleInBandwidth1S(Response& response)
|
void I2PControlSession::handleInBandwidth1S(Response& response)
|
||||||
{
|
{
|
||||||
response.setParam(
|
response.setParam(
|
||||||
I2P_CONTROL_ROUTER_INFO_BW_IB_1S,
|
constants::ROUTER_INFO_BW_IB_1S,
|
||||||
(double)i2p::transport::transports.GetInBandwidth()
|
(double)i2p::transport::transports.GetInBandwidth()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -340,7 +379,7 @@ void I2PControlSession::handleInBandwidth1S(Response& response)
|
|||||||
void I2PControlSession::handleOutBandwidth1S(Response& response)
|
void I2PControlSession::handleOutBandwidth1S(Response& response)
|
||||||
{
|
{
|
||||||
response.setParam(
|
response.setParam(
|
||||||
I2P_CONTROL_ROUTER_INFO_BW_OB_1S,
|
constants::ROUTER_INFO_BW_OB_1S,
|
||||||
(double)i2p::transport::transports.GetOutBandwidth()
|
(double)i2p::transport::transports.GetOutBandwidth()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -348,7 +387,7 @@ void I2PControlSession::handleOutBandwidth1S(Response& response)
|
|||||||
void I2PControlSession::handleShutdown(Response& response)
|
void I2PControlSession::handleShutdown(Response& response)
|
||||||
{
|
{
|
||||||
LogPrint(eLogInfo, "Shutdown requested");
|
LogPrint(eLogInfo, "Shutdown requested");
|
||||||
response.setParam(I2P_CONTROL_ROUTER_MANAGER_SHUTDOWN, "");
|
response.setParam(constants::ROUTER_MANAGER_SHUTDOWN, "");
|
||||||
// 1 second to make sure response has been sent
|
// 1 second to make sure response has been sent
|
||||||
shutdownTimer.expires_from_now(boost::posix_time::seconds(1));
|
shutdownTimer.expires_from_now(boost::posix_time::seconds(1));
|
||||||
shutdownTimer.async_wait([](const boost::system::error_code&) {
|
shutdownTimer.async_wait([](const boost::system::error_code&) {
|
||||||
@ -361,7 +400,7 @@ void I2PControlSession::handleShutdownGraceful(Response& response)
|
|||||||
i2p::context.SetAcceptsTunnels(false);
|
i2p::context.SetAcceptsTunnels(false);
|
||||||
int timeout = i2p::tunnel::tunnels.GetTransitTunnelsExpirationTimeout();
|
int timeout = i2p::tunnel::tunnels.GetTransitTunnelsExpirationTimeout();
|
||||||
LogPrint(eLogInfo, "Graceful shutdown requested. Will shutdown after ", timeout, " seconds");
|
LogPrint(eLogInfo, "Graceful shutdown requested. Will shutdown after ", timeout, " seconds");
|
||||||
response.setParam(I2P_CONTROL_ROUTER_MANAGER_SHUTDOWN_GRACEFUL, "");
|
response.setParam(constants::ROUTER_MANAGER_SHUTDOWN_GRACEFUL, "");
|
||||||
shutdownTimer.expires_from_now(boost::posix_time::seconds(timeout + 1));
|
shutdownTimer.expires_from_now(boost::posix_time::seconds(timeout + 1));
|
||||||
shutdownTimer.async_wait([](const boost::system::error_code&) {
|
shutdownTimer.async_wait([](const boost::system::error_code&) {
|
||||||
Daemon.running = 0;
|
Daemon.running = 0;
|
||||||
@ -371,7 +410,7 @@ void I2PControlSession::handleShutdownGraceful(Response& response)
|
|||||||
void I2PControlSession::handleReseed(Response& response)
|
void I2PControlSession::handleReseed(Response& response)
|
||||||
{
|
{
|
||||||
LogPrint(eLogInfo, "Reseed requested");
|
LogPrint(eLogInfo, "Reseed requested");
|
||||||
response.setParam(I2P_CONTROL_ROUTER_MANAGER_SHUTDOWN, "");
|
response.setParam(constants::ROUTER_MANAGER_SHUTDOWN, "");
|
||||||
i2p::data::netdb.Reseed();
|
i2p::data::netdb.Reseed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +424,7 @@ void I2PControlSession::expireTokens(const boost::system::error_code& error)
|
|||||||
const uint64_t now = util::GetSecondsSinceEpoch();
|
const uint64_t now = util::GetSecondsSinceEpoch();
|
||||||
std::lock_guard<std::mutex> lock(tokensMutex);
|
std::lock_guard<std::mutex> lock(tokensMutex);
|
||||||
for(auto it = tokens.begin(); it != tokens.end(); ) {
|
for(auto it = tokens.begin(); it != tokens.end(); ) {
|
||||||
if(now - it->second > I2P_CONTROL_TOKEN_LIFETIME)
|
if(now - it->second > constants::TOKEN_LIFETIME)
|
||||||
it = tokens.erase(it);
|
it = tokens.erase(it);
|
||||||
else
|
else
|
||||||
++it;
|
++it;
|
||||||
@ -394,7 +433,7 @@ void I2PControlSession::expireTokens(const boost::system::error_code& error)
|
|||||||
|
|
||||||
void I2PControlSession::startExpireTokensJob()
|
void I2PControlSession::startExpireTokensJob()
|
||||||
{
|
{
|
||||||
expireTokensTimer.expires_from_now(boost::posix_time::seconds(I2P_CONTROL_TOKEN_LIFETIME));
|
expireTokensTimer.expires_from_now(boost::posix_time::seconds(constants::TOKEN_LIFETIME));
|
||||||
expireTokensTimer.async_wait(std::bind(
|
expireTokensTimer.async_wait(std::bind(
|
||||||
&I2PControlSession::expireTokens, shared_from_this(), std::placeholders::_1
|
&I2PControlSession::expireTokens, shared_from_this(), std::placeholders::_1
|
||||||
));
|
));
|
||||||
@ -402,3 +441,4 @@ void I2PControlSession::startExpireTokensJob()
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -10,51 +10,60 @@
|
|||||||
|
|
||||||
namespace i2p {
|
namespace i2p {
|
||||||
namespace client {
|
namespace client {
|
||||||
|
namespace i2pcontrol {
|
||||||
|
|
||||||
const char I2P_CONTROL_DEFAULT_PASSWORD[] = "itoopie";
|
namespace constants {
|
||||||
const uint64_t I2P_CONTROL_TOKEN_LIFETIME = 600; // Token lifetime in seconds
|
|
||||||
const std::size_t I2P_CONTROL_TOKEN_SIZE = 8; // Token size in bytes
|
|
||||||
|
|
||||||
const char I2P_CONTROL_PROPERTY_ID[] = "id";
|
const char DEFAULT_PASSWORD[] = "itoopie";
|
||||||
const char I2P_CONTROL_PROPERTY_METHOD[] = "method";
|
const uint64_t TOKEN_LIFETIME = 600; // Token lifetime in seconds
|
||||||
const char I2P_CONTROL_PROPERTY_PARAMS[] = "params";
|
const std::size_t TOKEN_SIZE = 8; // Token size in bytes
|
||||||
const char I2P_CONTROL_PROPERTY_RESULT[] = "result";
|
|
||||||
|
const char PROPERTY_ID[] = "id";
|
||||||
|
const char PROPERTY_METHOD[] = "method";
|
||||||
|
const char PROPERTY_PARAMS[] = "params";
|
||||||
|
const char PROPERTY_RESULT[] = "result";
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
const char I2P_CONTROL_METHOD_AUTHENTICATE[] = "Authenticate";
|
const char METHOD_AUTHENTICATE[] = "Authenticate";
|
||||||
const char I2P_CONTROL_METHOD_ECHO[] = "Echo";
|
const char METHOD_ECHO[] = "Echo";
|
||||||
const char I2P_CONTROL_METHOD_I2PCONTROL[] = "I2PControl";
|
const char METHOD_I2PCONTROL[] = "I2PControl";
|
||||||
const char I2P_CONTROL_METHOD_ROUTER_INFO[] = "RouterInfo";
|
const char METHOD_ROUTER_INFO[] = "RouterInfo";
|
||||||
const char I2P_CONTROL_METHOD_ROUTER_MANAGER[] = "RouterManager";
|
const char METHOD_ROUTER_MANAGER[] = "RouterManager";
|
||||||
const char I2P_CONTROL_METHOD_NETWORK_SETTING[] = "NetworkSetting";
|
const char METHOD_NETWORK_SETTING[] = "NetworkSetting";
|
||||||
|
|
||||||
// params
|
// params
|
||||||
const char I2P_CONTROL_PARAM_API[] = "API";
|
const char PARAM_API[] = "API";
|
||||||
const char I2P_CONTROL_PARAM_PASSWORD[] = "Password";
|
const char PARAM_PASSWORD[] = "Password";
|
||||||
const char I2P_CONTROL_PARAM_TOKEN[] = "Token";
|
const char PARAM_TOKEN[] = "Token";
|
||||||
const char I2P_CONTROL_PARAM_ECHO[] = "Echo";
|
const char PARAM_ECHO[] = "Echo";
|
||||||
const char I2P_CONTROL_PARAM_RESULT[] = "Result";
|
const char PARAM_RESULT[] = "Result";
|
||||||
|
|
||||||
// I2PControl
|
// I2PControl
|
||||||
const char I2P_CONTROL_I2PCONTROL_ADDRESS[] = "i2pcontrol.address";
|
const char I2PCONTROL_ADDRESS[] = "i2pcontrol.address";
|
||||||
const char I2P_CONTROL_I2PCONTROL_PASSWORD[] = "i2pcontrol.password";
|
const char I2PCONTROL_PASSWORD[] = "i2pcontrol.password";
|
||||||
const char I2P_CONTROL_I2PCONTROL_PORT[] = "i2pcontrol.port";
|
const char I2PCONTROL_PORT[] = "i2pcontrol.port";
|
||||||
|
|
||||||
// RouterInfo requests
|
// RouterInfo requests
|
||||||
const char I2P_CONTROL_ROUTER_INFO_UPTIME[] = "i2p.router.uptime";
|
const char ROUTER_INFO_UPTIME[] = "i2p.router.uptime";
|
||||||
const char I2P_CONTROL_ROUTER_INFO_VERSION[] = "i2p.router.version";
|
const char ROUTER_INFO_VERSION[] = "i2p.router.version";
|
||||||
const char I2P_CONTROL_ROUTER_INFO_STATUS[] = "i2p.router.status";
|
const char ROUTER_INFO_STATUS[] = "i2p.router.status";
|
||||||
const char I2P_CONTROL_ROUTER_INFO_NETDB_KNOWNPEERS[] = "i2p.router.netdb.knownpeers";
|
const char ROUTER_INFO_DATAPATH[] = "i2p.router.datapath";
|
||||||
const char I2P_CONTROL_ROUTER_INFO_NETDB_ACTIVEPEERS[] = "i2p.router.netdb.activepeers";
|
const char ROUTER_INFO_NETDB_KNOWNPEERS[] = "i2p.router.netdb.knownpeers";
|
||||||
const char I2P_CONTROL_ROUTER_INFO_NET_STATUS[] = "i2p.router.net.status";
|
const char ROUTER_INFO_NETDB_ACTIVEPEERS[] = "i2p.router.netdb.activepeers";
|
||||||
const char I2P_CONTROL_ROUTER_INFO_TUNNELS_PARTICIPATING[] = "i2p.router.net.tunnels.participating";
|
const char ROUTER_INFO_NETDB_FLOODFILLS[] = "i2p.router.netdb.floodfills";
|
||||||
const char I2P_CONTROL_ROUTER_INFO_BW_IB_1S[] = "i2p.router.net.bw.inbound.1s";
|
const char ROUTER_INFO_NETDB_LEASESETS[] = "i2p.router.netdb.leasesets";
|
||||||
const char I2P_CONTROL_ROUTER_INFO_BW_OB_1S[] = "i2p.router.net.bw.outbound.1s";
|
const char ROUTER_INFO_NET_STATUS[] = "i2p.router.net.status";
|
||||||
|
const char ROUTER_INFO_TUNNELS_PARTICIPATING[] = "i2p.router.net.tunnels.participating";
|
||||||
|
const char ROUTER_INFO_TUNNELS_CREATION_SUCCESS[] = "i2p.router.net.tunnels.creationsuccessrate";
|
||||||
|
const char ROUTER_INFO_BW_IB_1S[] = "i2p.router.net.bw.inbound.1s";
|
||||||
|
const char ROUTER_INFO_BW_OB_1S[] = "i2p.router.net.bw.outbound.1s";
|
||||||
|
|
||||||
// RouterManager requests
|
// RouterManager requests
|
||||||
const char I2P_CONTROL_ROUTER_MANAGER_SHUTDOWN[] = "Shutdown";
|
const char ROUTER_MANAGER_SHUTDOWN[] = "Shutdown";
|
||||||
const char I2P_CONTROL_ROUTER_MANAGER_SHUTDOWN_GRACEFUL[] = "ShutdownGraceful";
|
const char ROUTER_MANAGER_SHUTDOWN_GRACEFUL[] = "ShutdownGraceful";
|
||||||
const char I2P_CONTROL_ROUTER_MANAGER_RESEED[] = "Reseed";
|
const char ROUTER_MANAGER_RESEED[] = "Reseed";
|
||||||
|
|
||||||
|
} // constants
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Null" I2P control implementation, does not do actual networking.
|
* "Null" I2P control implementation, does not do actual networking.
|
||||||
@ -113,7 +122,7 @@ public:
|
|||||||
* the lifetime of this I2PControlSession.
|
* the lifetime of this I2PControlSession.
|
||||||
*/
|
*/
|
||||||
I2PControlSession(boost::asio::io_service& ios,
|
I2PControlSession(boost::asio::io_service& ios,
|
||||||
const std::string& pass = I2P_CONTROL_DEFAULT_PASSWORD);
|
const std::string& pass = constants::DEFAULT_PASSWORD);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the I2PControlSession.
|
* Starts the I2PControlSession.
|
||||||
@ -172,10 +181,14 @@ private:
|
|||||||
void handleUptime(Response& response);
|
void handleUptime(Response& response);
|
||||||
void handleVersion(Response& response);
|
void handleVersion(Response& response);
|
||||||
void handleStatus(Response& response);
|
void handleStatus(Response& response);
|
||||||
|
void handleDatapath(Response& response);
|
||||||
void handleNetDbKnownPeers(Response& response);
|
void handleNetDbKnownPeers(Response& response);
|
||||||
void handleNetDbActivePeers(Response& response);
|
void handleNetDbActivePeers(Response& response);
|
||||||
|
void handleNetDbFloodfills(Response& response);
|
||||||
|
void handleNetDbLeaseSets(Response& response);
|
||||||
void handleNetStatus(Response& response);
|
void handleNetStatus(Response& response);
|
||||||
void handleTunnelsParticipating(Response& response);
|
void handleTunnelsParticipating(Response& response);
|
||||||
|
void handleTunnelsCreationSuccess(Response& response);
|
||||||
void handleInBandwidth1S(Response& response);
|
void handleInBandwidth1S(Response& response);
|
||||||
void handleOutBandwidth1S(Response& response);
|
void handleOutBandwidth1S(Response& response);
|
||||||
|
|
||||||
@ -198,6 +211,7 @@ private:
|
|||||||
boost::asio::deadline_timer expireTokensTimer;
|
boost::asio::deadline_timer expireTokensTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
namespace i2p {
|
namespace i2p {
|
||||||
namespace client {
|
namespace client {
|
||||||
|
namespace i2pcontrol {
|
||||||
|
|
||||||
I2PControlService::I2PControlService(const std::string& address, int port, const std::string& pass)
|
I2PControlService::I2PControlService(const std::string& address, int port, const std::string& pass)
|
||||||
: m_Session(std::make_shared<I2PControlSession>(m_Service, pass)),
|
: m_Session(std::make_shared<I2PControlSession>(m_Service, pass)),
|
||||||
@ -168,3 +169,4 @@ void I2PControlService::HandleResponseSent(const boost::system::error_code& ecod
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
namespace i2p {
|
namespace i2p {
|
||||||
namespace client {
|
namespace client {
|
||||||
|
namespace i2pcontrol {
|
||||||
|
|
||||||
const size_t I2P_CONTROL_MAX_REQUEST_SIZE = 1024;
|
const size_t I2P_CONTROL_MAX_REQUEST_SIZE = 1024;
|
||||||
typedef std::array<char, I2P_CONTROL_MAX_REQUEST_SIZE> I2PControlBuffer;
|
typedef std::array<char, I2P_CONTROL_MAX_REQUEST_SIZE> I2PControlBuffer;
|
||||||
@ -51,6 +52,7 @@ private:
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
6
webui/footer.html
Normal file
6
webui/footer.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<div id="main">
|
||||||
|
<noscript>
|
||||||
|
<div class="header"><h1>Please enable JavaScript!</h1></div>
|
||||||
|
</noscript>
|
||||||
|
</div>
|
||||||
|
|
@ -22,11 +22,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--#include virtual="menu.html" -->
|
<!--#include virtual="menu.html" -->
|
||||||
|
<!--#include virtual="footer.html" -->
|
||||||
|
|
||||||
<div id="main">
|
</body>
|
||||||
<noscript>
|
|
||||||
<div class="header"><h1>Please enable JavaScript!</h1></div>
|
|
||||||
</noscript>
|
|
||||||
</div>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -19,6 +19,7 @@ function updateRouterInfo(result, session) {
|
|||||||
"knownpeers" : result["i2p.router.netdb.knownpeers"],
|
"knownpeers" : result["i2p.router.netdb.knownpeers"],
|
||||||
"activepeers" : result["i2p.router.netdb.activepeers"],
|
"activepeers" : result["i2p.router.netdb.activepeers"],
|
||||||
"tunnels-participating" : result["i2p.router.net.tunnels.participating"],
|
"tunnels-participating" : result["i2p.router.net.tunnels.participating"],
|
||||||
|
"tunnels-successrate" : result["i2p.router.net.tunnels.creationsuccessrate"] + "%",
|
||||||
"bw-in" : result["i2p.router.net.bw.inbound.1s"],
|
"bw-in" : result["i2p.router.net.bw.inbound.1s"],
|
||||||
"bw-out" : result["i2p.router.net.bw.outbound.1s"]
|
"bw-out" : result["i2p.router.net.bw.outbound.1s"]
|
||||||
});
|
});
|
||||||
@ -34,6 +35,7 @@ function requestRouterInfo(session) {
|
|||||||
"i2p.router.netdb.knownpeers" : "",
|
"i2p.router.netdb.knownpeers" : "",
|
||||||
"i2p.router.netdb.activepeers" : "",
|
"i2p.router.netdb.activepeers" : "",
|
||||||
"i2p.router.net.tunnels.participating" : "",
|
"i2p.router.net.tunnels.participating" : "",
|
||||||
|
"i2p.router.net.tunnels.creationsuccessrate" : "",
|
||||||
"i2p.router.net.bw.inbound.1s" : "",
|
"i2p.router.net.bw.inbound.1s" : "",
|
||||||
"i2p.router.net.bw.outbound.1s" : ""
|
"i2p.router.net.bw.outbound.1s" : ""
|
||||||
}, updateRouterInfo);
|
}, updateRouterInfo);
|
||||||
@ -60,21 +62,27 @@ window.onload = function() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h2 class="content-subhead">Tunnels participating: <span id="tunnels-participating"></span></h2>
|
<h2 class="content-subhead">
|
||||||
<h2 class="content-subhead">Active peers: <span id="activepeers"></span></h2>
|
Tunnels participating: <span id="tunnels-participating"></span>
|
||||||
<h2 class="content-subhead">Known peers: <span id="knownpeers"></span></h2>
|
</h2>
|
||||||
<h2 class="content-subhead">Bandwidth:
|
<h2 class="content-subhead">
|
||||||
|
Tunnel create success rate: <span id="tunnels-successrate"></span>
|
||||||
|
</h2>
|
||||||
|
<h2 class="content-subhead">
|
||||||
|
Active peers: <span id="activepeers"></span>
|
||||||
|
</h2>
|
||||||
|
<h2 class="content-subhead">
|
||||||
|
Known peers: <span id="knownpeers"></span>
|
||||||
|
</h2>
|
||||||
|
<h2 class="content-subhead">
|
||||||
|
Bandwidth:
|
||||||
in <span id="bw-in"></span> Bps /
|
in <span id="bw-in"></span> Bps /
|
||||||
out <span id="bw-out"></span> Bps
|
out <span id="bw-out"></span> Bps
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--#include virtual="menu.html" -->
|
<!--#include virtual="menu.html" -->
|
||||||
|
<!--#include virtual="footer.html" -->
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
<noscript>
|
|
||||||
<div class="header"><h1>Please enable JavaScript!</h1></div>
|
|
||||||
</noscript>
|
|
||||||
</div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="index.html" class="menu-link">Home</a>
|
<a href="index.html" class="menu-link">Home</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="menu-item">
|
||||||
|
<a href="netdb.html" class="menu-link">Network Database</a>
|
||||||
|
</li>
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="#/config" class="menu-link">Configure</a>
|
<a href="#/config" class="menu-link">Configure</a>
|
||||||
</li>
|
</li>
|
||||||
|
59
webui/netdb.html
Normal file
59
webui/netdb.html
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Purple I2P 0.10.0 Webconsole</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="css/main.css">
|
||||||
|
<script type="text/javascript" src="javascript/I2PControl.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
function updateNetDbInfo(result, session) {
|
||||||
|
if(session.error) {
|
||||||
|
alert("Error: " + session.error["message"]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
I2PControl.updateDocument({
|
||||||
|
"knownpeers" : result["i2p.router.netdb.knownpeers"],
|
||||||
|
"activepeers" : result["i2p.router.netdb.activepeers"],
|
||||||
|
"floodfills" : result["i2p.router.netdb.floodfills"],
|
||||||
|
"leasesets" : result["i2p.router.netdb.leasesets"],
|
||||||
|
});
|
||||||
|
|
||||||
|
window.setTimeout(function() { requestNetDbInfo(session); }, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function requestNetDbInfo(session) {
|
||||||
|
session.request("RouterInfo", {
|
||||||
|
"i2p.router.netdb.knownpeers" : "",
|
||||||
|
"i2p.router.netdb.activepeers" : "",
|
||||||
|
"i2p.router.netdb.floodfills" : "",
|
||||||
|
"i2p.router.netdb.leasesets" : "",
|
||||||
|
}, updateNetDbInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.onload = function() {
|
||||||
|
var session = new I2PControl.Session("itoopie");
|
||||||
|
session.start(function() { requestNetDbInfo(session); });
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="header">
|
||||||
|
<h1>i2pd router console</h1>
|
||||||
|
<h2>Network Database Information</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<h2 class="content-subhead">Active peers: <span id="activepeers"></span></h2>
|
||||||
|
<h2 class="content-subhead">Known peers: <span id="knownpeers"></span></h2>
|
||||||
|
<h2 class="content-subhead">Floodfills: <span id="floodfills"></span></h2>
|
||||||
|
</br>
|
||||||
|
<h2 class="content-subhead">LeaseSets: <span id="leasesets"></span></h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--#include virtual="menu.html" -->
|
||||||
|
<!--#include virtual="footer.html" -->
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user