Hi,
When trying to create a simple app with a NEFilterPacketProvider, it seems that the class is not created, and StartFilter does not run.
Here is my configuration code in the app that installs the extension:
And here is the code of the extension:
None of the logs in the extension code are printed.
When running the "SimpleFirewall" sample code, it works. The only difference I can think of is that it's in Swift while my code is in objective-c.
Has anyone succeeded in implementing this?
Thanks!
When trying to create a simple app with a NEFilterPacketProvider, it seems that the class is not created, and StartFilter does not run.
Here is my configuration code in the app that installs the extension:
Code Block objective-c - (void) enableFilterConfiguration { void(^loadCompHandler)(NSError* error) = ^(NSError* error){ if (error != nil) { NSLog(@"loadFromPreferences failed with error: %@", error); return; } if ([NEFilterManager sharedManager].providerConfiguration == nil) { NSLog(@"Setting up filterProviderConfig"); NEFilterProviderConfiguration* filterProviderConfig = [[NEFilterProviderConfiguration alloc] init]; filterProviderConfig.filterPackets = YES; filterProviderConfig.filterSockets = NO; [NEFilterManager sharedManager].providerConfiguration = filterProviderConfig; } NSLog(@"Saving to preferences"); [[NEFilterManager sharedManager] setEnabled:YES]; void(^saveCompHandler)(NSError* error) = ^(NSError* error){ if (error != nil) { NSLog(@"saveToPreferences failed with error: %@", error); } }; [[NEFilterManager sharedManager] saveToPreferencesWithCompletionHandler:saveCompHandler]; }; [[NEFilterManager sharedManager] loadFromPreferencesWithCompletionHandler:loadCompHandler]; }
And here is the code of the extension:
Code Block objective-c - (instancetype)init { NSLog(@"FilterPacketProvider init"); self = [super init]; return self; } - (void)startFilterWithCompletionHandler:(void (^)(NSError *error))completionHandler { NSLog(@"Starting filter"); self.packetHandler = ^NEFilterPacketProviderVerdict(NEFilterPacketContext * _Nonnull context, nw_interface_t _Nonnull interface, NETrafficDirection direction, const void * _Nonnull packetBytes, const size_t packetLength) { NSLog(@"Packet caught"); return NEFilterPacketProviderVerdictAllow; }; NSError* error; completionHandler(error); } - (void)stopFilterWithReason:(NEProviderStopReason)reason completionHandler:(void (^)(void))completionHandler { completionHandler(); }
None of the logs in the extension code are printed.
When running the "SimpleFirewall" sample code, it works. The only difference I can think of is that it's in Swift while my code is in objective-c.
Has anyone succeeded in implementing this?
Thanks!