My VPN creates a null/loopback encapsulated tunnel in order to route the traffic to the vpn.
I've noticed that I get FilterSocketFlows through the FilterDataProvider but I never see any tunnel traffic appearing in the FilterPacketProvider.
How can the Packet provider be configured to filter tunnel traffic ?
Note : I have tried only registering a PacketProvider and still dont see any traffic. Is there any documentation of proper configuration ?
For anyone stumbling upon this question, I've found what I believe to be the answer.
In the NEFilterDataProvider
class, there is a method :
@available(macOS 10.15.4, *)
open func update(_ flow: NEFilterSocketFlow, using verdict: NEFilterDataVerdict, for direction: NETrafficDirection)
In an initial test demo, this appeared to be what I'm looking for. NEFilterFlow
objects from handleNewFlow
can be cached and this update
method can be used to change a verdict at a later date. No idea when this method was added to the system extension framework SDK as it definitely didn't exist when this problem initially arose.
Few other comments:
- it appears that trying to update a flow thats finished doesn't seem to cause harm
- I believe all flow operations take place on the extensions main dispatchqueue.
- If the new flow object doesn't contain the full 5 tuple information,
peek
ing 1 byte will allow the information to become available in the cachedNEFilterSocketFlow
object.