From dc91b66167611718b88a400156604f4b1aec1c14 Mon Sep 17 00:00:00 2001 From: halo Date: Fri, 9 Feb 2024 21:17:29 +0100 Subject: [PATCH] Invert scan denying setting --- LinkLiar/Classes/Config/Builder.swift | 4 ++-- .../Views/Settings/Sections/PreferencesView.swift | 12 ++++++------ LinkTools/Config/Arbiter.swift | 2 +- LinkTools/Config/General.swift | 8 ++++---- LinkTools/Config/Reader.swift | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/LinkLiar/Classes/Config/Builder.swift b/LinkLiar/Classes/Config/Builder.swift index c67e897..1f8e386 100644 --- a/LinkLiar/Classes/Config/Builder.swift +++ b/LinkLiar/Classes/Config/Builder.swift @@ -237,13 +237,13 @@ extension Config { func allowScan() -> [String: Any] { var dictionary = configDictionary - dictionary[Config.Key.scan.rawValue] = true + dictionary.removeValue(forKey: Config.Key.denyScan.rawValue) return dictionary } func denyScan() -> [String: Any] { var dictionary = configDictionary - dictionary.removeValue(forKey: Config.Key.scan.rawValue) + dictionary[Config.Key.denyScan.rawValue] = true return dictionary } diff --git a/LinkLiar/Views/Settings/Sections/PreferencesView.swift b/LinkLiar/Views/Settings/Sections/PreferencesView.swift index 5b7981a..b81ca38 100644 --- a/LinkLiar/Views/Settings/Sections/PreferencesView.swift +++ b/LinkLiar/Views/Settings/Sections/PreferencesView.swift @@ -13,8 +13,8 @@ extension SettingsView { GroupBox { HStack(alignment: .top) { - let scanPermission = Binding( - get: { state.config.general.scan }, + let allowScan = Binding( + get: { !state.config.general.denyScan }, set: { value, _ in value ? Config.Writer(state).allowScan() : Config.Writer(state).denyScan() } @@ -22,14 +22,14 @@ extension SettingsView { VStack(alignment: .leading, spacing: 3) { Text("Allow Wi-Fi Network Scanning") - if scanPermission.wrappedValue { + if allowScan.wrappedValue { Text(""" Currently, LinkLiar scans for Wi-Fi networks if you configured \ an interface to have a specific MAC depending on the presence of a Wi-Fi network SSID. \ Deactivate this, to prevent LinkLiar from ever scanning for networks. """) - .font(.caption) - .foregroundColor(.secondary) + .font(.caption) + .foregroundColor(.secondary) } else { Text(""" Currently, LinkLiar will never scan for Wi-Fi networks. \ @@ -41,7 +41,7 @@ extension SettingsView { } } Spacer() - Toggle(isOn: scanPermission) {} + Toggle(isOn: allowScan) {} .toggleStyle(.switch) .controlSize(.small) }.padding(4) diff --git a/LinkTools/Config/Arbiter.swift b/LinkTools/Config/Arbiter.swift index d39f674..1192406 100644 --- a/LinkTools/Config/Arbiter.swift +++ b/LinkTools/Config/Arbiter.swift @@ -55,7 +55,7 @@ extension Config { } var mayScan: Bool { - config.general.scan + !config.general.denyScan } var exceptionAddress: MAC? { diff --git a/LinkTools/Config/General.swift b/LinkTools/Config/General.swift index ce46d73..46552c1 100644 --- a/LinkTools/Config/General.swift +++ b/LinkTools/Config/General.swift @@ -14,7 +14,7 @@ extension Config { var dictionary: [String: Any] var isDismissingRecommendation: Bool { - guard let restriction = self.dictionary[Config.Key.recommendation.rawValue] as? Bool else { + guard let _ = self.dictionary[Config.Key.recommendation.rawValue] as? Bool else { return false } @@ -40,10 +40,10 @@ extension Config { self.dictionary[Config.Key.anonymize.rawValue] as? Bool ?? false } - /// Whether or not to scan for SSIDS on every daemon run. + /// Whether or not to scan for SSIDS on daemon synchronization runs. /// - var scan: Bool { - self.dictionary[Config.Key.scan.rawValue] as? Bool ?? false + var denyScan: Bool { + self.dictionary[Config.Key.denyScan.rawValue] as? Bool ?? false } } } diff --git a/LinkTools/Config/Reader.swift b/LinkTools/Config/Reader.swift index 2b5aac9..eeb17bc 100644 --- a/LinkTools/Config/Reader.swift +++ b/LinkTools/Config/Reader.swift @@ -94,7 +94,7 @@ extension Config { case anonymize case theDefault = "default" case except - case scan + case denyScan = "deny_scan" case skipRerandom = "skip_rerandom" case ssids case vendors