36 #include "net/net_utils_base.h"
41 #ifdef CRYPTONOTE_PRUNING_DEBUG_SPOOF_SEED
51 template <
class T,
class Archive>
52 inline void do_serialize(boost::mpl::false_, Archive &
a, epee::net_utils::network_address& na)
59 template <
class T,
class Archive>
60 inline void do_serialize(boost::mpl::true_, Archive &
a,
const epee::net_utils::network_address& na)
65 template <
class Archive,
class ver_type>
66 inline void serialize(Archive &
a, epee::net_utils::network_address& na,
const ver_type ver)
68 static constexpr
const typename Archive::is_saving is_saving{};
72 type = uint8_t(na.get_type_id());
74 switch (epee::net_utils::address_type(type))
76 case epee::net_utils::ipv4_network_address::get_type_id():
77 do_serialize<epee::net_utils::ipv4_network_address>(is_saving,
a, na);
79 case epee::net_utils::ipv6_network_address::get_type_id():
80 do_serialize<epee::net_utils::ipv6_network_address>(is_saving,
a, na);
83 do_serialize<net::tor_address>(is_saving,
a, na);
86 do_serialize<net::i2p_address>(is_saving,
a, na);
88 case epee::net_utils::address_type::invalid:
90 throw std::runtime_error(
"Unsupported network address type");
93 template <
class Archive,
class ver_type>
94 inline void serialize(Archive &
a, epee::net_utils::ipv4_network_address& na,
const ver_type ver)
97 uint16_t port{na.port()};
102 if (!
typename Archive::is_saving())
103 na = epee::net_utils::ipv4_network_address{ip, port};
106 template <
class Archive,
class ver_type>
107 inline void serialize(Archive &
a, boost::asio::ip::address_v6& v6,
const ver_type ver)
109 if (
typename Archive::is_saving())
111 auto bytes = v6.to_bytes();
112 for (
auto &e: bytes)
a & e;
116 boost::asio::ip::address_v6::bytes_type bytes;
117 for (
auto &e: bytes)
a & e;
118 v6 = boost::asio::ip::address_v6(bytes);
122 template <
class Archive,
class ver_type>
123 inline void serialize(Archive &
a, epee::net_utils::ipv6_network_address& na,
const ver_type ver)
125 boost::asio::ip::address_v6 ip{na.ip()};
126 uint16_t port{na.port()};
129 if (!
typename Archive::is_saving())
130 na = epee::net_utils::ipv6_network_address{ip, port};
134 template <
class Archive,
class ver_type>
137 const size_t length = std::strlen(na.
host_str());
141 const uint16_t port{na.
port()};
142 const uint8_t len = length;
148 template <
class Archive,
class ver_type>
151 const size_t length = std::strlen(na.
host_str());
155 const uint16_t port{na.
port()};
156 const uint8_t len = length;
162 template <
class Archive,
class ver_type>
171 if (length > buffer_size)
174 char host[buffer_size] = {0};
175 a.load_binary(host, length);
176 host[
sizeof(host) - 1] = 0;
184 template <
class Archive,
class ver_type>
193 if (length > buffer_size)
196 char host[buffer_size] = {0};
197 a.load_binary(host, length);
198 host[
sizeof(host) - 1] = 0;
206 template <
class Archive,
class ver_type>
209 boost::serialization::split_free(
a, na, ver);
212 template <
class Archive,
class ver_type>
215 boost::serialization::split_free(
a, na, ver);
218 template <
class Archive,
class ver_type>
226 if (!
typename Archive::is_saving())
231 #ifdef CRYPTONOTE_PRUNING_DEBUG_SPOOF_SEED
232 if (!
typename Archive::is_saving())
239 if (!
typename Archive::is_saving())
246 if (!
typename Archive::is_saving())
253 template <
class Archive,
class ver_type>
b32 i2p address; internal format not condensed/decoded.
Definition: i2p_address.h:52
std::uint16_t port() const noexcept
Definition: i2p_address.h:107
static i2p_address unknown() noexcept
Definition: i2p_address.h:70
static constexpr epee::net_utils::address_type get_type_id() noexcept
Definition: i2p_address.h:112
static constexpr std::size_t buffer_size() noexcept
Definition: i2p_address.h:61
static expect< i2p_address > make(boost::string_ref address, std::uint16_t default_port=0)
Definition: i2p_address.cpp:107
const char * host_str() const noexcept
Definition: i2p_address.h:104
static const char * unknown_str() noexcept
Definition: i2p_address.cpp:94
Tor onion address; internal format not condensed/decoded.
Definition: tor_address.h:52
static expect< tor_address > make(boost::string_ref address, std::uint16_t default_port=0)
Definition: tor_address.cpp:108
static constexpr std::size_t buffer_size() noexcept
Definition: tor_address.h:61
static const char * unknown_str() noexcept
Definition: tor_address.cpp:95
static constexpr epee::net_utils::address_type get_type_id() noexcept
Definition: tor_address.h:112
std::uint16_t port() const noexcept
Definition: tor_address.h:107
static tor_address unknown() noexcept
Definition: tor_address.h:70
const char * host_str() const noexcept
Definition: tor_address.h:104
#define CRYPTONOTE_PRUNING_LOG_STRIPES
Definition: cryptonote_config.h:195
#define MONERO_THROW(code, msg)
Definition: expect.h:66
#define MONERO_UNWRAP(...)
Definition: expect.h:60
const uint32_t T[512]
Definition: groestl_tables.h:36
string a
Definition: MakeCryptoOps.py:15
void load(Archive &a, net::i2p_address &na, const ver_type)
Definition: net_peerlist_boost_serialization.h:185
void do_serialize(boost::mpl::true_, Archive &a, const epee::net_utils::network_address &na)
Definition: net_peerlist_boost_serialization.h:60
void save(Archive &a, const net::i2p_address &na, const ver_type)
Definition: net_peerlist_boost_serialization.h:149
Definition: unordered_containers_boost_serialization.h:38
@ invalid_tor_address
Invalid base32 or length.
Definition: binary_utils.h:36
bool serialize(Archive &ar, T &v)
Definition: serialization.h:382
BOOST_CLASS_VERSION(nodetool::peerlist_types, nodetool::CURRENT_PEERLIST_STORAGE_ARCHIVE_VER)
Definition: p2p_protocol_defs.h:102
int64_t first_seen
Definition: p2p_protocol_defs.h:105
AddressType adr
Definition: p2p_protocol_defs.h:103
peerid_type id
Definition: p2p_protocol_defs.h:104
Definition: p2p_protocol_defs.h:72
uint32_t pruning_seed
Definition: p2p_protocol_defs.h:76
AddressType adr
Definition: p2p_protocol_defs.h:73
uint16_t rpc_port
Definition: p2p_protocol_defs.h:77
peerid_type id
Definition: p2p_protocol_defs.h:74
int64_t last_seen
Definition: p2p_protocol_defs.h:75
uint32_t rpc_credits_per_hash
Definition: p2p_protocol_defs.h:78