Skip to content

Commit

Permalink
fix: update disconnect method in VPNManager
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajhilje committed Oct 18, 2023
1 parent 9c83415 commit 8478edd
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions IVPNClient/Managers/VPNManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,21 @@ class VPNManager {
case .openvpn:
disable(tunnelType: .ipsec) { _ in
self.disable(tunnelType: .wireguard) { _ in
self.setup(settings: settings, accessDetails: accessDetails, status: .disconnected) { _ in }
self.setup(settings: settings, accessDetails: accessDetails, status: .disconnected) { _ in
DispatchQueue.async {
self.openvpnManager?.connection.stopVPNTunnel()
}
}
}
}
case .wireguard:
disable(tunnelType: .ipsec) { _ in
self.disable(tunnelType: .openvpn) { _ in
self.setup(settings: settings, accessDetails: accessDetails, status: .disconnected) { _ in }
self.setup(settings: settings, accessDetails: accessDetails, status: .disconnected) { _ in
DispatchQueue.async {
self.wireguardManager?.connection.stopVPNTunnel()
}
}
}
}
}
Expand All @@ -270,7 +278,10 @@ class VPNManager {
func disconnect(tunnelType: TunnelType, reconnectAutomatically: Bool = false) {
getManagerFor(tunnelType: tunnelType) { [self] manager in
manager.connection.stopVPNTunnel()
removeOnDemandRule(manager: manager)

if !UserDefaults.shared.networkProtectionEnabled || reconnectAutomatically {
removeOnDemandRule(manager: manager)
}
}
}

Expand Down

0 comments on commit 8478edd

Please sign in to comment.