// // XPCClient.swift // PrivadoVPN // // Created by Juraldinio on 7/28/20. // Copyright © 2020 Privado LLC. All rights reserved. // import Foundation enum XPCClientState: Equatable { case undefined case initializing case requireUpdate case installing case connected case invalid case interrupted /*static func == (lhs: Self, rhs: Self) -> Bool { switch (lhs, rhs) { case (undefined, undefined), (initializing, initializing), (requireUpdate, requireUpdate), (installing, installing), (connected, connected), (invalid, invalid), (interrupted, interrupted): return true case let (resume(v1), resume(v2)): return v1 == v2 default: return false } }*/ } enum XPCСommonClientError: Error { case unowned case alreadyConnected case proxy(Error) case incorrectType case notConnected case emptyRemoteObject } protocol XPCСonsoleClient: AnyObject { func console(message: String) } protocol XPCСommonClient: AnyObject { var state: XPCClientState { get } var stateEmitter: Emitter { get } var consoleClient: XPCСonsoleClient? { get } func install(installer: @escaping (String) -> Bool) -> Future func resume() } protocol XPCSystemClient: XPCСommonClient { func checkVersion() -> Future func flushDNS() -> Future func resolveDNS(name: String) -> Future func changeDNS(servers: [String], hardware: String) -> Future func currentDNS(hardware: [String]) -> Future<[String: [String]]> func ifconfig() -> Future func hardwarePorts() -> Future<[HardwarePort]> func removeUninstaller() -> Future } protocol XPCFirewallClient: XPCСommonClient { func firewallState() -> Future func firewallEnable(_ enable: Bool) -> Future func firewallActivate(rulesPath: String, validate: Bool) -> Future func firewallDeactivate() -> Future func firewallRulesSave() -> Future func firewallRulesRestore() -> Future } protocol OpenVPNConfiguration { var ovpnPath: String { get } var configPath: String { get } var username: String { get } var password: String { get } } protocol XPCOpenVPNClient: XPCСommonClient { func connect(type: Int, configuration: OpenVPNConfiguration) -> Future func disconnect() -> Future func isConnected() -> Future } protocol XPCUninstallerClient: XPCСommonClient { func uninstall() -> Future }