Monero
command_server.h
Go to the documentation of this file.
1 
12 // Copyright (c) 2014-2020, 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 #include "net/net_fwd.h"
47 
48 namespace daemonize {
49 
51 private:
53  epee::console_handlers_binder m_command_lookup;
54  bool m_is_rpc;
55 
56 public:
58  uint32_t ip
59  , uint16_t port
60  , const boost::optional<tools::login>& login
61  , const epee::net_utils::ssl_options_t& ssl_options
62  , bool is_rpc = true
63  , cryptonote::core_rpc_server* rpc_server = NULL
64  );
65 
66  bool process_command_str(const std::string& cmd);
67 
68  bool process_command_vec(const std::vector<std::string>& cmd);
69 
70  bool start_handling(std::function<void(void)> exit_handler = NULL);
71 
72  void stop_handling();
73 
74 private:
75  bool help(const std::vector<std::string>& args);
76  bool apropos(const std::vector<std::string>& args);
77 
78  std::string get_commands_str();
79  std::string get_command_usage(const std::vector<std::string> &args);
80 };
81 
82 } // namespace daemonize
Definition: core_rpc_server.h:60
Definition: command_parser_executor.h:49
Definition: command_server.h:50
t_command_parser_executor m_parser
Definition: command_server.h:52
std::string get_commands_str()
Definition: command_server.cpp:410
bool m_is_rpc
Definition: command_server.h:54
void stop_handling()
Definition: command_server.cpp:363
epee::console_handlers_binder m_command_lookup
Definition: command_server.h:53
bool help(const std::vector< std::string > &args)
Definition: command_server.cpp:370
bool process_command_vec(const std::vector< std::string > &cmd)
Definition: command_server.cpp:344
bool process_command_str(const std::string &cmd)
Definition: command_server.cpp:339
bool apropos(const std::vector< std::string > &args)
Definition: command_server.cpp:383
bool start_handling(std::function< void(void)> exit_handler=NULL)
Definition: command_server.cpp:354
t_command_server(uint32_t ip, uint16_t port, const boost::optional< tools::login > &login, const epee::net_utils::ssl_options_t &ssl_options, bool is_rpc=true, cryptonote::core_rpc_server *rpc_server=NULL)
Definition: command_server.cpp:42
std::string get_command_usage(const std::vector< std::string > &args)
Definition: command_server.cpp:422
args
Definition: build_protob.py:10
Definition: command_parser_executor.cpp:37