Monero
message_transporter.h
Go to the documentation of this file.
1 // Copyright (c) 2018-2022, The Monero Project
2 
3 //
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without modification, are
7 // permitted provided that the following conditions are met:
8 //
9 // 1. Redistributions of source code must retain the above copyright notice, this list of
10 // conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
13 // of conditions and the following disclaimer in the documentation and/or other
14 // materials provided with the distribution.
15 //
16 // 3. Neither the name of the copyright holder nor the names of its contributors may be
17 // used to endorse or promote products derived from this software without specific
18 // prior written permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30 #pragma once
36 #include "net/http_client.h"
38 #include "common/util.h"
39 #include "wipeable_string.h"
40 #include <vector>
41 
42 namespace mms
43 {
44 
46 {
51  crypto::chacha_iv iv;
62 
80 };
81 typedef epee::misc_utils::struct_init<transport_message_t> transport_message;
82 
84 {
85 public:
86  message_transporter(std::unique_ptr<epee::net_utils::http::abstract_http_client> http_client);
87  void set_options(const std::string &bitmessage_address, const epee::wipeable_string &bitmessage_login);
88  bool send_message(const transport_message &message);
89  bool receive_messages(const std::vector<std::string> &destination_transport_addresses,
90  std::vector<transport_message> &messages);
91  bool delete_message(const std::string &transport_id);
92  void stop() { m_run.store(false, std::memory_order_relaxed); }
93  std::string derive_transport_address(const std::string &seed);
94  bool delete_transport_address(const std::string &transport_address);
95 
96 private:
97  const std::unique_ptr<epee::net_utils::http::abstract_http_client> m_http_client;
100  std::atomic<bool> m_run;
101 
102  bool post_request(const std::string &request, std::string &answer);
103  static std::string get_str_between_tags(const std::string &s, const std::string &start_delim, const std::string &stop_delim);
104 
105  static void start_xml_rpc_cmd(std::string &xml, const std::string &method_name);
106  static void add_xml_rpc_string_param(std::string &xml, const std::string &param);
107  static void add_xml_rpc_base64_param(std::string &xml, const std::string &param);
108  static void add_xml_rpc_integer_param(std::string &xml, const int32_t &param);
109  static void end_xml_rpc_cmd(std::string &xml);
110 
111 };
112 
113 }
const std::unique_ptr< epee::net_utils::http::abstract_http_client > m_http_client
Definition: message_transporter.h:97
std::string destination_transport_address
Definition: message_transporter.h:50
std::string content
Definition: message_transporter.h:56
::std::string string
Definition: gtest-port.h:1097
Definition: message_transporter.h:83
const char * method_name
Definition: daemon_handler.cpp:55
uint32_t type
Definition: message_transporter.h:54
const char * s
Definition: minissdp.c:596
uint32_t signature_count
Definition: message_transporter.h:60
epee::wipeable_string m_bitmessage_login
Definition: message_transporter.h:99
std::string source_transport_address
Definition: message_transporter.h:48
#define KV_SERIALIZE(varialble)
Definition: keyvalue_serialization.h:120
crypto::signature signature
Definition: message_transporter.h:58
uint32_t round
Definition: message_transporter.h:59
std::string m_bitmessage_url
Definition: message_transporter.h:98
void stop()
Definition: message_transporter.h:92
crypto::chacha_iv iv
Definition: message_transporter.h:51
Definition: message_transporter.h:45
crypto::public_key encryption_public_key
Definition: message_transporter.h:52
std::string subject
Definition: message_transporter.h:55
unsigned int uint32_t
Definition: stdint.h:126
Definition: message_store.h:103
std::string transport_id
Definition: message_transporter.h:61
crypto::hash hash
Definition: message_transporter.h:57
unsigned __int64 uint64_t
Definition: stdint.h:136
uint64_t timestamp
Definition: message_transporter.h:53
Definition: message_store.cpp:51
#define KV_SERIALIZE_VAL_POD_AS_BLOB(varialble)
Definition: keyvalue_serialization.h:121
Definition: misc_language.h:103
std::atomic< bool > m_run
Definition: message_transporter.h:100
cryptonote::account_public_address destination_monero_address
Definition: message_transporter.h:49
POD_CLASS public_key
Definition: crypto.h:61
TODO: (mj-xmr) This will be reduced in an another PR.
Definition: byte_slice.h:39
POD_CLASS signature
Definition: crypto.h:98
Definition: cryptonote_basic.h:511
const uint8_t seed[32]
Definition: code-generator.cpp:37
Definition: wipeable_string.h:40
POD_CLASS hash
Definition: hash.h:49
cryptonote::account_public_address source_monero_address
Definition: message_transporter.h:47
#define END_KV_SERIALIZE_MAP()
Definition: keyvalue_serialization.h:118
signed int int32_t
Definition: stdint.h:123
#define BEGIN_KV_SERIALIZE_MAP()
Definition: keyvalue_serialization.h:43