Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
L
liberty-tunnel-client-library-apple
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liberty
tunnel
liberty-tunnel-client-library-apple
Commits
721386fe
Commit
721386fe
authored
Nov 05, 2020
by
Jose Blaya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fallback when the vpn connection fails
parent
d80ca2d5
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
119 additions
and
113 deletions
+119
-113
PIALibrary/Sources/Core/WebServices/Server.swift
PIALibrary/Sources/Core/WebServices/Server.swift
+32
-70
PIALibrary/Sources/Library/Client+Configuration.swift
PIALibrary/Sources/Library/Client+Configuration.swift
+13
-0
PIALibrary/Sources/Library/Daemons/PingTask.swift
PIALibrary/Sources/Library/Daemons/PingTask.swift
+4
-4
PIALibrary/Sources/Library/Daemons/ServersPinger.swift
PIALibrary/Sources/Library/Daemons/ServersPinger.swift
+1
-1
PIALibrary/Sources/Library/Daemons/VPNDaemon.swift
PIALibrary/Sources/Library/Daemons/VPNDaemon.swift
+61
-14
PIALibrary/Sources/Library/Notification+Library.swift
PIALibrary/Sources/Library/Notification+Library.swift
+2
-0
PIALibrary/Sources/Library/VPN/IKEv2Profile.swift
PIALibrary/Sources/Library/VPN/IKEv2Profile.swift
+1
-1
PIALibrary/Sources/Library/WebServices/GlossServer.swift
PIALibrary/Sources/Library/WebServices/GlossServer.swift
+0
-8
PIALibrary/Sources/Library/WebServices/PIAWebServices.swift
PIALibrary/Sources/Library/WebServices/PIAWebServices.swift
+1
-1
PIALibrary/Sources/Mock/MockServerProvider.swift
PIALibrary/Sources/Mock/MockServerProvider.swift
+0
-10
PIALibrary/Sources/VPN/PIATunnelProfile.swift
PIALibrary/Sources/VPN/PIATunnelProfile.swift
+1
-1
PIALibrary/Sources/VPN/PIAWGTunnelProfile.swift
PIALibrary/Sources/VPN/PIAWGTunnelProfile.swift
+3
-3
No files found.
PIALibrary/Sources/Core/WebServices/Server.swift
View file @
721386fe
...
...
@@ -86,7 +86,13 @@ public class Server: Hashable {
/// The response time for this address.
private(set)
var
responseTime
:
Int
?
private(set)
var
available
:
Bool
=
true
public
var
description
:
String
{
return
"
\(
ip
)
:0"
}
/// :nodoc:
public
init
(
ip
:
String
,
cn
:
String
)
{
self
.
ip
=
ip
...
...
@@ -97,6 +103,14 @@ public class Server: Hashable {
self
.
responseTime
=
time
}
func
markServerAsUnavailable
()
{
available
=
false
}
func
reset
()
{
available
=
true
}
}
/// The server name.
...
...
@@ -119,12 +133,6 @@ public class Server: Hashable {
/// The server is unavailable.
public
let
offline
:
Bool
/// The best address for establishing an OpenVPN connection over TCP.
public
let
bestOpenVPNAddressForTCP
:
Address
?
/// The best address for establishing an OpenVPN connection over UDP.
public
let
bestOpenVPNAddressForUDP
:
Address
?
/// The best address for establishing an OpenVPN connection over TCP.
public
let
openVPNAddressesForTCP
:
[
ServerAddressIP
]?
...
...
@@ -160,8 +168,6 @@ public class Server: Hashable {
name
:
String
,
country
:
String
,
hostname
:
String
,
bestOpenVPNAddressForTCP
:
Address
?,
bestOpenVPNAddressForUDP
:
Address
?,
openVPNAddressesForTCP
:
[
ServerAddressIP
]?
=
nil
,
openVPNAddressesForUDP
:
[
ServerAddressIP
]?
=
nil
,
wireGuardAddressesForUDP
:
[
ServerAddressIP
]?
=
nil
,
...
...
@@ -185,8 +191,6 @@ public class Server: Hashable {
self
.
regionIdentifier
=
regionIdentifier
identifier
=
hostname
.
components
(
separatedBy
:
"."
)
.
first
??
""
self
.
bestOpenVPNAddressForTCP
=
bestOpenVPNAddressForTCP
self
.
bestOpenVPNAddressForUDP
=
bestOpenVPNAddressForUDP
self
.
openVPNAddressesForTCP
=
openVPNAddressesForTCP
self
.
openVPNAddressesForUDP
=
openVPNAddressesForUDP
self
.
wireGuardAddressesForUDP
=
wireGuardAddressesForUDP
...
...
@@ -218,86 +222,44 @@ public class Server: Hashable {
extension
Server
{
func
bestAddressForOpenVPNTCP
()
->
Address
?
{
if
let
addresses
=
openVPNAddressesForTCP
{
let
sorted
=
addresses
.
sorted
(
by
:
{
$0
.
responseTime
??
0
>
$1
.
responseTime
??
0
})
return
nil
}
return
bestOpenVPNAddressForTCP
}
func
bestAddressForOpenVPNUDP
()
->
Address
?
{
if
let
addresses
=
openVPNAddressesForUDP
{
let
sorted
=
addresses
.
sorted
(
by
:
{
$0
.
responseTime
??
0
>
$1
.
responseTime
??
0
})
return
nil
}
return
bestOpenVPNAddressForUDP
}
func
bestAddressForIKEv2
()
->
ServerAddressIP
?
{
if
let
addresses
=
iKEv2AddressesForUDP
{
let
sorted
=
addresses
.
sorted
(
by
:
{
$0
.
responseTime
??
0
>
$1
.
responseTime
??
0
})
return
sorted
.
first
}
return
nil
// currently using DNS
}
func
bestAddressForWireGuard
()
->
ServerAddressIP
?
{
if
let
addresses
=
wireGuardAddressesForUDP
{
let
sorted
=
addresses
.
sorted
(
by
:
{
$0
.
responseTime
??
0
>
$1
.
responseTime
??
0
})
return
sorted
.
first
}
return
nil
}
public
func
bestPingAddress
()
->
[
Address
]
{
public
func
addresses
()
->
[
ServerAddressIP
]
{
switch
Client
.
providers
.
vpnProvider
.
currentVPNType
{
case
IKEv2Profile
.
vpnType
:
var
addresses
:
[
Address
]
=
[]
for
address
in
iKEv2AddressesForUDP
??
[]
{
addresses
.
append
(
Address
(
hostname
:
address
.
ip
,
port
:
0
))
}
return
addresses
return
iKEv2AddressesForUDP
??
[]
case
PIATunnelProfile
.
vpnType
:
var
addresses
:
[
Address
]
=
[]
for
address
in
openVPNAddressesForUDP
??
[]
{
addresses
.
append
(
Address
(
hostname
:
address
.
ip
,
port
:
0
))
}
return
addresses
return
openVPNAddressesForTCP
??
[]
case
PIAWGTunnelProfile
.
vpnType
:
var
addresses
:
[
Address
]
=
[]
for
address
in
wireGuardAddressesForUDP
??
[]
{
addresses
.
append
(
Address
(
hostname
:
address
.
ip
,
port
:
0
))
}
return
addresses
return
wireGuardAddressesForUDP
??
[]
default
:
return
[]
}
}
public
func
bestAddress
()
->
ServerAddressIP
?
{
let
availableServer
=
addresses
()
.
first
(
where
:
{
$0
.
available
})
if
availableServer
==
nil
{
addresses
()
.
map
({
$0
.
reset
()})
return
bestAddress
()
}
return
availableServer
}
}
extension
Server
{
func
updateResponseTime
(
_
time
:
Int
,
forAddress
address
:
Address
)
{
func
updateResponseTime
(
_
time
:
Int
,
forAddress
address
:
ServerAddressIP
)
{
switch
Client
.
providers
.
vpnProvider
.
currentVPNType
{
case
IKEv2Profile
.
vpnType
:
let
serverAddressIP
=
iKEv2AddressesForUDP
?
.
first
(
where
:
{
$0
.
ip
==
address
.
hostname
})
let
serverAddressIP
=
iKEv2AddressesForUDP
?
.
first
(
where
:
{
$0
.
ip
==
address
.
ip
})
serverAddressIP
?
.
updateResponseTime
(
time
)
case
PIATunnelProfile
.
vpnType
:
let
serverAddressIP
=
openVPNAddressesForUDP
?
.
first
(
where
:
{
$0
.
ip
==
address
.
hostname
})
let
serverAddressIP
=
openVPNAddressesForUDP
?
.
first
(
where
:
{
$0
.
ip
==
address
.
ip
})
serverAddressIP
?
.
updateResponseTime
(
time
)
case
PIAWGTunnelProfile
.
vpnType
:
let
serverAddressIP
=
wireGuardAddressesForUDP
?
.
first
(
where
:
{
$0
.
ip
==
address
.
hostname
})
let
serverAddressIP
=
wireGuardAddressesForUDP
?
.
first
(
where
:
{
$0
.
ip
==
address
.
ip
})
serverAddressIP
?
.
updateResponseTime
(
time
)
default
:
break
...
...
PIALibrary/Sources/Library/Client+Configuration.swift
View file @
721386fe
...
...
@@ -109,6 +109,15 @@ extension Client {
/// Sets the maximum number of failed connectivity checks before giving up.
public
var
connectivityMaxAttempts
:
Int
/// Sets the timeout for VPN connectivity checks.
public
var
vpnConnectivityTimeout
:
TimeInterval
/// Sets the delay after which to retry VPN connectivity checks.
public
var
vpnConnectivityRetryDelay
:
TimeInterval
/// Sets the maximum number of failed VPN connectivity attempts before giving up.
public
var
vpnConnectivityMaxAttempts
:
Int
let
maceHostname
:
String
let
macePort
:
UInt16
...
...
@@ -201,6 +210,10 @@ extension Client {
connectivityRetryDelay
=
5000
connectivityMaxAttempts
=
3
vpnConnectivityTimeout
=
2.0
vpnConnectivityRetryDelay
=
5.0
vpnConnectivityMaxAttempts
=
3
maceHostname
=
"209.222.18.222"
macePort
=
1111
maceDelay
=
5000
...
...
PIALibrary/Sources/Library/Daemons/PingTask.swift
View file @
721386fe
...
...
@@ -33,7 +33,7 @@ class PingTask {
let
identifier
:
String
let
server
:
Server
let
address
:
Server
.
Address
let
address
:
Server
.
ServerAddressIP
let
stateUpdateHandler
:
(
PingTask
)
->
()
var
state
=
PingTaskState
.
pending
{
didSet
{
...
...
@@ -41,7 +41,7 @@ class PingTask {
}
}
init
(
identifier
:
String
,
server
:
Server
,
address
:
Server
.
Address
,
stateUpdateHandler
:
@escaping
(
PingTask
)
->
())
{
init
(
identifier
:
String
,
server
:
Server
,
address
:
Server
.
ServerAddressIP
,
stateUpdateHandler
:
@escaping
(
PingTask
)
->
())
{
self
.
identifier
=
identifier
self
.
server
=
server
self
.
address
=
address
...
...
@@ -54,7 +54,7 @@ class PingTask {
let
persistence
=
Client
.
database
.
plain
self
.
state
=
.
pending
log
.
debug
(
"Starting to Ping
\(
server
.
identifier
)
with address:
\(
address
.
hostname
)
"
)
log
.
debug
(
"Starting to Ping
\(
server
.
identifier
)
with address:
\(
address
.
ip
)
"
)
queue
.
async
()
{
[
weak
self
]
in
...
...
@@ -62,7 +62,7 @@ class PingTask {
return
}
let
tcpAddress
=
Server
.
Address
(
hostname
:
address
.
hostname
,
port
:
443
)
let
tcpAddress
=
Server
.
Address
(
hostname
:
address
.
ip
,
port
:
443
)
response
=
server
.
ping
(
toAddress
:
tcpAddress
,
withProtocol
:
.
TCP
)
DispatchQueue
.
main
.
async
{
self
?
.
parsePingResponse
(
response
:
response
,
withServer
:
server
)
...
...
PIALibrary/Sources/Library/Daemons/ServersPinger.swift
View file @
721386fe
...
...
@@ -61,7 +61,7 @@ class ServersPinger: DatabaseAccess {
log
.
verbose
(
"Pinging
\(
server
.
identifier
)
"
)
for
address
in
server
.
bestPingAddres
s
()
{
for
address
in
server
.
addresse
s
()
{
let
pingTask
=
PingTask
(
identifier
:
server
.
identifier
,
server
:
server
,
address
:
address
,
stateUpdateHandler
:
{
(
task
)
in
...
...
PIALibrary/Sources/Library/Daemons/VPNDaemon.swift
View file @
721386fe
...
...
@@ -30,10 +30,14 @@ class VPNDaemon: Daemon, DatabaseAccess, ProvidersAccess {
static
let
shared
=
VPNDaemon
()
private(set)
var
hasEnabledUpdates
:
Bool
private
var
timer
:
Timer
!
private
var
fallbackTimer
:
Timer
!
private
var
numberOfAttempts
:
Int
private
var
isReconnecting
:
Bool
private
init
()
{
hasEnabledUpdates
=
false
isReconnecting
=
false
numberOfAttempts
=
0
}
func
start
()
{
...
...
@@ -62,30 +66,49 @@ class VPNDaemon: Daemon, DatabaseAccess, ProvidersAccess {
switch
connection
.
status
{
case
.
connected
:
nextStatus
=
.
connected
timer
?
.
invalidate
()
invalidateTimer
()
reset
()
case
.
connecting
,
.
reasserting
:
nextStatus
=
.
connecting
nextStatus
=
.
connecting
let
previousStatus
=
accessedDatabase
.
transient
.
vpnStatus
if
nextStatus
!=
previousStatus
{
timer
=
Timer
.
scheduledTimer
(
withTimeInterval
:
2.0
,
repeats
:
true
)
{
timer
in
let
status
=
NEVPNManager
.
shared
()
.
connection
.
status
if
status
==
.
invalid
{
log
.
debug
(
"NEVPNManager connection is invalid. Reconnecting..."
)
Client
.
providers
.
vpnProvider
.
reconnect
(
after
:
nil
,
forceDisconnect
:
true
,
{
error
in
timer
.
invalidate
()
if
fallbackTimer
==
nil
{
fallbackTimer
=
Timer
.
scheduledTimer
(
withTimeInterval
:
Client
.
configuration
.
vpnConnectivityRetryDelay
,
repeats
:
true
)
{
timer
in
let
address
=
Client
.
providers
.
serverProvider
.
targetServer
.
bestAddress
()
address
?
.
markServerAsUnavailable
()
log
.
debug
(
"NEVPNManager is still connecting. Reconnecting with a different server..."
)
self
.
numberOfAttempts
+=
1
if
self
.
numberOfAttempts
<
Client
.
configuration
.
vpnConnectivityMaxAttempts
{
self
.
updateUIWithAttemptNumber
(
self
.
numberOfAttempts
)
self
.
isReconnecting
=
true
Client
.
providers
.
vpnProvider
.
reconnect
(
after
:
0
,
{
_
in
self
.
isReconnecting
=
false
})
}
else
{
log
.
debug
(
"MAX number of VPN reconnections. Disconnecting..."
)
Client
.
providers
.
vpnProvider
.
disconnect
({
error
in
Macros
.
postNotification
(
.
PIAVPNDidFail
)
self
.
reset
()
self
.
invalidateTimer
()
})
}
}
}
case
.
disconnecting
:
nextStatus
=
.
disconnecting
case
.
disconnected
:
nextStatus
=
.
disconnected
if
!
isReconnecting
{
invalidateTimer
()
reset
()
}
default
:
nextStatus
=
.
disconnected
}
...
...
@@ -94,7 +117,10 @@ class VPNDaemon: Daemon, DatabaseAccess, ProvidersAccess {
guard
(
nextStatus
!=
previousStatus
)
else
{
return
}
accessedDatabase
.
transient
.
vpnStatus
=
nextStatus
if
!
isReconnecting
{
accessedDatabase
.
transient
.
vpnStatus
=
nextStatus
}
if
#available(iOS 12.0, *)
{
if
let
error
=
connection
.
value
(
forKey
:
"_lastDisconnectError"
)
{
...
...
@@ -107,6 +133,27 @@ class VPNDaemon: Daemon, DatabaseAccess, ProvidersAccess {
}
// MARK: Invalidate
private
func
invalidateTimer
()
{
fallbackTimer
?
.
invalidate
()
fallbackTimer
=
nil
}
// MARK: Reset
private
func
reset
()
{
self
.
isReconnecting
=
false
self
.
numberOfAttempts
=
0
self
.
updateUIWithAttemptNumber
(
0
)
Client
.
providers
.
serverProvider
.
targetServer
.
addresses
()
.
forEach
({
$0
.
reset
()})
}
// MARK: Update UI
private
func
updateUIWithAttemptNumber
(
_
number
:
Int
)
{
NotificationCenter
.
default
.
post
(
name
:
.
PIADaemonsConnectingVPNStatus
,
object
:
number
)
}
// MARK: Notifications
@objc
private
func
neStatusDidChange
(
notification
:
Notification
)
{
...
...
PIALibrary/Sources/Library/Notification+Library.swift
View file @
721386fe
...
...
@@ -41,6 +41,8 @@ extension Notification.Name {
/// - Seealso: `Client.Daemons`
public
static
let
PIADaemonsDidUpdateVPNStatus
=
Notification
.
Name
(
"PIADaemonsDidUpdateVPNStatus"
)
public
static
let
PIADaemonsConnectingVPNStatus
=
Notification
.
Name
(
"PIADaemonsStillConnectingVPNStatus"
)
// MARK: Servers
/// The target server has been updated.
...
...
PIALibrary/Sources/Library/VPN/IKEv2Profile.swift
View file @
721386fe
...
...
@@ -173,7 +173,7 @@ public class IKEv2Profile: NetworkExtensionProfile {
iKEv2Password
=
ikev2PasswordReference
()
let
cfg
=
NEVPNProtocolIKEv2
()
if
let
ip
=
configuration
.
server
.
bestAddress
ForIKEv2
()?
.
ip
{
if
let
ip
=
configuration
.
server
.
bestAddress
()?
.
ip
{
cfg
.
serverAddress
=
ip
}
else
{
cfg
.
serverAddress
=
configuration
.
server
.
hostname
...
...
PIALibrary/Sources/Library/WebServices/GlossServer.swift
View file @
721386fe
...
...
@@ -117,8 +117,6 @@ class GlossServer: GlossParser {
name
:
name
,
country
:
country
,
hostname
:
hostname
,
bestOpenVPNAddressForTCP
:
nil
,
bestOpenVPNAddressForUDP
:
nil
,
openVPNAddressesForTCP
:
ovpnTCPServerAddressIP
,
openVPNAddressesForUDP
:
ovpnUDPServerAddressIP
,
wireGuardAddressesForUDP
:
wgServerAddressIP
,
...
...
@@ -162,12 +160,6 @@ extension Server: JSONEncodable {
"geo"
~~>
geo
,
"offline"
~~>
offline
,
"dns"
~~>
hostname
,
"openvpn_tcp"
~~>
jsonify
([
"best"
~~>
bestOpenVPNAddressForTCP
?
.
description
]),
"openvpn_udp"
~~>
jsonify
([
"best"
~~>
bestOpenVPNAddressForUDP
?
.
description
]),
"ping"
~~>
pingAddress
?
.
description
,
"servers"
~~>
jsonify
([
"ovpnudp"
~~>
ovpnTCPobj
,
...
...
PIALibrary/Sources/Library/WebServices/PIAWebServices.swift
View file @
721386fe
...
...
@@ -245,7 +245,7 @@ class PIAWebServices: WebServices, ConfigurationAccess {
return
}
let
dipRegion
=
Server
(
serial
:
firstServer
.
serial
,
name
:
firstServer
.
name
,
country
:
firstServer
.
country
,
hostname
:
firstServer
.
hostname
,
bestOpenVPNAddressForTCP
:
firstServer
.
bestOpenVPNAddressForTCP
,
bestOpenVPNAddressForUDP
:
firstServer
.
bestOpenVPNAddressForUDP
,
openVPNAddressesForTCP
:
[
Server
.
ServerAddressIP
(
ip
:
ip
,
cn
:
cn
)],
openVPNAddressesForUDP
:
[
Server
.
ServerAddressIP
(
ip
:
ip
,
cn
:
cn
)],
wireGuardAddressesForUDP
:
[
Server
.
ServerAddressIP
(
ip
:
ip
,
cn
:
cn
)],
iKEv2AddressesForUDP
:
[
Server
.
ServerAddressIP
(
ip
:
ip
,
cn
:
cn
)],
pingAddress
:
firstServer
.
pingAddress
,
geo
:
false
,
meta
:
nil
,
dipExpire
:
Date
(
timeIntervalSince1970
:
TimeInterval
(
expirationTime
)),
dipToken
:
dipServer
.
dipToken
,
dipStatus
:
DedicatedIPStatus
.
active
,
regionIdentifier
:
firstServer
.
regionIdentifier
)
let
dipRegion
=
Server
(
serial
:
firstServer
.
serial
,
name
:
firstServer
.
name
,
country
:
firstServer
.
country
,
hostname
:
firstServer
.
hostname
,
openVPNAddressesForTCP
:
[
Server
.
ServerAddressIP
(
ip
:
ip
,
cn
:
cn
)],
openVPNAddressesForUDP
:
[
Server
.
ServerAddressIP
(
ip
:
ip
,
cn
:
cn
)],
wireGuardAddressesForUDP
:
[
Server
.
ServerAddressIP
(
ip
:
ip
,
cn
:
cn
)],
iKEv2AddressesForUDP
:
[
Server
.
ServerAddressIP
(
ip
:
ip
,
cn
:
cn
)],
pingAddress
:
firstServer
.
pingAddress
,
geo
:
false
,
meta
:
nil
,
dipExpire
:
Date
(
timeIntervalSince1970
:
TimeInterval
(
expirationTime
)),
dipToken
:
dipServer
.
dipToken
,
dipStatus
:
DedicatedIPStatus
.
active
,
regionIdentifier
:
firstServer
.
regionIdentifier
)
dipRegions
.
append
(
dipRegion
)
Client
.
database
.
secure
.
setDIPToken
(
dipServer
.
dipToken
)
...
...
PIALibrary/Sources/Mock/MockServerProvider.swift
View file @
721386fe
...
...
@@ -40,8 +40,6 @@ public class MockServerProvider: ServerProvider, DatabaseAccess, WebServicesCons
name
:
"France"
,
country
:
"fr"
,
hostname
:
"france.example.com"
,
bestOpenVPNAddressForTCP
:
nil
,
bestOpenVPNAddressForUDP
:
nil
,
pingAddress
:
nil
,
responseTime
:
0
,
regionIdentifier
:
""
...
...
@@ -50,8 +48,6 @@ public class MockServerProvider: ServerProvider, DatabaseAccess, WebServicesCons
name
:
"Germany"
,
country
:
"de"
,
hostname
:
"germany.example.com"
,
bestOpenVPNAddressForTCP
:
nil
,
bestOpenVPNAddressForUDP
:
nil
,
pingAddress
:
nil
,
responseTime
:
0
,
regionIdentifier
:
""
...
...
@@ -60,8 +56,6 @@ public class MockServerProvider: ServerProvider, DatabaseAccess, WebServicesCons
name
:
"Italy"
,
country
:
"it"
,
hostname
:
"italy.example.com"
,
bestOpenVPNAddressForTCP
:
nil
,
bestOpenVPNAddressForUDP
:
nil
,
pingAddress
:
nil
,
responseTime
:
0
,
regionIdentifier
:
""
...
...
@@ -70,8 +64,6 @@ public class MockServerProvider: ServerProvider, DatabaseAccess, WebServicesCons
name
:
"US East"
,
country
:
"us"
,
hostname
:
"us-east.example.com"
,
bestOpenVPNAddressForTCP
:
nil
,
bestOpenVPNAddressForUDP
:
nil
,
pingAddress
:
nil
,
responseTime
:
0
,
regionIdentifier
:
""
...
...
@@ -80,8 +72,6 @@ public class MockServerProvider: ServerProvider, DatabaseAccess, WebServicesCons
name
:
"US East Offline"
,
country
:
"us"
,
hostname
:
"us-east.example.com"
,
bestOpenVPNAddressForTCP
:
nil
,
bestOpenVPNAddressForUDP
:
nil
,
pingAddress
:
nil
,
responseTime
:
0
,
geo
:
true
,
...
...
PIALibrary/Sources/VPN/PIATunnelProfile.swift
View file @
721386fe
...
...
@@ -239,7 +239,7 @@ public class PIATunnelProfile: NetworkExtensionProfile {
var
customCfg
=
configuration
.
customConfiguration
if
let
piaCfg
=
customCfg
as?
OpenVPNTunnelProvider
.
Configuration
{
var
builder
=
piaCfg
.
builder
()
if
let
bestAddress
=
configuration
.
server
.
bestAddressForOpenVPNUDP
()?
.
hostname
{
// XXX: UDP address = TCP address
if
let
bestAddress
=
configuration
.
server
.
openVPNAddressesForTCP
?
.
first
?
.
ip
{
// XXX: UDP address = TCP address
builder
.
resolvedAddresses
=
[
bestAddress
]
}
customCfg
=
builder
.
build
()
...
...
PIALibrary/Sources/VPN/PIAWGTunnelProfile.swift
View file @
721386fe
...
...
@@ -238,8 +238,8 @@ public class PIAWGTunnelProfile: NetworkExtensionProfile {
var
serverAddress
=
configuration
.
server
.
hostname
var
serverCN
=
""
if
let
ip
=
configuration
.
server
.
bestAddress
ForWireGuard
()?
.
ip
,
let
cn
=
configuration
.
server
.
bestAddress
ForWireGuard
()?
.
cn
{
if
let
ip
=
configuration
.
server
.
bestAddress
()?
.
ip
,
let
cn
=
configuration
.
server
.
bestAddress
()?
.
cn
{
serverAddress
=
ip
serverCN
=
cn
}
...
...
@@ -251,7 +251,7 @@ public class PIAWGTunnelProfile: NetworkExtensionProfile {
cfg
.
disconnectOnSleep
=
configuration
.
disconnectsOnSleep
cfg
.
providerConfiguration
=
[
PIAWireguardConfiguration
.
Keys
.
token
:
Client
.
providers
.
accountProvider
.
token
,
PIAWireguardConfiguration
.
Keys
.
ping
:
configuration
.
server
.
best
PingAddress
()
.
first
?
.
description
,
PIAWireguardConfiguration
.
Keys
.
ping
:
configuration
.
server
.
best
Address
()
?
.
description
,
PIAWireguardConfiguration
.
Keys
.
serial
:
configuration
.
server
.
serial
,
PIAWireguardConfiguration
.
Keys
.
cn
:
serverCN
,
PIAWireguardConfiguration
.
Keys
.
useIP
:
true
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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