Skip to content

Commit

Permalink
Invert scan denying setting
Browse files Browse the repository at this point in the history
  • Loading branch information
halo committed Feb 9, 2024
1 parent aa04206 commit dc91b66
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions LinkLiar/Classes/Config/Builder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
12 changes: 6 additions & 6 deletions LinkLiar/Views/Settings/Sections/PreferencesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ extension SettingsView {

GroupBox {
HStack(alignment: .top) {
let scanPermission = Binding<Bool>(
get: { state.config.general.scan },
let allowScan = Binding<Bool>(
get: { !state.config.general.denyScan },
set: { value, _ in
value ? Config.Writer(state).allowScan() : Config.Writer(state).denyScan()
}
)

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. \
Expand All @@ -41,7 +41,7 @@ extension SettingsView {
}
}
Spacer()
Toggle(isOn: scanPermission) {}
Toggle(isOn: allowScan) {}
.toggleStyle(.switch)
.controlSize(.small)
}.padding(4)
Expand Down
2 changes: 1 addition & 1 deletion LinkTools/Config/Arbiter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extension Config {
}

var mayScan: Bool {
config.general.scan
!config.general.denyScan
}

var exceptionAddress: MAC? {
Expand Down
8 changes: 4 additions & 4 deletions LinkTools/Config/General.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}
}
}
2 changes: 1 addition & 1 deletion LinkTools/Config/Reader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dc91b66

Please sign in to comment.