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_service.hpp>
34#include <boost/asio/ip/address_v6.hpp>
35#include <typeinfo>
36#include <type_traits>
37#include "byte_slice.h"
38#include "enums.h"
39#include "misc_log_ex.h"
41#include "int-util.h"
42
43#undef MONERO_DEFAULT_LOG_CATEGORY
44#define MONERO_DEFAULT_LOG_CATEGORY "net"
45
46#ifndef MAKE_IP
47#define MAKE_IP( a1, a2, a3, a4 ) (a1|(a2<<8)|(a3<<16)|(((uint32_t)a4)<<24))
48#endif
49
50#if BOOST_VERSION >= 107000
51#define GET_IO_SERVICE(s) ((boost::asio::io_context&)(s).get_executor().context())
52#else
53#define GET_IO_SERVICE(s) ((s).get_io_service())
54#endif
55
56namespace net
57{
58 class tor_address;
59 class i2p_address;
60}
61
62namespace epee
63{
64namespace net_utils
65{
67 {
70
71 public:
72 constexpr ipv4_network_address() noexcept
74 {}
75
77 : m_ip(ip), m_port(port) {}
78
79 bool equal(const ipv4_network_address& other) const noexcept;
80 bool less(const ipv4_network_address& other) const noexcept;
81 constexpr bool is_same_host(const ipv4_network_address& other) const noexcept
82 { return ip() == other.ip(); }
83
84 constexpr uint32_t ip() const noexcept { return m_ip; }
85 constexpr uint16_t port() const noexcept { return m_port; }
86 std::string str() const;
87 std::string host_str() const;
88 bool is_loopback() const;
89 bool is_local() const;
90 static constexpr address_type get_type_id() noexcept { return address_type::ipv4; }
91 static constexpr zone get_zone() noexcept { return zone::public_; }
92 static constexpr bool is_blockable() noexcept { return true; }
93
95 if (is_store)
96 {
97 uint32_t ip = SWAP32LE(this_ref.m_ip);
98 epee::serialization::selector<is_store>::serialize(ip, stg, hparent_section, "m_ip");
99 }
100 else
101 {
103 const_cast<ipv4_network_address&>(this_ref).m_ip = SWAP32LE(this_ref.m_ip);
104 }
107 };
108
109 inline bool operator==(const ipv4_network_address& lhs, const ipv4_network_address& rhs) noexcept
110 { return lhs.equal(rhs); }
111 inline bool operator!=(const ipv4_network_address& lhs, const ipv4_network_address& rhs) noexcept
112 { return !lhs.equal(rhs); }
113 inline bool operator<(const ipv4_network_address& lhs, const ipv4_network_address& rhs) noexcept
114 { return lhs.less(rhs); }
115 inline bool operator<=(const ipv4_network_address& lhs, const ipv4_network_address& rhs) noexcept
116 { return !rhs.less(lhs); }
117 inline bool operator>(const ipv4_network_address& lhs, const ipv4_network_address& rhs) noexcept
118 { return rhs.less(lhs); }
119 inline bool operator>=(const ipv4_network_address& lhs, const ipv4_network_address& rhs) noexcept
120 { return !lhs.less(rhs); }
121
123 {
126
127 public:
128 constexpr ipv4_network_subnet() noexcept
129 : ipv4_network_subnet(0, 0)
130 {}
131
132 constexpr ipv4_network_subnet(uint32_t ip, uint8_t mask) noexcept
133 : m_ip(ip), m_mask(mask) {}
134
135 bool equal(const ipv4_network_subnet& other) const noexcept;
136 bool less(const ipv4_network_subnet& other) const noexcept;
137 constexpr bool is_same_host(const ipv4_network_subnet& other) const noexcept
138 { return subnet() == other.subnet(); }
139 bool matches(const ipv4_network_address &address) const;
140
141 constexpr uint32_t subnet() const noexcept { return m_ip & ~(0xffffffffull << m_mask); }
142 std::string str() const;
143 std::string host_str() const;
144 bool is_loopback() const;
145 bool is_local() const;
146 static constexpr address_type get_type_id() noexcept { return address_type::invalid; }
147 static constexpr zone get_zone() noexcept { return zone::public_; }
148 static constexpr bool is_blockable() noexcept { return true; }
149
154 };
155
156 inline bool operator==(const ipv4_network_subnet& lhs, const ipv4_network_subnet& rhs) noexcept
157 { return lhs.equal(rhs); }
158 inline bool operator!=(const ipv4_network_subnet& lhs, const ipv4_network_subnet& rhs) noexcept
159 { return !lhs.equal(rhs); }
160 inline bool operator<(const ipv4_network_subnet& lhs, const ipv4_network_subnet& rhs) noexcept
161 { return lhs.less(rhs); }
162 inline bool operator<=(const ipv4_network_subnet& lhs, const ipv4_network_subnet& rhs) noexcept
163 { return !rhs.less(lhs); }
164 inline bool operator>(const ipv4_network_subnet& lhs, const ipv4_network_subnet& rhs) noexcept
165 { return rhs.less(lhs); }
166 inline bool operator>=(const ipv4_network_subnet& lhs, const ipv4_network_subnet& rhs) noexcept
167 { return !lhs.less(rhs); }
168
170 {
171 protected:
172 boost::asio::ip::address_v6 m_address;
174
175 public:
177 : ipv6_network_address(boost::asio::ip::address_v6::loopback(), 0)
178 {}
179
180 ipv6_network_address(const boost::asio::ip::address_v6& ip, uint16_t port)
181 : m_address(ip), m_port(port)
182 {
183 }
184
185 bool equal(const ipv6_network_address& other) const noexcept;
186 bool less(const ipv6_network_address& other) const noexcept;
187 bool is_same_host(const ipv6_network_address& other) const noexcept
188 { return m_address == other.m_address; }
189
190 boost::asio::ip::address_v6 ip() const noexcept { return m_address; }
191 uint16_t port() const noexcept { return m_port; }
192 std::string str() const;
193 std::string host_str() const;
194 bool is_loopback() const;
195 bool is_local() const;
196 static constexpr address_type get_type_id() noexcept { return address_type::ipv6; }
197 static constexpr zone get_zone() noexcept { return zone::public_; }
198 static constexpr bool is_blockable() noexcept { return true; }
199
200 static const uint8_t ID = 2;
202 boost::asio::ip::address_v6::bytes_type bytes = this_ref.m_address.to_bytes();
203 epee::serialization::selector<is_store>::serialize_t_val_as_blob(bytes, stg, hparent_section, "addr");
204 const_cast<boost::asio::ip::address_v6&>(this_ref.m_address) = boost::asio::ip::address_v6(bytes);
205 KV_SERIALIZE(m_port)
207 };
208
209 inline bool operator==(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
210 { return lhs.equal(rhs); }
211 inline bool operator!=(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
212 { return !lhs.equal(rhs); }
213 inline bool operator<(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
214 { return lhs.less(rhs); }
215 inline bool operator<=(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
216 { return !rhs.less(lhs); }
217 inline bool operator>(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
218 { return rhs.less(lhs); }
219 inline bool operator>=(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
220 { return !lhs.less(rhs); }
221
223 {
225 {
226 virtual ~interface() {};
227
228 virtual bool equal(const interface&) const = 0;
229 virtual bool less(const interface&) const = 0;
230 virtual bool is_same_host(const interface&) const = 0;
231
232 virtual std::string str() const = 0;
233 virtual std::string host_str() const = 0;
234 virtual bool is_loopback() const = 0;
235 virtual bool is_local() const = 0;
236 virtual address_type get_type_id() const = 0;
237 virtual zone get_zone() const = 0;
238 virtual bool is_blockable() const = 0;
239 virtual std::uint16_t port() const = 0;
240 };
241
242 template<typename T>
244 {
246
247 implementation(const T& src) : value(src) {}
248 ~implementation() = default;
249
250 // Type-checks for cast are done in cpp
251 static const T& cast(const interface& src) noexcept
252 { return static_cast<const implementation<T>&>(src).value; }
253
254 virtual bool equal(const interface& other) const override
255 { return value.equal(cast(other)); }
256
257 virtual bool less(const interface& other) const override
258 { return value.less(cast(other)); }
259
260 virtual bool is_same_host(const interface& other) const override
261 { return value.is_same_host(cast(other)); }
262
263 virtual std::string str() const override { return value.str(); }
264 virtual std::string host_str() const override { return value.host_str(); }
265 virtual bool is_loopback() const override { return value.is_loopback(); }
266 virtual bool is_local() const override { return value.is_local(); }
267 virtual address_type get_type_id() const override { return value.get_type_id(); }
268 virtual zone get_zone() const override { return value.get_zone(); }
269 virtual bool is_blockable() const override { return value.is_blockable(); }
270 virtual std::uint16_t port() const override { return value.port(); }
271 };
272
273 std::shared_ptr<interface> self;
274
275 template<typename Type>
277 {
278 // types `implmentation<Type>` and `implementation<const Type>` are unique
279 using Type_ = typename std::remove_const<Type>::type;
280 network_address::interface* const self_ = self.get(); // avoid clang warning in typeid
281 if (!self_ || typeid(implementation<Type_>) != typeid(*self_))
282 throw std::bad_cast{};
283 return static_cast<implementation<Type_>*>(self_)->value;
284 }
285
286 template<typename T, typename t_storage>
287 bool serialize_addr(std::false_type, t_storage& stg, typename t_storage::hsection hparent)
288 {
289 T addr{};
290 if (!epee::serialization::selector<false>::serialize(addr, stg, hparent, "addr"))
291 return false;
292 *this = std::move(addr);
293 return true;
294 }
295
296 template<typename T, typename t_storage>
297 bool serialize_addr(std::true_type, t_storage& stg, typename t_storage::hsection hparent) const
298 {
299 return epee::serialization::selector<true>::serialize(as<T>(), stg, hparent, "addr");
300 }
301
302 public:
303 network_address() : self(nullptr) {}
304 template<typename T>
305 network_address(const T& src)
306 : self(std::make_shared<implementation<T>>(src)) {}
307 bool equal(const network_address &other) const;
308 bool less(const network_address &other) const;
309 bool is_same_host(const network_address &other) const;
310 std::string str() const { return self ? self->str() : "<none>"; }
311 std::string host_str() const { return self ? self->host_str() : "<none>"; }
312 bool is_loopback() const { return self ? self->is_loopback() : false; }
313 bool is_local() const { return self ? self->is_local() : false; }
314 address_type get_type_id() const { return self ? self->get_type_id() : address_type::invalid; }
315 zone get_zone() const { return self ? self->get_zone() : zone::invalid; }
316 bool is_blockable() const { return self ? self->is_blockable() : false; }
317 std::uint16_t port() const { return self ? self->port() : 0; }
318 template<typename Type> const Type &as() const { return as_mutable<const Type>(); }
319
321 // need to `#include "net/[i2p|tor]_address.h"` when serializing `network_address`
322 static constexpr std::integral_constant<bool, is_store> is_store_{};
323
324 std::uint8_t type = std::uint8_t(is_store ? this_ref.get_type_id() : address_type::invalid);
325 if (!epee::serialization::selector<is_store>::serialize(type, stg, hparent_section, "type"))
326 return false;
327
328 switch (address_type(type))
329 {
330 case address_type::ipv4:
331 return this_ref.template serialize_addr<ipv4_network_address>(is_store_, stg, hparent_section);
332 case address_type::ipv6:
333 return this_ref.template serialize_addr<ipv6_network_address>(is_store_, stg, hparent_section);
334 case address_type::tor:
335 return this_ref.template serialize_addr<net::tor_address>(is_store_, stg, hparent_section);
336 case address_type::i2p:
337 return this_ref.template serialize_addr<net::i2p_address>(is_store_, stg, hparent_section);
338 case address_type::invalid:
339 default:
340 break;
341 }
342
343 MERROR("Unsupported network address type: " << (unsigned)type);
344 return false;
346 };
347
348 inline bool operator==(const network_address& lhs, const network_address& rhs)
349 { return lhs.equal(rhs); }
350 inline bool operator!=(const network_address& lhs, const network_address& rhs)
351 { return !lhs.equal(rhs); }
352 inline bool operator<(const network_address& lhs, const network_address& rhs)
353 { return lhs.less(rhs); }
354 inline bool operator<=(const network_address& lhs, const network_address& rhs)
355 { return !rhs.less(lhs); }
356 inline bool operator>(const network_address& lhs, const network_address& rhs)
357 { return rhs.less(lhs); }
358 inline bool operator>=(const network_address& lhs, const network_address& rhs)
359 { return !lhs.less(rhs); }
360
361 /************************************************************************/
362 /* */
363 /************************************************************************/
365 {
366 const boost::uuids::uuid m_connection_id;
368 const bool m_is_income;
369 const time_t m_started;
370 const bool m_ssl;
379
380 connection_context_base(boost::uuids::uuid connection_id,
381 const network_address &remote_address, bool is_income, bool ssl,
382 time_t last_recv = 0, time_t last_send = 0,
383 uint64_t recv_cnt = 0, uint64_t send_cnt = 0):
384 m_connection_id(connection_id),
385 m_remote_address(remote_address),
386 m_is_income(is_income),
387 m_started(time(NULL)),
388 m_ssl(ssl),
389 m_last_recv(last_recv),
390 m_last_send(last_send),
391 m_recv_cnt(recv_cnt),
392 m_send_cnt(send_cnt),
393 m_current_speed_down(0),
394 m_current_speed_up(0),
395 m_max_speed_down(0),
396 m_max_speed_up(0)
397 {}
398
399 connection_context_base(): m_connection_id(),
400 m_remote_address(),
401 m_is_income(false),
402 m_started(time(NULL)),
403 m_ssl(false),
404 m_last_recv(0),
405 m_last_send(0),
406 m_recv_cnt(0),
407 m_send_cnt(0),
408 m_current_speed_down(0),
409 m_current_speed_up(0),
410 m_max_speed_down(0),
411 m_max_speed_up(0)
412 {}
413
415 {
416 set_details(a.m_connection_id, a.m_remote_address, a.m_is_income, a.m_ssl);
417 }
418
420 {
421 set_details(a.m_connection_id, a.m_remote_address, a.m_is_income, a.m_ssl);
422 return *this;
423 }
424
425 private:
426 template<class t_protocol_handler>
427 friend class connection;
428 void set_details(boost::uuids::uuid connection_id, const network_address &remote_address, bool is_income, bool ssl)
429 {
431 new(this) connection_context_base(connection_id, remote_address, is_income, ssl);
432 }
433
434 };
435
436 /************************************************************************/
437 /* */
438 /************************************************************************/
440 {
441 virtual bool do_send(byte_slice message)=0;
442 virtual bool close()=0;
443 virtual bool send_done()=0;
444 virtual bool call_run_once_service_io()=0;
445 virtual bool request_callback()=0;
446 virtual boost::asio::io_service& get_io_service()=0;
447 //protect from deletion connection object(with protocol instance) during external call "invoke"
448 virtual bool add_ref()=0;
449 virtual bool release()=0;
450 protected:
451 virtual ~i_service_endpoint() noexcept(false) {}
452 };
453
454
455 //some helpers
456
457
458 std::string print_connection_context(const connection_context_base& ctx);
459 std::string print_connection_context_short(const connection_context_base& ctx);
460
462{
464 return os;
465}
466
467#define LOG_ERROR_CC(ct, message) MERROR(ct << message)
468#define LOG_WARNING_CC(ct, message) MWARNING(ct << message)
469#define LOG_INFO_CC(ct, message) MINFO(ct << message)
470#define LOG_DEBUG_CC(ct, message) MDEBUG(ct << message)
471#define LOG_TRACE_CC(ct, message) MTRACE(ct << message)
472#define LOG_CC(level, ct, message) MLOG(level, ct << message)
473
474#define LOG_PRINT_CC_L0(ct, message) LOG_PRINT_L0(ct << message)
475#define LOG_PRINT_CC_L1(ct, message) LOG_PRINT_L1(ct << message)
476#define LOG_PRINT_CC_L2(ct, message) LOG_PRINT_L2(ct << message)
477#define LOG_PRINT_CC_L3(ct, message) LOG_PRINT_L3(ct << message)
478#define LOG_PRINT_CC_L4(ct, message) LOG_PRINT_L4(ct << message)
479
480#define LOG_PRINT_CCONTEXT_L0(message) LOG_PRINT_CC_L0(context, message)
481#define LOG_PRINT_CCONTEXT_L1(message) LOG_PRINT_CC_L1(context, message)
482#define LOG_PRINT_CCONTEXT_L2(message) LOG_PRINT_CC_L2(context, message)
483#define LOG_PRINT_CCONTEXT_L3(message) LOG_PRINT_CC_L3(context, message)
484#define LOG_ERROR_CCONTEXT(message) LOG_ERROR_CC(context, message)
485
486#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)
487
488}
489}
490
491#endif //_NET_UTILS_BASE_H_
Definition: byte_slice.h:69
Represents a single connection from a client.
Definition: abstract_tcp_server2.h:91
Definition: net_utils_base.h:67
static constexpr zone get_zone() noexcept
Definition: net_utils_base.h:91
bool is_loopback() const
Definition: net_utils_base.cpp:32
constexpr bool is_same_host(const ipv4_network_address &other) const noexcept
Definition: net_utils_base.h:81
static constexpr address_type get_type_id() noexcept
Definition: net_utils_base.h:90
uint32_t m_ip
Definition: net_utils_base.h:68
static constexpr bool is_blockable() noexcept
Definition: net_utils_base.h:92
bool is_local() const
Definition: net_utils_base.cpp:33
constexpr uint16_t port() const noexcept
Definition: net_utils_base.h:85
uint16_t m_port
Definition: net_utils_base.h:69
constexpr uint32_t ip() const noexcept
Definition: net_utils_base.h:84
bool equal(const ipv4_network_address &other) const noexcept
Definition: net_utils_base.cpp:22
if(is_store)
Definition: net_utils_base.h:95
std::string host_str() const
Definition: net_utils_base.cpp:31
constexpr ipv4_network_address(uint32_t ip, uint16_t port) noexcept
Definition: net_utils_base.h:76
std::string str() const
Definition: net_utils_base.cpp:28
constexpr ipv4_network_address() noexcept
Definition: net_utils_base.h:72
Definition: net_utils_base.h:123
bool is_loopback() const
Definition: net_utils_base.cpp:59
constexpr ipv4_network_subnet() noexcept
Definition: net_utils_base.h:128
bool equal(const ipv4_network_subnet &other) const noexcept
Definition: net_utils_base.cpp:49
std::string str() const
Definition: net_utils_base.cpp:55
constexpr ipv4_network_subnet(uint32_t ip, uint8_t mask) noexcept
Definition: net_utils_base.h:132
static constexpr address_type get_type_id() noexcept
Definition: net_utils_base.h:146
constexpr uint32_t subnet() const noexcept
Definition: net_utils_base.h:141
static constexpr zone get_zone() noexcept
Definition: net_utils_base.h:147
static constexpr bool is_blockable() noexcept
Definition: net_utils_base.h:148
bool matches(const ipv4_network_address &address) const
Definition: net_utils_base.cpp:61
bool is_local() const
Definition: net_utils_base.cpp:60
uint8_t m_mask
Definition: net_utils_base.h:125
uint32_t m_ip
Definition: net_utils_base.h:124
std::string host_str() const
Definition: net_utils_base.cpp:58
constexpr bool is_same_host(const ipv4_network_subnet &other) const noexcept
Definition: net_utils_base.h:137
Definition: net_utils_base.h:170
static constexpr zone get_zone() noexcept
Definition: net_utils_base.h:197
static constexpr address_type get_type_id() noexcept
Definition: net_utils_base.h:196
ipv6_network_address(const boost::asio::ip::address_v6 &ip, uint16_t port)
Definition: net_utils_base.h:180
boost::asio::ip::address_v6 m_address
Definition: net_utils_base.h:172
uint16_t m_port
Definition: net_utils_base.h:173
ipv6_network_address()
Definition: net_utils_base.h:176
bool is_same_host(const ipv6_network_address &other) const noexcept
Definition: net_utils_base.h:187
uint16_t port() const noexcept
Definition: net_utils_base.h:191
static constexpr bool is_blockable() noexcept
Definition: net_utils_base.h:198
boost::asio::ip::address_v6 ip() const noexcept
Definition: net_utils_base.h:190
Definition: net_utils_base.h:223
bool is_loopback() const
Definition: net_utils_base.h:312
bool equal(const network_address &other) const
Definition: net_utils_base.cpp:67
std::shared_ptr< interface > self
Definition: net_utils_base.h:273
std::string str() const
Definition: net_utils_base.h:310
MERROR("Unsupported network address type: "<<(unsigned) type)
network_address(const T &src)
Definition: net_utils_base.h:305
address_type get_type_id() const
Definition: net_utils_base.h:314
bool less(const network_address &other) const
Definition: net_utils_base.cpp:78
bool serialize_addr(std::true_type, t_storage &stg, typename t_storage::hsection hparent) const
Definition: net_utils_base.h:297
network_address()
Definition: net_utils_base.h:303
bool serialize_addr(std::false_type, t_storage &stg, typename t_storage::hsection hparent)
Definition: net_utils_base.h:287
Type & as_mutable() const
Definition: net_utils_base.h:276
std::uint16_t port() const
Definition: net_utils_base.h:317
bool is_local() const
Definition: net_utils_base.h:313
std::string host_str() const
Definition: net_utils_base.h:311
zone get_zone() const
Definition: net_utils_base.h:315
bool is_blockable() const
Definition: net_utils_base.h:316
const Type & as() const
Definition: net_utils_base.h:318
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 MAKE_LOGGABLE(ClassType, ClassInstance, OutputStreamInstance)
Definition: easylogging++.h:3712
static bool is_local(const char *s)
Definition: epee_utils.cpp:1634
bool operator!=(expect< T > const &lhs, expect< U > const &rhs) noexcept(noexcept(lhs.equal(rhs)))
Definition: expect.h:423
bool operator==(expect< T > const &lhs, expect< U > const &rhs) noexcept(noexcept(lhs.equal(rhs)))
Definition: expect.h:402
#define inline
Definition: inline_c.h:34
#define SWAP32LE
Definition: int-util.h:305
#define const
Definition: ipfrdr.c:80
#define KV_SERIALIZE(varialble)
Definition: keyvalue_serialization.h:118
#define END_KV_SERIALIZE_MAP()
Definition: keyvalue_serialization.h:116
#define BEGIN_KV_SERIALIZE_MAP()
Definition: keyvalue_serialization.h:43
uint32_t address
Definition: getifaddr.c:269
Definition: portable_binary_archive.hpp:29
bool operator<=(const ipv4_network_address &lhs, const ipv4_network_address &rhs) noexcept
Definition: net_utils_base.h:115
bool operator==(const ipv4_network_address &lhs, const ipv4_network_address &rhs) noexcept
Definition: net_utils_base.h:109
address_type
Definition: enums.h:40
zone
Definition: enums.h:50
std::string print_connection_context_short(const connection_context_base &ctx)
Definition: net_utils_base.cpp:128
bool operator!=(const ipv4_network_address &lhs, const ipv4_network_address &rhs) noexcept
Definition: net_utils_base.h:111
bool operator>=(const ipv4_network_address &lhs, const ipv4_network_address &rhs) noexcept
Definition: net_utils_base.h:119
bool operator>(const ipv4_network_address &lhs, const ipv4_network_address &rhs) noexcept
Definition: net_utils_base.h:117
bool operator<(const ipv4_network_address &lhs, const ipv4_network_address &rhs) noexcept
Definition: net_utils_base.h:113
TODO: (mj-xmr) This will be reduced in an another PR.
Definition: byte_slice.h:40
Definition: net_utils_base.h:57
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
const char *const str
Definition: portlistingparse.c:23
Type
Type of JSON value.
Definition: rapidjson.h:623
boost::endian::big_uint16_t port
Definition: socks.cpp:59
boost::endian::big_uint32_t ip
Definition: socks.cpp:60
static unsigned char equal(signed char b, signed char c)
Definition: crypto-ops.c:1588
#define false
Definition: stdbool.h:37
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:365
void set_details(boost::uuids::uuid connection_id, const network_address &remote_address, bool is_income, bool ssl)
Definition: net_utils_base.h:428
time_t m_last_send
Definition: net_utils_base.h:372
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:380
time_t m_last_recv
Definition: net_utils_base.h:371
connection_context_base()
Definition: net_utils_base.h:399
double m_max_speed_down
Definition: net_utils_base.h:377
uint64_t m_send_cnt
Definition: net_utils_base.h:374
connection_context_base(const connection_context_base &a)
Definition: net_utils_base.h:414
const bool m_is_income
Definition: net_utils_base.h:368
const bool m_ssl
Definition: net_utils_base.h:370
double m_max_speed_up
Definition: net_utils_base.h:378
connection_context_base & operator=(const connection_context_base &a)
Definition: net_utils_base.h:419
const boost::uuids::uuid m_connection_id
Definition: net_utils_base.h:366
const time_t m_started
Definition: net_utils_base.h:369
const network_address m_remote_address
Definition: net_utils_base.h:367
double m_current_speed_down
Definition: net_utils_base.h:375
double m_current_speed_up
Definition: net_utils_base.h:376
uint64_t m_recv_cnt
Definition: net_utils_base.h:373
Definition: net_utils_base.h:440
virtual ~i_service_endpoint() noexcept(false)
Definition: net_utils_base.h:451
virtual bool call_run_once_service_io()=0
virtual boost::asio::io_service & get_io_service()=0
virtual bool do_send(byte_slice message)=0
Definition: net_utils_base.h:244
virtual std::uint16_t port() const override
Definition: net_utils_base.h:270
virtual bool less(const interface &other) const override
Definition: net_utils_base.h:257
virtual bool is_same_host(const interface &other) const override
Definition: net_utils_base.h:260
T value
Definition: net_utils_base.h:245
virtual std::string host_str() const override
Definition: net_utils_base.h:264
virtual address_type get_type_id() const override
Definition: net_utils_base.h:267
virtual std::string str() const override
Definition: net_utils_base.h:263
virtual bool is_blockable() const override
Definition: net_utils_base.h:269
virtual bool equal(const interface &other) const override
Definition: net_utils_base.h:254
virtual bool is_local() const override
Definition: net_utils_base.h:266
virtual bool is_loopback() const override
Definition: net_utils_base.h:265
virtual zone get_zone() const override
Definition: net_utils_base.h:268
static const T & cast(const interface &src) noexcept
Definition: net_utils_base.h:251
implementation(const T &src)
Definition: net_utils_base.h:247
Definition: net_utils_base.h:225
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:226
virtual std::uint16_t port() const =0
Definition: keyvalue_serialization_overloads.h:322
#define T(x)