mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-03 07:32:54 +01:00
Merge pull request #1445 from cryptoknight/ip_stable_sort
Use stable_sort to preserve order of IP addresses from DNS
This commit is contained in:
commit
d9c3c5270a
@ -170,7 +170,7 @@ SocketAddress& SocketAddress::operator = (const SocketAddress& socketAddress)
|
|||||||
destruct();
|
destruct();
|
||||||
if (socketAddress.family() == IPv4)
|
if (socketAddress.family() == IPv4)
|
||||||
newIPv4(reinterpret_cast<const sockaddr_in*>(socketAddress.addr()));
|
newIPv4(reinterpret_cast<const sockaddr_in*>(socketAddress.addr()));
|
||||||
#if defined(POCO_HAVE_IPv6)
|
#if defined(POCO_HAVE_IPv6)
|
||||||
else if (socketAddress.family() == IPv6)
|
else if (socketAddress.family() == IPv6)
|
||||||
newIPv6(reinterpret_cast<const sockaddr_in6*>(socketAddress.addr()));
|
newIPv6(reinterpret_cast<const sockaddr_in6*>(socketAddress.addr()));
|
||||||
#endif
|
#endif
|
||||||
@ -252,7 +252,7 @@ void SocketAddress::init(const std::string& hostAddress, Poco::UInt16 portNumber
|
|||||||
{
|
{
|
||||||
#if defined(POCO_HAVE_IPv6)
|
#if defined(POCO_HAVE_IPv6)
|
||||||
// if we get both IPv4 and IPv6 addresses, prefer IPv4
|
// if we get both IPv4 and IPv6 addresses, prefer IPv4
|
||||||
std::sort(addresses.begin(), addresses.end(), AFLT());
|
std::stable_sort(addresses.begin(), addresses.end(), AFLT());
|
||||||
#endif
|
#endif
|
||||||
init(addresses[0], portNumber);
|
init(addresses[0], portNumber);
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@ void SocketAddress::init(const std::string& hostAndPort)
|
|||||||
std::string port;
|
std::string port;
|
||||||
std::string::const_iterator it = hostAndPort.begin();
|
std::string::const_iterator it = hostAndPort.begin();
|
||||||
std::string::const_iterator end = hostAndPort.end();
|
std::string::const_iterator end = hostAndPort.end();
|
||||||
|
|
||||||
#if defined(POCO_OS_FAMILY_UNIX)
|
#if defined(POCO_OS_FAMILY_UNIX)
|
||||||
if (*it == '/')
|
if (*it == '/')
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user