Monero
Loading...
Searching...
No Matches
net_utils_base.h
Go to the documentation of this file.
1// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are met:
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above copyright
9// notice, this list of conditions and the following disclaimer in the
10// documentation and/or other materials provided with the distribution.
11// * Neither the name of the Andrey N. Sabelnikov nor the
12// names of its contributors may be used to endorse or promote products
13// derived from this software without specific prior written permission.
14//
15// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER BE LIABLE FOR ANY
19// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25//
26
27
28
29#ifndef _NET_UTILS_BASE_H_
30#define _NET_UTILS_BASE_H_
31
32#include <boost/uuid/uuid.hpp>
33#include <boost/asio/io_context.hpp>
34#include <boost/asio/ip/address_v6.hpp>
35#include <cstddef>
36#include <typeinfo>
37#include <type_traits>
38#include "byte_slice.h"
39#include "enums.h"
40#include "misc_log_ex.h"
42#include "int-util.h"
43
44#undef MONERO_DEFAULT_LOG_CATEGORY
45#define MONERO_DEFAULT_LOG_CATEGORY "net"
46
47#ifndef MAKE_IP
48#define MAKE_IP( a1, a2, a3, a4 ) (a1|(a2<<8)|(a3<<16)|(((uint32_t)a4)<<24))
49#endif
50
51/* Use the below function carefully. The executor and io_context are slightly
52 different concepts. */
53#if BOOST_VERSION >= 107000
54 #define MONERO_GET_EXECUTOR(type) type . get_executor()
55#else
56 #define MONERO_GET_EXECUTOR(type) type . get_io_context()
57#endif
58
59namespace net
60{
61 class tor_address;
62 class i2p_address;
63}
64
65namespace epee
66{
67namespace net_utils
68{
70 {
73
74 public:
75 constexpr ipv4_network_address() noexcept
77 {}
78
80 : m_ip(ip), m_port(port) {}
81
82 bool equal(const ipv4_network_address& other) const noexcept;
83 bool less(const ipv4_network_address& other) const noexcept;
84 constexpr bool is_same_host(const ipv4_network_address& other) const noexcept
85 { return ip() == other.ip(); }
86
87 constexpr uint32_t ip() const noexcept { return m_ip; }
88 constexpr uint16_t port() const noexcept { return m_port; }
89 std::string str() const;
90 std::string host_str() const;
91 bool is_loopback() const;
92 bool is_local() const;
93 static constexpr address_type get_type_id() noexcept { return address_type::ipv4; }
94 static constexpr zone get_zone() noexcept { return zone::public_; }
95 static constexpr bool is_blockable() noexcept { return true; }
96
98 if (is_store)
99 {
100 uint32_t ip = SWAP32LE(this_ref.m_ip);
101 epee::serialization::selector<is_store>::serialize(ip, stg, hparent_section, "m_ip");
102 }
103 else
104 {
106 const_cast<ipv4_network_address&>(this_ref).m_ip = SWAP32LE(this_ref.m_ip);
107 }
110 };
111
112 inline bool operator==(const ipv4_network_address& lhs, const ipv4_network_address& rhs) noexcept
113 { return lhs.equal(rhs); }
114 inline bool operator!=(const ipv4_network_address& lhs, const ipv4_network_address& rhs) noexcept
115 { return !lhs.equal(rhs); }
116 inline bool operator<(const ipv4_network_address& lhs, const ipv4_network_address& rhs) noexcept
117 { return lhs.less(rhs); }
118 inline bool operator<=(const ipv4_network_address& lhs, const ipv4_network_address& rhs) noexcept
119 { return !rhs.less(lhs); }
120 inline bool operator>(const ipv4_network_address& lhs, const ipv4_network_address& rhs) noexcept
121 { return rhs.less(lhs); }
122 inline bool operator>=(const ipv4_network_address& lhs, const ipv4_network_address& rhs) noexcept
123 { return !lhs.less(rhs); }
124
126 {
129
130 public:
131 constexpr ipv4_network_subnet() noexcept
132 : ipv4_network_subnet(0, 0)
133 {}
134
135 constexpr ipv4_network_subnet(uint32_t ip, uint8_t mask) noexcept
136 : m_ip(ip), m_mask(mask) {}
137
138 bool equal(const ipv4_network_subnet& other) const noexcept;
139 bool less(const ipv4_network_subnet& other) const noexcept;
140 constexpr bool is_same_host(const ipv4_network_subnet& other) const noexcept
141 { return subnet() == other.subnet(); }
142 bool matches(const ipv4_network_address &address) const;
143
144 constexpr uint32_t subnet() const noexcept { return m_ip & ~(0xffffffffull << m_mask); }
145 std::string str() const;
146 std::string host_str() const;
147 bool is_loopback() const;
148 bool is_local() const;
149 static constexpr address_type get_type_id() noexcept { return address_type::invalid; }
150 static constexpr zone get_zone() noexcept { return zone::public_; }
151 static constexpr bool is_blockable() noexcept { return true; }
152
157 };
158
159 inline bool operator==(const ipv4_network_subnet& lhs, const ipv4_network_subnet& rhs) noexcept
160 { return lhs.equal(rhs); }
161 inline bool operator!=(const ipv4_network_subnet& lhs, const ipv4_network_subnet& rhs) noexcept
162 { return !lhs.equal(rhs); }
163 inline bool operator<(const ipv4_network_subnet& lhs, const ipv4_network_subnet& rhs) noexcept
164 { return lhs.less(rhs); }
165 inline bool operator<=(const ipv4_network_subnet& lhs, const ipv4_network_subnet& rhs) noexcept
166 { return !rhs.less(lhs); }
167 inline bool operator>(const ipv4_network_subnet& lhs, const ipv4_network_subnet& rhs) noexcept
168 { return rhs.less(lhs); }
169 inline bool operator>=(const ipv4_network_subnet& lhs, const ipv4_network_subnet& rhs) noexcept
170 { return !lhs.less(rhs); }
171
173 {
174 protected:
175 boost::asio::ip::address_v6 m_address;
177
178 public:
180 : ipv6_network_address(boost::asio::ip::address_v6::loopback(), 0)
181 {}
182
183 ipv6_network_address(const boost::asio::ip::address_v6& ip, uint16_t port)
185 {
186 }
187
188 bool equal(const ipv6_network_address& other) const noexcept;
189 bool less(const ipv6_network_address& other) const noexcept;
190 bool is_same_host(const ipv6_network_address& other) const noexcept
191 { return m_address == other.m_address; }
192
193 boost::asio::ip::address_v6 ip() const noexcept { return m_address; }
194 uint16_t port() const noexcept { return m_port; }
195 std::string str() const;
196 std::string host_str() const;
197 bool is_loopback() const;
198 bool is_local() const;
199 static constexpr address_type get_type_id() noexcept { return address_type::ipv6; }
200 static constexpr zone get_zone() noexcept { return zone::public_; }
201 static constexpr bool is_blockable() noexcept { return true; }
202
203 static const uint8_t ID = 2;
205 boost::asio::ip::address_v6::bytes_type bytes = this_ref.m_address.to_bytes();
206 epee::serialization::selector<is_store>::serialize_t_val_as_blob(bytes, stg, hparent_section, "addr");
207 const_cast<boost::asio::ip::address_v6&>(this_ref.m_address) = boost::asio::ip::address_v6(bytes);
210 };
211
212 bool should_group_ipv6_by_prefix(const boost::asio::ip::address_v6& ip);
213 boost::asio::ip::address_v6 get_ipv6_subnet_address(const boost::asio::ip::address_v6& ip, const std::size_t prefix_bits);
214
215 inline bool operator==(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
216 { return lhs.equal(rhs); }
217 inline bool operator!=(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
218 { return !lhs.equal(rhs); }
219 inline bool operator<(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
220 { return lhs.less(rhs); }
221 inline bool operator<=(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
222 { return !rhs.less(lhs); }
223 inline bool operator>(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
224 { return rhs.less(lhs); }
225 inline bool operator>=(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
226 { return !lhs.less(rhs); }
227
229 {
231 {
232 virtual ~interface() {};
233
234 virtual bool equal(const interface&) const = 0;
235 virtual bool less(const interface&) const = 0;
236 virtual bool is_same_host(const interface&) const = 0;
237
238 virtual std::string str() const = 0;
239 virtual std::string host_str() const = 0;
240 virtual bool is_loopback() const = 0;
241 virtual bool is_local() const = 0;
242 virtual address_type get_type_id() const = 0;
243 virtual zone get_zone() const = 0;
244 virtual bool is_blockable() const = 0;
245 virtual std::uint16_t port() const = 0;
246 };
247
248 template<typename T>
250 {
252
253 implementation(const T& src) : value(src) {}
254 ~implementation() = default;
255
256 // Type-checks for cast are done in cpp
257 static const T& cast(const interface& src) noexcept
258 { return static_cast<const implementation<T>&>(src).value; }
259
260 virtual bool equal(const interface& other) const override
261 { return value.equal(cast(other)); }
262
263 virtual bool less(const interface& other) const override
264 { return value.less(cast(other)); }
265
266 virtual bool is_same_host(const interface& other) const override
267 { return value.is_same_host(cast(other)); }
268
269 virtual std::string str() const override { return value.str(); }
270 virtual std::string host_str() const override { return value.host_str(); }
271 virtual bool is_loopback() const override { return value.is_loopback(); }
272 virtual bool is_local() const override { return value.is_local(); }
273 virtual address_type get_type_id() const override { return value.get_type_id(); }
274 virtual zone get_zone() const override { return value.get_zone(); }
275 virtual bool is_blockable() const override { return value.is_blockable(); }
276 virtual std::uint16_t port() const override { return value.port(); }
277 };
278
279 std::shared_ptr<interface> self;
280
281 template<typename Type>
283 {
284 // types `implmentation<Type>` and `implementation<const Type>` are unique
285 using Type_ = typename std::remove_const<Type>::type;
286 network_address::interface* const self_ = self.get(); // avoid clang warning in typeid
287 if (!self_ || typeid(implementation<Type_>) != typeid(*self_))
288 throw std::bad_cast{};
289 return static_cast<implementation<Type_>*>(self_)->value;
290 }
291
292 template<typename T, typename t_storage>
293 bool serialize_addr(std::false_type, t_storage& stg, typename t_storage::hsection hparent)
294 {
295 T addr{};
296 if (!epee::serialization::selector<false>::serialize(addr, stg, hparent, "addr"))
297 return false;
298 *this = std::move(addr);
299 return true;
300 }
301
302 template<typename T, typename t_storage>
303 bool serialize_addr(std::true_type, t_storage& stg, typename t_storage::hsection hparent) const
304 {
305 return epee::serialization::selector<true>::serialize(as<T>(), stg, hparent, "addr");
306 }
307
308 public:
309 network_address() : self(nullptr) {}
310 template<typename T>
311 network_address(const T& src)
312 : self(std::make_shared<implementation<T>>(src)) {}
313 bool equal(const network_address &other) const;
314 bool less(const network_address &other) const;
315 bool is_same_host(const network_address &other) const;
316 std::string str() const { return self ? self->str() : "<none>"; }
317 std::string host_str() const { return self ? self->host_str() : "<none>"; }
318 bool is_loopback() const { return self ? self->is_loopback() : false; }
319 bool is_local() const { return self ? self->is_local() : false; }
320 address_type get_type_id() const { return self ? self->get_type_id() : address_type::invalid; }
321 zone get_zone() const { return self ? self->get_zone() : zone::invalid; }
322 bool is_blockable() const { return self ? self->is_blockable() : false; }
323 std::uint16_t port() const { return self ? self->port() : 0; }
324 template<typename Type> const Type &as() const { return as_mutable<const Type>(); }
325
327 // need to `#include "net/[i2p|tor]_address.h"` when serializing `network_address`
328 static constexpr std::integral_constant<bool, is_store> is_store_{};
329
330 std::uint8_t type = std::uint8_t(is_store ? this_ref.get_type_id() : address_type::invalid);
331 if (!epee::serialization::selector<is_store>::serialize(type, stg, hparent_section, "type"))
332 return false;
333
335 {
337 return this_ref.template serialize_addr<ipv4_network_address>(is_store_, stg, hparent_section);
339 return this_ref.template serialize_addr<ipv6_network_address>(is_store_, stg, hparent_section);
341 return this_ref.template serialize_addr<net::tor_address>(is_store_, stg, hparent_section);
343 return this_ref.template serialize_addr<net::i2p_address>(is_store_, stg, hparent_section);
345 default:
346 break;
347 }
348
349 MERROR("Unsupported network address type: " << (unsigned)type);
350 return false;
352 };
353
354 inline bool operator==(const network_address& lhs, const network_address& rhs)
355 { return lhs.equal(rhs); }
356 inline bool operator!=(const network_address& lhs, const network_address& rhs)
357 { return !lhs.equal(rhs); }
358 inline bool operator<(const network_address& lhs, const network_address& rhs)
359 { return lhs.less(rhs); }
360 inline bool operator<=(const network_address& lhs, const network_address& rhs)
361 { return !rhs.less(lhs); }
362 inline bool operator>(const network_address& lhs, const network_address& rhs)
363 { return rhs.less(lhs); }
364 inline bool operator>=(const network_address& lhs, const network_address& rhs)
365 { return !lhs.less(rhs); }
366
367 /************************************************************************/
368 /* */
369 /************************************************************************/
371 {
372 const boost::uuids::uuid m_connection_id;
374 const bool m_is_income;
375 const time_t m_started;
376 const bool m_ssl;
385
386 connection_context_base(boost::uuids::uuid connection_id,
387 const network_address &remote_address, bool is_income, bool ssl,
388 time_t last_recv = 0, time_t last_send = 0,
389 uint64_t recv_cnt = 0, uint64_t send_cnt = 0):
390 m_connection_id(connection_id),
391 m_remote_address(remote_address),
392 m_is_income(is_income),
393 m_started(time(NULL)),
394 m_ssl(ssl),
395 m_last_recv(last_recv),
396 m_last_send(last_send),
397 m_recv_cnt(recv_cnt),
398 m_send_cnt(send_cnt),
403 {}
404
419
421 {
422 set_details(a.m_connection_id, a.m_remote_address, a.m_is_income, a.m_ssl);
423 }
424
426 {
427 set_details(a.m_connection_id, a.m_remote_address, a.m_is_income, a.m_ssl);
428 return *this;
429 }
430
431 private:
432 template<class t_protocol_handler>
433 friend class connection;
434 void set_details(boost::uuids::uuid connection_id, const network_address &remote_address, bool is_income, bool ssl)
435 {
437 new(this) connection_context_base(connection_id, remote_address, is_income, ssl);
438 }
439
440 };
441
442 /************************************************************************/
443 /* */
444 /************************************************************************/
446 {
447 virtual bool do_send(byte_slice message)=0;
448 virtual bool close(const bool wait_for_shutdown)=0;
449 virtual bool send_done()=0;
450 virtual bool call_run_once_service_io()=0;
451 virtual bool request_callback()=0;
452 virtual boost::asio::io_context& get_io_context()=0;
453 //protect from deletion connection object(with protocol instance) during external call "invoke"
454 virtual bool add_ref()=0;
455 virtual bool release()=0;
456 protected:
457 virtual ~i_service_endpoint() noexcept(false) {}
458 };
459
460
461 //some helpers
462
463
464 std::string print_connection_context(const connection_context_base& ctx);
465 std::string print_connection_context_short(const connection_context_base& ctx);
466
468{
470 return os;
471}
472
473#define LOG_ERROR_CC(ct, message) MERROR(ct << message)
474#define LOG_WARNING_CC(ct, message) MWARNING(ct << message)
475#define LOG_INFO_CC(ct, message) MINFO(ct << message)
476#define LOG_DEBUG_CC(ct, message) MDEBUG(ct << message)
477#define LOG_TRACE_CC(ct, message) MTRACE(ct << message)
478#define LOG_CC(level, ct, message) MLOG(level, ct << message)
479
480#define LOG_PRINT_CC_L0(ct, message) LOG_PRINT_L0(ct << message)
481#define LOG_PRINT_CC_L1(ct, message) LOG_PRINT_L1(ct << message)
482#define LOG_PRINT_CC_L2(ct, message) LOG_PRINT_L2(ct << message)
483#define LOG_PRINT_CC_L3(ct, message) LOG_PRINT_L3(ct << message)
484#define LOG_PRINT_CC_L4(ct, message) LOG_PRINT_L4(ct << message)
485
486#define LOG_PRINT_CCONTEXT_L0(message) LOG_PRINT_CC_L0(context, message)
487#define LOG_PRINT_CCONTEXT_L1(message) LOG_PRINT_CC_L1(context, message)
488#define LOG_PRINT_CCONTEXT_L2(message) LOG_PRINT_CC_L2(context, message)
489#define LOG_PRINT_CCONTEXT_L3(message) LOG_PRINT_CC_L3(context, message)
490#define LOG_ERROR_CCONTEXT(message) LOG_ERROR_CC(context, message)
491
492#define CHECK_AND_ASSERT_MES_CC(condition, return_val, err_message) CHECK_AND_ASSERT_MES(condition, return_val, "[" << epee::net_utils::print_connection_context_short(context) << "]" << err_message)
493
494}
495}
496
497#endif //_NET_UTILS_BASE_H_
Definition byte_slice.h:69
Definition net_utils_base.h:70
static constexpr zone get_zone() noexcept
Definition net_utils_base.h:94
bool is_loopback() const
Definition net_utils_base.cpp:34
constexpr bool is_same_host(const ipv4_network_address &other) const noexcept
Definition net_utils_base.h:84
bool less(const ipv4_network_address &other) const noexcept
Definition net_utils_base.cpp:27
static constexpr address_type get_type_id() noexcept
Definition net_utils_base.h:93
uint32_t m_ip
Definition net_utils_base.h:71
static constexpr bool is_blockable() noexcept
Definition net_utils_base.h:95
bool is_local() const
Definition net_utils_base.cpp:35
constexpr uint16_t port() const noexcept
Definition net_utils_base.h:88
uint16_t m_port
Definition net_utils_base.h:72
constexpr uint32_t ip() const noexcept
Definition net_utils_base.h:87
bool equal(const ipv4_network_address &other) const noexcept
Definition net_utils_base.cpp:24
if(is_store)
Definition net_utils_base.h:98
std::string host_str() const
Definition net_utils_base.cpp:33
constexpr ipv4_network_address(uint32_t ip, uint16_t port) noexcept
Definition net_utils_base.h:79
std::string str() const
Definition net_utils_base.cpp:30
constexpr ipv4_network_address() noexcept
Definition net_utils_base.h:75
Definition net_utils_base.h:126
bool is_loopback() const
Definition net_utils_base.cpp:89
constexpr ipv4_network_subnet() noexcept
Definition net_utils_base.h:131
bool equal(const ipv4_network_subnet &other) const noexcept
Definition net_utils_base.cpp:79
std::string str() const
Definition net_utils_base.cpp:85
constexpr ipv4_network_subnet(uint32_t ip, uint8_t mask) noexcept
Definition net_utils_base.h:135
static constexpr address_type get_type_id() noexcept
Definition net_utils_base.h:149
constexpr uint32_t subnet() const noexcept
Definition net_utils_base.h:144
static constexpr zone get_zone() noexcept
Definition net_utils_base.h:150
static constexpr bool is_blockable() noexcept
Definition net_utils_base.h:151
bool matches(const ipv4_network_address &address) const
Definition net_utils_base.cpp:91
bool is_local() const
Definition net_utils_base.cpp:90
uint8_t m_mask
Definition net_utils_base.h:128
uint32_t m_ip
Definition net_utils_base.h:127
std::string host_str() const
Definition net_utils_base.cpp:88
bool less(const ipv4_network_subnet &other) const noexcept
Definition net_utils_base.cpp:82
constexpr bool is_same_host(const ipv4_network_subnet &other) const noexcept
Definition net_utils_base.h:140
Definition net_utils_base.h:173
static constexpr zone get_zone() noexcept
Definition net_utils_base.h:200
static constexpr address_type get_type_id() noexcept
Definition net_utils_base.h:199
ipv6_network_address(const boost::asio::ip::address_v6 &ip, uint16_t port)
Definition net_utils_base.h:183
boost::asio::ip::address_v6 m_address
Definition net_utils_base.h:175
uint16_t m_port
Definition net_utils_base.h:176
boost::asio::ip::address_v6::bytes_type bytes
Definition net_utils_base.h:205
ipv6_network_address()
Definition net_utils_base.h:179
bool is_same_host(const ipv6_network_address &other) const noexcept
Definition net_utils_base.h:190
uint16_t port() const noexcept
Definition net_utils_base.h:194
static constexpr bool is_blockable() noexcept
Definition net_utils_base.h:201
epee::serialization::selector(bytes, stg, hparent_section, "addr")
static const uint8_t ID
Definition net_utils_base.h:203
boost::asio::ip::address_v6 ip() const noexcept
Definition net_utils_base.h:193
Definition net_utils_base.h:229
bool is_loopback() const
Definition net_utils_base.h:318
bool equal(const network_address &other) const
Definition net_utils_base.cpp:97
std::shared_ptr< interface > self
Definition net_utils_base.h:279
std::uint8_t type
Definition net_utils_base.h:330
std::string str() const
Definition net_utils_base.h:316
MERROR("Unsupported network address type: "<<(unsigned) type)
network_address(const T &src)
Definition net_utils_base.h:311
address_type get_type_id() const
Definition net_utils_base.h:320
bool less(const network_address &other) const
Definition net_utils_base.cpp:108
bool serialize_addr(std::true_type, t_storage &stg, typename t_storage::hsection hparent) const
Definition net_utils_base.h:303
network_address()
Definition net_utils_base.h:309
bool serialize_addr(std::false_type, t_storage &stg, typename t_storage::hsection hparent)
Definition net_utils_base.h:293
Type & as_mutable() const
Definition net_utils_base.h:282
static constexpr std::integral_constant< bool, is_store > is_store_
Definition net_utils_base.h:328
std::uint16_t port() const
Definition net_utils_base.h:323
bool is_local() const
Definition net_utils_base.h:319
std::string host_str() const
Definition net_utils_base.h:317
zone get_zone() const
Definition net_utils_base.h:321
bool is_blockable() const
Definition net_utils_base.h:322
const Type & as() const
Definition net_utils_base.h:324
b32 i2p address; internal format not condensed/decoded.
Definition i2p_address.h:52
Tor onion address; internal format not condensed/decoded.
Definition tor_address.h:53
#define false
#define inline
Definition inline_c.h:34
#define SWAP32LE
Definition int-util.h:277
#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
Definition portable_binary_archive.hpp:29
bool should_group_ipv6_by_prefix(const boost::asio::ip::address_v6 &ip)
Definition net_utils_base.cpp:56
bool operator<=(const ipv4_network_address &lhs, const ipv4_network_address &rhs) noexcept
Definition net_utils_base.h:118
bool operator==(const ipv4_network_address &lhs, const ipv4_network_address &rhs) noexcept
Definition net_utils_base.h:112
address_type
Definition enums.h:40
@ ipv4
Definition enums.h:43
@ i2p
Definition enums.h:45
@ tor
Definition enums.h:46
@ ipv6
Definition enums.h:44
@ invalid
Definition enums.h:42
zone
Definition enums.h:50
@ public_
Definition enums.h:52
@ invalid
Definition enums.h:51
std::string print_connection_context_short(const connection_context_base &ctx)
Definition net_utils_base.cpp:158
boost::asio::ip::address_v6 get_ipv6_subnet_address(const boost::asio::ip::address_v6 &ip, const std::size_t prefix_bits)
Definition net_utils_base.cpp:63
bool operator!=(const ipv4_network_address &lhs, const ipv4_network_address &rhs) noexcept
Definition net_utils_base.h:114
bool operator>=(const ipv4_network_address &lhs, const ipv4_network_address &rhs) noexcept
Definition net_utils_base.h:122
MAKE_LOGGABLE(connection_context_base, ct, os)
Definition net_utils_base.h:467
bool operator>(const ipv4_network_address &lhs, const ipv4_network_address &rhs) noexcept
Definition net_utils_base.h:120
bool operator<(const ipv4_network_address &lhs, const ipv4_network_address &rhs) noexcept
Definition net_utils_base.h:116
TODO: (mj-xmr) This will be reduced in an another PR.
Definition byte_slice.h:40
Definition net_utils_base.h:60
Definition binary_utils.h:36
Definition enums.h:68
const GenericPointer< typename T::ValueType > T2 value
Definition pointer.h:1225
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1124
Type
Type of JSON value.
Definition rapidjson.h:623
unsigned short uint16_t
Definition stdint.h:125
unsigned int uint32_t
Definition stdint.h:126
unsigned char uint8_t
Definition stdint.h:124
unsigned __int64 uint64_t
Definition stdint.h:136
Definition net_utils_base.h:371
void set_details(boost::uuids::uuid connection_id, const network_address &remote_address, bool is_income, bool ssl)
Definition net_utils_base.h:434
time_t m_last_send
Definition net_utils_base.h:378
connection_context_base(boost::uuids::uuid connection_id, const network_address &remote_address, bool is_income, bool ssl, time_t last_recv=0, time_t last_send=0, uint64_t recv_cnt=0, uint64_t send_cnt=0)
Definition net_utils_base.h:386
time_t m_last_recv
Definition net_utils_base.h:377
connection_context_base()
Definition net_utils_base.h:405
double m_max_speed_down
Definition net_utils_base.h:383
uint64_t m_send_cnt
Definition net_utils_base.h:380
connection_context_base(const connection_context_base &a)
Definition net_utils_base.h:420
const bool m_is_income
Definition net_utils_base.h:374
const bool m_ssl
Definition net_utils_base.h:376
friend class connection
Definition net_utils_base.h:433
double m_max_speed_up
Definition net_utils_base.h:384
connection_context_base & operator=(const connection_context_base &a)
Definition net_utils_base.h:425
const boost::uuids::uuid m_connection_id
Definition net_utils_base.h:372
const time_t m_started
Definition net_utils_base.h:375
const network_address m_remote_address
Definition net_utils_base.h:373
double m_current_speed_down
Definition net_utils_base.h:381
double m_current_speed_up
Definition net_utils_base.h:382
uint64_t m_recv_cnt
Definition net_utils_base.h:379
Definition net_utils_base.h:446
virtual ~i_service_endpoint() noexcept(false)
Definition net_utils_base.h:457
virtual bool call_run_once_service_io()=0
virtual bool close(const bool wait_for_shutdown)=0
virtual boost::asio::io_context & get_io_context()=0
virtual bool do_send(byte_slice message)=0
virtual std::uint16_t port() const override
Definition net_utils_base.h:276
virtual bool less(const interface &other) const override
Definition net_utils_base.h:263
virtual bool is_same_host(const interface &other) const override
Definition net_utils_base.h:266
T value
Definition net_utils_base.h:251
virtual std::string host_str() const override
Definition net_utils_base.h:270
virtual address_type get_type_id() const override
Definition net_utils_base.h:273
virtual std::string str() const override
Definition net_utils_base.h:269
virtual bool is_blockable() const override
Definition net_utils_base.h:275
virtual bool equal(const interface &other) const override
Definition net_utils_base.h:260
virtual bool is_local() const override
Definition net_utils_base.h:272
virtual bool is_loopback() const override
Definition net_utils_base.h:271
virtual zone get_zone() const override
Definition net_utils_base.h:274
static const T & cast(const interface &src) noexcept
Definition net_utils_base.h:257
implementation(const T &src)
Definition net_utils_base.h:253
Definition net_utils_base.h:231
virtual std::string host_str() const =0
virtual std::string str() const =0
virtual address_type get_type_id() const =0
virtual bool less(const interface &) const =0
virtual bool equal(const interface &) const =0
virtual bool is_same_host(const interface &) const =0
virtual ~interface()
Definition net_utils_base.h:232
virtual std::uint16_t port() const =0
Definition keyvalue_serialization_overloads.h:324
#define T(x)