1#include <xrpl/beast/net/IPAddress.h>
2#include <xrpl/beast/net/IPEndpoint.h>
4#include <boost/algorithm/string/trim.hpp>
5#include <boost/asio/ip/address.hpp>
6#include <boost/asio/ip/address_v4.hpp>
7#include <boost/system/detail/error_code.hpp>
35 if (!is.
fail() && is.
rdbuf()->in_avail() == 0)
55 (
port() == 0 ? 0 : 6 + (
address().is_v6() ? 2 : 0)));
94 addrStr.
reserve(INET6_ADDRSTRLEN);
103 while (is && is.
rdbuf()->in_avail() > 0 && is.
get(i))
110 if (isspace(
static_cast<unsigned char>(i)) || (readTo && i == readTo))
113 if ((i ==
'.') || (i >=
'0' && i <=
':') || (i >=
'a' && i <=
'f') ||
114 (i >=
'A' && i <=
'F'))
119 if (addrStr.
size() == INET6_ADDRSTRLEN ||
120 (readTo && readTo ==
':' && addrStr.
size() > 15))
122 is.
setstate(std::ios_base::failbit);
126 if (!readTo && (i ==
'.' || i ==
':'))
130 readTo = (i ==
'.') ?
':' :
' ';
136 is.
setstate(std::ios_base::failbit);
141 if (readTo ==
']' && is.
rdbuf()->in_avail() > 0)
144 if (!(isspace(
static_cast<unsigned char>(i)) || i ==
':'))
147 is.
setstate(std::ios_base::failbit);
152 boost::system::error_code ec;
153 auto addr = boost::asio::ip::make_address(addrStr, ec);
156 is.
setstate(std::ios_base::failbit);
160 if (is.
rdbuf()->in_avail() > 0)
A version-independent IP address and port combination.
Address const & address() const
Returns the address portion of this endpoint.
static std::optional< Endpoint > from_string_checked(std::string const &s)
Create an Endpoint from a string.
Endpoint()
Create an unspecified endpoint.
static Endpoint from_string(std::string const &s)
Port port() const
Returns the port number on the endpoint.
std::string to_string() const
Returns a string representing the endpoint.
std::istream & operator>>(std::istream &is, Endpoint &endpoint)
Input stream conversion.
bool operator<(Endpoint const &lhs, Endpoint const &rhs)
boost::asio::ip::address Address
bool operator==(Endpoint const &lhs, Endpoint const &rhs)