Hi there, I'm trying to build a MacOS VPN application from scratch. My VPN application is slightly from normal ones,
- It will include an authentication token and underlying process information (pid, application path etc.) in each connection made to the VPN gateway. Consider it a poor man's zerotrust implementation.
- NetworkExtension and PacketTunnel is a must, thus to retrieve process information via audit tokens.
However, I'm unable to find any working examples that can be built on MacOS 15.X. I tried to open an TSI case but didn't receive anything useful.
Anyone?
In xcode select File -> New -> Target Choose System Network Extension, select PacketTunnelProvider.
Now I get this stub code, but don't know what to do next. I need a minimal working example.
@implementation PacketTunnelProvider
- (void)startTunnelWithOptions:(NSDictionary *)options completionHandler:(void (^)(NSError *))completionHandler {
// maybe process the packet from there? a tcp level read / write method call?
}
- (void)stopTunnelWithReason:(NEProviderStopReason)reason completionHandler: (void (^)(void))completionHandler {
// Add code here to start the process of stopping the tunnel.
completionHandler();
}
- (void)handleAppMessage:(NSData *)messageData completionHandler:(void (^)(NSData *))completionHandler {
// Add code here to handle the message.
}
- (void)sleepWithCompletionHandler:(void (^)(void))completionHandler {
// Add code here to get ready to sleep.
completionHandler();
}
- (void)wake {
// Add code here to wake up.
}
@end