iOS implementing NETunnelProviderProtocol with no remote server - ios

I'm trying to implement a packet sniffer similar to Charles for iOS using iOS's NetworkExtension framework.
Objective
So, that's a big goal and I'm breaking it down into a tiny piece right now: I want to see the os_log from my NEPacketTunnelProvider (bottom box in diagram)
What I have done so far
I have created a NetworkExtension target on type PacketTunnel. This is the code snippet in the 3rd box in the diagram titled "NEPacketTunnelProvider".
I have included the "app groups", "personal VPN", and "Network extension" capabilities from within XCode.
Question
I am looking in the Console.app to see the output from os_log("STARTING TUNNEL!!!!"). When I load the configuration and make the call to startVPNTunnel(), why is my TunnelProvider code never called?
I have verified that startVPNTunnel() is being called by placing a breakpoint in my code.

There are a good number of reasons why your network extension process may not be starting:
I would put a breakpoint on the os_log("STARTING TUNNEL!!!!") and attach to your network extension process in Xcode via Debug -> Attach to Process by PID or Name... before you attempt to start the VPN
The network extension must extend the bundle id of the containing app. E.g. if the containing app is com.example.vpn then the network extension might be com.example.vpn.tunnel.
Ensure that your Network Extension Info.plist contains the NSExtension dictionary with NSExtensionPointIdentifier and NSExtensionPrincipalClass containing com.apple.networkextension.packet-tunnel and your NEPacketTunnelProvider class (e.g. $(PRODUCT_MODULE_NAME).PacketTunnelProvider) respectively.
Is the Packet Tunnel Provider Network Extension entitlement applied to both the containing application and the network extension?
If you are implementing a Packet Tunnel Provider, you do not want to enable the Personal VPN entitlement.

in startVPNTunnel func ,you should call setTunnelNetworkSettings,then the tunnel will started, after that ,you can read/write packet.
setTunnelNetworkSettings(nil) { error in
pendingStartCompletion(error)
}

Related

Unwanted Communication Reporting extension can't send network request

I am creating in the application support for the Unwanted Communication Reporting extension. All I found is this guide from Apple: https://developer.apple.com/documentation/sms_and_call_reporting/sms_and_call_spam_reporting and i follow it.
I've done:
Instantiates my ViewController from ILClassificationUIExtensionViewController.
Calls controller’s prepare(for:) method to customize UI.
Create button to notify the system when you have completed gathering information (setting setting isReadyForClassificationResponse property to true.)
Configure classificationResponse(for:) method after pressing Done button.
I want to send a response over the network so I add an associated domain to extension by following this instruction: https://developer.apple.com/documentation/xcode/supporting-associated-domain and advises from interenet. 
(Apple documentation supporting associated domain screenshots: https://i.stack.imgur.com/zxroa.png)
Create file apple-app-site-association, use classificationreport instead of webcredentials when specifying the domains.
{
 "applinks": {
  "apps": [],
  "details": [
   {
    "appID": “XXXX.com.project.UnwantedCommunicationExtension",
    "paths": ["*"]
   }
  ]
 },
 "classificationreport": {
   "apps": ["XXXX.com.project.UnwantedCommunicationExtension"]
  }
}
Add domain to the entitlement: https://i.stack.imgur.com/38qbn.png
Specify the network endpoint’s address using the ILClassificationExtensionNetworkReportDestination key in extension’s Info.plist file: https://i.stack.imgur.com/C6lbf.png
Create test server and sent the apple-app-site-association file to this server. 
Debugging and proxying my app, it doesn’t send any requests to the server. I can’t find any information about what request type should be sent, what data type will the server receive. Can anyone help to find information about it? Maybe advice what I did wrong, what settings should be on the server?

How to enable Ios Callkit Call Directory extension

I am trying to add the Callkit Call Directory extension to my React Native app so that I can add additional numbers that will show with caller id (populated from my app).
The Callkit documentation states:
"Before a Call Directory extension can operate on incoming calls, the user must explicitly enable the extension in the iOS Settings app."
However, there is no section for "Call blocking and identification" in my phone's settings (see here for similar issue: https://discussions.apple.com/thread/251896172)
I have tried using the openSettingsWithCompletionHandler method, which does open the settings on the phone, but still no option for "Call blocking and identification".
How can I let my app use this functionality if it cannot be seen in the phone settings? Am I doing something completely backward?
Thanks.

Self-hosted Signal iOS is unable to connect to internet

same issue, other person: https://github.com/signalapp/Signal-iOS/issues/2282
We've checked out the Signal-iOS repository and we're trying to make it connect to another server. We're running an instance of the server at signal.appcraft.nl. We've modified the defines in SignalServiceKit/src/TSConstants.h to match our server and we've changed the domains in App Transport Security Settings in /Signal/Signal-Info.plist
We also cloned the Android app and that one we managed to got working just fine. The iOS app seems not to be able to connect to the internet at all without a clear error. The first HTTP call that is done is GET https://signal.appcraft.nl/v1/accounts/sms/code/<MYNUMBER>?client=ios. When we invoke that URL using curl, we get a response (and SMS) just fine. From the app, we receive a Signal was unable to connect to the internet. Please try from another WiFi network or use mobile data. error. We also changed NSAllowsArbitraryLoads to Yes.
We've added a breakpoint in /Signal-iOS/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m:292
# /Signal-iOS/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m:292
(lldb) expr error
(NSURLError *) $3 = 0x00000001c0244800 domain: #"NSURLErrorDomain" - code: 18446744073709550617
Please advise

WatchKit: direct communication with the containing iOS app

I just get started with WatchKit and I'm trying to do this (if I'm not wrong, it is possible to do): I'd like the WatchKit Extension to ask the containing app for requesting some data to a web service, and then return the service response to the Extension to update the WatchKit App interface accordingly.
As I read in Apple Watch Programming Guide, yo can call the openParentApplication:reply: method in the WatchKit Extension to request something to its containing app, and then the application:handleWatchKitExtensionRequest:reply: method in the AppDelegate of the containing app should be called. Once this method called, I need to perform the service request, wait for its response, and then send it back to the Extension.
However, when I run the WatchKit App scheme in the simulator, the openParentApplication:reply: method is called, but a breakpoint within the application:handleWatchKitExtensionRequest:reply: is not reached. So I'm not even able to test if I can correctly perform the web service request and get its response back.
What could I be missing? Should I configure somehow the schema to reach breakpoints in the containing app as well? Is it needed to declare some kind of background feature for this?
Thanks in advance
I just answered a very similar question here which will allow you to open the iOS app from the Watch Extension and getting a reply back.
In order to debug the iOS app while running the Watch Extension, you should follow the steps explained here.

iOS Extension - Detect "extension state changes" (Background/Foreground)

I have a share extension implemented for iOS8. The service uses OAuth to authenticate. The login info I use for the extension is shared with the container app.
The problem is:
When I am in the extension, then app switch to the container app and logout, and then app switch back to the host app containing the extension - How do I detect that the extension has just re-appeared? The extension is relying on certain information to be present in the shared DB between the container app and the extension, however, that data is removed when the app logs out.
I have tried registering for various "app notifications" such as UIApplicationDidBecomeActiveNotification. However, as expected, these aren't called for extensions.
How can I detect when the state of the extension changes such that I can make my extension more robust when it reappears?
The viewDidAppear:animated: method of your main view controller class should be called every time you reenter your extension. When you are about to leave, viewWillDisappear:animated: should be called.
See
NSExtensionContext.h
iOS 8.2 added a number of notifications to use for extensions:
NSExtensionHostDidBecomeActiveNotification
NSExtensionHostDidEnterBackgroundNotification
NSExtensionHostWillEnterForegroundNotification
NSExtensionHostWillResignActiveNotification

Resources