1
0
mirror of https://github.com/moparisthebest/curl synced 2025-01-11 22:18:00 -05:00

lib/hostip6.c: make NAT64 address synthesis on macOS work

Closes #7121
This commit is contained in:
Radek Zajic 2021-05-24 16:38:40 +02:00 committed by Daniel Stenberg
parent a63dae5d07
commit 31f631a142
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
5 changed files with 82 additions and 0 deletions

View File

@ -386,6 +386,14 @@ if(CMAKE_USE_SECTRANSP)
list(APPEND CURL_LIBS "${COREFOUNDATION_FRAMEWORK}" "${SECURITY_FRAMEWORK}")
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
find_library(SYSTEMCONFIGURATION_FRAMEWORK "SystemConfiguration")
if(NOT SYSTEMCONFIGURATION_FRAMEWORK)
message(FATAL_ERROR "SystemConfiguration framework not found")
endif()
list(APPEND CURL_LIBS "${SYSTEMCONFIGURATION_FRAMEWORK}")
endif()
if(CMAKE_USE_OPENSSL)
find_package(OpenSSL REQUIRED)
set(SSL_ENABLED ON)

View File

@ -479,6 +479,7 @@ CURL_CHECK_WIN32_LARGEFILE
CURL_CHECK_WIN32_CRYPTO
CURL_DARWIN_CFLAGS
CURL_DARWIN_SYSTEMCONFIGURATION
CURL_SUPPORTS_BUILTIN_AVAILABLE

View File

@ -247,7 +247,11 @@
* performing this task will result in a synthesized IPv6 address.
*/
#if defined(__APPLE__) && !defined(USE_ARES)
#include <TargetConditionals.h>
#define USE_RESOLVE_ON_IPS 1
# if defined(TARGET_OS_OSX) && TARGET_OS_OSX
# define CURL_OSX_CALL_COPYPROXIES 1
# endif
#endif
#ifdef USE_LWIPSOCK

View File

@ -68,6 +68,10 @@
#include "curl_memory.h"
#include "memdebug.h"
#if defined(ENABLE_IPV6) && defined(CURL_OSX_CALL_COPYPROXIES)
#include <SystemConfiguration/SystemConfiguration.h>
#endif
#if defined(CURLRES_SYNCH) && \
defined(HAVE_ALARM) && defined(SIGALRM) && defined(HAVE_SIGSETJMP)
/* alarm-based timeouts can only be used with all the dependencies satisfied */
@ -529,6 +533,19 @@ enum resolve_t Curl_resolv(struct Curl_easy *data,
return CURLRESOLV_ERROR;
}
#if defined(ENABLE_IPV6) && defined(CURL_OSX_CALL_COPYPROXIES)
/*
* The automagic conversion from IPv4 literals to IPv6 literals only works
* if the SCDynamicStoreCopyProxies system function gets called first. As
* Curl currently doesn't support system-wide HTTP proxies, we therefore
* don't use any value this function might return.
*
* This function is only available on a macOS and is not needed for
* IPv4-only builds, hence the conditions above.
*/
SCDynamicStoreCopyProxies(NULL);
#endif
#ifndef USE_RESOLVE_ON_IPS
/* First check if this is an IPv4 address string */
if(Curl_inet_pton(AF_INET, hostname, &in) > 0)

52
m4/curl-sysconfig.m4 Normal file
View File

@ -0,0 +1,52 @@
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
#***************************************************************************
AC_DEFUN([CURL_DARWIN_SYSTEMCONFIGURATION], [
AC_MSG_CHECKING([whether to link macOS SystemConfiguration framework])
case $host_os in
darwin*)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
#include <TargetConditionals.h>
]],[[
#if (TARGET_OS_OSX)
return 0;
#else
#error Not a macOS
#endif
]])
],[
build_for_macos="yes"
],[
build_for_macos="no"
])
if test "x$build_for_macos" != xno; then
AC_MSG_RESULT(yes)
LDFLAGS="$LDFLAGS -framework SystemConfiguration"
else
AC_MSG_RESULT(no)
fi
;;
*)
AC_MSG_RESULT(no)
esac
])