Debian Codegraph @

src/daemon/command_server.h

raw symbols SCIP
1 /**
2 @file
3 @details
4
5
6 Passing RPC commands:
7
8 @image html images/other/runtime-commands.png
9
10 */
11
12 // Copyright (c) 2014-2022, 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"
45 #include "daemon/command_parser_executor.h"
46
47 namespace daemonize {
48
49 class t_command_server {
50 private:
51 t_command_parser_executor m_parser;
52 epee::console_handlers_binder m_command_lookup;
53 bool m_is_rpc;
54
55 public:
56 t_command_server(
57 uint32_t ip
58 , uint16_t port
59 , const boost::optional<tools::login>& login
60 , const epee::net_utils::ssl_options_t& ssl_options
61 , bool is_rpc = true
62 , cryptonote::core_rpc_server* rpc_server = NULL
63 );
64
65 bool process_command_str(const std::string& cmd);
66
67 bool process_command_vec(const std::vector<std::string>& cmd);
68
69 bool start_handling(std::function<void(void)> exit_handler = NULL);
70
71 void stop_handling();
72
73 private:
74 bool help(const std::vector<std::string>& args);
75 bool apropos(const std::vector<std::string>& args);
76
77 std::string get_commands_str();
78 std::string get_command_usage(const std::vector<std::string> &args);
79 };
80
81 } // namespace daemonize