Skip to content

Commit

Permalink
Merge pull request #140 from openziti/dh_dev
Browse files Browse the repository at this point in the history
macOS TestFlight restarts
  • Loading branch information
smilindave26 authored Apr 6, 2023
2 parents 2a02085 + fedd7eb commit 32ad3f2
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
run: |
mvers=$(agvtool mvers -terse1)
app="${{ steps.get_app_info.outputs.apple_id }}"
url="https://api.appstoreconnect.apple.com/v1/builds?filter[app]=${app}&fields[builds]=version&filter[preReleaseVersion.version]=${mvers}&limit=1"
url="https://api.appstoreconnect.apple.com/v1/builds?filter[app]=${app}&fields[builds]=version&limit=1"
acs_vers=$(curl -g -s -H "Authorization: Bearer ${bearer}" "${url}" | jq '.data[].attributes.version|tonumber')
echo "ACS Vers: ${acs_vers}"
curr=$([[ -z "${acs_vers}" ]] && echo ${steps.get_app_info.outputs.version_number} || echo ${acs_vers})
Expand Down
52 changes: 35 additions & 17 deletions Common/TunnelMgr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,26 @@ class TunnelMgr: NSObject {
}
}

func prefReloadHack(_ tpm: NETunnelProviderManager) {
tpm.saveToPreferences { error in
if let error = error {
zLog.error(error.localizedDescription)
} else {
zLog.info("Saved successfully. Re-loading preferences")
// ios hack per apple forums (else NEVPNErrorDomain Code=1 on starting tunnel)
tpm.loadFromPreferences { [weak tpm] error in
zLog.error("Re-loaded preferences, error=\(error != nil). Attempting to start")
do {
zLog.info("Attempting to start tunnel after load from preferences")
try (tpm?.connection as? NETunnelProviderSession)?.startTunnel()
} catch {
zLog.error("Failed starting tunnel after re-enabling. \(error.localizedDescription)")
}
}
}
}
}

func startTunnel() throws {
guard let tpm = self.tpm else {
zLog.error("Unable to access TPM")
Expand All @@ -172,26 +192,24 @@ class TunnelMgr: NSObject {
}
zLog.info("starting tunnel")
try tps.startTunnel()
} else {
zLog.warn("startTunnel - tunnel not enabled. Re-enabling and starting tunnel")
tpm.isEnabled = true
tpm.saveToPreferences { error in
if let error = error {
zLog.error(error.localizedDescription)
} else {
zLog.info("Saved successfully. Re-loading preferences")
// ios hack per apple forums (else NEVPNErrorDomain Code=1 on starting tunnel)
tpm.loadFromPreferences { [weak tpm] error in
zLog.error("Re-loaded preferences, error=\(error != nil). Attempting to start")
do {
zLog.info("Attempting to start tunnel after load from preferences")
try (tpm?.connection as? NETunnelProviderSession)?.startTunnel()
} catch {
zLog.error("Failed starting tunnel after re-enabling. \(error.localizedDescription)")
}
zLog.info("start tunnel called with no error")

if #available(iOS 16, *), #available(macOS 13, *) {
tps.fetchLastDisconnectError { err in
guard let err = err else {
zLog.info("No lastDisconnect error found")
return
}
zLog.error("lastDisconnectError: \(err.localizedDescription)")

zLog.info("Attempting reload prefs hack")
self.prefReloadHack(tpm)
}
}
} else {
zLog.warn("startTunnel - tunnel not enabled. Re-enabling and starting tunnel")
tpm.isEnabled = true
self.prefReloadHack(tpm)
}
}

Expand Down
2 changes: 1 addition & 1 deletion MobilePacketTunnelProvider/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>2.29</string>
<string>2.30</string>
<key>CFBundleVersion</key>
<string>0</string>
<key>NSExtension</key>
Expand Down
2 changes: 1 addition & 1 deletion MobileShare/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>2.29</string>
<string>2.30</string>
<key>CFBundleVersion</key>
<string>0</string>
<key>NSExtension</key>
Expand Down
2 changes: 1 addition & 1 deletion PacketTunnelProvider/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>2.29</string>
<string>2.30</string>
<key>CFBundleVersion</key>
<string>0</string>
<key>LSMinimumSystemVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion ZitiMobilePacketTunnel/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.29</string>
<string>2.30</string>
<key>CFBundleVersion</key>
<string>0</string>
<key>LSRequiresIPhoneOS</key>
Expand Down
2 changes: 1 addition & 1 deletion ZitiPacketTunnel/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.29</string>
<string>2.30</string>
<key>CFBundleVersion</key>
<string>0</string>
<key>LSApplicationCategoryType</key>
Expand Down

0 comments on commit 32ad3f2

Please sign in to comment.