Currently, we understand the lifecycle of our extension as follows:
First, the host app “installs” the network extension with an OSSystemExtensionRequest.activationRequest. After the user confirms the request and it succeeds, this starts the extension and executes the code in main.swift in the extension target, like in the SimpleFirewall example application. DNS traffic is not yet being routed to the proxy, however. For this post I would like to refer to the part that is running now as the “system extension” and the part that is not yet running as the “DNS proxy”.
To start the DNS proxy, you now need to enable it in the DNSProxyManager and save this to preferences.
If the user wants to enable/disable DNS blocking from a setting in the host app, we imagine that they will be enabling/disabling the DNS proxy through DNSProxyManager. This leaves the system extension running.
Is it indeed the intended practice to leave the system extension running and performing basic tasks even while the DNS proxy is disabled, or is this “abusing” the system extension? Such basic tasks could for example include occasional communication with the backend server, and leaving the XPC listener for communication with the host app running and would hence still use (some) system resources even though the user has decided to disable the functionality.
Is the system extension guaranteed to keep running indefinitely and to be launched at reboot, even if the DNS proxy remains disabled?
Is it even possible to shut down the system extension completely, without requiring a restart (like OSSystemExtensionRequest.deactivationRequest might)?
Since this is a Network System Extension and you want to distribute to the Mac App Store I will need to review what is and is not possible and get back to you on this. If you do not here from me on this, ping the post late next week sometime.We are developing an application to filter and block DNS traffic on macOS based on the NEDNSProxyProvider API and would like to comply with Apple's best practices, as well as be eligible for the App Store.
First, the host app “installs” the network extension with an OSSystemExtensionRequest.activationRequest.
Regarding:
If you mean that you are updating the network configuration for NEDNSProxyManager then you would stop and start the NEDNSProxyProvider and this would stop/start your Network System Extension also. If you are sending information to your provider from the container app then you could look at sending this information similar to how SimpleFirewall does it, but there is not method like sendProviderMessage and handleAppMessage on the packet tunel side.If the user wants to enable/disable DNS blocking from a setting in the host app, we
imagine that they will be enabling/disabling the DNS proxy through DNSProxyManager. This
leaves the system extension running.
Regarding:
If your Network System Extension is up and running and processing flows, then it is fine to keep it running. If it is not processing flows or performing the task that it was designed to do by the system then it should not be running.Is it indeed the intended practice to leave the system extension running and performing
basic tasks even while the DNS proxy is disabled
Regarding:
A functioning Network System Extension should start up again after reboot. If it is disabled there is no guarantee that this will happen.Is the system extension guaranteed to keep running indefinitely and to be launched at
reboot, even if the DNS proxy remains disabled?
Regarding:
Typically submitting a deactivationRequest is the workflow here. However, you can also stop your container app, and delete your container app. This typically provokes that deletion of your Network System Extension as well.Is it even possible to shut down the system extension completely, without requiring a
restart (like OSSystemExtensionRequest.deactivationRequest might)?
Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com