Class

NEAppProxyProvider

Create a principal class for an App Proxy Provider app extension.

Declaration

class NEAppProxyProvider : NETunnelProvider

Overview

The NEAppProxyProvider class provides access to flows of network data in the form of NEAppProxyFlow objects. Each NEAppProxyFlow object corresponds to a socket opened by an app that matches the app rules specified in the current App Proxy configuration. Your App Proxy Provider acts as a transparent network proxy for the flows of network data that it receives.

DNS Handling

In addition to flows of raw network data from applications, the App Proxy Provider also receives flows of DNS queries in the form of NEAppProxyUDPFlow objects. DNS query flows are received only for applications that use low-level DNS resolution APIs such as DNSServiceGetAddrInfo(). The App Proxy Provider can specify the DNS resolver configuration that will be used by these applications using the setTunnelNetworkSettings(_:completionHandler:) method.

Applications that use higher-level networking APIs such as URLSession and NSURLConnection do not generate DNS queries. Instead the destination hostname for the connection is included in the endpoint information of the NEAppProxyFlow object.

Creating an App Proxy Provider Extension

App Proxy Providers run as App Extensions for the com.apple.networkextension.app-proxy extension point.

To create a App Proxy Provider extension, first create a new App Extension target in your project.

For an example of an Xcode build target for this app extension, see the SimpleTunnel: Customized Networking Using the NetworkExtension Framework sample code project.

Once you have a App Proxy Provider extension target, create a sub-class of NEAppProxyProvider. Then, set the NSExtensionPrincipalClass key in the the extension’s Info.plist to the name of your sub-class.

If it is not already done, set the NSExtensionPointIdentifier key in the extension’s Info.plist to com.apple.networkextension.app-proxy.

Here is an example of the NSExtension dictionary in a App Proxy Provider extension’s Info.plist:

<key>NSExtension</key>
<dict>
    <key>NSExtensionPointIdentifier</key>
    <string>com.apple.networkextension.app-proxy</string>
    <key>NSExtensionPrincipalClass</key>
    <string>MyCustomAppProxyProvider</string>
</dict>

Finally, add your App Proxy Provider extension target to your app’s Embed App Extensions build phase.

Subclassing Notes

In order to create a App Proxy Provider extension, you must create a subclass of NEAppProxyProvider and override the methods listed below.

Methods to Override

Topics

Handle Network Data Flows

func handleNewFlow(NEAppProxyFlow) -> Bool

Handle a new flow of network data.

Relationships

Inherits From

Conforms To