Network Extension receives stop command right after start

Right after starting my Network Extension I see logs about it being stopped. This is unexpected, since I don't request a stop myself. See:

Secondly: I'm trying to build a Network Provider to stop any requests coming from a specific app. Am I correct I can do that using the NEFilterDataProvider without any filters configured?

override func startFilter(completionHandler: @escaping (Error?) -> Void) {
        log.log(level: .debug, "startFilter NEW3")
        completionHandler(nil)
}

Right after starting my Network Extension I see logs about it being stopped.

Is your start method called? What about your stop method? If so, what’s do you see passed to the reason parameter?

I'm trying to build a Network Provider to stop any requests coming from a specific app. Am I correct I can do that using the NEFilterDataProvider without any filters configured?

I’m not sure I undertand this question. However, the code snippet you posted in reasonable enough. There’s no requirement that your stopFilter(with:completionHandler:) method do anything other than call the completion handler. You can use it to configure your filter’s internal state but, if you have no internal state, calling the completion handler immediately is just fine.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Is your start method called? What about your stop method? If so, what’s do you see passed to the reason parameter?

I managed to find the cause, I was using true for both:

let providerConfiguration = NEFilterProviderConfiguration()
providerConfiguration.filterSockets = true
providerConfiguration.filterPackets = true

After changing filterPackets to false my extension didn't stop anymore!

I’m not sure I undertand this question. However, the code snippet you posted in reasonable enough.

Perfect, that's all I need to know right now! After my extension started working, I was able to disallow all incoming requests and verified my concept.


Btw, I found a small improvement in your guideline: https://developer.apple.com/forums/thread/725805

The next issue you’ll find is that choosing Product > Run runs the app from the build products directory rather than the Applications directory. To fix that:

Edit your app’s scheme again.

  • On the left, select Debug.

Debug was a bit unclear to me at first. I would better understand this if it was named Run. Btw, your instructions helped big time!

Network Extension receives stop command right after start
 
 
Q