network extension content filter application in objective-c

Hi,

I am new to network extensions.

Is there any sample program for network extension content filters in Objective-c? I have found in swift but not find in Objective-C.

I want to register network extensions and I want listen all TCP & UDP network operations using network extension content filters in Objective-C.
There is not an Objective-C sample project for SimpleFirewall, but if you run into issues while trying to translate, just let me know and I can try to assist.

To create a network rule to filter on both TCP and UDP for any direction, try something like:

Code Block objective-c
NWHostEndpoint *hostEndpoint = [NWHostEndpoint endpointWithHostname:@"0.0.0.0" port: @"0"];
NENetworkRule *anyHostAndPortRule = [[NENetworkRule alloc] initWithRemoteNetwork: hostEndpoint
remotePrefix: 0
localNetwork: nil
localPrefix: 0
protocol: NENetworkRuleProtocolAny
direction: NETrafficDirectionAny];
NEFilterRule *filterRule = [[NEFilterRule alloc] initWithNetworkRule: anyHostAndPortRule action: NEFilterActionFilterData];
NEFilterSettings *filterSettings = [[NEFilterSettings alloc] initWithRules:@[filterRule] defaultAction: NEFilterActionAllow];
[self applySettings:filterSettings completionHandler:^(NSError *error) {
}];


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
network extension content filter application in objective-c
 
 
Q