Ap Isolation check only when opening troubleshooting

This commit is contained in:
Leon Böttger committed 2025-05-18 12:22:34 +02:00
1 parent 3ccb41ae0f
commit 711519ded5
5 files changed
+67 -93

No files matched your search

+2 -2
View File
@@ -825,7 +825,7 @@
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SHARED_BUILD = 37;
SHARED_BUILD = 38;
SHARED_VERSION = 1.9;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -884,7 +884,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
SHARED_BUILD = 37;
SHARED_BUILD = 38;
SHARED_VERSION = 1.9;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
@@ -34,6 +34,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = "en"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
+2 -38
View File
@@ -93,30 +93,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
}
UNUserNotificationCenter.current().delegate = self
let monitor = NWPathMonitor()
monitor.pathUpdateHandler = { path in
if path.status == .satisfied {
if path.supportsIPv4 && !path.supportsIPv6 {
log("Detected IPv4-only network.")
self.performDeviceToDeviceCheck()
} else if !path.supportsIPv4 && path.supportsIPv6 {
log("IPv6-only network, likely iPhone hotspot. Skipping device-to-device check.")
} else if path.supportsIPv4 && path.supportsIPv6 {
log("Detected Dual stack network.")
self.performDeviceToDeviceCheck()
} else {
log("Detected no IP support")
}
} else {
log("Network unavailable")
}
monitor.cancel()
}
let queue = DispatchQueue(label: "NetworkMonitor")
monitor.start(queue: queue)
hasConnectionMonitor.pathUpdateHandler = { path in
DispatchQueue.main.async {
@@ -141,20 +117,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
log("✅ Device-to-device likely allowed (peer responded on LAN).")
self.apIsolationAlertWindow?.close()
} else {
log("❌ First check failed. Retrying in 10 seconds...")
DispatchQueue.main.asyncAfter(deadline: .now() + 10) {
scanner.scan { allowed in
if allowed {
log("✅ Device-to-device likely allowed (peer responded on LAN).")
self.apIsolationAlertWindow?.close()
} else {
log("❌ Second check failed. Informing user...")
self.openAlert(type: .ApIsolation)
}
}
}
log("❌ Device-to-device check failed. Informing user...")
self.openAlert(type: .ApIsolation)
}
}
}
+59 -53
View File
@@ -25,70 +25,76 @@ struct IssueView: View {
@State var isLoading = false
var body: some View {
let imageSize = 120.0
ScrollView {
ZStack {
ZStack {
if colorScheme == .light {
Color.gray.opacity(0.1)
}
else {
Color.black.opacity(0.2)
}
Image(image)
.resizable()
.frame(width: imageSize, height: imageSize)
.overlay(
Image(systemName: "exclamationmark.circle.fill")
.font(.system(size: imageSize * 0.2))
.background(Circle().foregroundColor(.white))
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomTrailing)
.foregroundColor(.red)
.padding(imageSize * 0.09)
.padding(.trailing, image == .filter ? 15 : 0)
.padding(.bottom, imageSize * 0.03)
)
.padding(.vertical)
if colorScheme == .light {
Color.white
}
.padding(.bottom, 20)
Text(header)
.font(.title2)
.fontWeight(.bold)
.multilineTextAlignment(.center)
Text(description)
.fixedSize(horizontal: false, vertical: true)
.opacity(0.7)
.padding()
if let actionLabel = actionLabel, let action = action {
Button(actionLabel) {
let imageSize = 120.0
ScrollView {
ZStack {
withAnimation {
isLoading = true
if colorScheme == .light {
Color.gray.opacity(0.1)
}
else {
Color.black.opacity(0.2)
}
Task {
await action()
Image(image)
.resizable()
.frame(width: imageSize, height: imageSize)
.overlay(
Image(systemName: "exclamationmark.circle.fill")
.font(.system(size: imageSize * 0.2))
.background(Circle().foregroundColor(.white))
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomTrailing)
.foregroundColor(.red)
.padding(imageSize * 0.09)
.padding(.trailing, image == .filter ? 15 : 0)
.padding(.bottom, imageSize * 0.03)
)
.padding(.vertical)
}
.padding(.bottom, 20)
Text(header)
.font(.title2)
.fontWeight(.bold)
.multilineTextAlignment(.center)
Text(description)
.fixedSize(horizontal: false, vertical: true)
.opacity(0.7)
.padding()
if let actionLabel = actionLabel, let action = action {
Button(actionLabel) {
withAnimation {
isLoading = false
isLoading = true
}
Task {
await action()
withAnimation {
isLoading = false
}
}
}
}
.opacity(isLoading ? 0 : 1)
.overlay(
ProgressView()
.opacity(isLoading ? 1 : 0)
.scaleEffect(0.7)
.opacity(isLoading ? 0 : 1)
.overlay(
ProgressView()
.opacity(isLoading ? 1 : 0)
.scaleEffect(0.7)
)
.padding(.bottom, 30)
.padding(.bottom, 30)
}
}
}
}
+3
View File
@@ -93,6 +93,9 @@ struct WelcomeScreen: View {
case .troubleshooting:
TutorialView(title: "Troubleshooting", text: "TroubleshootingDescription", showsLicense: false, openIAP: openPlusScreen)
.onAppear {
checkForNetworkIssues()
}
case .app:
TutorialView(title: "AndroidApp", text: "AndroidAppDescription", showsLicense: false, showsBetaJoinButton: true, openIAP: openPlusScreen)