aboutsummaryrefslogtreecommitdiff
path: root/src/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/command_parser_executor.cpp4
-rw-r--r--src/daemon/command_parser_executor.h5
-rw-r--r--src/daemon/command_server.cpp4
-rw-r--r--src/daemon/command_server.h4
-rw-r--r--src/daemon/daemon.cpp4
-rw-r--r--src/daemon/main.cpp23
-rw-r--r--src/daemon/rpc_command_executor.cpp12
-rw-r--r--src/daemon/rpc_command_executor.h5
8 files changed, 45 insertions, 16 deletions
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp
index 27f9d0fd7..fd73654ac 100644
--- a/src/daemon/command_parser_executor.cpp
+++ b/src/daemon/command_parser_executor.cpp
@@ -37,11 +37,11 @@ namespace daemonize {
t_command_parser_executor::t_command_parser_executor(
uint32_t ip
, uint16_t port
- , const std::string &user_agent
+ , const boost::optional<tools::login>& login
, bool is_rpc
, cryptonote::core_rpc_server* rpc_server
)
- : m_executor(ip, port, user_agent, is_rpc, rpc_server)
+ : m_executor(ip, port, login, is_rpc, rpc_server)
{}
bool t_command_parser_executor::print_peer_list(const std::vector<std::string>& args)
diff --git a/src/daemon/command_parser_executor.h b/src/daemon/command_parser_executor.h
index 15293ade9..1fe3e0f98 100644
--- a/src/daemon/command_parser_executor.h
+++ b/src/daemon/command_parser_executor.h
@@ -36,7 +36,10 @@
#pragma once
+#include <boost/optional/optional_fwd.hpp>
+
#include "daemon/rpc_command_executor.h"
+#include "common/common_fwd.h"
#include "rpc/core_rpc_server.h"
namespace daemonize {
@@ -49,7 +52,7 @@ public:
t_command_parser_executor(
uint32_t ip
, uint16_t port
- , const std::string &user_agent
+ , const boost::optional<tools::login>& login
, bool is_rpc
, cryptonote::core_rpc_server* rpc_server = NULL
);
diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp
index 95fd3178c..34868b576 100644
--- a/src/daemon/command_server.cpp
+++ b/src/daemon/command_server.cpp
@@ -40,11 +40,11 @@ namespace p = std::placeholders;
t_command_server::t_command_server(
uint32_t ip
, uint16_t port
- , const std::string &user_agent
+ , const boost::optional<tools::login>& login
, bool is_rpc
, cryptonote::core_rpc_server* rpc_server
)
- : m_parser(ip, port, user_agent, is_rpc, rpc_server)
+ : m_parser(ip, port, login, is_rpc, rpc_server)
, m_command_lookup()
, m_is_rpc(is_rpc)
{
diff --git a/src/daemon/command_server.h b/src/daemon/command_server.h
index fb1702aae..9ecf06b9d 100644
--- a/src/daemon/command_server.h
+++ b/src/daemon/command_server.h
@@ -39,6 +39,8 @@ Passing RPC commands:
#pragma once
+#include <boost/optional/optional_fwd.hpp>
+#include "common/common_fwd.h"
#include "console_handler.h"
#include "daemon/command_parser_executor.h"
@@ -54,7 +56,7 @@ public:
t_command_server(
uint32_t ip
, uint16_t port
- , const std::string &user_agent
+ , const boost::optional<tools::login>& login
, bool is_rpc = true
, cryptonote::core_rpc_server* rpc_server = NULL
);
diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp
index 287c30cb4..e40136a71 100644
--- a/src/daemon/daemon.cpp
+++ b/src/daemon/daemon.cpp
@@ -33,6 +33,7 @@
#include "misc_log_ex.h"
#include "daemon/daemon.h"
+#include "common/password.h"
#include "common/util.h"
#include "daemon/core.h"
#include "daemon/p2p.h"
@@ -127,7 +128,8 @@ bool t_daemon::run(bool interactive)
if (interactive)
{
- rpc_commands = new daemonize::t_command_server(0, 0, "", false, mp_internals->rpc.get_server());
+ // The first three variables are not used when the fourth is false
+ rpc_commands = new daemonize::t_command_server(0, 0, boost::none, false, mp_internals->rpc.get_server());
rpc_commands->start_handling(std::bind(&daemonize::t_daemon::stop_p2p, this));
}
diff --git a/src/daemon/main.cpp b/src/daemon/main.cpp
index e08065ccd..4822d8d8a 100644
--- a/src/daemon/main.cpp
+++ b/src/daemon/main.cpp
@@ -30,9 +30,10 @@
#include "common/command_line.h"
#include "common/scoped_message_writer.h"
+#include "common/password.h"
#include "common/util.h"
#include "cryptonote_core/cryptonote_core.h"
-#include "cryptonote_core/miner.h"
+#include "cryptonote_basic/miner.h"
#include "daemon/command_server.h"
#include "daemon/daemon.h"
#include "daemon/executor.h"
@@ -40,6 +41,7 @@
#include "misc_log_ex.h"
#include "p2p/net_node.h"
#include "rpc/core_rpc_server.h"
+#include "rpc/rpc_args.h"
#include "daemon/command_line_args.h"
#include "blockchain_db/db_types.h"
@@ -220,13 +222,13 @@ int main(int argc, char const * argv[])
if (command.size())
{
- auto rpc_ip_str = command_line::get_arg(vm, cryptonote::core_rpc_server::arg_rpc_bind_ip);
+ const cryptonote::rpc_args::descriptors arg{};
+ auto rpc_ip_str = command_line::get_arg(vm, arg.rpc_bind_ip);
auto rpc_port_str = command_line::get_arg(vm, cryptonote::core_rpc_server::arg_rpc_bind_port);
if (testnet_mode)
{
rpc_port_str = command_line::get_arg(vm, cryptonote::core_rpc_server::arg_testnet_rpc_bind_port);
}
- auto user_agent = command_line::get_arg(vm, cryptonote::core_rpc_server::arg_user_agent);
uint32_t rpc_ip;
uint16_t rpc_port;
@@ -241,7 +243,20 @@ int main(int argc, char const * argv[])
return 1;
}
- daemonize::t_command_server rpc_commands{rpc_ip, rpc_port, user_agent};
+ boost::optional<tools::login> login{};
+ if (command_line::has_arg(vm, arg.rpc_login))
+ {
+ login = tools::login::parse(
+ command_line::get_arg(vm, arg.rpc_login), false, "Daemon client password"
+ );
+ if (!login)
+ {
+ std::cerr << "Failed to obtain password" << std::endl;
+ return 1;
+ }
+ }
+
+ daemonize::t_command_server rpc_commands{rpc_ip, rpc_port, std::move(login)};
if (rpc_commands.process_command_vec(command))
{
return 0;
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp
index f7d85b5ef..469f83014 100644
--- a/src/daemon/rpc_command_executor.cpp
+++ b/src/daemon/rpc_command_executor.cpp
@@ -29,11 +29,12 @@
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#include "string_tools.h"
+#include "common/password.h"
#include "common/scoped_message_writer.h"
#include "daemon/rpc_command_executor.h"
#include "rpc/core_rpc_server_commands_defs.h"
#include "cryptonote_core/cryptonote_core.h"
-#include "cryptonote_core/hardfork.h"
+#include "cryptonote_basic/hardfork.h"
#include <boost/format.hpp>
#include <ctime>
#include <string>
@@ -95,7 +96,7 @@ namespace {
t_rpc_command_executor::t_rpc_command_executor(
uint32_t ip
, uint16_t port
- , const std::string &user_agent
+ , const boost::optional<tools::login>& login
, bool is_rpc
, cryptonote::core_rpc_server* rpc_server
)
@@ -103,7 +104,10 @@ t_rpc_command_executor::t_rpc_command_executor(
{
if (is_rpc)
{
- m_rpc_client = new tools::t_rpc_client(ip, port);
+ boost::optional<epee::net_utils::http::login> http_login{};
+ if (login)
+ http_login.emplace(login->username, login->password.password());
+ m_rpc_client = new tools::t_rpc_client(ip, port, std::move(http_login));
}
else
{
@@ -368,7 +372,7 @@ bool t_rpc_command_executor::show_status() {
std::time_t uptime = std::time(nullptr) - ires.start_time;
- tools::success_msg_writer() << boost::format("Height: %llu/%llu (%.1f%%) on %s, %s, net hash %s, v%u%s, %s, %u+%u connections, uptime %ud %uh %um %us")
+ tools::success_msg_writer() << boost::format("Height: %llu/%llu (%.1f%%) on %s, %s, net hash %s, v%u%s, %s, %u(out)+%u(in) connections, uptime %ud %uh %um %us")
% (unsigned long long)ires.height
% (unsigned long long)(ires.target_height >= ires.height ? ires.target_height : ires.height)
% get_sync_percentage(ires)
diff --git a/src/daemon/rpc_command_executor.h b/src/daemon/rpc_command_executor.h
index afcd99d32..4691844fa 100644
--- a/src/daemon/rpc_command_executor.h
+++ b/src/daemon/rpc_command_executor.h
@@ -38,6 +38,9 @@
#pragma once
+#include <boost/optional/optional_fwd.hpp>
+
+#include "common/common_fwd.h"
#include "common/rpc_client.h"
#include "misc_log_ex.h"
#include "cryptonote_core/cryptonote_core.h"
@@ -60,7 +63,7 @@ public:
t_rpc_command_executor(
uint32_t ip
, uint16_t port
- , const std::string &user_agent
+ , const boost::optional<tools::login>& user
, bool is_rpc = true
, cryptonote::core_rpc_server* rpc_server = NULL
);