Drop jazzy, will use DocC
This commit is contained in:
parent
bc776eda85
commit
9e14f33235
61
.jazzy.yaml
61
.jazzy.yaml
|
@ -1,61 +0,0 @@
|
||||||
clean:
|
|
||||||
module: "TunnelKit"
|
|
||||||
author: "Davide De Rosa"
|
|
||||||
author_url: "https://github.com/passepartoutvpn/tunnelkit"
|
|
||||||
|
|
||||||
theme: fullwidth
|
|
||||||
|
|
||||||
custom_categories:
|
|
||||||
- name: Core
|
|
||||||
children:
|
|
||||||
- BidirectionalState
|
|
||||||
- ConfigurationError
|
|
||||||
- DNSProtocol
|
|
||||||
- DNSResolver
|
|
||||||
- DNSRecord
|
|
||||||
- EndpointProtocol
|
|
||||||
- IOInterface
|
|
||||||
- IPv4Settings
|
|
||||||
- IPv6Settings
|
|
||||||
- LinkInterface
|
|
||||||
- Proxy
|
|
||||||
- Session
|
|
||||||
- SocketType
|
|
||||||
- TunnelInterface
|
|
||||||
- IPHeader
|
|
||||||
- name: AppExtension
|
|
||||||
children:
|
|
||||||
- GenericSocket
|
|
||||||
- GenericSocketDelegate
|
|
||||||
- InterfaceObserver
|
|
||||||
- Keychain
|
|
||||||
- KeychainError
|
|
||||||
- LinkProducer
|
|
||||||
- MemoryDestination
|
|
||||||
- NETCPSocket
|
|
||||||
- NETunnelInterface
|
|
||||||
- NEUDPSocket
|
|
||||||
- name: Manager
|
|
||||||
children:
|
|
||||||
- VPN
|
|
||||||
- VPNConfiguration
|
|
||||||
- VPNProvider
|
|
||||||
- VPNProviderIPC
|
|
||||||
- VPNStatus
|
|
||||||
- NetworkExtensionLocator
|
|
||||||
- NetworkExtensionNativeLocator
|
|
||||||
- NetworkExtensionTunnelLocator
|
|
||||||
- NetworkExtensionVPNConfiguration
|
|
||||||
- NetworkExtensionVPNProvider
|
|
||||||
- MockVPNProvider
|
|
||||||
- name: Protocols/Native
|
|
||||||
children:
|
|
||||||
- NativeProvider
|
|
||||||
- name: Protocols/OpenVPN
|
|
||||||
children:
|
|
||||||
- OpenVPN
|
|
||||||
- OpenVPNError
|
|
||||||
- OpenVPNProvider
|
|
||||||
- OpenVPNSession
|
|
||||||
- OpenVPNSessionDelegate
|
|
||||||
- OpenVPNTunnelProvider
|
|
|
@ -44,7 +44,6 @@ public class MemoryDestination: BaseDestination, CustomStringConvertible {
|
||||||
/// Max number of retained lines.
|
/// Max number of retained lines.
|
||||||
public var maxLines: Int?
|
public var maxLines: Int?
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public override init() {
|
public override init() {
|
||||||
super.init()
|
super.init()
|
||||||
asynchronously = false
|
asynchronously = false
|
||||||
|
@ -76,7 +75,6 @@ public class MemoryDestination: BaseDestination, CustomStringConvertible {
|
||||||
// MARK: BaseDestination
|
// MARK: BaseDestination
|
||||||
|
|
||||||
// XXX: executed in SwiftyBeaver queue. DO NOT invoke execute* here (sync in sync would crash otherwise)
|
// XXX: executed in SwiftyBeaver queue. DO NOT invoke execute* here (sync in sync would crash otherwise)
|
||||||
/// :nodoc:
|
|
||||||
public override func send(_ level: SwiftyBeaver.Level, msg: String, thread: String, file: String, function: String, line: Int, context: Any?) -> String? {
|
public override func send(_ level: SwiftyBeaver.Level, msg: String, thread: String, file: String, function: String, line: Int, context: Any?) -> String? {
|
||||||
guard let message = super.send(level, msg: msg, thread: thread, file: file, function: function, line: line) else {
|
guard let message = super.send(level, msg: msg, thread: thread, file: file, function: function, line: line) else {
|
||||||
return nil
|
return nil
|
||||||
|
@ -92,7 +90,6 @@ public class MemoryDestination: BaseDestination, CustomStringConvertible {
|
||||||
|
|
||||||
// MARK: CustomStringConvertible
|
// MARK: CustomStringConvertible
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var description: String {
|
public var description: String {
|
||||||
return executeSynchronously {
|
return executeSynchronously {
|
||||||
return self.buffer.joined(separator: "\n")
|
return self.buffer.joined(separator: "\n")
|
||||||
|
|
|
@ -45,10 +45,8 @@ private let log = SwiftyBeaver.self
|
||||||
public class NETCPSocket: NSObject, GenericSocket {
|
public class NETCPSocket: NSObject, GenericSocket {
|
||||||
private static var linkContext = 0
|
private static var linkContext = 0
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public let impl: NWTCPConnection
|
public let impl: NWTCPConnection
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init(impl: NWTCPConnection) {
|
public init(impl: NWTCPConnection) {
|
||||||
self.impl = impl
|
self.impl = impl
|
||||||
isActive = false
|
isActive = false
|
||||||
|
@ -61,23 +59,18 @@ public class NETCPSocket: NSObject, GenericSocket {
|
||||||
|
|
||||||
private var isActive: Bool
|
private var isActive: Bool
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public private(set) var isShutdown: Bool
|
public private(set) var isShutdown: Bool
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var remoteAddress: String? {
|
public var remoteAddress: String? {
|
||||||
return (impl.remoteAddress as? NWHostEndpoint)?.hostname
|
return (impl.remoteAddress as? NWHostEndpoint)?.hostname
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var hasBetterPath: Bool {
|
public var hasBetterPath: Bool {
|
||||||
return impl.hasBetterPath
|
return impl.hasBetterPath
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public weak var delegate: GenericSocketDelegate?
|
public weak var delegate: GenericSocketDelegate?
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func observe(queue: DispatchQueue, activeTimeout: Int) {
|
public func observe(queue: DispatchQueue, activeTimeout: Int) {
|
||||||
isActive = false
|
isActive = false
|
||||||
|
|
||||||
|
@ -95,19 +88,16 @@ public class NETCPSocket: NSObject, GenericSocket {
|
||||||
impl.addObserver(self, forKeyPath: #keyPath(NWTCPConnection.hasBetterPath), options: .new, context: &NETCPSocket.linkContext)
|
impl.addObserver(self, forKeyPath: #keyPath(NWTCPConnection.hasBetterPath), options: .new, context: &NETCPSocket.linkContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func unobserve() {
|
public func unobserve() {
|
||||||
impl.removeObserver(self, forKeyPath: #keyPath(NWTCPConnection.state), context: &NETCPSocket.linkContext)
|
impl.removeObserver(self, forKeyPath: #keyPath(NWTCPConnection.state), context: &NETCPSocket.linkContext)
|
||||||
impl.removeObserver(self, forKeyPath: #keyPath(NWTCPConnection.hasBetterPath), context: &NETCPSocket.linkContext)
|
impl.removeObserver(self, forKeyPath: #keyPath(NWTCPConnection.hasBetterPath), context: &NETCPSocket.linkContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func shutdown() {
|
public func shutdown() {
|
||||||
impl.writeClose()
|
impl.writeClose()
|
||||||
impl.cancel()
|
impl.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func upgraded() -> GenericSocket? {
|
public func upgraded() -> GenericSocket? {
|
||||||
guard impl.hasBetterPath else {
|
guard impl.hasBetterPath else {
|
||||||
return nil
|
return nil
|
||||||
|
@ -117,7 +107,6 @@ public class NETCPSocket: NSObject, GenericSocket {
|
||||||
|
|
||||||
// MARK: Connection KVO (any queue)
|
// MARK: Connection KVO (any queue)
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
|
public override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
|
||||||
guard (context == &NETCPSocket.linkContext) else {
|
guard (context == &NETCPSocket.linkContext) else {
|
||||||
super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
|
super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
|
||||||
|
@ -183,7 +172,6 @@ public class NETCPSocket: NSObject, GenericSocket {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
extension NETCPSocket {
|
extension NETCPSocket {
|
||||||
public override var description: String {
|
public override var description: String {
|
||||||
guard let hostEndpoint = impl.endpoint as? NWHostEndpoint else {
|
guard let hostEndpoint = impl.endpoint as? NWHostEndpoint else {
|
||||||
|
|
|
@ -45,21 +45,18 @@ private let log = SwiftyBeaver.self
|
||||||
public class NETunnelInterface: TunnelInterface {
|
public class NETunnelInterface: TunnelInterface {
|
||||||
private weak var impl: NEPacketTunnelFlow?
|
private weak var impl: NEPacketTunnelFlow?
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init(impl: NEPacketTunnelFlow) {
|
public init(impl: NEPacketTunnelFlow) {
|
||||||
self.impl = impl
|
self.impl = impl
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: TunnelInterface
|
// MARK: TunnelInterface
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var isPersistent: Bool {
|
public var isPersistent: Bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: IOInterface
|
// MARK: IOInterface
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func setReadHandler(queue: DispatchQueue, _ handler: @escaping ([Data]?, Error?) -> Void) {
|
public func setReadHandler(queue: DispatchQueue, _ handler: @escaping ([Data]?, Error?) -> Void) {
|
||||||
loopReadPackets(queue, handler)
|
loopReadPackets(queue, handler)
|
||||||
}
|
}
|
||||||
|
@ -75,14 +72,12 @@ public class NETunnelInterface: TunnelInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func writePacket(_ packet: Data, completionHandler: ((Error?) -> Void)?) {
|
public func writePacket(_ packet: Data, completionHandler: ((Error?) -> Void)?) {
|
||||||
let protocolNumber = IPHeader.protocolNumber(inPacket: packet)
|
let protocolNumber = IPHeader.protocolNumber(inPacket: packet)
|
||||||
impl?.writePackets([packet], withProtocols: [protocolNumber])
|
impl?.writePackets([packet], withProtocols: [protocolNumber])
|
||||||
completionHandler?(nil)
|
completionHandler?(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func writePackets(_ packets: [Data], completionHandler: ((Error?) -> Void)?) {
|
public func writePackets(_ packets: [Data], completionHandler: ((Error?) -> Void)?) {
|
||||||
let protocols = packets.map {
|
let protocols = packets.map {
|
||||||
IPHeader.protocolNumber(inPacket: $0)
|
IPHeader.protocolNumber(inPacket: $0)
|
||||||
|
|
|
@ -45,10 +45,8 @@ private let log = SwiftyBeaver.self
|
||||||
public class NEUDPSocket: NSObject, GenericSocket {
|
public class NEUDPSocket: NSObject, GenericSocket {
|
||||||
private static var linkContext = 0
|
private static var linkContext = 0
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public let impl: NWUDPSession
|
public let impl: NWUDPSession
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init(impl: NWUDPSession) {
|
public init(impl: NWUDPSession) {
|
||||||
self.impl = impl
|
self.impl = impl
|
||||||
|
|
||||||
|
@ -62,23 +60,18 @@ public class NEUDPSocket: NSObject, GenericSocket {
|
||||||
|
|
||||||
private var isActive: Bool
|
private var isActive: Bool
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public private(set) var isShutdown: Bool
|
public private(set) var isShutdown: Bool
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var remoteAddress: String? {
|
public var remoteAddress: String? {
|
||||||
return (impl.resolvedEndpoint as? NWHostEndpoint)?.hostname
|
return (impl.resolvedEndpoint as? NWHostEndpoint)?.hostname
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var hasBetterPath: Bool {
|
public var hasBetterPath: Bool {
|
||||||
return impl.hasBetterPath
|
return impl.hasBetterPath
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public weak var delegate: GenericSocketDelegate?
|
public weak var delegate: GenericSocketDelegate?
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func observe(queue: DispatchQueue, activeTimeout: Int) {
|
public func observe(queue: DispatchQueue, activeTimeout: Int) {
|
||||||
isActive = false
|
isActive = false
|
||||||
|
|
||||||
|
@ -96,18 +89,15 @@ public class NEUDPSocket: NSObject, GenericSocket {
|
||||||
impl.addObserver(self, forKeyPath: #keyPath(NWUDPSession.hasBetterPath), options: .new, context: &NEUDPSocket.linkContext)
|
impl.addObserver(self, forKeyPath: #keyPath(NWUDPSession.hasBetterPath), options: .new, context: &NEUDPSocket.linkContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func unobserve() {
|
public func unobserve() {
|
||||||
impl.removeObserver(self, forKeyPath: #keyPath(NWUDPSession.state), context: &NEUDPSocket.linkContext)
|
impl.removeObserver(self, forKeyPath: #keyPath(NWUDPSession.state), context: &NEUDPSocket.linkContext)
|
||||||
impl.removeObserver(self, forKeyPath: #keyPath(NWUDPSession.hasBetterPath), context: &NEUDPSocket.linkContext)
|
impl.removeObserver(self, forKeyPath: #keyPath(NWUDPSession.hasBetterPath), context: &NEUDPSocket.linkContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func shutdown() {
|
public func shutdown() {
|
||||||
impl.cancel()
|
impl.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func upgraded() -> GenericSocket? {
|
public func upgraded() -> GenericSocket? {
|
||||||
guard impl.hasBetterPath else {
|
guard impl.hasBetterPath else {
|
||||||
return nil
|
return nil
|
||||||
|
@ -117,7 +107,6 @@ public class NEUDPSocket: NSObject, GenericSocket {
|
||||||
|
|
||||||
// MARK: Connection KVO (any queue)
|
// MARK: Connection KVO (any queue)
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
|
public override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
|
||||||
guard (context == &NEUDPSocket.linkContext) else {
|
guard (context == &NEUDPSocket.linkContext) else {
|
||||||
super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
|
super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
|
||||||
|
@ -186,7 +175,6 @@ public class NEUDPSocket: NSObject, GenericSocket {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
extension NEUDPSocket {
|
extension NEUDPSocket {
|
||||||
public override var description: String {
|
public override var description: String {
|
||||||
guard let hostEndpoint = impl.endpoint as? NWHostEndpoint else {
|
guard let hostEndpoint = impl.endpoint as? NWHostEndpoint else {
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
import NetworkExtension
|
import NetworkExtension
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
extension NWTCPConnectionState: CustomStringConvertible {
|
extension NWTCPConnectionState: CustomStringConvertible {
|
||||||
public var description: String {
|
public var description: String {
|
||||||
switch self {
|
switch self {
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
import NetworkExtension
|
import NetworkExtension
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
extension NWUDPSessionState: CustomStringConvertible {
|
extension NWUDPSessionState: CustomStringConvertible {
|
||||||
public var description: String {
|
public var description: String {
|
||||||
switch self {
|
switch self {
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public class CoreConfiguration {
|
public class CoreConfiguration {
|
||||||
public static let identifier = "com.algoritmico.TunnelKit"
|
public static let identifier = "com.algoritmico.TunnelKit"
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,6 @@ public struct DNSRecord {
|
||||||
/// `true` if IPv6.
|
/// `true` if IPv6.
|
||||||
public let isIPv6: Bool
|
public let isIPv6: Bool
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init(address: String, isIPv6: Bool) {
|
public init(address: String, isIPv6: Bool) {
|
||||||
self.address = address
|
self.address = address
|
||||||
self.isIPv6 = isIPv6
|
self.isIPv6 = isIPv6
|
||||||
|
|
|
@ -34,7 +34,6 @@ public struct EndpointProtocol: RawRepresentable, Equatable, CustomStringConvert
|
||||||
/// The remote port.
|
/// The remote port.
|
||||||
public let port: UInt16
|
public let port: UInt16
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init(_ socketType: SocketType, _ port: UInt16) {
|
public init(_ socketType: SocketType, _ port: UInt16) {
|
||||||
self.socketType = socketType
|
self.socketType = socketType
|
||||||
self.port = port
|
self.port = port
|
||||||
|
@ -42,7 +41,6 @@ public struct EndpointProtocol: RawRepresentable, Equatable, CustomStringConvert
|
||||||
|
|
||||||
// MARK: RawRepresentable
|
// MARK: RawRepresentable
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init?(rawValue: String) {
|
public init?(rawValue: String) {
|
||||||
let components = rawValue.components(separatedBy: ":")
|
let components = rawValue.components(separatedBy: ":")
|
||||||
guard components.count == 2 else {
|
guard components.count == 2 else {
|
||||||
|
@ -57,27 +55,23 @@ public struct EndpointProtocol: RawRepresentable, Equatable, CustomStringConvert
|
||||||
self.init(socketType, port)
|
self.init(socketType, port)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var rawValue: String {
|
public var rawValue: String {
|
||||||
return "\(socketType.rawValue):\(port)"
|
return "\(socketType.rawValue):\(port)"
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Equatable
|
// MARK: Equatable
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public static func ==(lhs: EndpointProtocol, rhs: EndpointProtocol) -> Bool {
|
public static func ==(lhs: EndpointProtocol, rhs: EndpointProtocol) -> Bool {
|
||||||
return (lhs.socketType == rhs.socketType) && (lhs.port == rhs.port)
|
return (lhs.socketType == rhs.socketType) && (lhs.port == rhs.port)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: CustomStringConvertible
|
// MARK: CustomStringConvertible
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var description: String {
|
public var description: String {
|
||||||
return rawValue
|
return rawValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
extension EndpointProtocol: Codable {
|
extension EndpointProtocol: Codable {
|
||||||
public init(from decoder: Decoder) throws {
|
public init(from decoder: Decoder) throws {
|
||||||
let container = try decoder.singleValueContainer()
|
let container = try decoder.singleValueContainer()
|
||||||
|
|
|
@ -40,7 +40,6 @@ public struct IPv4Settings: Codable, CustomStringConvertible {
|
||||||
/// The address of the gateway (uses default gateway if not set).
|
/// The address of the gateway (uses default gateway if not set).
|
||||||
public let gateway: String
|
public let gateway: String
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init(_ destination: String, _ mask: String?, _ gateway: String) {
|
public init(_ destination: String, _ mask: String?, _ gateway: String) {
|
||||||
self.destination = destination
|
self.destination = destination
|
||||||
self.mask = mask ?? "255.255.255.255"
|
self.mask = mask ?? "255.255.255.255"
|
||||||
|
@ -49,7 +48,6 @@ public struct IPv4Settings: Codable, CustomStringConvertible {
|
||||||
|
|
||||||
// MARK: CustomStringConvertible
|
// MARK: CustomStringConvertible
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var description: String {
|
public var description: String {
|
||||||
return "{\(destination.maskedDescription)/\(mask) \(gateway.maskedDescription)}"
|
return "{\(destination.maskedDescription)/\(mask) \(gateway.maskedDescription)}"
|
||||||
}
|
}
|
||||||
|
@ -67,7 +65,6 @@ public struct IPv4Settings: Codable, CustomStringConvertible {
|
||||||
/// The additional routes.
|
/// The additional routes.
|
||||||
public let routes: [Route]
|
public let routes: [Route]
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init(address: String, addressMask: String, defaultGateway: String, routes: [Route]) {
|
public init(address: String, addressMask: String, defaultGateway: String, routes: [Route]) {
|
||||||
self.address = address
|
self.address = address
|
||||||
self.addressMask = addressMask
|
self.addressMask = addressMask
|
||||||
|
@ -77,7 +74,6 @@ public struct IPv4Settings: Codable, CustomStringConvertible {
|
||||||
|
|
||||||
// MARK: CustomStringConvertible
|
// MARK: CustomStringConvertible
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var description: String {
|
public var description: String {
|
||||||
return "addr \(address.maskedDescription) netmask \(addressMask) gw \(defaultGateway.maskedDescription) routes \(routes.map { $0.maskedDescription })"
|
return "addr \(address.maskedDescription) netmask \(addressMask) gw \(defaultGateway.maskedDescription) routes \(routes.map { $0.maskedDescription })"
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ public struct IPv6Settings: Codable, CustomStringConvertible {
|
||||||
/// The address of the gateway (uses default gateway if not set).
|
/// The address of the gateway (uses default gateway if not set).
|
||||||
public let gateway: String
|
public let gateway: String
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init(_ destination: String, _ prefixLength: UInt8?, _ gateway: String) {
|
public init(_ destination: String, _ prefixLength: UInt8?, _ gateway: String) {
|
||||||
self.destination = destination
|
self.destination = destination
|
||||||
self.prefixLength = prefixLength ?? 3
|
self.prefixLength = prefixLength ?? 3
|
||||||
|
@ -49,7 +48,6 @@ public struct IPv6Settings: Codable, CustomStringConvertible {
|
||||||
|
|
||||||
// MARK: CustomStringConvertible
|
// MARK: CustomStringConvertible
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var description: String {
|
public var description: String {
|
||||||
return "{\(destination.maskedDescription)/\(prefixLength) \(gateway.maskedDescription)}"
|
return "{\(destination.maskedDescription)/\(prefixLength) \(gateway.maskedDescription)}"
|
||||||
}
|
}
|
||||||
|
@ -67,7 +65,6 @@ public struct IPv6Settings: Codable, CustomStringConvertible {
|
||||||
/// The additional routes.
|
/// The additional routes.
|
||||||
public let routes: [Route]
|
public let routes: [Route]
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init(address: String, addressPrefixLength: UInt8, defaultGateway: String, routes: [Route]) {
|
public init(address: String, addressPrefixLength: UInt8, defaultGateway: String, routes: [Route]) {
|
||||||
self.address = address
|
self.address = address
|
||||||
self.addressPrefixLength = addressPrefixLength
|
self.addressPrefixLength = addressPrefixLength
|
||||||
|
@ -77,7 +74,6 @@ public struct IPv6Settings: Codable, CustomStringConvertible {
|
||||||
|
|
||||||
// MARK: CustomStringConvertible
|
// MARK: CustomStringConvertible
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var description: String {
|
public var description: String {
|
||||||
return "addr \(address.maskedDescription)/\(addressPrefixLength) gw \(defaultGateway.maskedDescription) routes \(routes.map { $0.maskedDescription })"
|
return "addr \(address.maskedDescription)/\(addressPrefixLength) gw \(defaultGateway.maskedDescription) routes \(routes.map { $0.maskedDescription })"
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ public struct Proxy: Codable, RawRepresentable, CustomStringConvertible {
|
||||||
/// The proxy port.
|
/// The proxy port.
|
||||||
public let port: UInt16
|
public let port: UInt16
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init(_ address: String, _ port: UInt16) {
|
public init(_ address: String, _ port: UInt16) {
|
||||||
self.address = address
|
self.address = address
|
||||||
self.port = port
|
self.port = port
|
||||||
|
@ -42,12 +41,10 @@ public struct Proxy: Codable, RawRepresentable, CustomStringConvertible {
|
||||||
|
|
||||||
// MARK: RawRepresentable
|
// MARK: RawRepresentable
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var rawValue: String {
|
public var rawValue: String {
|
||||||
return "\(address):\(port)"
|
return "\(address):\(port)"
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init?(rawValue: String) {
|
public init?(rawValue: String) {
|
||||||
let comps = rawValue.components(separatedBy: ":")
|
let comps = rawValue.components(separatedBy: ":")
|
||||||
guard comps.count == 2, let port = UInt16(comps[1]) else {
|
guard comps.count == 2, let port = UInt16(comps[1]) else {
|
||||||
|
@ -58,7 +55,6 @@ public struct Proxy: Codable, RawRepresentable, CustomStringConvertible {
|
||||||
|
|
||||||
// MARK: CustomStringConvertible
|
// MARK: CustomStringConvertible
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var description: String {
|
public var description: String {
|
||||||
return rawValue
|
return rawValue
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,12 +39,10 @@ import Security.SecRandom
|
||||||
import CTunnelKitCore
|
import CTunnelKitCore
|
||||||
import __TunnelKitUtils
|
import __TunnelKitUtils
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public enum SecureRandomError: Error {
|
public enum SecureRandomError: Error {
|
||||||
case randomGenerator
|
case randomGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public class SecureRandom {
|
public class SecureRandom {
|
||||||
@available(*, deprecated)
|
@available(*, deprecated)
|
||||||
static func uint32FromBuffer() throws -> UInt32 {
|
static func uint32FromBuffer() throws -> UInt32 {
|
||||||
|
|
|
@ -30,7 +30,6 @@ import TunnelKitManager
|
||||||
public class NativeProvider: VPNProvider {
|
public class NativeProvider: VPNProvider {
|
||||||
private let provider: NetworkExtensionVPNProvider
|
private let provider: NetworkExtensionVPNProvider
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init() {
|
public init() {
|
||||||
provider = NetworkExtensionVPNProvider(locator: NetworkExtensionNativeLocator())
|
provider = NetworkExtensionVPNProvider(locator: NetworkExtensionNativeLocator())
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ import Foundation
|
||||||
/// Simulates a VPN provider.
|
/// Simulates a VPN provider.
|
||||||
public class MockVPNProvider: VPNProvider, VPNProviderIPC {
|
public class MockVPNProvider: VPNProvider, VPNProviderIPC {
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init() {
|
public init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ public protocol NetworkExtensionLocator {
|
||||||
/// Locator for native VPN protocols.
|
/// Locator for native VPN protocols.
|
||||||
public class NetworkExtensionNativeLocator: NetworkExtensionLocator {
|
public class NetworkExtensionNativeLocator: NetworkExtensionLocator {
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init() {
|
public init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ import NetworkExtension
|
||||||
/// A `VPNConfiguration` built on top of NetworkExtension entities.
|
/// A `VPNConfiguration` built on top of NetworkExtension entities.
|
||||||
public struct NetworkExtensionVPNConfiguration: VPNConfiguration {
|
public struct NetworkExtensionVPNConfiguration: VPNConfiguration {
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var title: String
|
public var title: String
|
||||||
|
|
||||||
/// The `NEVPNProtocol` object embedding tunnel configuration.
|
/// The `NEVPNProtocol` object embedding tunnel configuration.
|
||||||
|
@ -38,7 +37,6 @@ public struct NetworkExtensionVPNConfiguration: VPNConfiguration {
|
||||||
/// The on-demand rules to establish.
|
/// The on-demand rules to establish.
|
||||||
public let onDemandRules: [NEOnDemandRule]
|
public let onDemandRules: [NEOnDemandRule]
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init(title: String, protocolConfiguration: NEVPNProtocol, onDemandRules: [NEOnDemandRule]) {
|
public init(title: String, protocolConfiguration: NEVPNProtocol, onDemandRules: [NEOnDemandRule]) {
|
||||||
self.title = title
|
self.title = title
|
||||||
self.protocolConfiguration = protocolConfiguration
|
self.protocolConfiguration = protocolConfiguration
|
||||||
|
|
|
@ -98,7 +98,6 @@ class NETCPLink: LinkInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
extension NETCPSocket: LinkProducer {
|
extension NETCPSocket: LinkProducer {
|
||||||
public func link(xorMask: UInt8?) -> LinkInterface {
|
public func link(xorMask: UInt8?) -> LinkInterface {
|
||||||
return NETCPLink(impl: impl, maxPacketSize: nil, xorMask: xorMask)
|
return NETCPLink(impl: impl, maxPacketSize: nil, xorMask: xorMask)
|
||||||
|
|
|
@ -101,7 +101,6 @@ class NEUDPLink: LinkInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
extension NEUDPSocket: LinkProducer {
|
extension NEUDPSocket: LinkProducer {
|
||||||
public func link(xorMask: UInt8?) -> LinkInterface {
|
public func link(xorMask: UInt8?) -> LinkInterface {
|
||||||
return NEUDPLink(impl: impl, maxDatagrams: nil, xorMask: xorMask)
|
return NEUDPLink(impl: impl, maxDatagrams: nil, xorMask: xorMask)
|
||||||
|
|
|
@ -141,14 +141,12 @@ open class OpenVPNTunnelProvider: NEPacketTunnelProvider {
|
||||||
|
|
||||||
// MARK: NEPacketTunnelProvider (XPC queue)
|
// MARK: NEPacketTunnelProvider (XPC queue)
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
open override var reasserting: Bool {
|
open override var reasserting: Bool {
|
||||||
didSet {
|
didSet {
|
||||||
log.debug("Reasserting flag \(reasserting ? "set" : "cleared")")
|
log.debug("Reasserting flag \(reasserting ? "set" : "cleared")")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
open override func startTunnel(options: [String : NSObject]? = nil, completionHandler: @escaping (Error?) -> Void) {
|
open override func startTunnel(options: [String : NSObject]? = nil, completionHandler: @escaping (Error?) -> Void) {
|
||||||
|
|
||||||
// required configuration
|
// required configuration
|
||||||
|
@ -262,7 +260,6 @@ open class OpenVPNTunnelProvider: NEPacketTunnelProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
open override func stopTunnel(with reason: NEProviderStopReason, completionHandler: @escaping () -> Void) {
|
open override func stopTunnel(with reason: NEProviderStopReason, completionHandler: @escaping () -> Void) {
|
||||||
pendingStartHandler = nil
|
pendingStartHandler = nil
|
||||||
log.info("Stopping tunnel...")
|
log.info("Stopping tunnel...")
|
||||||
|
@ -293,7 +290,6 @@ open class OpenVPNTunnelProvider: NEPacketTunnelProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
open override func handleAppMessage(_ messageData: Data, completionHandler: ((Data?) -> Void)? = nil) {
|
open override func handleAppMessage(_ messageData: Data, completionHandler: ((Data?) -> Void)? = nil) {
|
||||||
var response: Data?
|
var response: Data?
|
||||||
switch OpenVPNProvider.Message(messageData) {
|
switch OpenVPNProvider.Message(messageData) {
|
||||||
|
@ -321,12 +317,10 @@ open class OpenVPNTunnelProvider: NEPacketTunnelProvider {
|
||||||
|
|
||||||
// MARK: Wake/Sleep (debugging placeholders)
|
// MARK: Wake/Sleep (debugging placeholders)
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
open override func wake() {
|
open override func wake() {
|
||||||
log.verbose("Wake signal received")
|
log.verbose("Wake signal received")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
open override func sleep(completionHandler: @escaping () -> Void) {
|
open override func sleep(completionHandler: @escaping () -> Void) {
|
||||||
log.verbose("Sleep signal received")
|
log.verbose("Sleep signal received")
|
||||||
completionHandler()
|
completionHandler()
|
||||||
|
@ -439,7 +433,6 @@ extension OpenVPNTunnelProvider: GenericSocketDelegate {
|
||||||
|
|
||||||
// MARK: GenericSocketDelegate (tunnel queue)
|
// MARK: GenericSocketDelegate (tunnel queue)
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func socketDidTimeout(_ socket: GenericSocket) {
|
public func socketDidTimeout(_ socket: GenericSocket) {
|
||||||
log.debug("Socket timed out waiting for activity, cancelling...")
|
log.debug("Socket timed out waiting for activity, cancelling...")
|
||||||
shouldReconnect = true
|
shouldReconnect = true
|
||||||
|
@ -454,7 +447,6 @@ extension OpenVPNTunnelProvider: GenericSocketDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func socketDidBecomeActive(_ socket: GenericSocket) {
|
public func socketDidBecomeActive(_ socket: GenericSocket) {
|
||||||
guard let session = session, let producer = socket as? LinkProducer else {
|
guard let session = session, let producer = socket as? LinkProducer else {
|
||||||
return
|
return
|
||||||
|
@ -467,7 +459,6 @@ extension OpenVPNTunnelProvider: GenericSocketDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func socket(_ socket: GenericSocket, didShutdownWithFailure failure: Bool) {
|
public func socket(_ socket: GenericSocket, didShutdownWithFailure failure: Bool) {
|
||||||
guard let session = session else {
|
guard let session = session else {
|
||||||
return
|
return
|
||||||
|
@ -522,7 +513,6 @@ extension OpenVPNTunnelProvider: GenericSocketDelegate {
|
||||||
disposeTunnel(error: shutdownError)
|
disposeTunnel(error: shutdownError)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func socketHasBetterPath(_ socket: GenericSocket) {
|
public func socketHasBetterPath(_ socket: GenericSocket) {
|
||||||
log.debug("Stopping tunnel due to a new better path")
|
log.debug("Stopping tunnel due to a new better path")
|
||||||
logCurrentSSID()
|
logCurrentSSID()
|
||||||
|
@ -534,7 +524,6 @@ extension OpenVPNTunnelProvider: OpenVPNSessionDelegate {
|
||||||
|
|
||||||
// MARK: OpenVPNSessionDelegate (tunnel queue)
|
// MARK: OpenVPNSessionDelegate (tunnel queue)
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func sessionDidStart(_ session: OpenVPNSession, remoteAddress: String, options: OpenVPN.Configuration) {
|
public func sessionDidStart(_ session: OpenVPNSession, remoteAddress: String, options: OpenVPN.Configuration) {
|
||||||
log.info("Session did start")
|
log.info("Session did start")
|
||||||
|
|
||||||
|
@ -599,7 +588,6 @@ extension OpenVPNTunnelProvider: OpenVPNSessionDelegate {
|
||||||
refreshDataCount()
|
refreshDataCount()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func sessionDidStop(_: OpenVPNSession, withError error: Error?, shouldReconnect: Bool) {
|
public func sessionDidStop(_: OpenVPNSession, withError error: Error?, shouldReconnect: Bool) {
|
||||||
if let error = error {
|
if let error = error {
|
||||||
log.error("Session did stop with error: \(error)")
|
log.error("Session did stop with error: \(error)")
|
||||||
|
|
|
@ -40,7 +40,6 @@ extension OpenVPN {
|
||||||
/// Any other compression algorithm (unsupported).
|
/// Any other compression algorithm (unsupported).
|
||||||
case other
|
case other
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var native: CompressionAlgorithmNative {
|
public var native: CompressionAlgorithmNative {
|
||||||
guard let val = CompressionAlgorithmNative(rawValue: rawValue) else {
|
guard let val = CompressionAlgorithmNative(rawValue: rawValue) else {
|
||||||
fatalError("Unhandled CompressionAlgorithm bridging")
|
fatalError("Unhandled CompressionAlgorithm bridging")
|
||||||
|
@ -50,7 +49,6 @@ extension OpenVPN {
|
||||||
|
|
||||||
// MARK: CustomStringConvertible
|
// MARK: CustomStringConvertible
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var description: String {
|
public var description: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .disabled:
|
case .disabled:
|
||||||
|
|
|
@ -43,7 +43,6 @@ extension OpenVPN {
|
||||||
/// Framing compatible with 2.4 `compress` (version 2, e.g. stub-v2).
|
/// Framing compatible with 2.4 `compress` (version 2, e.g. stub-v2).
|
||||||
case compressV2
|
case compressV2
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var native: CompressionFramingNative {
|
public var native: CompressionFramingNative {
|
||||||
guard let val = CompressionFramingNative(rawValue: rawValue) else {
|
guard let val = CompressionFramingNative(rawValue: rawValue) else {
|
||||||
fatalError("Unhandled CompressionFraming bridging")
|
fatalError("Unhandled CompressionFraming bridging")
|
||||||
|
@ -53,7 +52,6 @@ extension OpenVPN {
|
||||||
|
|
||||||
// MARK: CustomStringConvertible
|
// MARK: CustomStringConvertible
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var description: String {
|
public var description: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .disabled:
|
case .disabled:
|
||||||
|
|
|
@ -59,7 +59,6 @@ extension OpenVPN {
|
||||||
|
|
||||||
// MARK: Equatable
|
// MARK: Equatable
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public static func ==(lhs: Credentials, rhs: Credentials) -> Bool {
|
public static func ==(lhs: Credentials, rhs: Credentials) -> Bool {
|
||||||
return (lhs.username == rhs.username) && (lhs.password == rhs.password)
|
return (lhs.username == rhs.username) && (lhs.password == rhs.password)
|
||||||
}
|
}
|
||||||
|
@ -112,7 +111,6 @@ extension OpenVPN {
|
||||||
return rawValue.hasSuffix("-GCM") ? "AES-GCM" : "AES-CBC"
|
return rawValue.hasSuffix("-GCM") ? "AES-GCM" : "AES-CBC"
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var description: String {
|
public var description: String {
|
||||||
return rawValue
|
return rawValue
|
||||||
}
|
}
|
||||||
|
@ -143,7 +141,6 @@ extension OpenVPN {
|
||||||
return "HMAC"
|
return "HMAC"
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var description: String {
|
public var description: String {
|
||||||
return "\(genericName)-\(rawValue)"
|
return "\(genericName)-\(rawValue)"
|
||||||
}
|
}
|
||||||
|
@ -162,7 +159,6 @@ extension OpenVPN {
|
||||||
case blockLocal
|
case blockLocal
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
private struct Fallback {
|
private struct Fallback {
|
||||||
static let cipher: Cipher = .aes128cbc
|
static let cipher: Cipher = .aes128cbc
|
||||||
|
|
||||||
|
@ -301,7 +297,6 @@ extension OpenVPN {
|
||||||
/// Policies for redirecting traffic through the VPN gateway.
|
/// Policies for redirecting traffic through the VPN gateway.
|
||||||
public var routingPolicies: [RoutingPolicy]?
|
public var routingPolicies: [RoutingPolicy]?
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init() {
|
public init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,22 +347,18 @@ extension OpenVPN {
|
||||||
|
|
||||||
// MARK: Shortcuts
|
// MARK: Shortcuts
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var fallbackCipher: Cipher {
|
public var fallbackCipher: Cipher {
|
||||||
return cipher ?? Fallback.cipher
|
return cipher ?? Fallback.cipher
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var fallbackDigest: Digest {
|
public var fallbackDigest: Digest {
|
||||||
return digest ?? Fallback.digest
|
return digest ?? Fallback.digest
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var fallbackCompressionFraming: CompressionFraming {
|
public var fallbackCompressionFraming: CompressionFraming {
|
||||||
return compressionFraming ?? Fallback.compressionFraming
|
return compressionFraming ?? Fallback.compressionFraming
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var fallbackCompressionAlgorithm: CompressionAlgorithm {
|
public var fallbackCompressionAlgorithm: CompressionAlgorithm {
|
||||||
return compressionAlgorithm ?? Fallback.compressionAlgorithm
|
return compressionAlgorithm ?? Fallback.compressionAlgorithm
|
||||||
}
|
}
|
||||||
|
@ -483,17 +474,14 @@ extension OpenVPN {
|
||||||
|
|
||||||
// MARK: Shortcuts
|
// MARK: Shortcuts
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var fallbackCipher: Cipher {
|
public var fallbackCipher: Cipher {
|
||||||
return cipher ?? Fallback.cipher
|
return cipher ?? Fallback.cipher
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var fallbackDigest: Digest {
|
public var fallbackDigest: Digest {
|
||||||
return digest ?? Fallback.digest
|
return digest ?? Fallback.digest
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public var fallbackCompressionFraming: CompressionFraming {
|
public var fallbackCompressionFraming: CompressionFraming {
|
||||||
return compressionFraming ?? Fallback.compressionFraming
|
return compressionFraming ?? Fallback.compressionFraming
|
||||||
}
|
}
|
||||||
|
@ -554,7 +542,6 @@ extension OpenVPN.Configuration {
|
||||||
|
|
||||||
extension OpenVPN.Configuration {
|
extension OpenVPN.Configuration {
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func print() {
|
public func print() {
|
||||||
guard let endpointProtocols = endpointProtocols else {
|
guard let endpointProtocols = endpointProtocols else {
|
||||||
fatalError("No sessionConfiguration.endpointProtocols set")
|
fatalError("No sessionConfiguration.endpointProtocols set")
|
||||||
|
|
|
@ -84,7 +84,6 @@ extension OpenVPN {
|
||||||
|
|
||||||
// MARK: Server
|
// MARK: Server
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public static let authToken = NSRegularExpression("^auth-token +[a-zA-Z0-9/=+]+")
|
public static let authToken = NSRegularExpression("^auth-token +[a-zA-Z0-9/=+]+")
|
||||||
|
|
||||||
static let peerId = NSRegularExpression("^peer-id +[0-9]+")
|
static let peerId = NSRegularExpression("^peer-id +[0-9]+")
|
||||||
|
|
|
@ -54,7 +54,6 @@ extension OpenVPN {
|
||||||
return pem.contains("ENCRYPTED")
|
return pem.contains("ENCRYPTED")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init(pem: String) {
|
public init(pem: String) {
|
||||||
guard let beginRange = pem.range(of: CryptoContainer.begin) else {
|
guard let beginRange = pem.range(of: CryptoContainer.begin) else {
|
||||||
self.pem = ""
|
self.pem = ""
|
||||||
|
@ -75,21 +74,18 @@ extension OpenVPN {
|
||||||
|
|
||||||
// MARK: Equatable
|
// MARK: Equatable
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public static func ==(lhs: CryptoContainer, rhs: CryptoContainer) -> Bool {
|
public static func ==(lhs: CryptoContainer, rhs: CryptoContainer) -> Bool {
|
||||||
return lhs.pem == rhs.pem
|
return lhs.pem == rhs.pem
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Codable
|
// MARK: Codable
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init(from decoder: Decoder) throws {
|
public init(from decoder: Decoder) throws {
|
||||||
let container = try decoder.singleValueContainer()
|
let container = try decoder.singleValueContainer()
|
||||||
let pem = try container.decode(String.self)
|
let pem = try container.decode(String.self)
|
||||||
self.init(pem: pem)
|
self.init(pem: pem)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.singleValueContainer()
|
var container = encoder.singleValueContainer()
|
||||||
try container.encode(pem)
|
try container.encode(pem)
|
||||||
|
|
|
@ -61,7 +61,6 @@ extension OpenVPN {
|
||||||
|
|
||||||
private let secureData: ZeroingData
|
private let secureData: ZeroingData
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public let direction: Direction?
|
public let direction: Direction?
|
||||||
|
|
||||||
/// Returns the encryption key.
|
/// Returns the encryption key.
|
||||||
|
@ -153,7 +152,6 @@ extension OpenVPN {
|
||||||
self.init(lines: lines, direction: direction)
|
self.init(lines: lines, direction: direction)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public convenience init?(lines: [Substring], direction: Direction?) {
|
public convenience init?(lines: [Substring], direction: Direction?) {
|
||||||
var isHead = true
|
var isHead = true
|
||||||
var hexLines: [Substring] = []
|
var hexLines: [Substring] = []
|
||||||
|
@ -208,26 +206,22 @@ extension OpenVPN {
|
||||||
return secureData.withOffset(at * size, count: size)
|
return secureData.withOffset(at * size, count: size)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public static func deserialized(_ data: Data) throws -> StaticKey {
|
public static func deserialized(_ data: Data) throws -> StaticKey {
|
||||||
return try JSONDecoder().decode(StaticKey.self, from: data)
|
return try JSONDecoder().decode(StaticKey.self, from: data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func serialized() -> Data? {
|
public func serialized() -> Data? {
|
||||||
return try? JSONEncoder().encode(self)
|
return try? JSONEncoder().encode(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Codable
|
// MARK: Codable
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public required init(from decoder: Decoder) throws {
|
public required init(from decoder: Decoder) throws {
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
secureData = Z(try container.decode(Data.self, forKey: .data))
|
secureData = Z(try container.decode(Data.self, forKey: .data))
|
||||||
direction = try container.decodeIfPresent(Direction.self, forKey: .dir)
|
direction = try container.decodeIfPresent(Direction.self, forKey: .dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(secureData.toData(), forKey: .data)
|
try container.encode(secureData.toData(), forKey: .data)
|
||||||
|
|
|
@ -46,18 +46,15 @@ extension OpenVPN {
|
||||||
/// The static encryption key.
|
/// The static encryption key.
|
||||||
public let key: StaticKey
|
public let key: StaticKey
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init(strategy: Strategy, key: StaticKey) {
|
public init(strategy: Strategy, key: StaticKey) {
|
||||||
self.strategy = strategy
|
self.strategy = strategy
|
||||||
self.key = key
|
self.key = key
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public static func deserialized(_ data: Data) throws -> TLSWrap {
|
public static func deserialized(_ data: Data) throws -> TLSWrap {
|
||||||
return try JSONDecoder().decode(TLSWrap.self, from: data)
|
return try JSONDecoder().decode(TLSWrap.self, from: data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func serialized() -> Data? {
|
public func serialized() -> Data? {
|
||||||
return try? JSONEncoder().encode(self)
|
return try? JSONEncoder().encode(self)
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ extension OpenVPNProvider {
|
||||||
/// The way to create a `OpenVPNProvider.Configuration` object for the tunnel profile.
|
/// The way to create a `OpenVPNProvider.Configuration` object for the tunnel profile.
|
||||||
public struct ConfigurationBuilder {
|
public struct ConfigurationBuilder {
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public static let defaults = Configuration(
|
public static let defaults = Configuration(
|
||||||
sessionConfiguration: OpenVPN.ConfigurationBuilder().build(),
|
sessionConfiguration: OpenVPN.ConfigurationBuilder().build(),
|
||||||
prefersResolvedAddresses: false,
|
prefersResolvedAddresses: false,
|
||||||
|
@ -154,7 +153,6 @@ extension OpenVPNProvider {
|
||||||
|
|
||||||
static let debugLogFilename = "debug.log"
|
static let debugLogFilename = "debug.log"
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public static let lastErrorKey = "TunnelKitLastError"
|
public static let lastErrorKey = "TunnelKitLastError"
|
||||||
|
|
||||||
fileprivate static let dataCountKey = "TunnelKitDataCount"
|
fileprivate static let dataCountKey = "TunnelKitDataCount"
|
||||||
|
@ -304,7 +302,6 @@ extension OpenVPNProvider {
|
||||||
return protocolConfiguration
|
return protocolConfiguration
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func print(appVersion: String?) {
|
public func print(appVersion: String?) {
|
||||||
if let appVersion = appVersion {
|
if let appVersion = appVersion {
|
||||||
log.info("App version: \(appVersion)")
|
log.info("App version: \(appVersion)")
|
||||||
|
@ -337,7 +334,6 @@ extension OpenVPNProvider.Configuration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public extension UserDefaults {
|
public extension UserDefaults {
|
||||||
@objc var dataCountArray: [Int]? {
|
@objc var dataCountArray: [Int]? {
|
||||||
get {
|
get {
|
||||||
|
|
|
@ -53,14 +53,12 @@ extension OpenVPNProvider {
|
||||||
data = Data([byte])
|
data = Data([byte])
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public init(_ data: Data) {
|
public init(_ data: Data) {
|
||||||
self.data = data
|
self.data = data
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Equatable
|
// MARK: Equatable
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public static func ==(lhs: Message, rhs: Message) -> Bool {
|
public static func ==(lhs: Message, rhs: Message) -> Bool {
|
||||||
return (lhs.data == rhs.data)
|
return (lhs.data == rhs.data)
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,7 +203,6 @@ public class OpenVPNSession: Session {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
deinit {
|
deinit {
|
||||||
cleanup()
|
cleanup()
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,8 @@ import TunnelKitOpenVPNCore
|
||||||
import CTunnelKitCore
|
import CTunnelKitCore
|
||||||
import CTunnelKitOpenVPNProtocol
|
import CTunnelKitOpenVPNProtocol
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
extension ControlPacket {
|
extension ControlPacket {
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
open override var description: String {
|
open override var description: String {
|
||||||
var msg: [String] = ["\(code) | \(key)"]
|
var msg: [String] = ["\(code) | \(key)"]
|
||||||
msg.append("sid: \(sessionId.toHex())")
|
msg.append("sid: \(sessionId.toHex())")
|
||||||
|
@ -86,7 +84,6 @@ extension OpenVPN {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
extension PacketCode: CustomStringConvertible {
|
extension PacketCode: CustomStringConvertible {
|
||||||
public var description: String {
|
public var description: String {
|
||||||
switch self {
|
switch self {
|
||||||
|
|
|
@ -60,7 +60,6 @@ extension OpenVPN {
|
||||||
|
|
||||||
// MARK: CustomStringConvertible
|
// MARK: CustomStringConvertible
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
var description: String {
|
var description: String {
|
||||||
let stripped = NSMutableString(string: original)
|
let stripped = NSMutableString(string: original)
|
||||||
ConfigurationParser.Regex.authToken.replaceMatches(
|
ConfigurationParser.Regex.authToken.replaceMatches(
|
||||||
|
|
|
@ -39,7 +39,6 @@ import Foundation
|
||||||
// hex -> Data conversion code from: http://stackoverflow.com/questions/32231926/nsdata-from-hex-string
|
// hex -> Data conversion code from: http://stackoverflow.com/questions/32231926/nsdata-from-hex-string
|
||||||
// Data -> hex conversion code from: http://stackoverflow.com/questions/39075043/how-to-convert-data-to-hex-string-in-swift
|
// Data -> hex conversion code from: http://stackoverflow.com/questions/39075043/how-to-convert-data-to-hex-string-in-swift
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
extension UnicodeScalar {
|
extension UnicodeScalar {
|
||||||
public var hexNibble: UInt8 {
|
public var hexNibble: UInt8 {
|
||||||
let value = self.value
|
let value = self.value
|
||||||
|
@ -56,7 +55,6 @@ extension UnicodeScalar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
extension Data {
|
extension Data {
|
||||||
public init(hex: String) {
|
public init(hex: String) {
|
||||||
let scalars = hex.unicodeScalars
|
let scalars = hex.unicodeScalars
|
||||||
|
@ -84,7 +82,6 @@ extension Data {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
extension Data {
|
extension Data {
|
||||||
public mutating func append(_ value: UInt16) {
|
public mutating func append(_ value: UInt16) {
|
||||||
var localValue = value
|
var localValue = value
|
||||||
|
@ -204,28 +201,24 @@ extension Data {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
extension Data {
|
extension Data {
|
||||||
public func subdata(offset: Int, count: Int) -> Data {
|
public func subdata(offset: Int, count: Int) -> Data {
|
||||||
return subdata(in: offset..<(offset + count))
|
return subdata(in: offset..<(offset + count))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
extension Array where Element == Data {
|
extension Array where Element == Data {
|
||||||
public var flatCount: Int {
|
public var flatCount: Int {
|
||||||
return reduce(0) { $0 + $1.count }
|
return reduce(0) { $0 + $1.count }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
extension UnsafeRawBufferPointer {
|
extension UnsafeRawBufferPointer {
|
||||||
public var bytePointer: UnsafePointer<Element> {
|
public var bytePointer: UnsafePointer<Element> {
|
||||||
return bindMemory(to: Element.self).baseAddress!
|
return bindMemory(to: Element.self).baseAddress!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
extension UnsafeMutableRawBufferPointer {
|
extension UnsafeMutableRawBufferPointer {
|
||||||
public var bytePointer: UnsafeMutablePointer<Element> {
|
public var bytePointer: UnsafeMutablePointer<Element> {
|
||||||
return bindMemory(to: Element.self).baseAddress!
|
return bindMemory(to: Element.self).baseAddress!
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
extension NSRegularExpression {
|
extension NSRegularExpression {
|
||||||
public convenience init(_ pattern: String) {
|
public convenience init(_ pattern: String) {
|
||||||
try! self.init(pattern: pattern, options: [])
|
try! self.init(pattern: pattern, options: [])
|
||||||
|
|
|
@ -36,20 +36,17 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public extension DispatchQueue {
|
public extension DispatchQueue {
|
||||||
func schedule(after: DispatchTimeInterval, block: @escaping () -> Void) {
|
func schedule(after: DispatchTimeInterval, block: @escaping () -> Void) {
|
||||||
asyncAfter(deadline: .now() + after, execute: block)
|
asyncAfter(deadline: .now() + after, execute: block)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public func fromDictionary<T: Decodable>(_ type: T.Type, _ dictionary: [String: Any]) throws -> T {
|
public func fromDictionary<T: Decodable>(_ type: T.Type, _ dictionary: [String: Any]) throws -> T {
|
||||||
let data = try JSONSerialization.data(withJSONObject: dictionary, options: .fragmentsAllowed)
|
let data = try JSONSerialization.data(withJSONObject: dictionary, options: .fragmentsAllowed)
|
||||||
return try JSONDecoder().decode(T.self, from: data)
|
return try JSONDecoder().decode(T.self, from: data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
public extension Encodable {
|
public extension Encodable {
|
||||||
func asDictionary() throws -> [String: Any] {
|
func asDictionary() throws -> [String: Any] {
|
||||||
let data = try JSONEncoder().encode(self)
|
let data = try JSONEncoder().encode(self)
|
||||||
|
@ -60,7 +57,6 @@ public extension Encodable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
|
||||||
extension TimeInterval {
|
extension TimeInterval {
|
||||||
public var asTimeString: String {
|
public var asTimeString: String {
|
||||||
var ticks = Int(self)
|
var ticks = Int(self)
|
||||||
|
|
Loading…
Reference in New Issue