diff --git a/CMakeLists.txt b/CMakeLists.txt index 236b972..65cd2ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.12) +include(CheckIncludeFile) + option(PROXYRES_CURL "Enable support for downloading PAC scripts using curl." OFF) option(PROXYRES_EXECUTE "Enable support for PAC script execution." ON) @@ -187,6 +189,13 @@ target_include_directories(proxyres PRIVATE target_include_directories(proxyres PUBLIC $) +if(NOT WIN32) + check_include_file("net/if_arp.h" HAVE_NET_IF_ARP_H) + if(HAVE_NET_IF_ARP_H) + target_compile_definitions(proxyres PRIVATE HAVE_NET_IF_ARP_H) + endif() +endif() + if(PROXYRES_CURL AND (PROXYRES_EXECUTE OR PROXYRES_BUILD_CLI)) if(NOT TARGET CURL::libcurl) include(FetchContent) diff --git a/config_mac.c b/config_mac.c index d1362c6..c09839d 100644 --- a/config_mac.c +++ b/config_mac.c @@ -4,6 +4,7 @@ #include #include +#include #include "config.h" #include "config_i.h" @@ -20,8 +21,8 @@ static bool get_cf_dictionary_bool(CFDictionaryRef dictionary, CFStringRef key) } bool proxy_config_mac_get_auto_discover(void) { +#if !TARGET_OS_IPHONE bool auto_discover = false; - CFDictionaryRef proxy_settings = CFNetworkCopySystemProxySettings(); if (!proxy_settings) return false; @@ -32,6 +33,9 @@ bool proxy_config_mac_get_auto_discover(void) { CFRelease(proxy_settings); return auto_discover; +#else + return false; +#endif } char *proxy_config_mac_get_auto_config_url(void) { @@ -76,6 +80,7 @@ char *proxy_config_mac_get_proxy(const char *scheme) { CFStringRef host_index = kCFNetworkProxiesHTTPProxy; CFStringRef port_index = kCFNetworkProxiesHTTPPort; +#if !TARGET_OS_IPHONE if (strncasecmp(scheme, "https", 5) == 0) { enable_index = kCFNetworkProxiesHTTPSEnable; host_index = kCFNetworkProxiesHTTPSProxy; @@ -93,6 +98,7 @@ char *proxy_config_mac_get_proxy(const char *scheme) { host_index = kCFNetworkProxiesRTSPProxy; port_index = kCFNetworkProxiesRTSPPort; } +#endif CFDictionaryRef proxy_settings = CFNetworkCopySystemProxySettings(); if (!proxy_settings) @@ -147,16 +153,21 @@ char *proxy_config_mac_get_bypass_list(void) { return NULL; // Get whether to exclude simple hostnames - bool exclude_simple_hostnames = get_cf_dictionary_bool(proxy_settings, kCFNetworkProxiesExcludeSimpleHostnames); + bool exclude_simple_hostnames = false; +#if !TARGET_OS_IPHONE + exclude_simple_hostnames = get_cf_dictionary_bool(proxy_settings, kCFNetworkProxiesExcludeSimpleHostnames); if (exclude_simple_hostnames) bypass_list_count++; - +#endif // Get exception list - CFArrayRef exceptions_list = CFDictionaryGetValue(proxy_settings, kCFNetworkProxiesExceptionsList); + CFArrayRef exceptions_list = NULL; +#if !TARGET_OS_IPHONE + exceptions_list = CFDictionaryGetValue(proxy_settings, kCFNetworkProxiesExceptionsList); if (exceptions_list) { exception_count = CFArrayGetCount(exceptions_list); bypass_list_count += exception_count; } +#endif if (!bypass_list_count) goto bypass_list_error; diff --git a/net_adapter_linux.c b/net_adapter_linux.c index 215405c..0279dae 100644 --- a/net_adapter_linux.c +++ b/net_adapter_linux.c @@ -10,7 +10,12 @@ #include #include #include +#ifdef HAVE_NET_IF_ARP_H #include +#else +#define ARPHRD_ETHER 1 // Ethernet hardware format +#define ARPHRD_IEEE802 6 // IEEE 802.2 Ethernet/TR/TB +#endif #include #include "log.h" diff --git a/net_adapter_mac.c b/net_adapter_mac.c index e54347b..4e403a1 100644 --- a/net_adapter_mac.c +++ b/net_adapter_mac.c @@ -7,7 +7,11 @@ #include #include #include +#ifdef HAVE_NET_IF_ARP_H #include +#else +#define ARPHRD_ETHER 1 // Ethernet hardware format +#endif #include #include diff --git a/wpad_dhcp_mac.c b/wpad_dhcp_mac.c index 8bc01f1..21471ef 100644 --- a/wpad_dhcp_mac.c +++ b/wpad_dhcp_mac.c @@ -5,10 +5,12 @@ #include #include #include +#include #include "net_adapter.h" char *wpad_dhcp_adapter_mac(uint8_t bind_ip[4], net_adapter_s *adapter, int32_t timeout_sec) { +#if !TARGET_OS_IPHONE CFDictionaryRef dhcp_info = NULL; CFDataRef dhcp_wpad_url = NULL; char *wpad = NULL; @@ -24,4 +26,10 @@ char *wpad_dhcp_adapter_mac(uint8_t bind_ip[4], net_adapter_s *adapter, int32_t wpad = strdup((const char *)CFDataGetBytePtr(dhcp_wpad_url)); CFRelease(dhcp_info); return wpad; +#else + UNUSED(bind_ip); + UNUSED(adapter); + UNUSED(timeout_sec); + return NULL; +#endif }