Merge pull request #201 from moneroexamples/devel
Add --daemon-login option
This commit is contained in:
commit
2b7b07f3be
|
@ -92,7 +92,7 @@ Current development branch:
|
||||||
|
|
||||||
- https://github.com/moneroexamples/onion-monero-blockchain-explorer/tree/devel
|
- https://github.com/moneroexamples/onion-monero-blockchain-explorer/tree/devel
|
||||||
|
|
||||||
Note: `devel` branch of the explorer follows `master` branch of the monero.
|
Note: `devel` branch of the explorer follows `master` branch of the monero!
|
||||||
|
|
||||||
## Compilation on Ubuntu 16.04/18.04
|
## Compilation on Ubuntu 16.04/18.04
|
||||||
|
|
||||||
|
@ -208,6 +208,8 @@ xmrblocks, Onion Monero Blockchain Explorer:
|
||||||
functionality
|
functionality
|
||||||
-d [ --deamon-url ] arg (=http:://127.0.0.1:18081)
|
-d [ --deamon-url ] arg (=http:://127.0.0.1:18081)
|
||||||
Monero daemon url
|
Monero daemon url
|
||||||
|
--daemon-login arg Specify username[:password] for daemon
|
||||||
|
RPC client
|
||||||
```
|
```
|
||||||
|
|
||||||
Example usage, defined as bash aliases.
|
Example usage, defined as bash aliases.
|
||||||
|
|
43
main.cpp
43
main.cpp
|
@ -65,6 +65,7 @@ main(int ac, const char* av[])
|
||||||
auto mainnet_url = opts.get_option<string>("mainnet-url");
|
auto mainnet_url = opts.get_option<string>("mainnet-url");
|
||||||
auto mempool_info_timeout_opt = opts.get_option<string>("mempool-info-timeout");
|
auto mempool_info_timeout_opt = opts.get_option<string>("mempool-info-timeout");
|
||||||
auto mempool_refresh_time_opt = opts.get_option<string>("mempool-refresh-time");
|
auto mempool_refresh_time_opt = opts.get_option<string>("mempool-refresh-time");
|
||||||
|
auto daemon_login_opt = opts.get_option<string>("daemon-login");
|
||||||
auto testnet_opt = opts.get_option<bool>("testnet");
|
auto testnet_opt = opts.get_option<bool>("testnet");
|
||||||
auto stagenet_opt = opts.get_option<bool>("stagenet");
|
auto stagenet_opt = opts.get_option<bool>("stagenet");
|
||||||
auto enable_key_image_checker_opt = opts.get_option<bool>("enable-key-image-checker");
|
auto enable_key_image_checker_opt = opts.get_option<bool>("enable-key-image-checker");
|
||||||
|
@ -79,7 +80,6 @@ main(int ac, const char* av[])
|
||||||
auto enable_emission_monitor_opt = opts.get_option<bool>("enable-emission-monitor");
|
auto enable_emission_monitor_opt = opts.get_option<bool>("enable-emission-monitor");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool testnet {*testnet_opt};
|
bool testnet {*testnet_opt};
|
||||||
bool stagenet {*stagenet_opt};
|
bool stagenet {*stagenet_opt};
|
||||||
|
|
||||||
|
@ -123,9 +123,41 @@ main(int ac, const char* av[])
|
||||||
string ssl_crt_file;
|
string ssl_crt_file;
|
||||||
string ssl_key_file;
|
string ssl_key_file;
|
||||||
|
|
||||||
|
xmreg::rpccalls::login_opt daemon_rpc_login {};
|
||||||
|
|
||||||
|
|
||||||
|
if (daemon_login_opt)
|
||||||
|
{
|
||||||
|
|
||||||
|
string user {};
|
||||||
|
epee::wipeable_string pass {};
|
||||||
|
|
||||||
|
string daemon_login = *daemon_login_opt;
|
||||||
|
|
||||||
|
size_t colon_location = daemon_login.find_first_of(':');
|
||||||
|
|
||||||
|
if (colon_location != std::string::npos)
|
||||||
|
{
|
||||||
|
// have colon for user:password
|
||||||
|
user = daemon_login.substr(0, colon_location);
|
||||||
|
pass = daemon_login.substr(colon_location + 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
user = *daemon_login_opt;
|
||||||
|
}
|
||||||
|
|
||||||
|
daemon_rpc_login = epee::net_utils::http::login {user, pass};
|
||||||
|
|
||||||
|
//cout << "colon_location: " << colon_location << endl;
|
||||||
|
// cout << "user: " << user << endl;
|
||||||
|
// cout << "pass: " << std::string(pass.data(), pass.size()) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// check if ssl enabled and files exist
|
// check if ssl enabled and files exist
|
||||||
|
|
||||||
if (ssl_crt_file_opt and ssl_key_file_opt)
|
if (ssl_crt_file_opt && ssl_key_file_opt)
|
||||||
{
|
{
|
||||||
if (!boost::filesystem::exists(boost::filesystem::path(*ssl_crt_file_opt)))
|
if (!boost::filesystem::exists(boost::filesystem::path(*ssl_crt_file_opt)))
|
||||||
{
|
{
|
||||||
|
@ -237,6 +269,8 @@ main(int ac, const char* av[])
|
||||||
= nettype;
|
= nettype;
|
||||||
xmreg::MempoolStatus::deamon_url
|
xmreg::MempoolStatus::deamon_url
|
||||||
= deamon_url;
|
= deamon_url;
|
||||||
|
xmreg::MempoolStatus::login
|
||||||
|
= daemon_rpc_login;
|
||||||
xmreg::MempoolStatus::set_blockchain_variables(
|
xmreg::MempoolStatus::set_blockchain_variables(
|
||||||
&mcore, core_storage);
|
&mcore, core_storage);
|
||||||
|
|
||||||
|
@ -281,7 +315,8 @@ main(int ac, const char* av[])
|
||||||
mempool_info_timeout,
|
mempool_info_timeout,
|
||||||
*testnet_url,
|
*testnet_url,
|
||||||
*stagenet_url,
|
*stagenet_url,
|
||||||
*mainnet_url);
|
*mainnet_url,
|
||||||
|
daemon_rpc_login);
|
||||||
|
|
||||||
// crow instance
|
// crow instance
|
||||||
crow::SimpleApp app;
|
crow::SimpleApp app;
|
||||||
|
@ -808,7 +843,7 @@ main(int ac, const char* av[])
|
||||||
([&]() {
|
([&]() {
|
||||||
uint64_t page_no {0};
|
uint64_t page_no {0};
|
||||||
bool refresh_page {true};
|
bool refresh_page {true};
|
||||||
return xmrblocks.index2(page_no, refresh_page);
|
return myxmr::htmlresponse(xmrblocks.index2(page_no, refresh_page));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,8 @@ namespace xmreg
|
||||||
"path to crt file for ssl (https) functionality")
|
"path to crt file for ssl (https) functionality")
|
||||||
("ssl-key-file", value<string>(),
|
("ssl-key-file", value<string>(),
|
||||||
"path to key file for ssl (https) functionality")
|
"path to key file for ssl (https) functionality")
|
||||||
|
("daemon-login", value<string>(),
|
||||||
|
"Specify username[:password] for daemon RPC client")
|
||||||
("deamon-url,d", value<string>()->default_value("http:://127.0.0.1:18081"),
|
("deamon-url,d", value<string>()->default_value("http:://127.0.0.1:18081"),
|
||||||
"Monero daemon url");
|
"Monero daemon url");
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#include "MempoolStatus.h"
|
#include "MempoolStatus.h"
|
||||||
|
|
||||||
#include "rpccalls.h"
|
|
||||||
|
|
||||||
namespace xmreg
|
namespace xmreg
|
||||||
{
|
{
|
||||||
|
@ -97,7 +96,7 @@ MempoolStatus::start_mempool_status_thread()
|
||||||
bool
|
bool
|
||||||
MempoolStatus::read_mempool()
|
MempoolStatus::read_mempool()
|
||||||
{
|
{
|
||||||
rpccalls rpc {deamon_url};
|
rpccalls rpc {deamon_url, login};
|
||||||
|
|
||||||
string error_msg;
|
string error_msg;
|
||||||
|
|
||||||
|
@ -242,7 +241,7 @@ MempoolStatus::read_mempool()
|
||||||
bool
|
bool
|
||||||
MempoolStatus::read_network_info()
|
MempoolStatus::read_network_info()
|
||||||
{
|
{
|
||||||
rpccalls rpc {deamon_url};
|
rpccalls rpc {deamon_url, login};
|
||||||
|
|
||||||
COMMAND_RPC_GET_INFO::response rpc_network_info;
|
COMMAND_RPC_GET_INFO::response rpc_network_info;
|
||||||
|
|
||||||
|
@ -352,6 +351,7 @@ atomic<bool> MempoolStatus::is_running {false};
|
||||||
boost::thread MempoolStatus::m_thread;
|
boost::thread MempoolStatus::m_thread;
|
||||||
Blockchain* MempoolStatus::core_storage {nullptr};
|
Blockchain* MempoolStatus::core_storage {nullptr};
|
||||||
xmreg::MicroCore* MempoolStatus::mcore {nullptr};
|
xmreg::MicroCore* MempoolStatus::mcore {nullptr};
|
||||||
|
rpccalls::login_opt MempoolStatus::login {};
|
||||||
vector<MempoolStatus::mempool_tx> MempoolStatus::mempool_txs;
|
vector<MempoolStatus::mempool_tx> MempoolStatus::mempool_txs;
|
||||||
atomic<MempoolStatus::network_info> MempoolStatus::current_network_info;
|
atomic<MempoolStatus::network_info> MempoolStatus::current_network_info;
|
||||||
atomic<uint64_t> MempoolStatus::mempool_no {0}; // no of txs
|
atomic<uint64_t> MempoolStatus::mempool_no {0}; // no of txs
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "MicroCore.h"
|
#include "MicroCore.h"
|
||||||
|
#include "rpccalls.h"
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
|
@ -131,6 +132,8 @@ struct MempoolStatus
|
||||||
static string deamon_url;
|
static string deamon_url;
|
||||||
static cryptonote::network_type nettype;
|
static cryptonote::network_type nettype;
|
||||||
|
|
||||||
|
static rpccalls::login_opt login;
|
||||||
|
|
||||||
// make object for accessing the blockchain here
|
// make object for accessing the blockchain here
|
||||||
static MicroCore* mcore;
|
static MicroCore* mcore;
|
||||||
static Blockchain* core_storage;
|
static Blockchain* core_storage;
|
||||||
|
|
|
@ -518,10 +518,11 @@ page(MicroCore* _mcore,
|
||||||
uint64_t _mempool_info_timeout,
|
uint64_t _mempool_info_timeout,
|
||||||
string _testnet_url,
|
string _testnet_url,
|
||||||
string _stagenet_url,
|
string _stagenet_url,
|
||||||
string _mainnet_url)
|
string _mainnet_url,
|
||||||
|
rpccalls::login_opt _daemon_rpc_login)
|
||||||
: mcore {_mcore},
|
: mcore {_mcore},
|
||||||
core_storage {_core_storage},
|
core_storage {_core_storage},
|
||||||
rpc {_deamon_url},
|
rpc {_deamon_url, _daemon_rpc_login},
|
||||||
server_timestamp {std::time(nullptr)},
|
server_timestamp {std::time(nullptr)},
|
||||||
nettype {_nettype},
|
nettype {_nettype},
|
||||||
enable_pusher {_enable_pusher},
|
enable_pusher {_enable_pusher},
|
||||||
|
|
|
@ -8,7 +8,9 @@ namespace xmreg
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
rpccalls::rpccalls(string _deamon_url,
|
rpccalls::rpccalls(
|
||||||
|
string _deamon_url,
|
||||||
|
login_opt login,
|
||||||
uint64_t _timeout)
|
uint64_t _timeout)
|
||||||
: deamon_url {_deamon_url},
|
: deamon_url {_deamon_url},
|
||||||
timeout_time {_timeout}
|
timeout_time {_timeout}
|
||||||
|
@ -17,11 +19,12 @@ rpccalls::rpccalls(string _deamon_url,
|
||||||
|
|
||||||
port = std::to_string(url.port);
|
port = std::to_string(url.port);
|
||||||
|
|
||||||
timeout_time_ms = std::chrono::milliseconds {timeout_time};
|
timeout_time_ms = std::chrono::milliseconds {timeout_time};
|
||||||
|
|
||||||
m_http_client.set_server(
|
m_http_client.set_server(
|
||||||
deamon_url,
|
deamon_url,
|
||||||
boost::optional<epee::net_utils::http::login>{}, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
|
login,
|
||||||
|
epee::net_utils::ssl_support_t::e_ssl_support_disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
#include "monero_headers.h"
|
#include "monero_headers.h"
|
||||||
|
|
||||||
|
#include "wipeable_string.h"
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
@ -81,7 +83,10 @@ class rpccalls
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
using login_opt = boost::optional<epee::net_utils::http::login>;
|
||||||
|
|
||||||
rpccalls(string _deamon_url = "http:://127.0.0.1:18081",
|
rpccalls(string _deamon_url = "http:://127.0.0.1:18081",
|
||||||
|
login_opt _login = login_opt {},
|
||||||
uint64_t _timeout = 200000);
|
uint64_t _timeout = 200000);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
Loading…
Reference in New Issue