Electroneum
Toggle main menu visibility
Loading...
Searching...
No Matches
message_transporter.h
Go to the documentation of this file.
1
// Copyright (c) 2018, The Monero Project
2
//
3
// All rights reserved.
4
//
5
// Redistribution and use in source and binary forms, with or without modification, are
6
// permitted provided that the following conditions are met:
7
//
8
// 1. Redistributions of source code must retain the above copyright notice, this list of
9
// conditions and the following disclaimer.
10
//
11
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
// of conditions and the following disclaimer in the documentation and/or other
13
// materials provided with the distribution.
14
//
15
// 3. Neither the name of the copyright holder nor the names of its contributors may be
16
// used to endorse or promote products derived from this software without specific
17
// prior written permission.
18
//
19
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29
#pragma once
30
#include "
serialization/keyvalue_serialization.h
"
31
#include "
cryptonote_basic/cryptonote_basic.h
"
32
#include "
cryptonote_basic/cryptonote_boost_serialization.h
"
33
#include "
cryptonote_basic/account_boost_serialization.h
"
34
#include "
cryptonote_basic/cryptonote_basic.h
"
35
#include "
net/http_server_impl_base.h
"
36
#include "
net/http_client.h
"
37
#include "
common/util.h
"
38
#include "
wipeable_string.h
"
39
#include "
serialization/keyvalue_serialization.h
"
40
#include <vector>
41
42
namespace
mms
43
{
44
45
struct
transport_message_t
46
{
47
cryptonote::account_public_address
source_etn_address
;
48
std::string
source_transport_address
;
49
cryptonote::account_public_address
destination_etn_address
;
50
std::string
destination_transport_address
;
51
crypto::chacha_iv
iv
;
52
crypto::public_key
encryption_public_key
;
53
uint64_t
timestamp
;
54
uint32_t
type
;
55
std::string
subject
;
56
std::string
content
;
57
crypto::hash
hash
;
58
crypto::signature
signature
;
59
uint32_t
round
;
60
uint32_t
signature_count
;
61
std::string
transport_id
;
62
63
BEGIN_KV_SERIALIZE_MAP
()
64
KV_SERIALIZE
(
source_etn_address
)
65
KV_SERIALIZE
(
source_transport_address
)
66
KV_SERIALIZE
(
destination_etn_address
)
67
KV_SERIALIZE
(
destination_transport_address
)
68
KV_SERIALIZE_VAL_POD_AS_BLOB
(
iv
)
69
KV_SERIALIZE_VAL_POD_AS_BLOB
(
encryption_public_key
)
70
KV_SERIALIZE
(
timestamp
)
71
KV_SERIALIZE
(
type
)
72
KV_SERIALIZE
(
subject
)
73
KV_SERIALIZE
(
content
)
74
KV_SERIALIZE_VAL_POD_AS_BLOB
(
hash
)
75
KV_SERIALIZE_VAL_POD_AS_BLOB
(
signature
)
76
KV_SERIALIZE
(
round
)
77
KV_SERIALIZE
(
signature_count
)
78
KV_SERIALIZE
(
transport_id
)
79
END_KV_SERIALIZE_MAP
()
80
};
81
typedef
epee
::misc_utils::struct_init<
transport_message_t
>
transport_message
;
82
83
class
message_transporter
84
{
85
public
:
86
message_transporter
();
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
std::string derive_and_receive_transport_address(
const
std::string &seed);
95
bool
delete_transport_address(
const
std::string &transport_address);
96
97
private
:
98
epee::net_utils::http::http_simple_client
m_http_client;
99
std::string m_bitmessage_url;
100
epee::wipeable_string
m_bitmessage_login;
101
std::atomic<bool> m_run;
102
103
bool
post_request(
const
std::string &request, std::string &answer);
104
static
std::string get_str_between_tags(
const
std::string &s,
const
std::string &start_delim,
const
std::string &stop_delim);
105
106
static
void
start_xml_rpc_cmd(std::string &xml,
const
std::string &method_name);
107
static
void
add_xml_rpc_string_param(std::string &xml,
const
std::string ¶m);
108
static
void
add_xml_rpc_base64_param(std::string &xml,
const
std::string ¶m);
109
static
void
add_xml_rpc_integer_param(std::string &xml,
const
int32_t
¶m);
110
static
void
end_xml_rpc_cmd(std::string &xml);
111
112
};
113
114
}
account_boost_serialization.h
epee::wipeable_string
Definition
wipeable_string.h:41
mms::message_transporter::set_options
void set_options(const std::string &bitmessage_address, const epee::wipeable_string &bitmessage_login)
Definition
message_transporter.cpp:88
mms::message_transporter::delete_message
bool delete_message(const std::string &transport_id)
Definition
message_transporter.cpp:184
mms::message_transporter::send_message
bool send_message(const transport_message &message)
Definition
message_transporter.cpp:166
mms::message_transporter::stop
void stop()
Definition
message_transporter.h:92
mms::message_transporter::receive_messages
bool receive_messages(const std::vector< std::string > &destination_transport_addresses, std::vector< transport_message > &messages)
Definition
message_transporter.cpp:102
mms::message_transporter::message_transporter
message_transporter()
Definition
message_transporter.cpp:83
cryptonote_basic.h
cryptonote_boost_serialization.h
http_client.h
http_server_impl_base.h
keyvalue_serialization.h
KV_SERIALIZE_VAL_POD_AS_BLOB
#define KV_SERIALIZE_VAL_POD_AS_BLOB(varialble)
Definition
keyvalue_serialization.h:105
KV_SERIALIZE
#define KV_SERIALIZE(varialble)
Definition
keyvalue_serialization.h:104
END_KV_SERIALIZE_MAP
#define END_KV_SERIALIZE_MAP()
Definition
keyvalue_serialization.h:102
BEGIN_KV_SERIALIZE_MAP
#define BEGIN_KV_SERIALIZE_MAP()
Definition
keyvalue_serialization.h:43
crypto::signature
POD_CLASS signature
Definition
crypto.h:108
crypto::public_key
POD_CLASS public_key
Definition
crypto.h:79
crypto::hash
POD_CLASS hash
Definition
hash.h:50
epee::net_utils::http::http_simple_client
http_simple_client_template< blocked_mode_client > http_simple_client
Definition
http_client.h:1018
epee
Definition
ado_db_helper.h:67
mms
Definition
message_store.cpp:49
mms::transport_message
epee::misc_utils::struct_init< transport_message_t > transport_message
Definition
message_transporter.h:81
util.h
uint32_t
unsigned int uint32_t
Definition
stdint.h:126
int32_t
signed int int32_t
Definition
stdint.h:123
uint64_t
unsigned __int64 uint64_t
Definition
stdint.h:136
cryptonote::account_public_address
Definition
cryptonote_basic.h:75
mms::message
Definition
message_store.h:99
mms::transport_message_t
Definition
message_transporter.h:46
mms::transport_message_t::source_etn_address
cryptonote::account_public_address source_etn_address
Definition
message_transporter.h:47
mms::transport_message_t::transport_id
std::string transport_id
Definition
message_transporter.h:61
mms::transport_message_t::hash
crypto::hash hash
Definition
message_transporter.h:57
mms::transport_message_t::content
std::string content
Definition
message_transporter.h:56
mms::transport_message_t::signature
crypto::signature signature
Definition
message_transporter.h:58
mms::transport_message_t::timestamp
uint64_t timestamp
Definition
message_transporter.h:53
mms::transport_message_t::destination_transport_address
std::string destination_transport_address
Definition
message_transporter.h:50
mms::transport_message_t::round
uint32_t round
Definition
message_transporter.h:59
mms::transport_message_t::signature_count
uint32_t signature_count
Definition
message_transporter.h:60
mms::transport_message_t::subject
std::string subject
Definition
message_transporter.h:55
mms::transport_message_t::iv
crypto::chacha_iv iv
Definition
message_transporter.h:51
mms::transport_message_t::source_transport_address
std::string source_transport_address
Definition
message_transporter.h:48
mms::transport_message_t::encryption_public_key
crypto::public_key encryption_public_key
Definition
message_transporter.h:52
mms::transport_message_t::type
uint32_t type
Definition
message_transporter.h:54
mms::transport_message_t::destination_etn_address
cryptonote::account_public_address destination_etn_address
Definition
message_transporter.h:49
wipeable_string.h
src
wallet
message_transporter.h
Generated on
for Electroneum by
1.17.0