Files

102 lines
2.6 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//
// 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<XPCClientState> { get }
var consoleClient: XPCСonsoleClient? { get }
func install(installer: @escaping (String) -> Bool) -> Future<XPCСommonClient>
func resume()
}
protocol XPCSystemClient: XPCСommonClient {
func checkVersion() -> Future<Void>
func flushDNS() -> Future<Bool>
func resolveDNS(name: String) -> Future<String>
func changeDNS(servers: [String], hardware: String) -> Future<Bool>
func currentDNS(hardware: [String]) -> Future<[String: [String]]>
func ifconfig() -> Future<String>
func hardwarePorts() -> Future<[HardwarePort]>
func removeUninstaller() -> Future<Void>
}
protocol XPCFirewallClient: XPCСommonClient {
func firewallState() -> Future<Bool>
func firewallEnable(_ enable: Bool) -> Future<Bool>
func firewallActivate(rulesPath: String, validate: Bool) -> Future<Bool>
func firewallDeactivate() -> Future<Bool>
func firewallRulesSave() -> Future<Void>
func firewallRulesRestore() -> Future<Void>
}
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<Void>
func disconnect() -> Future<Void>
func isConnected() -> Future<Bool>
}
protocol XPCUninstallerClient: XPCСommonClient {
func uninstall() -> Future<Void>
}