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);
107 while (is && is.
rdbuf()->in_avail() > 0 && is.
get(i))
114 if ((isspace(
static_cast<unsigned char>(i)) != 0) || ((readTo != 0) && i == readTo))
117 if ((i ==
'.') || (i >=
'0' && i <=
':') || (i >=
'a' && i <=
'f') ||
118 (i >=
'A' && i <=
'F'))
123 if (addrStr.
size() == INET6_ADDRSTRLEN || (readTo ==
':' && addrStr.
size() > 15))
125 is.
setstate(std::ios_base::failbit);
129 if ((readTo == 0) && (i ==
'.' || i ==
':'))
133 readTo = (i ==
'.') ?
':' :
' ';
139 is.
setstate(std::ios_base::failbit);
144 if (readTo ==
']' && is.
rdbuf()->in_avail() > 0)
147 if ((isspace(
static_cast<unsigned char>(i)) == 0) && i !=
':')
150 is.
setstate(std::ios_base::failbit);
155 boost::system::error_code ec;
156 auto addr = boost::asio::ip::make_address(addrStr, ec);
159 is.
setstate(std::ios_base::failbit);
163 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)