IfaceScanner: used the user specified IP to directly test if device is available there instead of assuming it to be under the subnet of tunnel coz it is fake endpoint interceptable by the tunnel's included routes

This commit is contained in:
mahee96
2026-03-03 03:23:00 +05:30
parent 0837f82a69
commit c4139473fa
2 changed files with 14 additions and 26 deletions

View File

@@ -15,8 +15,6 @@ struct VPNConfigurationView: View {
@Environment(\.presentationMode) var presentationMode @Environment(\.presentationMode) var presentationMode
@StateObject private var config = TunnelConfig.shared @StateObject private var config = TunnelConfig.shared
@State private var showNetworkWarning = false
var body: some View { var body: some View {
List { List {
Section(header: Text("Discovered from network")) { Section(header: Text("Discovered from network")) {
@@ -42,19 +40,10 @@ struct VPNConfigurationView: View {
} footer: { } footer: {
HStack(alignment: .top, spacing: 0) { HStack(alignment: .top, spacing: 0) {
Text("Note: ") Text("Note: ")
Text("if the override configuration is invalid or unusable SideStore may use auto-discovered configuration as fallback") Text("if override configuration is invalid or unusable SideStore may use auto-discovered configuration as fallback")
} }
} }
} }
.alert(isPresented: $showNetworkWarning) {
Alert(
title: Text("Warning"),
message: Text("Changing tunnel IP settings can disrupt your network connection. Proceed only if you are sure of what you are doing."),
dismissButton: .cancel(Text("I Understand")) {
config.shownTunnelAlert = true
}
)
}
.navigationTitle("VPN Configuration") .navigationTitle("VPN Configuration")
.toolbar { .toolbar {
ToolbarItem(placement: .topBarTrailing) { ToolbarItem(placement: .topBarTrailing) {
@@ -96,11 +85,6 @@ struct VPNConfigurationView: View {
.keyboardType(.numbersAndPunctuation) .keyboardType(.numbersAndPunctuation)
.onChange(of: proxy.wrappedValue) { newValue in .onChange(of: proxy.wrappedValue) { newValue in
guard editable else { return } guard editable else { return }
if !config.shownTunnelAlert {
showNetworkWarning = true
}
proxy.wrappedValue = proxy.wrappedValue =
newValue.filter { "0123456789.".contains($0) } newValue.filter { "0123456789.".contains($0) }
} }
@@ -113,21 +97,25 @@ final class TunnelConfig: ObservableObject {
static let shared = TunnelConfig() static let shared = TunnelConfig()
private static let defaultOverrideIP: String = {
if #available(iOS 26.4, *) { return "192.168.1.50" }
return "10.7.0.1"
}()
@Published var deviceIP: String? @Published var deviceIP: String?
@Published var subnetMask: String? @Published var subnetMask: String?
@Published var fakeIP: String? @Published var fakeIP: String?
@Published var overrideFakeIP: String = UserDefaults.standard.string(forKey: "TunnelOverrideFakeIP") ?? "10.7.0.1" { @Published var overrideFakeIP: String = overrideIPStorage {
didSet { UserDefaults.standard.set(overrideFakeIP, forKey: "TunnelOverrideFakeIP") } didSet { Self.overrideIPStorage = overrideFakeIP }
} }
@Published var overrideEffective: Bool = false @Published var overrideEffective: Bool = false
var overrideActive: String { private static var overrideIPStorage: String {
((fakeIP?.isEmpty == false) && !overrideFakeIP.isEmpty && fakeIP == overrideFakeIP) ? "Yes" : "No" get { UserDefaults.standard.string(forKey: "TunnelOverrideFakeIP") ?? defaultOverrideIP }
set { UserDefaults.standard.set(newValue, forKey: "TunnelOverrideFakeIP") }
} }
@Published var shownTunnelAlert: Bool = UserDefaults.standard.bool(forKey: "shownTunnelAlert") { var overrideActive: String { overrideEffective ? "Yes" : "No" }
didSet { UserDefaults.standard.set(shownTunnelAlert, forKey: "shownTunnelAlert") }
}
func commitFakeIP() { func commitFakeIP() {
fakeIP = overrideFakeIP fakeIP = overrideFakeIP