mirror of
https://github.com/StikDebug/StikDebug.git
synced 2026-10-16 12:30:29 +00:00
Merge pull request #44 from hugeBlack/main
Don't detect wifi as we have stosvpn now
This commit is contained in:
commit
6a1142731e
1 changed files with 2 additions and 31 deletions
|
|
@ -45,14 +45,6 @@ struct HeartbeatApp: App {
|
|||
if isLoading {
|
||||
LoadingView()
|
||||
.onAppear {
|
||||
if !isConnectedToWifi() {
|
||||
showAlert(title: "Connection Required",
|
||||
message: "Please connect to WiFi to continue",
|
||||
showOk: true) { _ in
|
||||
exit(0)
|
||||
}
|
||||
return
|
||||
}
|
||||
startProxy() { result, error in
|
||||
if result {
|
||||
checkVPNConnection() { result, vpn_error in
|
||||
|
|
@ -184,7 +176,7 @@ struct HeartbeatApp: App {
|
|||
DispatchQueue.main.async {
|
||||
// Only call back if we haven't already
|
||||
if timeoutWorkItem?.isCancelled == false {
|
||||
callback(false, "[TIMEOUT] Wireguard is not connected. Try closing this app, turn Wireguard off and back on.")
|
||||
callback(false, "[TIMEOUT] The loopback VPN is not connected. Try closing this app, turn it off and back on.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -205,7 +197,7 @@ struct HeartbeatApp: App {
|
|||
connection?.cancel()
|
||||
DispatchQueue.main.async {
|
||||
if error == NWError.posix(.ETIMEDOUT) {
|
||||
callback(false, "Wireguard is not connected. Try closing the app, turn it off and back on.")
|
||||
callback(false, "The loopback VPN is not connected. Try closing the app, turn it off and back on.")
|
||||
} else if error == NWError.posix(.ECONNREFUSED) {
|
||||
callback(false, "Wifi is not connected. StikJIT won't work on cellular data.")
|
||||
} else {
|
||||
|
|
@ -225,27 +217,6 @@ struct HeartbeatApp: App {
|
|||
DispatchQueue.global().asyncAfter(deadline: .now() + 20, execute: workItem)
|
||||
}
|
||||
}
|
||||
|
||||
func isConnectedToWifi() -> Bool {
|
||||
var isWifi = false
|
||||
let monitor = NWPathMonitor(requiredInterfaceType: .wifi)
|
||||
let semaphore = DispatchSemaphore(value: 0)
|
||||
|
||||
monitor.pathUpdateHandler = { path in
|
||||
isWifi = path.status == .satisfied
|
||||
semaphore.signal()
|
||||
}
|
||||
|
||||
let queue = DispatchQueue(label: "WiFiCheckQueue")
|
||||
monitor.start(queue: queue)
|
||||
|
||||
// Wait for the result with a timeout to avoid hanging
|
||||
let result = semaphore.wait(timeout: .now() + 2)
|
||||
monitor.cancel()
|
||||
|
||||
// Return false if we timed out
|
||||
return result == .success && isWifi
|
||||
}
|
||||
}
|
||||
|
||||
var pubHeartBeat = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue