20#include <xrpl/beast/net/IPAddress.h>
21#include <xrpl/beast/net/IPEndpoint.h>
23#include <boost/algorithm/string/trim.hpp>
24#include <boost/system/detail/error_code.hpp>
52 if (!is.
fail() && is.
rdbuf()->in_avail() == 0)
111 addrStr.
reserve(INET6_ADDRSTRLEN);
120 while (is && is.
rdbuf()->in_avail() > 0 && is.
get(i))
127 if (isspace(
static_cast<unsigned char>(i)) || (readTo && i == readTo))
130 if ((i ==
'.') || (i >=
'0' && i <=
':') || (i >=
'a' && i <=
'f') ||
131 (i >=
'A' && i <=
'F'))
136 if (addrStr.
size() == INET6_ADDRSTRLEN ||
137 (readTo && readTo ==
':' && addrStr.
size() > 15))
139 is.
setstate(std::ios_base::failbit);
143 if (!readTo && (i ==
'.' || i ==
':'))
147 readTo = (i ==
'.') ?
':' :
' ';
153 is.
setstate(std::ios_base::failbit);
158 if (readTo ==
']' && is.
rdbuf()->in_avail() > 0)
161 if (!(isspace(
static_cast<unsigned char>(i)) || i ==
':'))
164 is.
setstate(std::ios_base::failbit);
169 boost::system::error_code ec;
170 auto addr = Address::from_string(addrStr, ec);
173 is.
setstate(std::ios_base::failbit);
177 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)