Question: Best Practice for NEFilterRule and NENetworkRule Initializers with Deprecated NEHostEndpoint?
Hi all,
I'm looking for guidance on the right way to construct an NEFilterRule that takes a NENetworkRule parameter. Reading the latest documentation, it looks like:
- All initializers for
NENetworkRulethat accept anNEHostEndpointare now deprecated, includinginitWithDestinationHost:protocol:and those using the various*Network:prefix:forms.NEHostEndpointitself is also deprecated; Apple recommends using thenw_endpoint_ttype from the Network framework instead. - However,
NEFilterRulestill requires aNENetworkRulefor its initializer (docs).
With all NENetworkRule initializers that take NEHostEndpoint deprecated, it’s unclear what the recommended way is to create a NENetworkRule (and thus an NEFilterRule) that matches host/domain or network traffic.
What’s the proper way to construct these objects now—should we create the endpoints using nw_endpoint_t and use new/undocumented initializers, or is there an updated approach that’s considered best practice?
Helpful doc links for reference:
AFAIK all the places where we deprecated NetworkExtension.NWEndpoint have a replacement based on Network.NWEndpoint. However, this can be quite tricky. I’ve explained this numerous times before, so I used your question as an excuse to write it up properly. See NWEndpoint History and Advice. The bulk of the post is backstory, but the last section covers your specific question.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"