I am trying to connect to an accessory's WiFi network using the below code and I always see the message "connection succeded" even if I provide an incorrect passphrase. I tried with different accessories and see the same behavior.
hotspotConfigurationManager.joinAccessoryHotspot(accessory, passphrase: passphrase) { error in
if let error = error {
print("connection failed: \(error.localizedDescription)")
} else {
print("connection succeeded")
}
}
Network Extension
RSS for tagCustomize and extend the core networking features of iOS, iPad OS, and macOS using Network Extension.
Posts under Network Extension tag
200 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi
I am developing the packet tunnel extension on a SIP enabled device.
If I build the app and notarize and install it on the device, it works fine.
If I modify, build and execute the App (which contains the system extension), it fails with below error. 102.3.1.4 is production build. And 201.202.0.101 is for XCode build.
SystemExtension "<<complete name>>.pkttunnel" request for replacement from 102.3.1.4 to 201.202.0.101
Packet Tunnel SystemExtension "<<complete name>>.pkttunnel" activation request did fail: Error Domain=OSSystemExtensionErrorDomain Code=8 "(null)"
If SIP is disabled, it works fine.
Is there a way the system extension can be developed even if SIP remains enabled?
Hello.
Background: Most learning resources are for leaning Swift/Objective-C. I'm pretty sure I need something different. I'm already an experienced software engineer, just new to iOS/MacOS development. My problem is not learning the language, but rather how to learn modern best practices. I cannot find examples for what I'm looking for. So much seems to be sparse on implementation details, out of date, or both.
I'm trying to write an app that has a few distinct parts. The UI portion will be mostly a menu bar app, which I am not having a problem discovering resources for how to implement. The app will also have a daemon and utilize network extensions. This is where I am having trouble.
What's the current best practices on how to write and launch a daemon?
Should the daemon be its own library/package which is them imported into the main app? If so, which Xcode template do I use for this? Are there any Hello World! examples of this?
What is the best way for a UI app to communicate with a daemon?
Are there any Hello World! repositories on how to implement network extensions? Should this be done in the main UI app, or in a separate library/package?
TIA
Topic:
App & System Services
SubTopic:
General
Tags:
Network Extension
Service Management
Background Tasks
My personal project is a bit further along however after not being able to get this to work in my app I fell back to a much simpler/proven implementation out there. There is this project on GitHub with a guide that implements a barebones app extension with packet tunneling. I figure this can give us common ground.
After changing the bundle and group identifiers to all end with -Caleb and or match up I tried running the app. The app extension does not work whatsoever and seemingly for reasons that are similar to my personal project.
If I pull up the console and filter for the subsystem (com.github.kean.vpn-client-caleb.vpn-tunnel) I see the following.
First you see installd installing it
0x16ba5f000 -[MIUninstaller _uninstallBundleWithIdentity:linkedToChildren:waitForDeletion:uninstallReason:temporaryReference:deleteDataContainers:wasLastReference:error:]: Destroying container com.github.kean.vpn-client-caleb.vpn-tunnel with persona 54D15361-A614-4E0D-931A-0953CDB50CE8 at /private/var/mobile/Containers/Data/PluginKitPlugin/2D0AE485-BB56-4E3E-B59E-48424CD4FD65
And then installd says this (No idea what it means)
0x16b9d3000 -[MIInstallationJournalEntry _refreshUUIDForContainer:withError:]: Data container for com.github.kean.vpn-client-caleb.vpn-tunnel is now at /private/var/mobile/Containers/Data/PluginKitPlugin/2D0AE485-BB56-4E3E-B59E-48424CD4FD65
Concerningly runningboardd seems to immediately try and stop it?
Executing termination request for: <RBSProcessPredicate <RBSProcessBundleIdentifiersPredicate| {(
"com.github.kean.vpn-client-caleb",
"com.github.kean.vpn-client-caleb.vpn-tunnel"
)}>>
[app<com.github.kean.vpn-client-caleb(54D15361-A614-4E0D-931A-0953CDB50CE8)>:1054] Terminating with context: <RBSTerminateContext| explanation:installcoordinationd app:[com.github.kean.vpn-client-caleb/54D15361-A614-4E0D-931A-0953CDB50CE8] uuid:963149FA-F712-460B-9B5C-5CE1C309B2FC isPlaceholder:Y reportType:None maxTerminationResistance:Absolute attrs:[
<RBSPreventLaunchLimitation| <RBSProcessPredicate <RBSProcessBundleIdentifiersPredicate| {(
"com.github.kean.vpn-client-caleb",
"com.github.kean.vpn-client-caleb.vpn-tunnel"
)}>> allow:(null)>
]>
Then runningboardd leaves a cryptic message
Acquiring assertion targeting system from originator [osservice<com.apple.installcoordinationd>:244] with description <RBSAssertionDescriptor| "installcoordinationd app:[com.github.kean.vpn-client-caleb/54D15361-A614-4E0D-931A-0953CDB50CE8] uuid:963149FA-F712-460B-9B5C-5CE1C309B2FC isPlaceholder:Y" ID:33-244-5222 target:system attributes:[
<RBSPreventLaunchLimitation| <RBSProcessPredicate <RBSProcessBundleIdentifiersPredicate| {(
"com.github.kean.vpn-client-caleb",
"com.github.kean.vpn-client-caleb.vpn-tunnel"
)}>> allow:(null)>
]>
And that seems to be all I have to go off of.... If I widen my search a bit I can see backboardd saying things like
Connection removed: IOHIDEventSystemConnection uuid:57E97E5D-8CDE-467B-81CA-36A93C7684AD pid:1054 process:vpn-client type:Passive entitlements:0x0 caller:BackBoardServices: <redacted> + 280 attributes:{
HighFrequency = 1;
bundleID = "com.github.kean.vpn-client-caleb";
pid = 1054;
} state:0x1 events:119 mask:0x800 dropped:0 dropStatus:0 droppedMask:0x0 lastDroppedTime:NONE
Or
Removing client connection <BKHIDClientConnection: 0xbf9828cd0; IOHIDEventSystemConnectionRef: 0xbf96d9600; vpid: 1054(vAF7); taskPort: 0x5D777; bundleID: com.github.kean.vpn-client-caleb> for client: IOHIDEventSystemConnection uuid:57E97E5D-8CDE-467B-81CA-36A93C7684AD pid:1054 process:vpn-client type:Passive entitlements:0x0 caller:BackBoardServices: <redacted> + 280 attributes:{
HighFrequency = 1;
bundleID = "com.github.kean.vpn-client-caleb";
pid = 1054;
} state:0x1 events:119 mask:0x800 dropped:0 dropStatus:0 droppedMask:0x0 lastDroppedTime:NONE source:HID
There's really nothing in the sysdiagnose either. No crash no nothing.
I am stumped. Any idea what might be going wrong for me here? Has something about the way app extensions or sandbox rules work changed in later OSes?
I'm working on a Network Extension using NEDNSProxyProvider to inspect DNS traffic. However, I've run into a couple of issues:
DNS Proxy is not capturing traffic when a public DNS (like 8.8.8.8 or 1.1.1.1) is manually configured in the WiFi settings. It seems like the system bypasses the proxy in this case. Is this expected behavior? Is there a way to force DNS traffic through the proxy even if a public DNS is set?
Using DNS Proxy and DNS Settings simultaneously doesn't work. Is there a known limitation or a correct way to combine these?
How to set DNS or DNSSettings using DNSProxy?
import NetworkExtension
import SystemExtensions
import SwiftUI
protocol DNSProxyManagerDelegate {
func managerStateDidChange(_ manager: DNSProxyManager)
}
class DNSProxyManager: NSObject {
private let manager = NEDNSProxyManager.shared()
var delegate: DNSProxyManagerDelegate?
private(set) var isEnabled: Bool = false {
didSet {
delegate?.managerStateDidChange(self)
}
}
var completion: (() -> Void)?
override init() {
super.init()
self.load()
}
func toggle() {
isEnabled ? disable() : start()
}
private func start() {
let request = OSSystemExtensionRequest
.activationRequest(forExtensionWithIdentifier: Constants.extensionBundleID,
queue: DispatchQueue.main)
request.delegate = self
OSSystemExtensionManager.shared.submitRequest(request)
log.info("Submitted extension activation request")
}
private func enable() {
update {
self.manager.localizedDescription = "DNS Proxy"
let proto = NEDNSProxyProviderProtocol()
proto.providerBundleIdentifier = Constants.extensionBundleID
self.manager.providerProtocol = proto
self.manager.isEnabled = true
}
}
private func disable() {
update {
self.manager.isEnabled = false
}
}
private func remove() {
update {
self.manager.removeFromPreferences { _ in
self.isEnabled = self.manager.isEnabled
}
}
}
private func update(_ body: @escaping () -> Void) {
self.manager.loadFromPreferences { (error) in
if let error = error {
log.error("Failed to load DNS manager: \(error)")
return
}
self.manager.saveToPreferences { (error) in
if let error = error {
return
}
log.info("Saved DNS manager")
self.isEnabled = self.manager.isEnabled
}
}
}
private func load() {
manager.loadFromPreferences { error in
guard error == nil else { return }
self.isEnabled = self.manager.isEnabled
}
}
}
extension DNSProxyManager: OSSystemExtensionRequestDelegate {
func requestNeedsUserApproval(_ request: OSSystemExtensionRequest) {
log.info("Extension activation request needs user approval")
}
func request(_ request: OSSystemExtensionRequest, didFailWithError error: Error) {
log.error("Extension activation request failed: \(error)")
}
func request(_ request: OSSystemExtensionRequest, foundProperties properties: [OSSystemExtensionProperties]) {
log.info("Extension activation request found properties: \(properties)")
}
func request(_ request: OSSystemExtensionRequest, didFinishWithResult result: OSSystemExtensionRequest.Result) {
guard result == .completed else {
log.error("Unexpected result \(result.description) for system extension request")
return
}
log.info("Extension activation request did finish with result: \(result.description)")
enable()
}
func request(_ request: OSSystemExtensionRequest, actionForReplacingExtension existing: OSSystemExtensionProperties, withExtension ext: OSSystemExtensionProperties) -> OSSystemExtensionRequest.ReplacementAction {
log.info("Existing extension willt be replaced: \(existing.bundleIdentifier) -> \(ext.bundleIdentifier)")
return .replace
}
}
import NetworkExtension
class DNSProxyProvider: NEDNSProxyProvider {
var handlers: [String: FlowHandler] = [:]
var isReady = false
let queue = DispatchQueue(label: "DNSProxyProvider")
override func startProxy(options:[String: Any]? = nil, completionHandler: @escaping (Error?) -> Void) {
completionHandler(nil)
}
override func stopProxy(with reason: NEProviderStopReason, completionHandler: @escaping () -> Void) {
completionHandler()
}
override func handleNewUDPFlow(_ flow: NEAppProxyUDPFlow, initialRemoteEndpoint remoteEndpoint: NWEndpoint) -> Bool {
let id = shortUUID()
handlers[id] = FlowHandler(flow: flow, remoteEndpoint: remoteEndpoint, id: id, delegate: self)
return true
}
override func handleNewFlow(_ flow: NEAppProxyFlow) -> Bool {
return false
}
}
class FlowHandler {
let id: String
let flow: NEAppProxyUDPFlow
let remoteEndpoint: NWHostEndpoint
let delegate: FlowHandlerDelegate
private var connections: [String: RemoteConnection] = [:]
private var pendingPacketsByDomain: [String: [(packet: Data, endpoint: NWEndpoint, uniqueID: String, timestamp: Date)]] = [:]
private let packetQueue = DispatchQueue(label: "com.flowhandler.packetQueue")
init(flow: NEAppProxyUDPFlow, remoteEndpoint: NWEndpoint, id: String, delegate: FlowHandlerDelegate) {
log.info("Flow received for \(id) flow: \(String(describing: flow))")
self.flow = flow
self.remoteEndpoint = remoteEndpoint as! NWHostEndpoint
self.id = id
self.delegate = delegate
defer { start() }
}
deinit {
closeAll(nil)
}
func start() {
flow.open(withLocalEndpoint: flow.localEndpoint as? NWHostEndpoint) { error in
if let error = error {
self.delegate.flowClosed(self)
return
}
self.readFromFlow()
}
}
func readFromFlow() {
self.flow.readDatagrams { packets, endpoint, error in
if let error = error {
self.closeAll(error)
return
}
guard let packets = packets, let endpoints = endpoint, !packets.isEmpty, !endpoints.isEmpty else {
self.closeAll(nil)
return
}
self.processFlowPackets(packets, endpoints)
self.readFromFlow()
}
}
}
Any insights or suggestions would be greatly appreciated. Thanks!
Does someone know how to debug ios app on mac designed for iPad?
i can debug on real iOS device but cant attach Tunnel to work for mac.
I am currently creating a MacOS app that uses NetworkExtension and SystemExtension without going through the Store.
Using entitlements, I manually codesign and create a pkg Installer, but when I run it I get an error message saying "No matching profile found."
Below is the log
/Applications/Runetale.app/Contents/MacOS/Runetale not valid: Error Domain=AppleMobileFileIntegrityError Code=-413 "No matching profile found" UserInfo={NSURL=file:///Applications/Runetale.app/, unsatisfiedEntitlements=<CFArray 0x71c040fa0 [0x1f7bec120]>{type = immutable, count = 3, values = (
0 : <CFString 0x71c04f340 [0x1f7bec120]>{contents = "com.apple.developer.system-extension.install"}
1 : <CFString 0x71c1ccaf0 [0x1f7bec120]>{contents = "com.apple.developer.networking.networkextension"}
2 : <CFString 0x71c04fc00 [0x1f7bec120]>{contents = "com.apple.developer.team-identifier"}
)}, NSLocalizedDescription=No matching profile found}
I looked into it myself and found that if you want to install the app without going through the Store, you need to use packet-tunnel-provider-systemextension instead of packet-tunnel-provider. here
However, simply changing to packet-tunnel-provider-systemextension does not allow the build to pass.
I use a build method that changes the value of entitlements only during codesign in order to pass the build.
SYSEXT="$APP_BUNDLE/Contents/Library/SystemExtensions/com.runetale.desktop.PacketTunnel.systemextension"
if [ -d "$SYSEXT" ]; then
echo "Signing PacketTunnel system extension with entitlements..."
cp macos/PacketTunnel/PacketTunnelRelease.entitlements macos/PacketTunnel/PacketTunnelRelease-sign.entitlements
sed -i '' 's/packet-tunnel-provider/packet-tunnel-provider-systemextension/' macos/PacketTunnel/PacketTunnelRelease-sign.entitlements
codesign --force --options runtime --timestamp --entitlements "$ENTITLEMENTS_FILE" --sign "$DEV_ID_APP_CERT" "$SYSEXT"
fi
# 3. Sign the entire .app bundle (deep sign by signing the outer app after inner ones)
echo "Signing Runetale App with entitlements..."
cp macos/Runner/Release.entitlements macos/PacketTunnel/Release-sign.entitlements
sed -i '' 's/packet-tunnel-provider/packet-tunnel-provider-systemextension/' macos/PacketTunnel/Release-sign.entitlementsmacos/PacketTunnel/Release-sign.entitlements
codesign --force --options runtime --timestamp --entitlements "$APP_ENTITLEMENTS_FILE" --sign "$DEV_ID_APP_CERT" "$APP_BUNDLE"
Is this build method wrong?
The next solution I'm thinking of is as follows.
Is there a way to write packet-tunnel-provider-systemextension directly to entitlments and pass the build? (provisioning profile?)
Apply to forum and get permission to use packet-tunnel-provider-systemextension
Thank you.
Topic:
App & System Services
SubTopic:
Networking
Tags:
Entitlements
System Extensions
Network Extension
Hi everyone,
I'm developing an enterprise iOS application and need to access the WiFi connection channel. I understand that Apple's privacy and security policies restrict direct access to certain network details, including the WiFi connection channel.
After some research, I found that this data might be accessible via the private API MobileWiFi.framework. However, when I tried to use this framework, I encountered the following error:
Missing com.apple.wifi.manager-access entitlement
I reached out to Apple regarding this entitlement, but they were not familiar with it, suggesting it might be deprecated.
Here are my questions:
Is there an official or supported way to access the WiFi connection channel in an enterprise iOS app?
If not, is there any workaround or additional steps required to use the MobileWiFi.framework without encountering the entitlement error?
Are there any specific entitlements or provisioning profile configurations that I need to be aware of to resolve this issue?
Any guidance or suggestions would be greatly appreciated. Thank you!
Hello,
Recently I am trying to add stub dns server to my Network Extension (a VPN app), after some research on this forum, and since my language is C, I have the following plan:
create a udp socket which use setsockopt(IP_BOUND_IF) to bound the socket to the utun if index obtained, and also bind to the address of the utun address I set(let's say 192.168.99.2), then listen on the udp port 53 which is ready to handle dns request.
configure the dns server to 192.168.99.2 in the provider's Network Settings, thus iOS system will send udp query to the udp socket created in step 1, and it can then do some split dns function such as resolve using local interface (cellular or wifi), or some nameserve which will be routed to the VPN tunnel (will create new UDP socket and do IP_BOUND_IF to ensure the traffic will enter the VPN tunnel), and the result should be return to the system and then the non VPP apps.
But I observer weird issue, indeed I can get the system send the dns request to the listening udp socket and I can get the result write to the system(address like 192.168.99.2:56144, the port should be allocated by the iOS system's DNS component) without any failure(I did get some error before due to I using the wrong utun if index, but fixed it later), but it seems non VPN app like browser can't get the resolved ip for domains.
I want to ask is this limited by the sandbox? or any special sock opt I need to do.
Thanks.
PS:
in the provider's network settings, all the system's traffic will be point to the utun, which means the VPN process will process all the traffic.
the reason I do not set the dns server to utun peers side which is my userspace networking stack's ip (192.168.99.1) is the stack is not be able to leverage some dns libraries due to architecture issue. (it's fd.io vpp which we ported to apple platform).
In my Packet Tunnel Provider, I'm setting the NEDNSSettings to localhost as I have a local DNS server listening on port 53 (this is a dns forwarder which conditionally forwards to different upstreams based on rules).
On iOS it works just fine, I'm able to listen on localhost:53 in the Network Extension, then set NEDNSSettings servers to "127.0.0.1".
However on macOS due to the port being under 1024, I get a Permission denied OS code 13 error. I'm assuming this is due to the Network Extension not running as root. Can this be changed?
This could be rectified if you could customize the port in NEDNSSettings, as the listener could be on port 5353, but it doesn't look like it is possible?
Just wondering if there is some other way to accomplish what I'm trying to do in the macOS Network Extension?
Our enterprise product uses a content filter, normally customers deploy MDM profiles to authorise and allow the content filter to work.
Some customers however do not use these profiles, requiring them to enable the system extension in System Settings and allow the content filter via the popup below.
If the user selects "Don't Allow", intentionally or by mistake, there does not appear to be an mechanism for them to change their mind and allow it instead.
If the user fails to enable the system extension on the first prompt, there is an option to enable if via System Settings. There doesn't seem to be a similar option if they "Don't Allow" the content filter.
How can the user allow a previously denied content filter?
Topic:
App & System Services
SubTopic:
Networking
Tags:
Extensions
System Extensions
Network Extension
In our App, we have a network extension with a NEAppPushProvider subclass running. We run the following steps
Setup a dual-band wireless router per the following:
Broadcasting 2.4 GHz and 5 GHz channels
Same SSID names for both channels
Connected to the production network to the router
DHCP assigning addresses in the 10.1.x.x network
Connect the mobile device to the 5 GHz network (if needed, turn off the 2.4 GHz network temporarily; once the device connects to the 5 GHz network, the 2.4 GHz network can be turned back on).
Create a NEAppPushManager in the App, using the SSID from the above mentioned network and set it to the matchSSIDs property. Call saveToPreferences() on the push manager to save.
A. We have UI that shows the extension has been started and it has connected to the server successfully.
Walk out of the range of the 5 GHz channel of the router, but stay within range of the 2.4ghz channel.
Wait for the mobile device to connect to the 2.4 GHz channel.
Expected:
The extension would reconnect to the 2.4ghz network.
Observed:
The extension does not reconnect. Checking the logs for the extension we see that the following was called in the push provider subclass.
stop(with:completionHandler:) > PID: 808 | 🗒️🛑 Stopped with reason 3: "noNetworkAvailable"
The expectation is that start() on the NEAppPushProvider subclass would be called. Is this an incorrect expectation?
How does the NEAppPushProvider handle same network SSID roaming among various band frequencies? I looked at the documentation and did not find any settings targeting 2.4 or 5 ghz networks. Please advise on what to do.
I've implemented a custom system extension VPN for macOS using Packet Tunnel Provider. The VPN is configured with on-demand, and a rule to always connect whenever there's traffic:
onDemandRules = [NEOnDemandRuleConnect()]
As expected, if the VPN isn't active, all traffic gets blocked until it is ready.
Not expected: In the following scenario, there is some 'traffic leak':
Use only WiFi (not wired cable)
Connect the VPN
Disable the WiFi and wait for the VPN to disconnect
Enable the WiFi
Some packets are routed outside the VPN, and aren't being blocked
Some moments after, all traffic will be blocked, and the VPN will start the 'connecting' process.
Is the above scenario a 'known' issue? Can it be a race condition in the OS, where some packets can be sent after the network is brought back before the VPN process starts? Is there any way to fix this problem?
P.S:
I'm not using flags such as 'capture all network'
Hi there!
We are working on our SkyElectric App which is being developed in Flutter framework, where we need user to connect with the Wifi of the the inverter.
We are trying to direct user to WiFi Settings page of the iOS in general settings where all the available WiFi Networks are listed but unfortunately user is being directed to App's Settings page.
We are using package of app_settings and launcher.
I've read that Apple changed a policy in 2019 where it restricts Apps to navigate to OS pages.
Question: Could you please verify if I APPLE allows us to access the General Settings or WiFi Settings through clicking a button in our App name "Open WiFi Settings", If not then Why?
I found a problem where a process tries to connect to System Extension and connection is invalidated. XPC listener has to be disposed and initialized again.
This happens when System Extension executes tasks in following order:
NSXPCListener initialized
NSXPCListener.resume()
NSProvider.startSystemExtensionMode()
Result: Connection is invalidated and not only that the client has to retry connection, nut also System Extension must reinitialize listener (execute step 1 and 2).
However if I call
NSProvider.startSystemExtensionMode()
NSXPCListener initialized
NSXPCListener.resume()
It works as expected and even if the connection is invalidated/interrupted, client process can always reconnect and no other action is necessary in System Extension (no need to reinitialize XPC listener),
In Apple docs about NSProvider.startSystemExtensionMode() it says that this method starts handling request, but in another online article written by Scott Knight I found that startSystemExtensionMode() also starts listener server. Is that right? PLease could you add this info into the docs if it is so?
https://knight.sc/reverse%20engineering/2019/08/24/system-extension-internals.html
I would like to use following logic:
Call NSProvider.startSystemExtensionMode() only under certain circumstances - I have received some configuration that I need to process and do some setup. If I don't receive it, there is no reason to call startSystemExtensionMode() yet, I don't need to handle handleNewFlow() yet.
Connect XPC client to System Extension under certain conditions. Ideally communicate with client even though System Extension is not handling network requests yet, that is without receiving handleNewFlow().
Basically I consider XPC and System Extension handling network requests as separate things. Is that correct, are they separate and independent?
Does XPC communication really depend on calling startSystemExtensionMode()?
Another potential issue: Is it possible that XPC listener fails to validate connection when client tries to connect before System Extension manages to complete init and park the main thread in CFRunLoop?
Note: These querstions arose mostly from handling upgrades of System Extension (extension is already running, network filter is created and is connected and new version of the app upgrades System Exension).
Thanks.
Our app has a network extension (as I've mentioned lots 😄). We do an upgrade by downloading the new package, stopping & removing all of our components except for the network extension, and then installing the new package, which then loads a LaunchAgent causing the containing app to run. (The only difference between a new install and upgrade is the old extension is left running, but not having anything to tell it what to do, just logs and continues.)
On some (but not all) upgrades... nothing ends up able to communicate via XPC with the Network Extension. My simplest cli program to talk to it gets
Could not create proxy: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named blah was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named bla was invalidated: failed at lookup with error 3 - No such process.}
Could not communicate with blah
Restarting the extension by doing a kill -9 doesn't fix it; neither does restarting the control daemon. The only solution we've come across so far is rebooting.
I filed FB11086599 about this, but has anyone thoughts about this?
Hi,
I built a system that can detect and block Short Form Videos like Instagram Reels and Youtube Shorts. It works by connecting the iphone to a VPN and then do statistics on network packets (no decryption).
I was wondering the feasibility of porting this to run on device.
Functionality wise I would need: packet interception, packet drop, DNS query interception.
I saw that Content filter providers could be something to look into, but then I read an article of how you would have to have a managed device which is not ideal for the end user.
New to apple development, the lack of snippets and code examples is confusing.
Dear Apple:
We encountered a problem when using the Wi-Fi connection feature. When calling the Wi-Fi connection interface NEHotspotConfigurationManager applyConfiguration, it fails probabilistically. After analyzing the air interface packets, it appears that the Apple device did not send the auth message. How should we locate this issue? Are there any points to pay attention to when calling the Wi-Fi connection interface? Thanks
Hi,
In my attempt to reconnect NEPacketTunnelProvider, when there is a network change, I am making use of self.reasserting and setTunnelNetworkSettings, and I am calling it with similar parameters as during the startTunnelWithOptions callback and making sure to make a new call for setting the includedRoutes:
NEPacketTunnelNetworkSettings.IPv4Settings.includedRoutes = @[NEIPv4Route.defaultRoute];
This works sometimes, when I switch to a new network, but most of the time the traffic flow stops and it only works when I switch back to the first network.
The only difference I could see in the routing table when it works is when there is a presence of Apple Specific network routes as follows:
17.57.145.133 link#22 UHWIig utun4
17.57.145.135 link#22 UHWIig utun4
17.57.145.137 link#22 UHWIig utun4
or
13.107.246.47 link#22 UHW3Ig utun4
17.57.145.148 link#22 UHWIig utun4
17.57.145.149 link#22 UHWIig utun4
37.252.171.52 link#22 UHWIig utun4
37.252.173.215 link#22 UHWIig utun4
Note: utun4 has index of 22
or some other combination of routes for Apple, I am not sure what these routes are for but they are present when NEPacketTunnelProvider starts.
When switching to a new network and calling setTunnelNetworkSettings of NEPacketTunnelProvider, in any case when these routes are not present the traffic flow stops and it works otherwise. Switching back the first network, brings back these routes and the traffic flow continues, although it also goes through the same setTunnelNetworkSettings call and logic.
I am not sure if these route table entries could be the culprit, because I did try to add them manually and that didn't help but my guess is that some system calls are failing for some unknown reason which might be the reason for the missing routes and some other configuration needed for proper traffic flow, which I am not seeing.
Any help or information would be greatly appreciated.
Thanks.
We have used ::gethostname to retrieve hostname in our tunnel provider extension and found it returns "localhost" on iOS 17+. So we changed to use [[NSProcessInfo processInfo] hostName]. However it often caused 30+ delay in the extension process on a few devices and always returns "localhost".
The sysdiagnose shows a lot of DNS query logs as below:
default mDNSResponder 2025-03-19 17:15:12.453769 +0800 75281: 0x11ad501 [R80937] DNSServiceCreateConnection START PID[79767](ACExtension)
default mDNSResponder 2025-03-19 17:15:12.453892 +0800 75281: 0x11ad501 [R80938] DNSServiceQueryRecord START -- qname: <mask.hash: 'fNnSAdyuhKXqCny8+neXvw=='>, qtype: PTR, flags: 0x15000, interface index: -1, client pid: 79767 (ACExtension), name hash: 84de01e1
default mDNSResponder 2025-03-19 17:15:12.458395 +0800 75281: 0x11ad501 [R80939] DNSServiceQueryRecord START -- qname: <mask.hash: '2X6qN/YT0yh2psKwrGWokg=='>, qtype: PTR, flags: 0x15000, interface index: 0, client pid: 79767 (ACExtension), name hash: f25c923e
default mDNSResponder 2025-03-19 17:15:12.462924 +0800 75281: 0x11ad501 [R80940] DNSServiceQueryRecord START -- qname: <mask.hash: 'peyRWEblLKbNvcOXPjSeMQ=='>, qtype: PTR, flags: 0x15000, interface index: 0, client pid: 79767 (ACExtension), name hash: 83323cc4