fixed dns lib for linux

This commit is contained in:
WolverinDEV
2019-10-26 01:42:37 +02:00
parent b9bd60f4e1
commit 55f3f7656a
4 changed files with 16 additions and 5 deletions
+11 -3
View File
@@ -13,10 +13,10 @@
#include <cstring>
#ifndef WIN32
#include <arpa/inet.h>
#include <arpa/inet.h>
#else
#include <Ws2ipdef.h>
#include <ip2string.h>
#include <Ws2ipdef.h>
#include <ip2string.h>
#endif
using namespace tc::dns;
@@ -181,7 +181,11 @@ void tc::dns::cr_srv(Resolver& resolver, const ServerAddress& address, const cr_
for(auto [priority, pentries] : entries) {
uint32_t count = 0;
for(const auto& entry : pentries) {
#ifdef WIN32
count += max((size_t) entry.weight, 1UL);
#else
count += std::max((size_t) entry.weight, 1UL);
#endif
}
std::uniform_int_distribution<std::mt19937::result_type> dist(0, (uint32_t) (count - 1));
@@ -189,7 +193,11 @@ void tc::dns::cr_srv(Resolver& resolver, const ServerAddress& address, const cr_
count = 0;
for(const auto& entry : pentries) {
#ifdef WIN32
count += max((size_t) entry.weight, 1UL);
#else
count += std::max((size_t) entry.weight, 1UL);
#endif
if(count > index) {
count = -1;
results.emplace_back(priority, entry);