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
0fd52d70
Commit
0fd52d70
authored
Mar 12, 2019
by
Jose Blaya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ignore rules to onDemand property
parent
746333ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
6 deletions
+35
-6
PIALibrary/Sources/Library/VPN/NetworkExtensionProfile.swift
PIALibrary/Sources/Library/VPN/NetworkExtensionProfile.swift
+35
-6
No files found.
PIALibrary/Sources/Library/VPN/NetworkExtensionProfile.swift
View file @
0fd52d70
...
...
@@ -9,6 +9,9 @@
import
Foundation
import
NetworkExtension
import
SwiftyBeaver
import
SystemConfiguration
import
UIKit
private
let
log
=
SwiftyBeaver
.
self
...
...
@@ -77,18 +80,30 @@ extension NetworkExtensionProfile {
vpn
.
onDemandRules
?
.
append
(
contentsOf
:
[
ruleDisconnect
,
ruleConnect
])
}
}
else
{
let
ruleDisconnect
=
NEOnDemandRuleDisconnect
()
ruleDisconnect
.
interfaceTypeMatch
=
.
wiFi
vpn
.
onDemandRules
?
.
append
(
ruleDisconnect
)
if
let
_
=
UIDevice
.
current
.
ssid
{
//If trying to connect from a WiFi network...
let
ruleIgnore
=
NEOnDemandRuleIgnore
()
ruleIgnore
.
interfaceTypeMatch
=
.
wiFi
vpn
.
onDemandRules
?
.
append
(
ruleIgnore
)
}
else
{
let
ruleDisconnect
=
NEOnDemandRuleDisconnect
()
ruleDisconnect
.
interfaceTypeMatch
=
.
wiFi
vpn
.
onDemandRules
?
.
append
(
ruleDisconnect
)
}
}
if
!
Client
.
preferences
.
trustCellularData
{
let
ruleConnect
=
NEOnDemandRuleConnect
()
ruleConnect
.
interfaceTypeMatch
=
.
cellular
vpn
.
onDemandRules
?
.
append
(
ruleConnect
)
}
else
{
let
ruleDisconnect
=
NEOnDemandRuleDisconnect
()
ruleDisconnect
.
interfaceTypeMatch
=
.
cellular
vpn
.
onDemandRules
?
.
append
(
ruleDisconnect
)
if
let
_
=
UIDevice
.
current
.
ssid
{
//If trying to connect from a Cellular network...
let
ruleDisconnect
=
NEOnDemandRuleDisconnect
()
ruleDisconnect
.
interfaceTypeMatch
=
.
cellular
vpn
.
onDemandRules
?
.
append
(
ruleDisconnect
)
}
else
{
let
ruleIgnore
=
NEOnDemandRuleIgnore
()
ruleIgnore
.
interfaceTypeMatch
=
.
cellular
vpn
.
onDemandRules
?
.
append
(
ruleIgnore
)
}
}
}
else
{
if
!
Client
.
preferences
.
trustCellularData
{
...
...
@@ -134,3 +149,17 @@ extension NetworkExtensionProfile {
}
}
}
extension
UIDevice
{
var
ssid
:
String
?
{
guard
let
interfaces
=
CNCopySupportedInterfaces
()
as?
[
String
]
else
{
return
nil
}
let
key
=
kCNNetworkInfoKeySSID
as
String
for
interface
in
interfaces
{
guard
let
interfaceInfo
=
CNCopyCurrentNetworkInfo
(
interface
as
CFString
)
as
NSDictionary
?
else
{
continue
}
return
interfaceInfo
[
key
]
as?
String
}
return
nil
}
}
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