Hi,
I am new to network extension programming. I have one 'cpp' application which will run under /usr/local/sample directory. I want to listen all UDP & TCP network operation using network extension Content Filter in my c++ application, and I want execute my own rules on received event.
Is it possible to register network extensions from my 'cpp' application and Is it possible to catch the events on TCP & UDP using network extension from my c++ application? How it would be possible? Please provide any sample program.
Post
Replies
Boosts
Views
Activity
Hi,
I am new to network applications.
Should place network extension application in /Applications to run it? or Is network extension application run from any where on the machine?
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.
Hi,
I have tried to compile and run SimpleFirewall - https://developer.apple.com/documentation/networkextension/filtering_network_traffic example on MacBook Pro. Where can I get 'os_log' output logs in this example? I have verified in system.log but no use.
Hi, I am new to Swift language. I am trying to convert below C++ function to Swift function as below.
C++ function:
int test(test_type type, request_info_t *request, size_t request_len)
{
size_t size = request_len;
int mib[] = {0,0,0,0,0};
int ret = sysctl(mib, 5, request, &size, NULL, 0)
return ret;
}
Swift function:
func test( type: test_type, request: request_info_t, request_len: size_t) -> Int64
{
let size: Int = request_len
let mib: [Int]= [0, 0, 0, 0, 0]
let val: Int32 = sysctl(mib, 5, request, size, nil, 0)
return val
}
But I am facing below issues with arguments at sysctl(). Could any one please to convert this. Error due to first argument mib: Cannot convert value of type '[Int]' to expected argument type 'UnsafeMutablePointer<Int32>?'
Error due to third argument request: Cannot convert value of type 'Int' to expected argument type 'UnsafeMutablePointer<Int>?'
Error due to fourth argument size: Cannot convert value of type 'requestinfot' to expected argument type 'UnsafeMutableRawPointer?'
Hi, I am new to Swift language.
In my C++ application, I able to convert 'void *' to 'int * 'as below. Here, 'request' type is 'void *' type.
int *ret = request;
I am trying to do same thing in Swift also. Here 'request' type is 'UnsafeMutableRawPointer' But I am facing with error
"Cannot convert value of type 'UnsafeMutableRawPointer' to specified type 'UnsafeMutablePointer<Int32>'" let ret: UnsafeMutablePointer<Int32> = request
Any one please help to convert from UnsafeMutableRawPointer type to UnsafeMutablePointer<Int32>.
Hi,
I want to activate/deactivate network extension on Mac without any user consent (I want allow network extension activation/deactivation on Mac by default) and Mac is under un-managed environment (Not managed by MDM tools).
Is there any way to activate/deactivate network extension in unmanaged environment without use. consent.
Thanks.
HI,
I am using Content Filter simple firewall Network Extension (NE). I have couple of doubts about NE deactivation. Please clarify.
Is it possible to deactivate the NE without user consent?
If not possible without user consent, why we need to authorise even for deactivate? Is it restricted by Apple?
Please clarify.
HI,
I want to know whether my extension is in active state or not as part of my swift application.
It would get this on terminal usingsystemextensionsctl list | grep FilterExtension | grep activated command. It can be possible with system() on C++ as system("systemextensionsctl list | grep FilterExtension | grep activated")
But how can I achieve this in swift language?
Help me.
Thanks.
HI, I have a swift project and I am calling few objective C APIs as part of my swift project. I am using bridge header for this.
I am creating swift project using CMake files. I able to create the swift project and compiling successfully for Xcode But I unable to compile successfully for Ninja.
I am using XCODE_ATTRIBUTE_SWIFT_OBJC_BRIDGING_HEADER to import bridge header file to the swift project in my CMake file like set_target_properties(ADE PROPERTIES FRAMEWORK TRUE XCODE_ATTRIBUTE_SWIFT_OBJC_BRIDGING_HEADER ADE-Bridging-Header.h). But I failed to import successfully for Ninja.
Is there any way to import Bridge header file through CMake for both Xcode and Ninja?
HI, I have a swift project and I want to compile it for both "x86_64" and "arm64" architectures on my Mac for both Xcode & Ninja.
My swift project was successfully compiled for both "x86_64" and "arm64" with Xcode.
But I am facing with multiple values for CMAKE_OSX_ARCHITECTURES not supported with Swift error in CMake while creating the swift project for Ninja.
Pls help to fix this fir Ninja.
I able to create Universal Swift library with CMake+Xcode. But failed to create universal swift library with CMake+ninja.
Is there any way create universal swift library using CMake which is suitable for any build manager like Xcode and Ninja?
Hi, I have Content Filter Simple Firewall example from Apple site and modified as per my requirement and I able to compile & run with my developer id account.
As part of NE activation request, throwing the Allow/Don't Allow popup after allowing the NE from security preferences. When I went through the code I got to know that this popup is getting from filterManager.saveToPreferences as part of activation request. Attached the screen shot for reference.
How to suppress this allow/disallow popup? Please help me.
Hi, I am using file provide extension to sync the app with remote storage. createItem() fileprovideer extension is calling when I copy a file and I able to sync properly with normal file and symlink files. itemTemplate.symlinkTargetPath helps me to sync symlink file.
But, I am facing the with alias file to sync. I tried to get original file name of alias file but I haven't found any option. How to get the original file name of alias file at createItem() of fileprovider extension. Is there any way to sync alias file?
My createItem() sample code at extension which sends the call to server through grpc.
public func createItem(
basedOn itemTemplate: NSFileProviderItem,
fields: NSFileProviderItemFields,
contents contentsUrl: URL?,
options: NSFileProviderCreateItemOptions = [],
request: NSFileProviderRequest,
progress: Progress
) async throws -> (NSFileProviderItem, NSFileProviderItemFields) {
var (templateAttributes, _) = self.load(fields: fields, from: itemTemplate)
templateAttributes.ownerAccountID = getuid();
templateAttributes.groupOwnerAccountID = getgid();
let identifier: NSFileProviderItemIdentifier
let attributes: FileProviderItemAttributes
if itemTemplate.contentType?.conforms(to: .directory) == true {
// Handle folder creation
.....
.....
} else if itemTemplate.contentType?.conforms(to: .symbolicLink) == true {
// Handle symlinks
guard let targetPath = itemTemplate.symlinkTargetPath else {
fatalError("couldn't get symlinkTargetPath on \(itemTemplate)")
}
....
....
}
else if itemTemplate.contentType?.conforms(to: .aliasFile) == true {
// TODO I am not yet handled this case. I need to get original path of alias file.
}
else {
// Handle file creation
....
....
}
let item = try FileSystemItem.any(filename: itemTemplate.filename,
identifier: identifier,
parentIdentifier: itemTemplate.parentItemIdentifier,
attributes: attributes)
return (item, [])
}
My customer installed two different apps on his Mac machine. These two apps are using ContentFilter extensions. One of the app is mine and another app is different vendor.
If my customer enabled both ContentFilter extensions then he fails to connect immediately to its required destination to allow it to run. If one of the ContentFilter extension is disabled then there is no issue.
Is it not possible to run two different ContentFilter extensions on same Mac machine? Is there any way to fix these type of issues?
Thank You
Nagendra R