Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
liberty
tunnel
liberty-tunnel-ios
Commits
b5935524
Commit
b5935524
authored
Dec 20, 2018
by
Jose Blaya
Browse files
- Added - icon to remove a trusted network tapping the cell
- Refactor
parent
4672ba67
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
PIA VPN.xcodeproj/project.pbxproj
View file @
b5935524
This diff is collapsed.
Click to expand it.
PIA VPN/Images.xcassets/icon-remove.imageset/Contents.json
0 → 100644
View file @
b5935524
{
"images"
:
[
{
"idiom"
:
"universal"
,
"filename"
:
"rectangleCopy3.pdf"
}
],
"info"
:
{
"version"
:
1
,
"author"
:
"xcode"
}
}
\ No newline at end of file
PIA VPN/Images.xcassets/icon-remove.imageset/rectangleCopy3.pdf
0 → 100644
View file @
b5935524
File added
PIA VPN/PIAHotspotHelper.swift
View file @
b5935524
...
...
@@ -47,7 +47,12 @@ class PIAHotspotHelper {
- Returns: true if correctly configured.
*/
public
func
configureHotspotHelper
()
->
Bool
{
let
options
:
[
String
:
NSObject
]
=
[
kNEHotspotHelperOptionDisplayName
:
L10n
.
Hotspothelper
.
Display
.
name
as
NSObject
]
let
hotspotDisplayName
=
Client
.
preferences
.
useWiFiProtection
?
L10n
.
Hotspothelper
.
Display
.
Protected
.
name
:
L10n
.
Hotspothelper
.
Display
.
name
let
options
:
[
String
:
NSObject
]
=
[
kNEHotspotHelperOptionDisplayName
:
hotspotDisplayName
as
NSObject
]
let
queue
:
DispatchQueue
=
DispatchQueue
(
label
:
"com.privateinternetaccess.hotspot"
,
attributes
:
DispatchQueue
.
Attributes
.
concurrent
)
NEHotspotHelper
.
supportedNetworkInterfaces
()
return
NEHotspotHelper
.
register
(
options
:
options
,
...
...
@@ -59,7 +64,8 @@ class PIAHotspotHelper {
var
availableList
:
[
String
]
=
[]
var
unsecuredList
:
[
NEHotspotNetwork
]
=
[]
for
element
in
cmd
.
networkList
!
{
if
!
element
.
ssid
.
isEmpty
{
if
!
element
.
ssid
.
isEmpty
,
!
availableList
.
contains
(
element
.
ssid
)
{
availableList
.
append
(
element
.
ssid
)
}
if
!
element
.
isSecure
{
...
...
@@ -75,20 +81,19 @@ class PIAHotspotHelper {
}
response
.
deliver
()
}
else
if
cmd
.
commandType
==
.
evaluate
{
if
let
network
=
cmd
.
network
{
if
let
network
=
cmd
.
network
,
Client
.
preferences
.
useWiFiProtection
{
if
!
Client
.
providers
.
vpnProvider
.
isVPNConnected
{
if
((
Client
.
preferences
.
shouldConnectWithUnsecuredNetworks
&&
!
network
.
isSecure
)
||
Client
.
preferences
.
shouldConnectForAllNetworks
||
!
weakSelf
.
trustedNetworks
()
.
contains
(
network
.
ssid
))
{
if
Client
.
preferences
.
shouldConnectForAllNetworks
||
!
weakSelf
.
trustedNetworks
()
.
contains
(
network
.
ssid
)
{
network
.
setConfidence
(
.
high
)
//Connect the VPN
if
!
Client
.
providers
.
vpnProvider
.
isVPNConnected
{
Macros
.
dispatch
(
after
:
.
milliseconds
(
200
))
{
log
.
info
(
"connecting VPN because network "
+
network
.
ssid
+
"has passed the filter"
)
Client
.
providers
.
vpnProvider
.
connect
(
nil
)
}
Macros
.
dispatch
(
after
:
.
milliseconds
(
200
))
{
log
.
info
(
"connecting VPN because network "
+
network
.
ssid
+
"has passed the filter"
)
Client
.
providers
.
vpnProvider
.
connect
(
nil
)
}
}
let
response
=
cmd
.
createResponse
(
.
success
)
...
...
PIA VPN/SettingsViewController.swift
View file @
b5935524
...
...
@@ -41,8 +41,6 @@ enum Setting: Int {
case
automaticReconnection
case
trustedNetworks
case
shouldConnectWithUnsecuredNetworks
case
contentBlockerState
...
...
@@ -131,8 +129,7 @@ class SettingsViewController: AutolayoutViewController {
],
.
applicationSettings
:
[],
// dynamic
.
autoConnectSettings
:
[
.
trustedNetworks
,
.
shouldConnectWithUnsecuredNetworks
,
.
trustedNetworks
],
.
contentBlocker
:
[
.
contentBlockerState
,
...
...
@@ -161,8 +158,6 @@ class SettingsViewController: AutolayoutViewController {
private
lazy
var
switchAutoJoinWiFi
=
UISwitch
()
private
lazy
var
switchAutoJoinAllNetworks
=
UISwitch
()
private
lazy
var
switchPersistent
=
UISwitch
()
private
lazy
var
switchMACE
=
UISwitch
()
...
...
@@ -227,8 +222,6 @@ class SettingsViewController: AutolayoutViewController {
tableView
.
estimatedSectionFooterHeight
=
1.0
}
switchPersistent
.
addTarget
(
self
,
action
:
#selector(
togglePersistentConnection(_:)
)
,
for
:
.
valueChanged
)
switchAutoJoinWiFi
.
addTarget
(
self
,
action
:
#selector(
toggleAutoconnectWithUnsecuredNetworks(_:)
)
,
for
:
.
valueChanged
)
switchAutoJoinAllNetworks
.
addTarget
(
self
,
action
:
#selector(
toggleAutoconnectWithAllNetworks(_:)
)
,
for
:
.
valueChanged
)
switchMACE
.
addTarget
(
self
,
action
:
#selector(
toggleMACE(_:)
)
,
for
:
.
valueChanged
)
// switchContentBlocker.isGrayed = true
switchContentBlocker
.
addTarget
(
self
,
action
:
#selector(
showContentBlockerTutorial
)
,
for
:
.
touchUpInside
)
...
...
@@ -275,18 +268,6 @@ class SettingsViewController: AutolayoutViewController {
reportUpdatedPreferences
()
}
@objc
private
func
toggleAutoconnectWithUnsecuredNetworks
(
_
sender
:
UISwitch
)
{
pendingPreferences
.
shouldConnectWithUnsecuredNetworks
=
sender
.
isOn
redisplaySettings
()
reportUpdatedPreferences
()
}
@objc
private
func
toggleAutoconnectWithAllNetworks
(
_
sender
:
UISwitch
)
{
pendingPreferences
.
shouldConnectForAllNetworks
=
sender
.
isOn
redisplaySettings
()
reportUpdatedPreferences
()
}
@objc
private
func
toggleMACE
(
_
sender
:
UISwitch
)
{
pendingPreferences
.
mace
=
sender
.
isOn
redisplaySettings
()
...
...
@@ -491,6 +472,7 @@ class SettingsViewController: AutolayoutViewController {
pendingPreferences
.
trustedNetworks
=
Client
.
preferences
.
trustedNetworks
pendingPreferences
.
availableNetworks
=
Client
.
preferences
.
availableNetworks
pendingPreferences
.
shouldConnectForAllNetworks
=
Client
.
preferences
.
shouldConnectForAllNetworks
pendingPreferences
.
useWiFiProtection
=
Client
.
preferences
.
useWiFiProtection
pendingPreferences
.
commit
()
}
...
...
@@ -779,13 +761,6 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate {
cell
.
accessoryView
=
switchPersistent
cell
.
selectionStyle
=
.
none
switchPersistent
.
isOn
=
pendingPreferences
.
isPersistentConnection
case
.
shouldConnectWithUnsecuredNetworks
:
cell
.
textLabel
?
.
text
=
L10n
.
Settings
.
Hotspothelper
.
title
cell
.
detailTextLabel
?
.
text
=
nil
cell
.
accessoryView
=
switchAutoJoinWiFi
cell
.
selectionStyle
=
.
none
switchAutoJoinWiFi
.
isOn
=
pendingPreferences
.
shouldConnectWithUnsecuredNetworks
case
.
mace
:
cell
.
textLabel
?
.
text
=
L10n
.
Settings
.
ApplicationSettings
.
Mace
.
title
...
...
@@ -839,8 +814,10 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate {
cell
.
detailTextLabel
?
.
text
=
nil
case
.
trustedNetworks
:
cell
.
textLabel
?
.
text
=
L10n
.
Settings
.
Hotspothelper
.
trustedNetworks
cell
.
detailTextLabel
?
.
text
=
nil
cell
.
textLabel
?
.
text
=
L10n
.
Settings
.
Hotspothelper
.
title
cell
.
detailTextLabel
?
.
text
=
Client
.
preferences
.
useWiFiProtection
?
L10n
.
Global
.
enabled
:
L10n
.
Global
.
disabled
}
...
...
PIA VPN/SwiftGen+Assets.swift
View file @
b5935524
...
...
@@ -281,6 +281,7 @@ enum Asset {
static
let
iconLogout
=
ImageAsset
(
name
:
"icon-logout"
)
static
let
iconPrivacy
=
ImageAsset
(
name
:
"icon-privacy"
)
static
let
iconRegion
=
ImageAsset
(
name
:
"icon-region"
)
static
let
iconRemove
=
ImageAsset
(
name
:
"icon-remove"
)
static
let
iconSelectedWhite
=
ImageAsset
(
name
:
"icon-selected-white"
)
static
let
iconSelected
=
ImageAsset
(
name
:
"icon-selected"
)
static
let
iconSettings
=
ImageAsset
(
name
:
"icon-settings"
)
...
...
@@ -538,6 +539,7 @@ enum Asset {
iconLogout
,
iconPrivacy
,
iconRegion
,
iconRemove
,
iconSelectedWhite
,
iconSelected
,
iconSettings
,
...
...
PIA VPN/SwiftGen+Strings.swift
View file @
b5935524
...
...
@@ -178,8 +178,12 @@ internal enum L10n {
internal
static
let
clear
=
L10n
.
tr
(
"Localizable"
,
"global.clear"
)
/// Close
internal
static
let
close
=
L10n
.
tr
(
"Localizable"
,
"global.close"
)
/// Disabled
internal
static
let
disabled
=
L10n
.
tr
(
"Localizable"
,
"global.disabled"
)
/// Edit
internal
static
let
edit
=
L10n
.
tr
(
"Localizable"
,
"global.edit"
)
/// Enabled
internal
static
let
enabled
=
L10n
.
tr
(
"Localizable"
,
"global.enabled"
)
/// Error
internal
static
let
error
=
L10n
.
tr
(
"Localizable"
,
"global.error"
)
/// OK
...
...
@@ -194,8 +198,12 @@ internal enum L10n {
internal
enum
Hotspothelper
{
internal
enum
Display
{
/// 🛡
Open Network: Use PIA for Prot
ection.
/// 🛡
Activate VPN WiFi Protection in PIA Settings to secure this conn
ection.
internal
static
let
name
=
L10n
.
tr
(
"Localizable"
,
"hotspothelper.display.name"
)
internal
enum
Protected
{
/// 🛡 PIA VPN WiFi Protection Enabled - We got your back.
internal
static
let
name
=
L10n
.
tr
(
"Localizable"
,
"hotspothelper.display.protected.name"
)
}
}
}
...
...
@@ -440,18 +448,30 @@ internal enum L10n {
}
}
internal
enum
Hotspothelper
{
/// VPN WiFi Protection automatically
connect
s the VPN when connecting to
an Open
network.
/// VPN WiFi Protection automatically
engage
s the VPN when connecting to
untrusted
network
s
.
internal
static
let
description
=
L10n
.
tr
(
"Localizable"
,
"settings.hotspothelper.description"
)
/// VPN WiFi Protection
internal
static
let
title
=
L10n
.
tr
(
"Localizable"
,
"settings.hotspothelper.title"
)
/// Trusted networks
internal
static
let
trustedNetworks
=
L10n
.
tr
(
"Localizable"
,
"settings.hotspothelper.trustedNetworks"
)
internal
enum
All
{
///
Automatically connect for all WiFi
networks.
///
VPN WiFi Protection will activate on all networks, including trusted
networks.
internal
static
let
description
=
L10n
.
tr
(
"Localizable"
,
"settings.hotspothelper.all.description"
)
///
Connect for all
///
Protect all networks
internal
static
let
title
=
L10n
.
tr
(
"Localizable"
,
"settings.hotspothelper.all.title"
)
}
internal
enum
Available
{
/// To populate this list go to iOS Settings > WiFi.
internal
static
let
help
=
L10n
.
tr
(
"Localizable"
,
"settings.hotspothelper.available.help"
)
internal
enum
Add
{
/// Tap + to add to Trusted networks.
internal
static
let
help
=
L10n
.
tr
(
"Localizable"
,
"settings.hotspothelper.available.add.help"
)
}
}
internal
enum
Enable
{
/// VPN WiFi Protection automatically enables the VPN when connecting to untrusted networks.
internal
static
let
description
=
L10n
.
tr
(
"Localizable"
,
"settings.hotspothelper.enable.description"
)
}
}
internal
enum
Reset
{
/// This will reset all of the above settings to default.
...
...
@@ -472,7 +492,7 @@ internal enum L10n {
}
}
internal
enum
TrustedNetworks
{
///
Trusted networks are networks to automatically join blablabla
///
PIA won't automatically connect on these networks.
internal
static
let
message
=
L10n
.
tr
(
"Localizable"
,
"settings.trustedNetworks.message"
)
internal
enum
Sections
{
/// Available networks
...
...
PIA VPN/TrustedNetworksViewController.swift
View file @
b5935524
...
...
@@ -16,13 +16,15 @@ class TrustedNetworksViewController: AutolayoutViewController {
private
var
trustedNetworks
:
[
String
]
=
[]
private
let
currentNetwork
:
String
?
=
nil
private
var
hotspotHelper
:
PIAHotspotHelper
!
private
lazy
var
switchWiFiProtection
=
UISwitch
()
private
lazy
var
switchAutoJoinAllNetworks
=
UISwitch
()
private
enum
Sections
:
Int
,
EnumsBuilder
{
case
current
=
0
case
useVpnWifiProtection
=
0
case
autoConnectAllNetworksSettings
case
current
case
available
case
trusted
case
autoConnectAllNetworksSettings
}
private
struct
Cells
{
...
...
@@ -31,9 +33,10 @@ class TrustedNetworksViewController: AutolayoutViewController {
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
self
.
title
=
L10n
.
Settings
.
TrustedNetworks
.
Sections
.
trusted
self
.
title
=
L10n
.
Settings
.
Hotspothelper
.
title
self
.
hotspotHelper
=
PIAHotspotHelper
(
withDelegate
:
self
)
self
.
switchAutoJoinAllNetworks
.
addTarget
(
self
,
action
:
#selector(
toggleAutoconnectWithAllNetworks(_:)
)
,
for
:
.
valueChanged
)
self
.
switchWiFiProtection
.
addTarget
(
self
,
action
:
#selector(
toggleUseWiFiProtection(_:)
)
,
for
:
.
valueChanged
)
configureTableView
()
}
...
...
@@ -66,6 +69,13 @@ class TrustedNetworksViewController: AutolayoutViewController {
preferences
.
commit
()
}
@objc
private
func
toggleUseWiFiProtection
(
_
sender
:
UISwitch
)
{
let
preferences
=
Client
.
preferences
.
editable
()
preferences
.
useWiFiProtection
=
sender
.
isOn
preferences
.
commit
()
filterAvailableNetworks
()
}
// MARK: Private Methods
private
func
configureTableView
()
{
if
#available(iOS 11, *)
{
...
...
@@ -87,28 +97,36 @@ class TrustedNetworksViewController: AutolayoutViewController {
extension
TrustedNetworksViewController
:
UITableViewDelegate
,
UITableViewDataSource
{
func
numberOfSections
(
in
tableView
:
UITableView
)
->
Int
{
return
Sections
.
countCases
()
return
Client
.
preferences
.
useWiFiProtection
?
Sections
.
countCases
()
:
1
}
func
tableView
(
_
tableView
:
UITableView
,
titleForHeaderInSection
section
:
Int
)
->
String
?
{
switch
Sections
.
objectIdentifyBy
(
index
:
section
)
{
case
.
useVpnWifiProtection
:
return
L10n
.
Settings
.
Hotspothelper
.
title
.
uppercased
()
case
.
current
:
return
L10n
.
Settings
.
TrustedNetworks
.
Sections
.
current
.
uppercased
()
case
.
available
:
return
L10n
.
Settings
.
TrustedNetworks
.
Sections
.
available
.
uppercased
()
case
.
trusted
:
return
L10n
.
Settings
.
TrustedNetworks
.
Sections
.
trusted
.
uppercased
()
case
.
autoConnectAllNetworksSettings
:
default
:
return
nil
}
}
func
tableView
(
_
tableView
:
UITableView
,
titleForFooterInSection
section
:
Int
)
->
String
?
{
switch
Sections
.
objectIdentifyBy
(
index
:
section
)
{
case
.
useVpnWifiProtection
:
return
L10n
.
Settings
.
Hotspothelper
.
Enable
.
description
case
.
trusted
:
return
L10n
.
Settings
.
TrustedNetworks
.
message
case
.
autoConnectAllNetworksSettings
:
return
L10n
.
Settings
.
Hotspothelper
.
All
.
description
case
.
available
:
return
availableNetworks
.
isEmpty
?
L10n
.
Settings
.
Hotspothelper
.
Available
.
help
:
L10n
.
Settings
.
Hotspothelper
.
Available
.
Add
.
help
default
:
return
nil
}
...
...
@@ -122,7 +140,7 @@ extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSou
return
availableNetworks
.
count
case
.
trusted
:
return
trustedNetworks
.
count
case
.
autoConnectAllNetworksSettings
:
default
:
return
1
}
}
...
...
@@ -149,6 +167,7 @@ extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSou
cell
.
accessoryView
=
UIImageView
(
image
:
Asset
.
iconAdd
.
image
)
cell
.
textLabel
?
.
text
=
availableNetworks
[
indexPath
.
row
]
case
.
trusted
:
cell
.
accessoryView
=
UIImageView
(
image
:
Asset
.
iconRemove
.
image
)
cell
.
selectionStyle
=
.
none
cell
.
textLabel
?
.
text
=
trustedNetworks
[
indexPath
.
row
]
case
.
autoConnectAllNetworksSettings
:
...
...
@@ -157,6 +176,13 @@ extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSou
cell
.
accessoryView
=
switchAutoJoinAllNetworks
cell
.
selectionStyle
=
.
none
switchAutoJoinAllNetworks
.
isOn
=
Client
.
preferences
.
shouldConnectForAllNetworks
case
.
useVpnWifiProtection
:
cell
.
imageView
?
.
image
=
nil
cell
.
textLabel
?
.
text
=
L10n
.
Global
.
enabled
cell
.
accessoryView
=
switchWiFiProtection
cell
.
selectionStyle
=
.
none
switchWiFiProtection
.
isOn
=
Client
.
preferences
.
useWiFiProtection
}
Theme
.
current
.
applySolidLightBackground
(
cell
)
...
...
@@ -175,6 +201,9 @@ extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSou
case
.
available
:
let
ssid
=
availableNetworks
[
indexPath
.
row
]
hotspotHelper
.
saveTrustedNetwork
(
ssid
)
case
.
trusted
:
let
ssid
=
trustedNetworks
[
indexPath
.
row
]
hotspotHelper
.
removeTrustedNetwork
(
ssid
)
default
:
break
}
...
...
PIA VPN/en.lproj/Localizable.strings
View file @
b5935524
...
...
@@ -10,6 +10,8 @@
"global.clear" = "Clear";
"global.update" = "Update";
"global.edit" = "Edit";
"global.enabled" = "Enabled";
"global.disabled" = "Disabled";
// NOTIFICATIONS
...
...
@@ -200,12 +202,16 @@
// HOTSPOT HELPER
"settings.hotspothelper.title" = "VPN WiFi Protection";
"settings.hotspothelper.description" = "VPN WiFi Protection automatically connects the VPN when connecting to an Open network.";
"settings.hotspothelper.all.title" = "Connect for all";
"settings.hotspothelper.all.description" = "Automatically connect for all WiFi networks.";
"settings.hotspothelper.description" = "VPN WiFi Protection automatically engages the VPN when connecting to untrusted networks.";
"settings.hotspothelper.enable.description" = "VPN WiFi Protection automatically enables the VPN when connecting to untrusted networks.";
"settings.hotspothelper.all.title" = "Protect all networks";
"settings.hotspothelper.all.description" = "VPN WiFi Protection will activate on all networks, including trusted networks.";
"settings.hotspothelper.trustedNetworks" = "Trusted networks";
"settings.hotspothelper.available.help" = "To populate this list go to iOS Settings > WiFi.";
"settings.hotspothelper.available.add.help" = "Tap + to add to Trusted networks.";
"settings.trustedNetworks.sections.current" = "Current network";
"settings.trustedNetworks.sections.available" = "Available networks";
"settings.trustedNetworks.sections.trusted" = "Trusted networks";
"settings.trustedNetworks.message" = "Trusted networks are networks to automatically join blablabla";
"hotspothelper.display.name" = "🛡 Open Network: Use PIA for Protection.";
"settings.trustedNetworks.message" = "PIA won't automatically connect on these networks.";
"hotspothelper.display.name" = "🛡 Activate VPN WiFi Protection in PIA Settings to secure this connection.";
"hotspothelper.display.protected.name" = "🛡 PIA VPN WiFi Protection Enabled - We got your back.";
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment