Skip to content

Instantly share code, notes, and snippets.

View fakiho's full-sized avatar
:electron:
Focusing

Ali Fakih fakiho

:electron:
Focusing
View GitHub Profile
//
// DefaultVPNRepository.swift
// Secure VPN
//
// Created by Ali Fakih on 5/20/20.
// Copyright © 2020 beApp. All rights reserved.
//
import Foundation
import AFNetworks
final class DefaultVPNRepository {
private(set) var vpnManager: VPNRepository!
private let dataTransferService: DataTransferService
init(vpnManager: VPNRepository, dataTransfer: DataTransferService) {
self.vpnManager = vpnManager
self.dataTransferService = dataTransfer
}
}
import Foundation
import NetworkExtension
final class DefaultVPNManager: VPNRepository {
var selectedVPN: String = ""
var activatedVPN: String = ""
extension VPNRepository {
var manager: NEVPNManager {
return NEVPNManager.shared()
}
var status: NEVPNStatus {
get {
return manager.connection.status
}
protocol VPNRepository {
var manager: NEVPNManager { get }
var selectedVPN: String { get set }
var activatedVPN: String { get set }
var status: NEVPNStatus { get set }
func loadPreferences(completion: @escaping () -> ())
func save(config: VPNAccount, completion: @escaping () -> Void)
func connect()
import Foundation
public enum NetworkVPNStatus: String {
case invalid = "Press to allow VPN"
case disconnected = "Tap to Connect"
case connecting = "Connecting"
case connected = "Tap to disconnect"
case reasserting = "Reasserting"
case disconnecting = "Disconnecting"
}
protocol DVPNRepository {
func connect(configuration: VPNAccount)
func getStatus(completion: @escaping (NetworkVPNStatus) -> ())
func disconnect()
func loadVPNConfig(completion: @escaping () -> Void)
func getServers(completion: @escaping (Result<[Server], Error>) -> Void) -> Cancellable?
}
protocol NetworkVPNUseCase {
func connect(configuration: VPNAccount)
func getStatus() -> Observable<NetworkVPNStatus>
func disconnect()
func loadVPNConfig(completion: @escaping () -> Void)
func getServers(completion: @escaping (Result<[Server], Error>) -> Void) -> Cancellable?
}
enum DashboardViewModelLoading {
case none
case fullScreen
case connecting
case connected
case disconnected
case disconnecting
}
enum DashboardViewModelRoute {
case initial
case inAppPurchaseView
case purchased
case showPurchaseDeeplink
case showAds
case showServers(delegate: ServerListViewModelDelegate)
case closeServers
case showUpdate
case none