RPC: allow binding of restricted port in addition to core port
This commit is contained in:
+17
-11
@@ -47,35 +47,41 @@ public:
|
||||
}
|
||||
private:
|
||||
cryptonote::core_rpc_server m_server;
|
||||
const std::string m_description;
|
||||
public:
|
||||
t_rpc(
|
||||
boost::program_options::variables_map const & vm
|
||||
, t_core & core
|
||||
, t_p2p & p2p
|
||||
, const bool restricted
|
||||
, const bool testnet
|
||||
, const std::string & port
|
||||
, const std::string & description
|
||||
)
|
||||
: m_server{core.get(), p2p.get()}
|
||||
: m_server{core.get(), p2p.get()}, m_description{description}
|
||||
{
|
||||
MGINFO("Initializing core rpc server...");
|
||||
if (!m_server.init(vm))
|
||||
MGINFO("Initializing " << m_description << " rpc server...");
|
||||
|
||||
if (!m_server.init(vm, restricted, testnet, port))
|
||||
{
|
||||
throw std::runtime_error("Failed to initialize core rpc server.");
|
||||
throw std::runtime_error("Failed to initialize " + m_description + " rpc server.");
|
||||
}
|
||||
MGINFO("Core rpc server initialized OK on port: " << m_server.get_binded_port());
|
||||
MGINFO(m_description << " rpc server initialized OK on port: " << m_server.get_binded_port());
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
MGINFO("Starting core rpc server...");
|
||||
MGINFO("Starting " << m_description << " rpc server...");
|
||||
if (!m_server.run(2, false))
|
||||
{
|
||||
throw std::runtime_error("Failed to start core rpc server.");
|
||||
throw std::runtime_error("Failed to start " + m_description + " rpc server.");
|
||||
}
|
||||
MGINFO("Core rpc server started ok");
|
||||
MGINFO(m_description << " rpc server started ok");
|
||||
}
|
||||
|
||||
void stop()
|
||||
{
|
||||
MGINFO("Stopping core rpc server...");
|
||||
MGINFO("Stopping " << m_description << " rpc server...");
|
||||
m_server.send_stop_signal();
|
||||
m_server.timed_wait_server_stop(5000);
|
||||
}
|
||||
@@ -87,11 +93,11 @@ public:
|
||||
|
||||
~t_rpc()
|
||||
{
|
||||
MGINFO("Deinitializing rpc server...");
|
||||
MGINFO("Deinitializing " << m_description << " rpc server...");
|
||||
try {
|
||||
m_server.deinit();
|
||||
} catch (...) {
|
||||
MERROR("Failed to deinitialize rpc server...");
|
||||
MERROR("Failed to deinitialize " << m_description << " rpc server...");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user