37 #include "net/net_utils_base.h" 42 #ifdef CRYPTONOTE_PRUNING_DEBUG_SPOOF_SEED 52 template <
class T,
class Archive>
53 inline void do_serialize(boost::mpl::false_, Archive &
a, epee::net_utils::network_address& na)
60 template <
class T,
class Archive>
61 inline void do_serialize(boost::mpl::true_, Archive &
a,
const epee::net_utils::network_address& na)
66 template <
class Archive,
class ver_type>
67 inline void serialize(Archive &
a, epee::net_utils::network_address& na,
const ver_type ver)
69 static constexpr
const typename Archive::is_saving is_saving{};
73 type = uint8_t(na.get_type_id());
75 switch (epee::net_utils::address_type(type))
77 case epee::net_utils::ipv4_network_address::get_type_id():
78 do_serialize<epee::net_utils::ipv4_network_address>(is_saving,
a, na);
81 do_serialize<net::tor_address>(is_saving,
a, na);
84 do_serialize<net::i2p_address>(is_saving,
a, na);
86 case epee::net_utils::address_type::invalid:
88 throw std::runtime_error(
"Unsupported network address type");
91 template <
class Archive,
class ver_type>
92 inline void serialize(Archive &
a, epee::net_utils::ipv4_network_address& na,
const ver_type ver)
95 uint16_t port{na.port()};
98 if (!
typename Archive::is_saving())
99 na = epee::net_utils::ipv4_network_address{ip, port};
102 template <
class Archive,
class ver_type>
105 const size_t length = std::strlen(na.
host_str());
109 const uint16_t port{na.
port()};
110 const uint8_t len = length;
116 template <
class Archive,
class ver_type>
119 const size_t length = std::strlen(na.
host_str());
123 const uint16_t port{na.
port()};
124 const uint8_t len = length;
130 template <
class Archive,
class ver_type>
139 if (length > buffer_size)
142 char host[buffer_size] = {0};
143 a.load_binary(host, length);
144 host[
sizeof(host) - 1] = 0;
152 template <
class Archive,
class ver_type>
161 if (length > buffer_size)
164 char host[buffer_size] = {0};
165 a.load_binary(host, length);
166 host[
sizeof(host) - 1] = 0;
174 template <
class Archive,
class ver_type>
177 boost::serialization::split_free(
a, na, ver);
180 template <
class Archive,
class ver_type>
183 boost::serialization::split_free(
a, na, ver);
186 template <
class Archive,
class ver_type>
194 if (!
typename Archive::is_saving())
199 #ifdef CRYPTONOTE_PRUNING_DEBUG_SPOOF_SEED 200 if (!
typename Archive::is_saving())
207 if (!
typename Archive::is_saving())
214 template <
class Archive,
class ver_type>
Definition: binary_utils.h:37
int64_t last_seen
Definition: p2p_protocol_defs.h:78
static constexpr std::size_t buffer_size() noexcept
Definition: tor_address.h:61
const uint32_t T[512]
Definition: groestl_tables.h:37
Definition: unordered_containers_boost_serialization.h:38
b32 i2p address; internal format not condensed/decoded.
Definition: i2p_address.h:51
uint16_t rpc_port
Definition: p2p_protocol_defs.h:80
AddressType adr
Definition: p2p_protocol_defs.h:76
static const char * unknown_str() noexcept
Definition: tor_address.cpp:95
static const char * unknown_str() noexcept
Definition: i2p_address.cpp:94
#define CRYPTONOTE_PRUNING_LOG_STRIPES
Definition: cryptonote_config.h:184
static i2p_address unknown() noexcept
Definition: i2p_address.h:70
AddressType adr
Definition: p2p_protocol_defs.h:96
uint32_t pruning_seed
Definition: p2p_protocol_defs.h:79
static tor_address unknown() noexcept
Definition: tor_address.h:70
void save(Archive &a, const net::i2p_address &na, const ver_type)
Definition: net_peerlist_boost_serialization.h:117
int64_t first_seen
Definition: p2p_protocol_defs.h:98
const char * host_str() const noexcept
Definition: i2p_address.h:104
peerid_type id
Definition: p2p_protocol_defs.h:77
static constexpr std::size_t buffer_size() noexcept
Definition: i2p_address.h:61
bool serialize(Archive &ar, T &v)
Definition: serialization.h:360
peerid_type id
Definition: p2p_protocol_defs.h:97
Definition: p2p_protocol_defs.h:94
const char * host_str() const noexcept
Definition: tor_address.h:104
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
#define ELECTRONEUM_UNWRAP(...)
Definition: expect.h:60
Tor onion address; internal format not condensed/decoded.
Definition: tor_address.h:51
string a
Definition: MakeCryptoOps.py:15
Invalid base32 or length.
BOOST_CLASS_VERSION(nodetool::peerlist_types, nodetool::CURRENT_PEERLIST_STORAGE_ARCHIVE_VER)
static expect< i2p_address > make(boost::string_ref address, std::uint16_t default_port=0)
Definition: i2p_address.cpp:107
static constexpr epee::net_utils::address_type get_type_id() noexcept
Definition: i2p_address.h:112
#define ELECTRONEUM_THROW(code, msg)
Definition: expect.h:66
void do_serialize(boost::mpl::true_, Archive &a, const epee::net_utils::network_address &na)
Definition: net_peerlist_boost_serialization.h:61
static expect< tor_address > make(boost::string_ref address, std::uint16_t default_port=0)
Definition: tor_address.cpp:108
std::uint16_t port() const noexcept
Definition: i2p_address.h:107
Definition: p2p_protocol_defs.h:74
void load(Archive &a, net::i2p_address &na, const ver_type)
Definition: net_peerlist_boost_serialization.h:153