Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
liberty
tunnel
liberty-tunnel-client-library-apple
Commits
c814f139
Commit
c814f139
authored
Jan 24, 2019
by
Jose Blaya
Browse files
Improve how the library remove and save profiles switching between the different protocols
parent
4ceb613b
Changes
1
Hide whitespace changes
Inline
Side-by-side
PIALibrary/Sources/Library/VPN/DefaultVPNProvider.swift
View file @
c814f139
...
...
@@ -104,8 +104,15 @@ class DefaultVPNProvider: VPNProvider, ConfigurationAccess, DatabaseAccess, Pref
callback
?(
error
)
return
}
previousProfile
?
.
remove
(
nil
)
self
.
activeProfile
=
profile
if
!
((
profile
.
vpnType
==
IPSecProfile
.
vpnType
||
profile
.
vpnType
==
IKEv2Profile
.
vpnType
)
&&
(
previousProfile
?
.
vpnType
==
IPSecProfile
.
vpnType
||
previousProfile
?
.
vpnType
==
IKEv2Profile
.
vpnType
))
{
//only remove the profile if is not Ipsec or IKEv2, if are one of them, override instead
previousProfile
?
.
remove
(
nil
)
}
else
{
self
.
connect
(
nil
)
}
Macros
.
postNotification
(
.
PIAVPNDidInstall
)
callback
?(
nil
)
}
...
...
@@ -114,7 +121,10 @@ class DefaultVPNProvider: VPNProvider, ConfigurationAccess, DatabaseAccess, Pref
if
let
previousProfile
=
previousProfile
{
previousProfile
.
disconnect
(
installBlock
)
}
else
{
installBlock
(
nil
)
if
newVPNType
!=
activeProfile
?
.
vpnType
{
//only install if new
installBlock
(
nil
)
}
}
}
...
...
@@ -226,16 +236,19 @@ class DefaultVPNProvider: VPNProvider, ConfigurationAccess, DatabaseAccess, Pref
@discardableResult
private
func
activeProfileRemovingInactive
()
->
VPNProfile
?
{
let
activeVPNType
=
accessedPreferences
.
vpnType
var
activeProfile
:
VPNProfile
?
let
activeProfile
:
VPNProfile
?
=
accessedConfiguration
.
profile
(
forVPNType
:
activeVPNType
)
for
vpnType
in
availableVPNTypes
{
let
profile
=
accessedConfiguration
.
profile
(
forVPNType
:
vpnType
)
!
guard
(
vpnType
==
activeVPNType
)
else
{
profile
.
disconnect
(
nil
)
profile
.
remove
(
nil
)
if
!
((
profile
.
vpnType
==
IPSecProfile
.
vpnType
||
profile
.
vpnType
==
IKEv2Profile
.
vpnType
)
&&
(
activeProfile
?
.
vpnType
==
IPSecProfile
.
vpnType
||
activeProfile
?
.
vpnType
==
IKEv2Profile
.
vpnType
))
{
//only remove the profile if is not Ipsec or IKEv2, if are one of them, override instead
profile
.
disconnect
(
nil
)
profile
.
remove
(
nil
)
}
continue
}
activeProfile
=
profile
}
return
activeProfile
}
...
...
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