xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
test
beast
IPEndpointCommon.h
1
#pragma once
2
3
#include <xrpl/basics/random.h>
4
#include <xrpl/beast/net/IPAddressV4.h>
5
#include <xrpl/beast/net/IPAddressV6.h>
6
#include <xrpl/beast/net/IPEndpoint.h>
7
8
#include <
cstdint
>
9
10
namespace
beast::ip
{
11
12
inline
Endpoint
13
randomEP
(
bool
v4 =
true
)
14
{
15
using namespace
xrpl
;
16
auto
const
dv4 = [] -> AddressV4::bytes_type {
17
return
{
18
{
19
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
20
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
21
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
22
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
23
},
24
};
25
};
26
auto
const
dv6 = [] -> AddressV6::bytes_type {
27
return
{
28
{
29
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
30
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
31
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
32
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
33
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
34
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
35
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
36
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
37
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
38
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
39
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
40
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
41
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
42
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
43
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
44
static_cast<
std::uint8_t
>
(
randInt<int>
(1, UINT8_MAX)),
45
},
46
};
47
};
48
return
Endpoint
{
49
v4 ?
Address
{
AddressV4
{dv4()}} :
Address
{
AddressV6
{dv6()}},
50
randInt<std::uint16_t>
(1, UINT16_MAX)};
51
}
52
53
}
// namespace beast::ip
beast::ip::Endpoint
A version-independent IP address and port combination.
Definition
IPEndpoint.h:24
cstdint
std::uint8_t
beast::ip
Definition
IPAddress.h:18
beast::ip::Address
boost::asio::ip::address Address
Definition
IPAddress.h:20
beast::ip::AddressV6
boost::asio::ip::address_v6 AddressV6
Definition
IPAddressV6.h:7
beast::ip::randomEP
Endpoint randomEP(bool v4=true)
Definition
IPEndpointCommon.h:13
beast::ip::AddressV4
boost::asio::ip::address_v4 AddressV4
Definition
IPAddressV4.h:7
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::randInt
Integral randInt(Engine &engine, Integral min, Integral max)
Return a uniformly distributed random integer.
Definition
include/xrpl/basics/random.h:97
Generated by
1.17.0