From 1788a02338e7d1514e376b698ae7da1935f6781c Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 7 Aug 2024 20:21:39 -0400 Subject: [PATCH] Add c-ares. These are the hoops I have to jump through to be able to provide some bootstrap nodes. --- .gitmodules | 3 + GNUmakefile | 102 ++++++++++++++++++++ deps/c-ares | 1 + deps/c-ares_config/ares_build.h | 163 ++++++++++++++++++++++++++++++++ 4 files changed, 269 insertions(+) create mode 160000 deps/c-ares create mode 100644 deps/c-ares_config/ares_build.h diff --git a/.gitmodules b/.gitmodules index 104b24af..486f1d6c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -23,3 +23,6 @@ path = deps/openssl_src url = https://github.com/openssl/openssl.git shallow = true +[submodule "deps/c-ares"] + path = deps/c-ares + url = https://github.com/c-ares/c-ares.git diff --git a/GNUmakefile b/GNUmakefile index f3d30f63..b145db3a 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -248,6 +248,8 @@ APP_SOURCES_ios := $(wildcard src/*.m) APP_OBJS := $(call get_objs,APP_SOURCES) $(APP_OBJS): CFLAGS += \ -Ideps/base64c/include \ + -Ideps/c-ares/include \ + -Ideps/c-ares_config \ -Ideps/crypt_blowfish \ -Ideps/libbacktrace \ -Ideps/libsodium \ @@ -266,6 +268,105 @@ $(filter-out $(BUILD_DIR)/android% $(BUILD_DIR)/macos% $(BUILD_DIR)/ios%,$(APP_O -fanalyzer endif +ARES_SOURCES := \ + deps/c-ares/src/lib/ares_platform.c \ + deps/c-ares/src/lib/record/ares_dns_mapping.c \ + deps/c-ares/src/lib/record/ares_dns_parse.c \ + deps/c-ares/src/lib/record/ares_dns_write.c \ + deps/c-ares/src/lib/record/ares_dns_name.c \ + deps/c-ares/src/lib/record/ares_dns_record.c \ + deps/c-ares/src/lib/record/ares_dns_multistring.c \ + deps/c-ares/src/lib/ares_destroy.c \ + deps/c-ares/src/lib/ares_data.c \ + deps/c-ares/src/lib/ares_sysconfig.c \ + deps/c-ares/src/lib/ares_cancel.c \ + deps/c-ares/src/lib/ares_metrics.c \ + deps/c-ares/src/lib/ares_getnameinfo.c \ + deps/c-ares/src/lib/legacy/ares_parse_txt_reply.c \ + deps/c-ares/src/lib/legacy/ares_parse_naptr_reply.c \ + deps/c-ares/src/lib/legacy/ares_create_query.c \ + deps/c-ares/src/lib/legacy/ares_parse_mx_reply.c \ + deps/c-ares/src/lib/legacy/ares_parse_srv_reply.c \ + deps/c-ares/src/lib/legacy/ares_parse_ptr_reply.c \ + deps/c-ares/src/lib/legacy/ares_parse_caa_reply.c \ + deps/c-ares/src/lib/legacy/ares_parse_aaaa_reply.c \ + deps/c-ares/src/lib/legacy/ares_expand_name.c \ + deps/c-ares/src/lib/legacy/ares_parse_uri_reply.c \ + deps/c-ares/src/lib/legacy/ares_parse_a_reply.c \ + deps/c-ares/src/lib/legacy/ares_expand_string.c \ + deps/c-ares/src/lib/legacy/ares_fds.c \ + deps/c-ares/src/lib/legacy/ares_parse_ns_reply.c \ + deps/c-ares/src/lib/legacy/ares_parse_soa_reply.c \ + deps/c-ares/src/lib/legacy/ares_getsock.c \ + deps/c-ares/src/lib/windows_port.c \ + deps/c-ares/src/lib/ares_qcache.c \ + deps/c-ares/src/lib/ares_update_servers.c \ + deps/c-ares/src/lib/ares_process.c \ + deps/c-ares/src/lib/ares_getenv.c \ + deps/c-ares/src/lib/ares_gethostbyname.c \ + deps/c-ares/src/lib/ares_send.c \ + deps/c-ares/src/lib/dsa/ares__slist.c \ + deps/c-ares/src/lib/dsa/ares__htable.c \ + deps/c-ares/src/lib/dsa/ares__llist.c \ + deps/c-ares/src/lib/dsa/ares__htable_szvp.c \ + deps/c-ares/src/lib/dsa/ares__htable_asvp.c \ + deps/c-ares/src/lib/dsa/ares__htable_vpvp.c \ + deps/c-ares/src/lib/dsa/ares__htable_strvp.c \ + deps/c-ares/src/lib/dsa/ares__array.c \ + deps/c-ares/src/lib/ares__socket.c \ + deps/c-ares/src/lib/event/ares_event_poll.c \ + deps/c-ares/src/lib/event/ares_event_thread.c \ + deps/c-ares/src/lib/event/ares_event_select.c \ + deps/c-ares/src/lib/event/ares_event_kqueue.c \ + deps/c-ares/src/lib/event/ares_event_configchg.c \ + deps/c-ares/src/lib/event/ares_event_epoll.c \ + deps/c-ares/src/lib/event/ares_event_wake_pipe.c \ + deps/c-ares/src/lib/event/ares_event_win32.c \ + deps/c-ares/src/lib/ares_search.c \ + deps/c-ares/src/lib/ares__parse_into_addrinfo.c \ + deps/c-ares/src/lib/ares__hosts_file.c \ + deps/c-ares/src/lib/ares_getaddrinfo.c \ + deps/c-ares/src/lib/ares__addrinfo2hostent.c \ + deps/c-ares/src/lib/ares_freeaddrinfo.c \ + deps/c-ares/src/lib/ares_strerror.c \ + deps/c-ares/src/lib/ares_version.c \ + deps/c-ares/src/lib/ares_gethostbyaddr.c \ + deps/c-ares/src/lib/ares__addrinfo_localhost.c \ + deps/c-ares/src/lib/ares_free_hostent.c \ + deps/c-ares/src/lib/ares__close_sockets.c \ + deps/c-ares/src/lib/ares_free_string.c \ + deps/c-ares/src/lib/ares_init.c \ + deps/c-ares/src/lib/ares_options.c \ + deps/c-ares/src/lib/str/ares_strcasecmp.c \ + deps/c-ares/src/lib/str/ares__buf.c \ + deps/c-ares/src/lib/str/ares_strsplit.c \ + deps/c-ares/src/lib/str/ares_str.c \ + deps/c-ares/src/lib/ares_sysconfig_mac.c \ + deps/c-ares/src/lib/ares__sortaddrinfo.c \ + deps/c-ares/src/lib/ares_sysconfig_files.c \ + deps/c-ares/src/lib/util/ares__iface_ips.c \ + deps/c-ares/src/lib/util/ares__timeval.c \ + deps/c-ares/src/lib/util/ares_math.c \ + deps/c-ares/src/lib/util/ares_rand.c \ + deps/c-ares/src/lib/util/ares__threads.c \ + deps/c-ares/src/lib/ares_query.c \ + deps/c-ares/src/lib/ares_cookie.c \ + deps/c-ares/src/lib/inet_net_pton.c \ + deps/c-ares/src/lib/inet_ntop.c \ + deps/c-ares/src/lib/ares_library_init.c \ + deps/c-ares/src/lib/ares_android.c \ + deps/c-ares/src/lib/ares_sysconfig_win.c \ + deps/c-ares/src/lib/ares_timeout.c +ARES_OBJS := $(call get_objs,ARES_SOURCES) +$(ARES_OBJS): CFLAGS += \ + -Ideps/c-ares/include \ + -Ideps/c-ares/src/lib \ + -Ideps/c-ares_config/ \ + -D_GNU_SOURCE \ + -Wno-unused-function \ + -Wno-deprecated-declarations \ + -Wno-unused-result + BLOWFISH_SOURCES := \ deps/crypt_blowfish/crypt_blowfish.c \ deps/crypt_blowfish/crypt_gensalt.c \ @@ -631,6 +732,7 @@ all: $(BUILD_TYPES) ALL_APP_OBJS := \ $(APP_OBJS) \ + $(ARES_OBJS) \ $(BLOWFISH_OBJS) \ $(LIBBACKTRACE_OBJS) \ $(MINIUNZIP_OBJS) \ diff --git a/deps/c-ares b/deps/c-ares new file mode 160000 index 00000000..caffa5ff --- /dev/null +++ b/deps/c-ares @@ -0,0 +1 @@ +Subproject commit caffa5ffb3826cf0926405793361bbad11db3268 diff --git a/deps/c-ares_config/ares_build.h b/deps/c-ares_config/ares_build.h new file mode 100644 index 00000000..f32386c7 --- /dev/null +++ b/deps/c-ares_config/ares_build.h @@ -0,0 +1,163 @@ +#ifndef __CARES_BUILD_H +#define __CARES_BUILD_H +/* + * Copyright (C) The c-ares project and its contributors + * SPDX-License-Identifier: MIT + */ + +#define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t +#define CARES_TYPEOF_ARES_SSIZE_T ssize_t + +#define CARES_STATICLIB + +#ifdef CARES_HAVE_SYS_TYPES_H +# include +#endif + +#ifdef CARES_HAVE_SYS_SOCKET_H +# include +#endif + +#ifdef CARES_HAVE_SYS_SELECT_H +# include +#endif + +#ifdef CARES_HAVE_WINSOCK2_H +# include +#endif + +#ifdef CARES_HAVE_WS2TCPIP_H +# include +#endif + +#ifdef CARES_HAVE_WINDOWS_H +# include +#endif + +#if !defined(__ANDROID__) && !defined(__APPLE__) && !defined(_WIN32) +#define GETSERVBYNAME_R_ARGS 6 +#define GETSERVBYPORT_R_ARGS 6 +#define HAVE_GETSERVBYNAME_R 1 +#define HAVE_GETSERVBYPORT_R 1 +#define HAVE_PIPE2 1 +#endif + +#if !defined(__APPLE__) && !defined(_WIN32) +#define HAVE_MALLOC_H 1 +#define HAVE_EPOLL 1 +#define HAVE_SYS_EPOLL_H 1 +#define HAVE_SYS_RANDOM_H 1 +#endif + +#if !defined(__WIN32) +#undef AC_APPLE_UNIVERSAL_BUILD +#undef ETC_INET +#define GETHOSTNAME_TYPE_ARG2 size_t +#define GETNAMEINFO_QUAL_ARG1 +#define GETNAMEINFO_TYPE_ARG1 struct sockaddr * +#define GETNAMEINFO_TYPE_ARG2 socklen_t +#define GETNAMEINFO_TYPE_ARG46 socklen_t +#define GETNAMEINFO_TYPE_ARG7 int +#define HAVE_AF_INET6 1 +#define HAVE_ARPA_INET_H 1 +#define HAVE_ARPA_NAMESER_COMPAT_H 1 +#define HAVE_ARPA_NAMESER_H 1 +#define HAVE_ASSERT_H 1 +#define HAVE_CLOCK_GETTIME_MONOTONIC 1 +#define HAVE_CONNECT 1 +#define HAVE_DLFCN_H 1 +#define HAVE_ERRNO_H 1 +#define HAVE_POLL_H 1 +#define HAVE_POLL 1 +#define HAVE_PIPE 1 +#define HAVE_FCNTL 1 +#define HAVE_FCNTL_H 1 +#define HAVE_FCNTL_O_NONBLOCK 1 +#define HAVE_FREEADDRINFO 1 +#define HAVE_GETADDRINFO 1 +#define HAVE_GETENV 1 +#define HAVE_GETHOSTNAME 1 +#define HAVE_GETNAMEINFO 1 +#define HAVE_GETRANDOM 1 +#define HAVE_GETTIMEOFDAY 1 +#define HAVE_IF_INDEXTONAME 1 +#define HAVE_IF_NAMETOINDEX 1 +#define HAVE_INET_NTOP 1 +#define HAVE_INET_PTON 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_IOCTL 1 +#define HAVE_IOCTL_FIONBIO 1 +#define HAVE_IOCTL_SIOCGIFADDR 1 +#define HAVE_LIMITS_H 1 +#define HAVE_LONGLONG 1 +#define HAVE_MEMORY_H 1 +#define HAVE_MSG_NOSIGNAL 1 +#define HAVE_NETDB_H 1 +#define HAVE_NETINET_IN_H 1 +#define HAVE_NETINET_TCP_H 1 +#define HAVE_NET_IF_H 1 +#define HAVE_PF_INET6 1 +#define HAVE_RECV 1 +#define HAVE_RECVFROM 1 +#define HAVE_SEND 1 +#define HAVE_SETSOCKOPT 1 +#define HAVE_SIGNAL_H 1 +#define HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID 1 +#define HAVE_SOCKET 1 +#define HAVE_STDBOOL_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRDUP 1 +#define HAVE_STRINGS_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_STRUCT_ADDRINFO 1 +#define HAVE_STRUCT_IN6_ADDR 1 +#define HAVE_STRUCT_SOCKADDR_IN6 1 +#define HAVE_STRUCT_SOCKADDR_STORAGE 1 +#define HAVE_STRUCT_TIMEVAL 1 +#define HAVE_SYS_IOCTL_H 1 +#define HAVE_SYS_PARAM_H 1 +#define HAVE_SYS_SELECT_H 1 +#define HAVE_SYS_SOCKET_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_TIME_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_SYS_UIO_H 1 +#define HAVE_TIME_H 1 +#define HAVE_IFADDRS_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_WRITEV 1 +#define HAVE_ARC4RANDOM_BUF 1 +#define HAVE_GETIFADDRS 1 +#define HAVE_STAT 1 +#define CARES_RANDOM_FILE "/dev/urandom" +#define RECVFROM_QUAL_ARG5 +#define RECVFROM_TYPE_ARG1 int +#define RECVFROM_TYPE_ARG2 void * +#define RECVFROM_TYPE_ARG2_IS_VOID 0 +#define RECVFROM_TYPE_ARG3 size_t +#define RECVFROM_TYPE_ARG4 int +#define RECVFROM_TYPE_ARG5 struct sockaddr * +#define RECVFROM_TYPE_ARG5_IS_VOID 0 +#define RECVFROM_TYPE_ARG6 socklen_t * +#define RECVFROM_TYPE_ARG6_IS_VOID 0 +#define RECVFROM_TYPE_RETV ssize_t +#define RECV_TYPE_ARG1 int +#define RECV_TYPE_ARG2 void * +#define RECV_TYPE_ARG3 size_t +#define RECV_TYPE_ARG4 int +#define RECV_TYPE_RETV ssize_t +#define SEND_TYPE_ARG1 int +#define SEND_TYPE_ARG2 const void * +#define SEND_TYPE_ARG3 size_t +#define SEND_TYPE_ARG4 int +#define SEND_TYPE_RETV ssize_t +#undef USE_BLOCKING_SOCKETS +#undef WIN32_LEAN_AND_MEAN +#define HAVE_PTHREAD_H 1 +#define CARES_THREADS 1 +#endif + +#endif /* __CARES_BUILD_H */