Skip to content

Network iOS xcode15.0 b1

Manuel de la Pena edited this page Dec 12, 2023 · 2 revisions

#Network.framework https://github.com/xamarin/xamarin-macios/pull/19418

diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/NSURLSession+Network.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/NSURLSession+Network.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/NSURLSession+Network.h	1969-12-31 19:00:00
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/NSURLSession+Network.h	2023-05-20 01:46:49
@@ -0,0 +1,32 @@
+//
+//  NSURLSession+Network.h
+//  Network
+//
+//  Copyright (c) 2023 Apple Inc. All rights reserved.
+//
+
+#if defined(__OBJC__)
+
+#import <Network/Network.h>
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+@interface NSURLSessionConfiguration (Network)
+
+/*!
+ * @property proxyConfigurations
+ * @discussion An array of `nw_proxy_config_t` objects to apply to all connections in the URL session.
+ */
+#if OS_OBJECT_USE_OBJC
+@property (copy) NSArray<nw_proxy_config_t> *proxyConfigurations NS_REFINED_FOR_SWIFT;
+#else
+@property (copy) NSArray *proxyConfigurations NS_REFINED_FOR_SWIFT;
+#endif
+
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif // __OBJC__
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/Network.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/Network.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/Network.h	2023-03-04 19:11:42
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/Network.h	2023-05-20 01:46:48
@@ -35,6 +35,7 @@
 #include <Network/path.h>
 #include <Network/privacy_context.h>
 #include <Network/protocol_options.h>
+#include <Network/proxy_config.h>
 #include <Network/quic_options.h>
 #include <Network/resolver_config.h>
 #include <Network/tcp_options.h>
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/endpoint.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/endpoint.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/endpoint.h	2023-03-09 23:53:02
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/endpoint.h	2023-05-20 00:07:20
@@ -2,7 +2,7 @@
 //  endpoint.h
 //  Network
 //
-//  Copyright (c) 2014-2022 Apple Inc. All rights reserved.
+//  Copyright (c) 2014-2023 Apple Inc. All rights reserved.
 //
 
 #ifndef __NW_ENDPOINT_H__
@@ -35,7 +35,7 @@
  *		nw_retain() and nw_release() to retain and release the object.
  */
 #ifndef NW_ENDPOINT_IMPL
-NW_OBJECT_DECL(nw_endpoint);
+NW_SENDABLE_OBJECT_DECL(nw_endpoint);
 #endif // NW_ENDPOINT_IMPL
 
 /*!
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/nw_object.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/nw_object.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/nw_object.h	2023-03-09 19:13:21
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/nw_object.h	2023-05-20 00:07:20
@@ -2,7 +2,7 @@
 //  nw_object.h
 //  Network
 //
-//  Copyright (c) 2016-2021 Apple Inc. All rights reserved.
+//  Copyright (c) 2016-2023 Apple Inc. All rights reserved.
 //
 
 #ifndef __NW_OBJECT_H__
@@ -24,9 +24,15 @@
  * See <os/object.h> for details.
  */
 
+#if __has_attribute(__swift_attr__)
+#  define NW_SWIFT_SENDABLE __attribute__((swift_attr("@Sendable")))
+#else // __has_attribute(__swift_attr__)
+#  define NW_SWIFT_SENDABLE
+#endif // __has_attribute(__swift_attr__)
 
 #if OS_OBJECT_USE_OBJC
 #  define NW_OBJECT_DECL(type) OS_OBJECT_DECL(type)
+#  define NW_SENDABLE_OBJECT_DECL(type) NW_SWIFT_SENDABLE NW_OBJECT_DECL(type)
 #  define NW_OBJECT_DECL_SUBCLASS(type, super) OS_OBJECT_DECL_SUBCLASS(type, super)
 #else // OS_OBJECT_USE_OBJC
 #  define NW_OBJECT_DECL(type)					\
@@ -34,6 +40,7 @@
 		typedef	struct type *type##_t
 #  define NW_OBJECT_DECL_SUBCLASS(type, super)	\
 		typedef super##_t type##_t
+#  define NW_SENDABLE_OBJECT_DECL(type) NW_OBJECT_DECL(type)
 #endif // OS_OBJECT_USE_OBJC
 
 
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/path.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/path.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/path.h	2023-03-09 19:24:00
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/path.h	2023-05-19 23:57:26
@@ -84,12 +84,14 @@
 typedef enum {
 	/*! @const nw_path_unsatisfied_reason_not_available No reason is given */
 	nw_path_unsatisfied_reason_not_available = 0,
-	/*! @const nw_path_unsatisfied_reason_not_available The user has disabled cellular */
+	/*! @const nw_path_unsatisfied_reason_cellular_denied The user has disabled cellular */
 	nw_path_unsatisfied_reason_cellular_denied = 1,
-	/*! @const nw_path_unsatisfied_reason_not_available The user has disabled Wi-Fi */
+	/*! @const nw_path_unsatisfied_reason_wifi_denied The user has disabled Wi-Fi */
 	nw_path_unsatisfied_reason_wifi_denied = 2,
-	/*! @const nw_path_unsatisfied_reason_not_available The user has disabled local network access */
+	/*! @const nw_path_unsatisfied_reason_local_network_denied The user has disabled local network access */
 	nw_path_unsatisfied_reason_local_network_denied = 3,
+	/*! @const nw_path_unsatisfied_reason_vpn_inactive A required VPN is not active */
+	nw_path_unsatisfied_reason_vpn_inactive API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0)) = 4,
 } nw_path_unsatisfied_reason_t;
 
 /*!
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/privacy_context.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/privacy_context.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/privacy_context.h	2023-03-09 19:24:01
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/privacy_context.h	2023-05-20 01:43:49
@@ -2,7 +2,7 @@
 //  privacy_context.h
 //  Network
 //
-//  Copyright (c) 2020 Apple Inc. All rights reserved.
+//  Copyright (c) 2020-2023 Apple Inc. All rights reserved.
 //
 
 #ifndef __NW_PRIVACY_CONTEXT_H__
@@ -14,6 +14,7 @@
 
 #include <Network/nw_object.h>
 #include <Network/resolver_config.h>
+#include <Network/proxy_config.h>
 
 #include <stdbool.h>
 #include <stdint.h>
@@ -147,6 +148,38 @@
 nw_privacy_context_require_encrypted_name_resolution(nw_privacy_context_t privacy_context,
 													 bool require_encrypted_name_resolution,
 													 _Nullable nw_resolver_config_t fallback_resolver_config);
+
+/*!
+ * @function nw_privacy_context_add_proxy
+ *
+ * @abstract
+ * 		Add a proxy configuration to apply to all connections that participate in this
+ * 		context. If set on `NW_DEFAULT_PRIVACY_CONTEXT`, this will additionally
+ * 		apply to other networking APIs used by the calling process.
+ *
+ * @param privacy_context
+ * 		A privacy context to modify. This can include the default privacy context.
+ *
+ * @param proxy_config
+ * 		A proxy configuration object to apply to all connections that use this context.
+ */
+API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+void
+nw_privacy_context_add_proxy(nw_privacy_context_t privacy_context,
+							 nw_proxy_config_t proxy_config);
+
+/*!
+ * @function nw_privacy_context_clear_proxies
+ *
+ * @abstract
+ * 		Clear out any proxies added using `nw_privacy_context_add_proxy`.
+ *
+ * @param privacy_context
+ * 		A privacy context to modify. This can include the default privacy context.
+ */
+API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+void
+nw_privacy_context_clear_proxies(nw_privacy_context_t privacy_context);
 
 NW_ASSUME_NONNULL_END
 
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/proxy_config.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/proxy_config.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/proxy_config.h	1969-12-31 19:00:00
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/proxy_config.h	2023-05-19 23:52:31
@@ -0,0 +1,254 @@
+//
+//  proxy_config.h
+//  libnetwork
+//
+//  Copyright (c) 2023 Apple Inc. All rights reserved.
+//
+
+#ifndef __NW_PROXY_CONFIG_H__
+#define __NW_PROXY_CONFIG_H__
+
+#ifndef __NW_INDIRECT__
+#warning "Please include <Network/Network.h> instead of this file directly."
+#endif // __NW_INDIRECT__
+
+#include <Network/nw_object.h>
+#include <Network/endpoint.h>
+#include <Network/protocol_options.h>
+
+
+NW_ASSUME_NONNULL_BEGIN
+
+__BEGIN_DECLS
+
+/*!
+ * @typedef nw_proxy_config_t
+ * @abstract
+ *		A Proxy Config object stores a proxy configuration. These can be used to specify custom
+ *		proxies, such as ones that use HTTP CONNECT.
+ *
+ *		This type supports ARC and the -[description] method. In non-ARC files, use
+ *		nw_retain() and nw_release() to retain and release the object.
+ */
+#ifndef NW_PROXY_CONFIG_IMPL
+NW_OBJECT_DECL(nw_proxy_config);
+#endif // NW_PROXY_CONFIG_IMPL
+
+#pragma mark - Secure Relays
+
+/*!
+ * @typedef nw_relay_hop_t
+ * @abstract
+ *		A Relay Hop object represents a single hop in a multi-hop relay configuration.
+ *
+ *		This type supports ARC and the -[description] method. In non-ARC files, use
+ *		nw_retain() and nw_release() to retain and release the object.
+ */
+#ifndef NW_RELAY_HOP_IMPL
+NW_OBJECT_DECL(nw_relay_hop);
+#endif // NW_RELAY_HOP_IMPL
+
+/*!
+ * @function nw_relay_hop_create
+ *
+ * @abstract
+ *		Creates a configuration for a secure relay. A relay is a proxy that is accessible using
+ *		HTTP/3, HTTP/2, or both, and uses the CONNECT method to proxy TCP or UDP
+ *		connections. At least one of `http3_relay_endpoint` and
+ *		`http2_relay_endpoint` must be non-null.
+ *
+ * @param http3_relay_endpoint
+ *		A URL or host endpoint identifying the relay server accessible using HTTP/3.
+ *
+ * @param http2_relay_endpoint
+ *		A URL or host endpoint identifying the relay server accessible using HTTP/2.
+ *
+ * @param relay_tls_options
+ *		Optional TLS options to use for the TLS handshake to the relay. If this is null, default
+ *		TLS options will be used.
+ *
+ * @result
+ *		Returns an allocated `nw_relay_hop_t` object on success.
+ */
+API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+NW_RETURNS_RETAINED nw_relay_hop_t
+nw_relay_hop_create(nw_endpoint_t _Nullable http3_relay_endpoint,
+					nw_endpoint_t _Nullable http2_relay_endpoint,
+					nw_protocol_options_t _Nullable relay_tls_options);
+
+/*!
+ * @function nw_relay_hop_add_additional_http_header_field
+ *
+ * @abstract
+ *		Adds additional HTTP headers to send as part of CONNECT requests to the
+ *		relay.
+ *
+ * @param relay_hop
+ *		The proxy hop object.
+ *
+ * @param field_name
+ *		The HTTP header field name.
+ *
+ * @param field_value
+ *		The HTTP header field value.
+ */
+API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+void
+nw_relay_hop_add_additional_http_header_field(nw_relay_hop_t relay_hop,
+											  const char *field_name,
+											  const char *field_value);
+
+/*!
+ * @function nw_proxy_config_create_relay
+ *
+ * @abstract
+ *		Creates a proxy configuration with one or two secure relay hops.
+ *
+ * @param first_hop
+ *		The first or only relay hop.
+ *
+ * @param second_hop
+ *		An optional second relay hop.
+ *
+ * @result
+ *		Returns an allocated `nw_proxy_config_t` object on success.
+ */
+API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+NW_RETURNS_RETAINED nw_proxy_config_t
+nw_proxy_config_create_relay(nw_relay_hop_t first_hop,
+							 nw_relay_hop_t _Nullable second_hop);
+
+#pragma mark - Oblivious HTTP
+
+/*!
+ * @function nw_proxy_config_create_oblivious_http
+ *
+ * @abstract
+ *		Creates a proxy configuration for an Oblivious HTTP relay and gateway.
+ *
+ * @param relay
+ *		The Oblivious HTTP relay hop.
+ *
+ * @param relay_resource_path
+ *		The HTTP path to use for requests to the Oblivious HTTP relay that will forward requests to the gateway.
+ *
+ * @param gateway_key_config
+ *		The key configuration bytes for the Oblivious HTTP gateway.
+ *
+ * @param gateway_key_config_length
+ *		The length of the buffer in `gateway_key_config`.
+ *
+ * @result
+ *		Returns an allocated `nw_proxy_config_t` object on success.
+ */
+API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+NW_RETURNS_RETAINED nw_proxy_config_t
+nw_proxy_config_create_oblivious_http(nw_relay_hop_t relay,
+									  const char *relay_resource_path,
+									  const uint8_t *gateway_key_config,
+									  size_t gateway_key_config_length);
+
+#pragma mark - HTTP CONNECT Proxies
+
+/*!
+ * @function nw_proxy_config_create_http_connect
+ *
+ * @abstract
+ *		Creates a legacy HTTP CONNECT proxy configuration for a proxy server accessible
+ *		using HTTP/1.1. This proxy will only relay TCP connections.
+ *
+ * @param proxy_endpoint
+ *		A host endpoint identifying the proxy server accessible using HTTP/1.1.
+ *
+ * @param proxy_tls_options
+ *		Optional TLS options to use for a TLS handshake to the relay. If no options are provided,
+ *		the proxy will be accessed using cleartext HTTP.
+ *
+ * @result
+ *		Returns an allocated `nw_proxy_config_t` object on success.
+ */
+API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+NW_RETURNS_RETAINED nw_proxy_config_t
+nw_proxy_config_create_http_connect(nw_endpoint_t proxy_endpoint,
+									nw_protocol_options_t _Nullable proxy_tls_options);
+
+#pragma mark - SOCKS Proxies
+
+/*!
+ * @function nw_proxy_config_create_socksv5
+ *
+ * @abstract
+ *		Creates a SOCKSv5 proxy configuration.
+ *
+ * @param proxy_endpoint
+ *		A host endpoint identifying the SOCKS proxy server.
+ *
+ * @result
+ *		Returns an allocated `nw_proxy_config_t` object on success.
+ */
+API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+NW_RETURNS_RETAINED nw_proxy_config_t
+nw_proxy_config_create_socksv5(nw_endpoint_t proxy_endpoint);
+
+#pragma mark - Generic Proxy Options
+
+/*!
+ * @function nw_proxy_config_set_username_and_password
+ *
+ * @abstract
+ *		Configures a username and password to use with a proxy configuration.
+ *
+ * @param proxy_config
+ *		The proxy configuration object.
+ *
+ * @param username
+ *		A proxy authentication username.
+ *
+ * @param password
+ *		A proxy authentication password.
+ */
+API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+void
+nw_proxy_config_set_username_and_password(nw_proxy_config_t proxy_config,
+										  const char *username,
+										  const char * _Nullable password);
+
+/*!
+ * @function nw_proxy_config_set_failover_allowed
+ *
+ * @abstract
+ *		Set whether or not a proxy configuration allows failover to non-proxied connections.
+ *		Failover is not allowed by default.
+ *
+ * @param proxy_config
+ *		The proxy configuration object.
+ *
+ * @param failover_allowed
+ *		A Boolean indicating if failover is allowed.
+ */
+API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+void
+nw_proxy_config_set_failover_allowed(nw_proxy_config_t proxy_config,
+									 bool failover_allowed);
+
+/*!
+ * @function nw_proxy_config_get_failover_allowed
+ *
+ * @abstract
+ *		Check whether or not a proxy configuration allows failover to non-proxied connections.
+ *
+ * @param proxy_config
+ *		The proxy configuration object.
+ *
+ * @result
+ *		A Boolean indicating if failover is allowed.
+ */
+API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+bool
+nw_proxy_config_get_failover_allowed(nw_proxy_config_t proxy_config);
+
+__END_DECLS
+
+NW_ASSUME_NONNULL_END
+
+#endif // __NW_PROXY_CONFIG_H__
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/resolver_config.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/resolver_config.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/resolver_config.h	2023-03-09 23:53:03
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/resolver_config.h	2023-05-20 01:46:50
@@ -2,14 +2,14 @@
 //  resolver_config.h
 //  libnetwork
 //
-//  Copyright (c) 2020 Apple Inc. All rights reserved.
+//  Copyright (c) 2020-2023 Apple Inc. All rights reserved.
 //
 
 #ifndef __NW_RESOLVER_CONFIG_H__
 #define __NW_RESOLVER_CONFIG_H__
 
 #ifndef __NW_INDIRECT__
-#warning "Please include <Network/Network_Private.h> instead of this file directly."
+#warning "Please include <Network/Network.h> instead of this file directly."
 #endif // __NW_INDIRECT__
 
 #include <Network/nw_object.h>
Clone this wiki locally