From 05855a2d50d623133db970a16eedfda73bd6b88c Mon Sep 17 00:00:00 2001 From: anulax1225 Date: Sat, 2 Mar 2024 17:24:14 +0100 Subject: [PATCH] Removed dns lookup function from file --- bakanet/src/bakanet/socket.cpp | 39 ---------------------------------- bakanet/src/bakanet/socket.h | 4 ---- 2 files changed, 43 deletions(-) diff --git a/bakanet/src/bakanet/socket.cpp b/bakanet/src/bakanet/socket.cpp index a02acbe..ec3c6dd 100644 --- a/bakanet/src/bakanet/socket.cpp +++ b/bakanet/src/bakanet/socket.cpp @@ -2,45 +2,6 @@ #include namespace Bk::Net { - - std::vector dns_lookup(const std::string &host_name, IpVersion ipv = IpVersion::IPv4) - { - std::vector output; - - struct addrinfo hints, *res, *p; - int status, ai_family; - char ip_address[INET6_ADDRSTRLEN]; - - ai_family = (int)ipv; - memset(&hints, 0, sizeof hints); - hints.ai_family = ai_family; - hints.ai_socktype = SOCK_STREAM; - - if ((status = getaddrinfo(host_name.c_str(), NULL, &hints, &res)) != 0) { - //cerr << "getaddrinfo: "<< gai_strerror(status) << endl; - return output; - } - - for(p = res;p != NULL; p = p->ai_next) { - void *addr; - if (p->ai_family == AF_INET) { // IPv4 - struct sockaddr_in *ipv4 = (struct sockaddr_in *)p->ai_addr; - addr = &(ipv4->sin_addr); - } else { // IPv6 - struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)p->ai_addr; - addr = &(ipv6->sin6_addr); - } - - // convert the IP to a string - inet_ntop(p->ai_family, addr, ip_address, sizeof ip_address); - output.push_back(ip_address); - } - - freeaddrinfo(res); // free the linked list - - return output; - } - Socket::Socket(IpAddress ip, int port,IpProtocol proto) : ip_addr(ip), ip_proto(proto) { diff --git a/bakanet/src/bakanet/socket.h b/bakanet/src/bakanet/socket.h index 3c150e3..98abd89 100644 --- a/bakanet/src/bakanet/socket.h +++ b/bakanet/src/bakanet/socket.h @@ -14,14 +14,10 @@ #include "ip_address.h" #include "ip_protocol.h" -#define log(str) std::cout << str << "\n"; - namespace Bk::Net { using Connection = int; - std::vector dns_lookup(const std::string &host_name, IpVersion ipv); - class Socket { public: