Monero
command_server.h
Go to the documentation of this file.
1 
12 // Copyright (c) 2014-2018, The Monero Project
13 //
14 // All rights reserved.
15 //
16 // Redistribution and use in source and binary forms, with or without modification, are
17 // permitted provided that the following conditions are met:
18 //
19 // 1. Redistributions of source code must retain the above copyright notice, this list of
20 // conditions and the following disclaimer.
21 //
22 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
23 // of conditions and the following disclaimer in the documentation and/or other
24 // materials provided with the distribution.
25 //
26 // 3. Neither the name of the copyright holder nor the names of its contributors may be
27 // used to endorse or promote products derived from this software without specific
28 // prior written permission.
29 //
30 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
31 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
32 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
33 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
35 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
38 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 
40 #pragma once
41 
42 #include <boost/optional/optional_fwd.hpp>
43 #include "common/common_fwd.h"
44 #include "console_handler.h"
46 
47 namespace daemonize {
48 
50 private:
52  epee::console_handlers_binder m_command_lookup;
53  bool m_is_rpc;
54 
55 public:
57  uint32_t ip
58  , uint16_t port
59  , const boost::optional<tools::login>& login
60  , bool is_rpc = true
61  , cryptonote::core_rpc_server* rpc_server = NULL
62  );
63 
64  bool process_command_str(const std::string& cmd);
65 
66  bool process_command_vec(const std::vector<std::string>& cmd);
67 
68  bool start_handling(std::function<void(void)> exit_handler = NULL);
69 
70  void stop_handling();
71 
72 private:
73  bool help(const std::vector<std::string>& args);
74 
75  std::string get_commands_str();
76  std::string get_command_usage(const std::vector<std::string> &args);
77 };
78 
79 } // namespace daemonize
t_command_parser_executor m_parser
Definition: command_server.h:51
Definition: command_parser_executor.cpp:37
t_command_server(uint32_t ip, uint16_t port, const boost::optional< tools::login > &login, bool is_rpc=true, cryptonote::core_rpc_server *rpc_server=NULL)
Definition: command_server.cpp:42
bool help(const std::vector< std::string > &args)
Definition: command_server.cpp:322
bool process_command_str(const std::string &cmd)
Definition: command_server.cpp:291
bool m_is_rpc
Definition: command_server.h:53
Definition: command_server.h:49
Definition: command_parser_executor.h:47
std::string get_commands_str()
Definition: command_server.cpp:335
epee::console_handlers_binder m_command_lookup
Definition: command_server.h:52
bool start_handling(std::function< void(void)> exit_handler=NULL)
Definition: command_server.cpp:306
Definition: core_rpc_server.h:52
bool process_command_vec(const std::vector< std::string > &cmd)
Definition: command_server.cpp:296
std::string get_command_usage(const std::vector< std::string > &args)
Definition: command_server.cpp:347
void stop_handling()
Definition: command_server.cpp:315