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
77c59f1b
Commit
77c59f1b
authored
Jul 10, 2018
by
Davide De Rosa
Browse files
Add local socket type for OpenVPN
nil is automatic (UDP with fallback to TCP).
parent
cfff30eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
PIA VPN/AppPreferences.swift
View file @
77c59f1b
...
...
@@ -8,6 +8,7 @@
import
Foundation
import
PIALibrary
import
PIATunnel
import
SwiftyBeaver
private
let
log
=
SwiftyBeaver
.
self
...
...
@@ -25,6 +26,8 @@ class AppPreferences {
static
let
themeCode
=
"Theme"
// reuse 2.2 key
static
let
lastVPNConnectionStatus
=
"LastVPNConnectionStatus"
static
let
piaSocketType
=
"PIASocketType"
}
static
let
shared
=
AppPreferences
()
...
...
@@ -81,6 +84,23 @@ class AppPreferences {
defaults
.
set
(
newValue
.
rawValue
,
forKey
:
Entries
.
lastVPNConnectionStatus
)
}
}
// nil = automatic
var
piaSocketType
:
PIATunnelProvider
.
SocketType
?
{
get
{
guard
let
rawValue
=
defaults
.
string
(
forKey
:
Entries
.
piaSocketType
)
else
{
return
nil
}
return
PIATunnelProvider
.
SocketType
(
rawValue
:
rawValue
)
}
set
{
if
let
rawValue
=
newValue
?
.
rawValue
{
defaults
.
set
(
rawValue
,
forKey
:
Entries
.
piaSocketType
)
}
else
{
defaults
.
removeObject
(
forKey
:
Entries
.
piaSocketType
)
}
}
}
private
init
()
{
guard
let
defaults
=
UserDefaults
(
suiteName
:
AppConstants
.
appGroup
)
else
{
...
...
@@ -124,8 +144,8 @@ class AppPreferences {
// otherwise, app version < 2.1 (local defaults/keychain)
// it used to be here in app version <= 2.0
let
oldKeychain
=
Keychain
()
let
newKeychain
=
Keychain
(
team
:
AppConstants
.
teamId
,
group
:
AppConstants
.
appGroup
)
let
oldKeychain
=
PIALibrary
.
Keychain
()
let
newKeychain
=
PIALibrary
.
Keychain
(
team
:
AppConstants
.
teamId
,
group
:
AppConstants
.
appGroup
)
// migrate credentials from local to shared keychain
if
let
legacyPassword
=
try
?
oldKeychain
.
password
(
for
:
loggedUsername
)
{
...
...
PIA VPN/Bootstrapper.swift
View file @
77c59f1b
...
...
@@ -110,15 +110,17 @@ class Bootstrapper {
// automatic
let
tunnelConfiguration
=
pref
.
vpnCustomConfiguration
(
for
:
PIATunnelProfile
.
vpnType
)
as?
PIATunnelProvider
.
Configuration
if
tunnelConfiguration
?
.
endpointProtocols
.
isEmpty
??
true
{
AppPreferences
.
shared
.
piaSocketType
=
nil
var
tunnelConfigurationBuilder
=
tunnelConfiguration
?
.
builder
()
let
vpnPorts
=
Client
.
providers
.
serverProvider
.
currentServersConfiguration
.
vpnPorts
var
protos
:
[
PIATunnelProvider
.
EndpointProtocol
]
=
[]
for
port
in
vpnPorts
.
udp
{
protos
.
append
(
PIATunnelProvider
.
EndpointProtocol
(
.
udp
,
port
,
.
pia
))
}
//
for port in vpnPorts.tcp {
//
protos.append(PIATunnelProvider.EndpointProtocol(.tcp, port, .pia))
//
}
for
port
in
vpnPorts
.
tcp
{
protos
.
append
(
PIATunnelProvider
.
EndpointProtocol
(
.
tcp
,
port
,
.
pia
))
}
tunnelConfigurationBuilder
?
.
endpointProtocols
=
protos
if
let
newConfiguration
=
tunnelConfigurationBuilder
?
.
build
()
{
pref
.
setVPNCustomConfiguration
(
newConfiguration
,
for
:
PIATunnelProfile
.
vpnType
)
...
...
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