From 23b6f685de3df9c073078bc60f6f87d7c8d6f8f7 Mon Sep 17 00:00:00 2001 From: Tim L Date: Wed, 15 Nov 2017 22:58:11 -0500 Subject: RPC: allow binding of restricted port in addition to core port --- src/daemon/rpc.h | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'src/daemon/rpc.h') diff --git a/src/daemon/rpc.h b/src/daemon/rpc.h index 0ecfdd120..9b7438053 100644 --- a/src/daemon/rpc.h +++ b/src/daemon/rpc.h @@ -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..."); } } }; -- cgit v1.2.3