Commit abae2b05 authored by Jose Blaya's avatar Jose Blaya
Browse files

- Allow Hotspot Helper notice to be hidden

- Update quick settings label
parent 52803e24
......@@ -48,46 +48,55 @@ class PIAHotspotHelper {
*/
public func configureHotspotHelper() -> Bool {
let hotspotDisplayName = (Client.preferences.nmtRulesEnabled && Client.preferences.useWiFiProtection) ?
L10n.Hotspothelper.Display.Protected.name :
L10n.Hotspothelper.Display.name
let options: [String: NSObject] = [kNEHotspotHelperOptionDisplayName : hotspotDisplayName as NSObject]
let options: [String: NSObject] = [kNEHotspotHelperOptionDisplayName : self.hotspotHelperMessage() as NSObject]
let queue: DispatchQueue = DispatchQueue(label: "com.privateinternetaccess.hotspot", attributes: DispatchQueue.Attributes.concurrent)
NEHotspotHelper.supportedNetworkInterfaces()
return NEHotspotHelper.register(options: options,
queue: queue) { [weak self] (cmd: NEHotspotHelperCommand) in
if let weakSelf = self {
if cmd.commandType == .filterScanList {
log.info("filtering ssid list")
var availableList: [String] = []
var unsecuredList: [NEHotspotNetwork] = []
for element in cmd.networkList! {
if !element.ssid.isEmpty,
!availableList.contains(element.ssid) {
availableList.append(element.ssid)
if Client.preferences.nmtRulesEnabled {
return NEHotspotHelper.register(options: options,
queue: queue) { [weak self] (cmd: NEHotspotHelperCommand) in
if let weakSelf = self {
if cmd.commandType == .filterScanList {
log.info("filtering ssid list")
var availableList: [String] = []
var unsecuredList: [NEHotspotNetwork] = []
for element in cmd.networkList! {
if !element.ssid.isEmpty,
!availableList.contains(element.ssid) {
availableList.append(element.ssid)
}
if !element.isSecure {
element.setConfidence(.high)
unsecuredList.append(element)
}
}
if !element.isSecure {
element.setConfidence(.high)
unsecuredList.append(element)
weakSelf.saveCurrentNetworkList(availableNetworks: availableList)
let response = cmd.createResponse(NEHotspotHelperResult.success)
if !Client.providers.vpnProvider.isVPNConnected {
response.setNetworkList(unsecuredList)
log.info("present PIA message for unprotected networks")
}
response.deliver()
}
weakSelf.saveCurrentNetworkList(availableNetworks: availableList)
let response = cmd.createResponse(NEHotspotHelperResult.success)
if !Client.providers.vpnProvider.isVPNConnected {
response.setNetworkList(unsecuredList)
log.info("present PIA message for unprotected networks")
}
response.deliver()
}
}
}
} else {
return false
}
}
private func hotspotHelperMessage() -> String {
if Client.preferences.nmtRulesEnabled,
Client.preferences.useWiFiProtection {
return L10n.Hotspothelper.Display.Protected.name
} else {
return L10n.Hotspothelper.Display.name
}
}
private func saveCurrentNetworkList(availableNetworks: [String]) {
let preferences = Client.preferences.editable()
preferences.availableNetworks = availableNetworks
......
......@@ -599,7 +599,7 @@ internal enum L10n {
}
internal enum Quicksetting {
internal enum Nmt {
/// Network tool
/// Network Management
internal static let title = L10n.tr("Localizable", "tiles.quicksetting.nmt.title")
}
}
......
......@@ -219,7 +219,7 @@
"settings.hotspothelper.rules.title" = "Rules";
"settings.trusted.networks.sections.trusted.rule.description"= "Perform actions when joining trusted networks.";
"settings.trusted.networks.sections.trusted.rule.action"= "Disconnect from PIA VPN";
"tiles.quicksetting.nmt.title" = "Network tool";
"tiles.quicksetting.nmt.title" = "Network Management";
// REGION
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment