Monero
Loading...
Searching...
No Matches
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
42namespace mms
43{
44
81typedef epee::misc_utils::struct_init<transport_message_t> transport_message;
82
84{
85public:
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);
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
96private:
97 const std::unique_ptr<epee::net_utils::http::abstract_http_client> m_http_client;
98 std::string m_bitmessage_url;
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}
#define s(x, c)
Definition aesb.c:47
Definition wipeable_string.h:41
bool post_request(const std::string &request, std::string &answer)
Definition message_transporter.cpp:243
void set_options(const std::string &bitmessage_address, const epee::wipeable_string &bitmessage_login)
Definition message_transporter.cpp:89
std::atomic< bool > m_run
Definition message_transporter.h:100
const std::unique_ptr< epee::net_utils::http::abstract_http_client > m_http_client
Definition message_transporter.h:97
bool delete_message(const std::string &transport_id)
Definition message_transporter.cpp:185
epee::wipeable_string m_bitmessage_login
Definition message_transporter.h:99
std::string m_bitmessage_url
Definition message_transporter.h:98
static void end_xml_rpc_cmd(std::string &xml)
Definition message_transporter.cpp:336
bool send_message(const transport_message &message)
Definition message_transporter.cpp:167
static void add_xml_rpc_base64_param(std::string &xml, const std::string &param)
Definition message_transporter.cpp:324
void stop()
Definition message_transporter.h:92
bool receive_messages(const std::vector< std::string > &destination_transport_addresses, std::vector< transport_message > &messages)
Definition message_transporter.cpp:103
static std::string get_str_between_tags(const std::string &s, const std::string &start_delim, const std::string &stop_delim)
Definition message_transporter.cpp:299
static void add_xml_rpc_string_param(std::string &xml, const std::string &param)
Definition message_transporter.cpp:319
message_transporter(std::unique_ptr< epee::net_utils::http::abstract_http_client > http_client)
Definition message_transporter.cpp:84
static void start_xml_rpc_cmd(std::string &xml, const std::string &method_name)
Definition message_transporter.cpp:314
static void add_xml_rpc_integer_param(std::string &xml, const int32_t &param)
Definition message_transporter.cpp:331
const uint8_t seed[32]
Definition code-generator.cpp:37
#define KV_SERIALIZE_VAL_POD_AS_BLOB(varialble)
Definition keyvalue_serialization.h:121
#define KV_SERIALIZE(varialble)
Definition keyvalue_serialization.h:120
#define END_KV_SERIALIZE_MAP()
Definition keyvalue_serialization.h:118
#define BEGIN_KV_SERIALIZE_MAP()
Definition keyvalue_serialization.h:43
POD_CLASS signature
Definition crypto.h:98
POD_CLASS public_key
Definition crypto.h:64
POD_CLASS hash
Definition hash.h:49
TODO: (mj-xmr) This will be reduced in an another PR.
Definition byte_slice.h:40
Definition message_store.cpp:52
epee::misc_utils::struct_init< transport_message_t > transport_message
Definition message_transporter.h:81
unsigned int uint32_t
Definition stdint.h:126
signed int int32_t
Definition stdint.h:123
unsigned __int64 uint64_t
Definition stdint.h:136
Definition cryptonote_basic.h:512
Definition message_store.h:104
Definition message_transporter.h:46
cryptonote::account_public_address source_monero_address
Definition message_transporter.h:47
std::string transport_id
Definition message_transporter.h:61
crypto::hash hash
Definition message_transporter.h:57
std::string content
Definition message_transporter.h:56
crypto::signature signature
Definition message_transporter.h:58
uint64_t timestamp
Definition message_transporter.h:53
std::string destination_transport_address
Definition message_transporter.h:50
uint32_t round
Definition message_transporter.h:59
cryptonote::account_public_address destination_monero_address
Definition message_transporter.h:49
uint32_t signature_count
Definition message_transporter.h:60
std::string subject
Definition message_transporter.h:55
crypto::chacha_iv iv
Definition message_transporter.h:51
std::string source_transport_address
Definition message_transporter.h:48
crypto::public_key encryption_public_key
Definition message_transporter.h:52
uint32_t type
Definition message_transporter.h:54