Initial commit

This commit is contained in:
2026-01-24 16:10:02 -05:00
parent e053f094b3
commit cf4020fa08
10 changed files with 267 additions and 0 deletions

26
ip.h Normal file
View File

@@ -0,0 +1,26 @@
#ifndef IP_UTIL_H
#define IP_UTIL_H
#include <string>
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#define CLOSE_SOCKET closesocket
#pragma comment(lib, "ws2_32.lib")
typedef SOCKET socket_t;
#else
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <unistd.h>
#define CLOSE_SOCKET close
typedef int socket_t;
#endif
bool is_valid_ipv4(const std::string &ip) {
struct in_addr addr;
return inet_pton(AF_INET, ip.c_str(), &addr) == 1;
}
#endif // IP_UTIL_H