This commit is contained in:
Lion Kortlepel
2024-06-17 22:01:15 +02:00
parent 3488136ca4
commit a82b9fb36f
21 changed files with 1085 additions and 1017 deletions

View File

@@ -12,31 +12,32 @@
#include <winsock2.h>
#elif defined(__linux__)
#include "linuxfixes.h"
#include <netdb.h>
#include <arpa/inet.h>
#include <netdb.h>
#endif
#include "Logger.h"
std::string GetAddr(const std::string&IP){
if(IP.find_first_not_of("0123456789.") == -1)return IP;
hostent *host;
#ifdef _WIN32
std::string GetAddr(const std::string& IP) {
if (IP.find_first_not_of("0123456789.") == -1)
return IP;
hostent* host;
#ifdef _WIN32
WSADATA wsaData;
if(WSAStartup(514, &wsaData) != 0){
if (WSAStartup(514, &wsaData) != 0) {
error("WSA Startup Failed!");
WSACleanup();
return "";
}
#endif
#endif
host = gethostbyname(IP.c_str());
if(!host){
if (!host) {
error("DNS lookup failed! on " + IP);
WSACleanup();
return "DNS";
}
std::string Ret = inet_ntoa(*((struct in_addr *)host->h_addr));
std::string Ret = inet_ntoa(*((struct in_addr*)host->h_addr));
WSACleanup();
return Ret;
}