Convert CocoaPods project to SwiftPM
This commit is contained in:
parent
1b5f5dd663
commit
50ea1ea81a
2
.gitignore
vendored
2
.gitignore
vendored
@ -7,3 +7,5 @@
|
||||
Pods
|
||||
docs
|
||||
build
|
||||
.swiftpm
|
||||
.build
|
||||
|
@ -5,14 +5,6 @@ author_url: "https://github.com/passepartoutvpn/tunnelkit"
|
||||
|
||||
theme: fullwidth
|
||||
|
||||
xcodebuild_arguments:
|
||||
- "-workspace"
|
||||
- "TunnelKit.xcworkspace"
|
||||
- "-scheme"
|
||||
- "TunnelKit-iOS"
|
||||
- "-sdk"
|
||||
- "iphoneos"
|
||||
|
||||
custom_categories:
|
||||
- name: Core
|
||||
children:
|
||||
|
@ -24,7 +24,8 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import TunnelKit
|
||||
import TunnelKitCore
|
||||
import TunnelKitOpenVPN
|
||||
|
||||
struct Configuration {
|
||||
static let ca = OpenVPN.CryptoContainer(pem: """
|
@ -23,7 +23,7 @@
|
||||
// along with TunnelKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
import TunnelKit
|
||||
import TunnelKitOpenVPN
|
||||
|
||||
class PacketTunnelProvider: OpenVPNTunnelProvider {
|
||||
}
|
6
Demo/Demo/iOS/Assets.xcassets/Contents.json
Normal file
6
Demo/Demo/iOS/Assets.xcassets/Contents.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -24,7 +24,10 @@
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import TunnelKit
|
||||
import TunnelKitCore
|
||||
import TunnelKitAppExtension
|
||||
import TunnelKitManager
|
||||
import TunnelKitOpenVPN
|
||||
|
||||
private let appGroup = "group.com.algoritmico.TunnelKit.Demo"
|
||||
|
@ -24,7 +24,10 @@
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
import TunnelKit
|
||||
import TunnelKitCore
|
||||
import TunnelKitAppExtension
|
||||
import TunnelKitManager
|
||||
import TunnelKitOpenVPN
|
||||
|
||||
private let appGroup = "DTDYD63ZX9.group.com.algoritmico.TunnelKit.Demo"
|
||||
|
1054
Demo/TunnelKit.xcodeproj/project.pbxproj
Normal file
1054
Demo/TunnelKit.xcodeproj/project.pbxproj
Normal file
File diff suppressed because it is too large
Load Diff
97
Gemfile.lock
97
Gemfile.lock
@ -1,97 +0,0 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
CFPropertyList (3.0.4)
|
||||
rexml
|
||||
activesupport (6.1.4.1)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 1.6, < 2)
|
||||
minitest (>= 5.1)
|
||||
tzinfo (~> 2.0)
|
||||
zeitwerk (~> 2.3)
|
||||
addressable (2.8.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
algoliasearch (1.27.5)
|
||||
httpclient (~> 2.8, >= 2.8.3)
|
||||
json (>= 1.5.1)
|
||||
atomos (0.1.3)
|
||||
claide (1.0.3)
|
||||
cocoapods (1.11.2)
|
||||
addressable (~> 2.8)
|
||||
claide (>= 1.0.2, < 2.0)
|
||||
cocoapods-core (= 1.11.2)
|
||||
cocoapods-deintegrate (>= 1.0.3, < 2.0)
|
||||
cocoapods-downloader (>= 1.4.0, < 2.0)
|
||||
cocoapods-plugins (>= 1.0.0, < 2.0)
|
||||
cocoapods-search (>= 1.0.0, < 2.0)
|
||||
cocoapods-trunk (>= 1.4.0, < 2.0)
|
||||
cocoapods-try (>= 1.1.0, < 2.0)
|
||||
colored2 (~> 3.1)
|
||||
escape (~> 0.0.4)
|
||||
fourflusher (>= 2.3.0, < 3.0)
|
||||
gh_inspector (~> 1.0)
|
||||
molinillo (~> 0.8.0)
|
||||
nap (~> 1.0)
|
||||
ruby-macho (>= 1.0, < 3.0)
|
||||
xcodeproj (>= 1.21.0, < 2.0)
|
||||
cocoapods-core (1.11.2)
|
||||
activesupport (>= 5.0, < 7)
|
||||
addressable (~> 2.8)
|
||||
algoliasearch (~> 1.0)
|
||||
concurrent-ruby (~> 1.1)
|
||||
fuzzy_match (~> 2.0.4)
|
||||
nap (~> 1.0)
|
||||
netrc (~> 0.11)
|
||||
public_suffix (~> 4.0)
|
||||
typhoeus (~> 1.0)
|
||||
cocoapods-deintegrate (1.0.5)
|
||||
cocoapods-downloader (1.5.1)
|
||||
cocoapods-plugins (1.0.0)
|
||||
nap
|
||||
cocoapods-search (1.0.1)
|
||||
cocoapods-trunk (1.6.0)
|
||||
nap (>= 0.8, < 2.0)
|
||||
netrc (~> 0.11)
|
||||
cocoapods-try (1.2.0)
|
||||
colored2 (3.1.2)
|
||||
concurrent-ruby (1.1.9)
|
||||
escape (0.0.4)
|
||||
ethon (0.15.0)
|
||||
ffi (>= 1.15.0)
|
||||
ffi (1.15.4)
|
||||
fourflusher (2.3.1)
|
||||
fuzzy_match (2.0.4)
|
||||
gh_inspector (1.1.3)
|
||||
httpclient (2.8.3)
|
||||
i18n (1.8.10)
|
||||
concurrent-ruby (~> 1.0)
|
||||
json (2.6.0)
|
||||
minitest (5.14.4)
|
||||
molinillo (0.8.0)
|
||||
nanaimo (0.3.0)
|
||||
nap (1.1.0)
|
||||
netrc (0.11.0)
|
||||
public_suffix (4.0.6)
|
||||
rexml (3.2.5)
|
||||
ruby-macho (2.5.1)
|
||||
typhoeus (1.4.0)
|
||||
ethon (>= 0.9.0)
|
||||
tzinfo (2.0.4)
|
||||
concurrent-ruby (~> 1.0)
|
||||
xcodeproj (1.21.0)
|
||||
CFPropertyList (>= 2.3.3, < 4.0)
|
||||
atomos (~> 0.1.3)
|
||||
claide (>= 1.0.2, < 2.0)
|
||||
colored2 (~> 3.1)
|
||||
nanaimo (~> 0.3.0)
|
||||
rexml (~> 3.2.4)
|
||||
zeitwerk (2.4.2)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
cocoapods
|
||||
|
||||
BUNDLED WITH
|
||||
2.2.15
|
25
Package.resolved
Normal file
25
Package.resolved
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"object": {
|
||||
"pins": [
|
||||
{
|
||||
"package": "openssl-apple",
|
||||
"repositoryURL": "https://github.com/keeshux/openssl-apple",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "1889136399ba40e4fc358cfe7fafef7170aac3f7",
|
||||
"version": "1.1.112"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "SwiftyBeaver",
|
||||
"repositoryURL": "https://github.com/SwiftyBeaver/SwiftyBeaver",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "2c039501d6eeb4d4cd4aec4a8d884ad28862e044",
|
||||
"version": "1.9.5"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"version": 1
|
||||
}
|
116
Package.swift
Normal file
116
Package.swift
Normal file
@ -0,0 +1,116 @@
|
||||
// swift-tools-version:5.5
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "TunnelKit",
|
||||
platforms: [
|
||||
.macOS(.v10_15), .iOS(.v12)
|
||||
],
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||
.library(
|
||||
name: "TunnelKitCore",
|
||||
targets: ["TunnelKitCore"]
|
||||
),
|
||||
.library(
|
||||
name: "TunnelKitAppExtension",
|
||||
targets: ["TunnelKitAppExtension"]
|
||||
),
|
||||
.library(
|
||||
name: "TunnelKitManager",
|
||||
targets: ["TunnelKitManager"]
|
||||
),
|
||||
.library(
|
||||
name: "TunnelKitNative",
|
||||
targets: ["TunnelKitNative"]
|
||||
),
|
||||
.library(
|
||||
name: "TunnelKitOpenVPN",
|
||||
targets: ["TunnelKitOpenVPN"]
|
||||
),
|
||||
.library(
|
||||
name: "TunnelKitLZO",
|
||||
targets: ["TunnelKitLZO"]
|
||||
)
|
||||
],
|
||||
dependencies: [
|
||||
// Dependencies declare other packages that this package depends on.
|
||||
// .package(url: /* package url */, from: "1.0.0"),
|
||||
.package(url: "https://github.com/SwiftyBeaver/SwiftyBeaver", from: "1.9.0"),
|
||||
.package(url: "https://github.com/keeshux/openssl-apple", from: "1.1.100")
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
// Targets can depend on other targets in this package, and on products in packages this package depends on.
|
||||
.target(
|
||||
name: "TunnelKitCore",
|
||||
dependencies: [
|
||||
"InternalUtils",
|
||||
"TunnelKitCoreObjC",
|
||||
"SwiftyBeaver"]),
|
||||
.target(
|
||||
name: "TunnelKitCoreObjC",
|
||||
dependencies: []),
|
||||
.target(
|
||||
name: "TunnelKitAppExtension",
|
||||
dependencies: [
|
||||
"TunnelKitCore",
|
||||
"SwiftyBeaver"]),
|
||||
.target(
|
||||
name: "TunnelKitManager",
|
||||
dependencies: [
|
||||
"TunnelKitCore"]),
|
||||
.target(
|
||||
name: "TunnelKitNative",
|
||||
dependencies: [
|
||||
"TunnelKitCore",
|
||||
"TunnelKitManager"]),
|
||||
.target(
|
||||
name: "TunnelKitOpenVPN",
|
||||
dependencies: [
|
||||
"TunnelKitCore",
|
||||
"TunnelKitOpenVPNObjC",
|
||||
"TunnelKitAppExtension",
|
||||
"TunnelKitManager"]),
|
||||
.target(
|
||||
name: "TunnelKitOpenVPNObjC",
|
||||
dependencies: [
|
||||
"TunnelKitCoreObjC",
|
||||
"openssl-apple"]),
|
||||
.target(
|
||||
name: "TunnelKitLZO",
|
||||
dependencies: [],
|
||||
exclude: [
|
||||
"lib/COPYING",
|
||||
"lib/Makefile",
|
||||
"lib/README.LZO"
|
||||
]),
|
||||
.target(
|
||||
name: "InternalUtils",
|
||||
dependencies: []),
|
||||
.testTarget(
|
||||
name: "TunnelKitCoreTests",
|
||||
dependencies: [
|
||||
"TunnelKitCore",
|
||||
"TunnelKitCoreObjC"
|
||||
]),
|
||||
.testTarget(
|
||||
name: "TunnelKitOpenVPNTests",
|
||||
dependencies: [
|
||||
"TunnelKitCoreTests",
|
||||
"TunnelKitOpenVPN",
|
||||
"TunnelKitOpenVPNObjC",
|
||||
"TunnelKitLZO"
|
||||
],
|
||||
resources: [
|
||||
.process("Resources")
|
||||
]),
|
||||
.testTarget(
|
||||
name: "TunnelKitLZOTests",
|
||||
dependencies: [
|
||||
"TunnelKitLZO"
|
||||
]),
|
||||
]
|
||||
)
|
41
Podfile
41
Podfile
@ -1,41 +0,0 @@
|
||||
source 'https://github.com/CocoaPods/Specs.git'
|
||||
use_frameworks!
|
||||
|
||||
def shared_pods
|
||||
pod 'SwiftyBeaver'
|
||||
pod 'OpenSSL-Apple', '~> 1.1.1l.11'
|
||||
end
|
||||
|
||||
def demo_pods
|
||||
pod 'SwiftyBeaver'
|
||||
end
|
||||
|
||||
abstract_target 'ios' do
|
||||
platform :ios, '12.0'
|
||||
target 'TunnelKit-iOS' do
|
||||
shared_pods
|
||||
end
|
||||
target 'TunnelKitTests-iOS' do
|
||||
end
|
||||
target 'TunnelKitHost' do
|
||||
end
|
||||
target 'TunnelKitDemo-iOS' do
|
||||
demo_pods
|
||||
end
|
||||
target 'TunnelKitDemoTunnel-iOS' do
|
||||
end
|
||||
end
|
||||
|
||||
abstract_target 'macos' do
|
||||
platform :osx, '10.15'
|
||||
target 'TunnelKit-macOS' do
|
||||
shared_pods
|
||||
end
|
||||
target 'TunnelKitTests-macOS' do
|
||||
end
|
||||
target 'TunnelKitDemo-macOS' do
|
||||
demo_pods
|
||||
end
|
||||
target 'TunnelKitDemoTunnel-macOS' do
|
||||
end
|
||||
end
|
20
Podfile.lock
20
Podfile.lock
@ -1,20 +0,0 @@
|
||||
PODS:
|
||||
- OpenSSL-Apple (1.1.1l.11)
|
||||
- SwiftyBeaver (1.9.5)
|
||||
|
||||
DEPENDENCIES:
|
||||
- OpenSSL-Apple (~> 1.1.1l.11)
|
||||
- SwiftyBeaver
|
||||
|
||||
SPEC REPOS:
|
||||
https://github.com/CocoaPods/Specs.git:
|
||||
- OpenSSL-Apple
|
||||
- SwiftyBeaver
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
OpenSSL-Apple: fb93d9a7ce4529054764ce19bb80947a38aee09b
|
||||
SwiftyBeaver: 84069991dd5dca07d7069100985badaca7f0ce82
|
||||
|
||||
PODFILE CHECKSUM: acb440e8c365ee318f02b159fee4a173163fa454
|
||||
|
||||
COCOAPODS: 1.11.2
|
@ -39,8 +39,9 @@ import Foundation
|
||||
// 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
|
||||
|
||||
/// :nodoc:
|
||||
extension UnicodeScalar {
|
||||
var hexNibble: UInt8 {
|
||||
public var hexNibble: UInt8 {
|
||||
let value = self.value
|
||||
if 48 <= value && value <= 57 {
|
||||
return UInt8(value - 48)
|
||||
@ -55,8 +56,9 @@ extension UnicodeScalar {
|
||||
}
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
extension Data {
|
||||
init(hex: String) {
|
||||
public init(hex: String) {
|
||||
let scalars = hex.unicodeScalars
|
||||
var bytes = Array<UInt8>(repeating: 0, count: (scalars.count + 1) >> 1)
|
||||
for (index, scalar) in scalars.enumerated() {
|
||||
@ -69,21 +71,22 @@ extension Data {
|
||||
self = Data(bytes)
|
||||
}
|
||||
|
||||
func toHex() -> String {
|
||||
public func toHex() -> String {
|
||||
return map { String(format: "%02hhx", $0) }.joined()
|
||||
}
|
||||
|
||||
mutating func zero() {
|
||||
public mutating func zero() {
|
||||
resetBytes(in: 0..<count)
|
||||
}
|
||||
|
||||
mutating func zero(from: Int, to: Int) {
|
||||
public mutating func zero(from: Int, to: Int) {
|
||||
resetBytes(in: from..<to)
|
||||
}
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
extension Data {
|
||||
mutating func append(_ value: UInt16) {
|
||||
public mutating func append(_ value: UInt16) {
|
||||
var localValue = value
|
||||
let buffer = withUnsafePointer(to: &localValue) {
|
||||
return UnsafeBufferPointer(start: $0, count: 1)
|
||||
@ -91,7 +94,7 @@ extension Data {
|
||||
append(buffer)
|
||||
}
|
||||
|
||||
mutating func append(_ value: UInt32) {
|
||||
public mutating func append(_ value: UInt32) {
|
||||
var localValue = value
|
||||
let buffer = withUnsafePointer(to: &localValue) {
|
||||
return UnsafeBufferPointer(start: $0, count: 1)
|
||||
@ -99,7 +102,7 @@ extension Data {
|
||||
append(buffer)
|
||||
}
|
||||
|
||||
mutating func append(_ value: UInt64) {
|
||||
public mutating func append(_ value: UInt64) {
|
||||
var localValue = value
|
||||
let buffer = withUnsafePointer(to: &localValue) {
|
||||
return UnsafeBufferPointer(start: $0, count: 1)
|
||||
@ -107,12 +110,12 @@ extension Data {
|
||||
append(buffer)
|
||||
}
|
||||
|
||||
mutating func append(nullTerminatedString: String) {
|
||||
public mutating func append(nullTerminatedString: String) {
|
||||
append(nullTerminatedString.data(using: .ascii)!)
|
||||
append(UInt8(0))
|
||||
}
|
||||
|
||||
func nullTerminatedString(from: Int) -> String? {
|
||||
public func nullTerminatedString(from: Int) -> String? {
|
||||
var nullOffset: Int?
|
||||
for i in from..<count {
|
||||
if (self[i] == 0) {
|
||||
@ -127,7 +130,7 @@ extension Data {
|
||||
}
|
||||
|
||||
// best
|
||||
func UInt16Value(from: Int) -> UInt16 {
|
||||
public func UInt16Value(from: Int) -> UInt16 {
|
||||
var value: UInt16 = 0
|
||||
for i in 0..<2 {
|
||||
let byte = self[from + i]
|
||||
@ -169,7 +172,7 @@ extension Data {
|
||||
}
|
||||
|
||||
// best
|
||||
func UInt32Value(from: Int) -> UInt32 {
|
||||
public func UInt32Value(from: Int) -> UInt32 {
|
||||
return subdata(in: from..<(from + 4)).withUnsafeBytes {
|
||||
$0.load(as: UInt32.self)
|
||||
}
|
||||
@ -188,39 +191,43 @@ extension Data {
|
||||
return value
|
||||
}
|
||||
|
||||
func networkUInt16Value(from: Int) -> UInt16 {
|
||||
public func networkUInt16Value(from: Int) -> UInt16 {
|
||||
return UInt16(bigEndian: subdata(in: from..<(from + 2)).withUnsafeBytes {
|
||||
$0.load(as: UInt16.self)
|
||||
})
|
||||
}
|
||||
|
||||
func networkUInt32Value(from: Int) -> UInt32 {
|
||||
public func networkUInt32Value(from: Int) -> UInt32 {
|
||||
return UInt32(bigEndian: subdata(in: from..<(from + 4)).withUnsafeBytes {
|
||||
$0.load(as: UInt32.self)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
extension Data {
|
||||
func subdata(offset: Int, count: Int) -> Data {
|
||||
public func subdata(offset: Int, count: Int) -> Data {
|
||||
return subdata(in: offset..<(offset + count))
|
||||
}
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
extension Array where Element == Data {
|
||||
var flatCount: Int {
|
||||
public var flatCount: Int {
|
||||
return reduce(0) { $0 + $1.count }
|
||||
}
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
extension UnsafeRawBufferPointer {
|
||||
var bytePointer: UnsafePointer<Element> {
|
||||
public var bytePointer: UnsafePointer<Element> {
|
||||
return bindMemory(to: Element.self).baseAddress!
|
||||
}
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
extension UnsafeMutableRawBufferPointer {
|
||||
var bytePointer: UnsafeMutablePointer<Element> {
|
||||
public var bytePointer: UnsafeMutablePointer<Element> {
|
||||
return bindMemory(to: Element.self).baseAddress!
|
||||
}
|
||||
}
|
@ -25,12 +25,13 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/// :nodoc:
|
||||
extension NSRegularExpression {
|
||||
convenience init(_ pattern: String) {
|
||||
public convenience init(_ pattern: String) {
|
||||
try! self.init(pattern: pattern, options: [])
|
||||
}
|
||||
|
||||
func enumerateComponents(in string: String, using block: ([String]) -> Void) {
|
||||
public func enumerateComponents(in string: String, using block: ([String]) -> Void) {
|
||||
enumerateMatches(in: string, options: [], range: NSMakeRange(0, string.count)) { (result, flags, stop) in
|
||||
guard let range = result?.range else {
|
||||
return
|
||||
@ -41,7 +42,7 @@ extension NSRegularExpression {
|
||||
}
|
||||
}
|
||||
|
||||
func enumerateArguments(in string: String, using block: ([String]) -> Void) {
|
||||
public func enumerateArguments(in string: String, using block: ([String]) -> Void) {
|
||||
enumerateComponents(in: string) { (tokens) in
|
||||
var args = tokens
|
||||
args.removeFirst()
|
@ -44,7 +44,7 @@ public extension DispatchQueue {
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
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)
|
||||
return try JSONDecoder().decode(T.self, from: data)
|
||||
}
|
||||
@ -62,7 +62,7 @@ public extension Encodable {
|
||||
|
||||
/// :nodoc:
|
||||
extension TimeInterval {
|
||||
var asTimeString: String {
|
||||
public var asTimeString: String {
|
||||
var ticks = Int(self)
|
||||
let hours = ticks / 3600
|
||||
ticks %= 3600
|
@ -24,6 +24,7 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import TunnelKitCore
|
||||
|
||||
/// Entity able to produce a `LinkInterface`.
|
||||
public protocol LinkProducer {
|
@ -37,6 +37,7 @@
|
||||
import Foundation
|
||||
import NetworkExtension
|
||||
import SwiftyBeaver
|
||||
import TunnelKitCore
|
||||
|
||||
private let log = SwiftyBeaver.self
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
import Foundation
|
||||
import NetworkExtension
|
||||
import TunnelKitCore
|
||||
import SwiftyBeaver
|
||||
|
||||
private let log = SwiftyBeaver.self
|
@ -37,6 +37,7 @@
|
||||
import Foundation
|
||||
import NetworkExtension
|
||||
import SwiftyBeaver
|
||||
import TunnelKitCore
|
||||
|
||||
private let log = SwiftyBeaver.self
|
||||
|
@ -36,10 +36,11 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
class CoreConfiguration {
|
||||
static let identifier = "com.algoritmico.TunnelKit"
|
||||
/// :nodoc:
|
||||
public class CoreConfiguration {
|
||||
public static let identifier = "com.algoritmico.TunnelKit"
|
||||
|
||||
static let version: String = {
|
||||
public static let version: String = {
|
||||
let bundle = Bundle(for: CoreConfiguration.self)
|
||||
guard let info = bundle.infoDictionary else {
|
||||
return ""
|
||||
@ -55,17 +56,17 @@ class CoreConfiguration {
|
||||
}()
|
||||
|
||||
// configurable
|
||||
static var masksPrivateData = true
|
||||
public static var masksPrivateData = true
|
||||
|
||||
static var versionIdentifier: String?
|
||||
public static var versionIdentifier: String?
|
||||
|
||||
static let logsSensitiveData = false
|
||||
public static let logsSensitiveData = false
|
||||
|
||||
static var reconnectionDelay = 2.0
|
||||
public static var reconnectionDelay = 2.0
|
||||
}
|
||||
|
||||
extension CustomStringConvertible {
|
||||
var maskedDescription: String {
|
||||
public var maskedDescription: String {
|
||||
guard CoreConfiguration.masksPrivateData else {
|
||||
return description
|
||||
}
|
@ -44,6 +44,12 @@ public struct DNSRecord {
|
||||
|
||||
/// `true` if IPv6.
|
||||
public let isIPv6: Bool
|
||||
|
||||
/// :nodoc:
|
||||
public init(address: String, isIPv6: Bool) {
|
||||
self.address = address
|
||||
self.isIPv6 = isIPv6
|
||||
}
|
||||
}
|
||||
|
||||
/// Convenient methods for DNS resolution.
|
@ -24,15 +24,15 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import __TunnelKitCore
|
||||
import TunnelKitCoreObjC
|
||||
|
||||
extension Error {
|
||||
func isTunnelKitError() -> Bool {
|
||||
public func isTunnelKitError() -> Bool {
|
||||
let te = self as NSError
|
||||
return te.domain == TunnelKitErrorDomain
|
||||
}
|
||||
|
||||
func tunnelKitErrorCode() -> TunnelKitErrorCode? {
|
||||
public func tunnelKitErrorCode() -> TunnelKitErrorCode? {
|
||||
let te = self as NSError
|
||||
guard te.domain == TunnelKitErrorDomain else {
|
||||
return nil
|
@ -40,7 +40,8 @@ public struct IPv4Settings: Codable, CustomStringConvertible {
|
||||
/// The address of the gateway (uses default gateway if not set).
|
||||
public let gateway: String
|
||||
|
||||
init(_ destination: String, _ mask: String?, _ gateway: String) {
|
||||
/// :nodoc:
|
||||
public init(_ destination: String, _ mask: String?, _ gateway: String) {
|
||||
self.destination = destination
|
||||
self.mask = mask ?? "255.255.255.255"
|
||||
self.gateway = gateway
|
||||
@ -66,6 +67,14 @@ public struct IPv4Settings: Codable, CustomStringConvertible {
|
||||
/// The additional routes.
|
||||
public let routes: [Route]
|
||||
|
||||
/// :nodoc:
|
||||
public init(address: String, addressMask: String, defaultGateway: String, routes: [Route]) {
|
||||
self.address = address
|
||||
self.addressMask = addressMask
|
||||
self.defaultGateway = defaultGateway
|
||||
self.routes = routes
|
||||
}
|
||||
|
||||
// MARK: CustomStringConvertible
|
||||
|
||||
/// :nodoc:
|
@ -40,7 +40,8 @@ public struct IPv6Settings: Codable, CustomStringConvertible {
|
||||
/// The address of the gateway (uses default gateway if not set).
|
||||
public let gateway: String
|
||||
|
||||
init(_ destination: String, _ prefixLength: UInt8?, _ gateway: String) {
|
||||
/// :nodoc:
|
||||
public init(_ destination: String, _ prefixLength: UInt8?, _ gateway: String) {
|
||||
self.destination = destination
|
||||
self.prefixLength = prefixLength ?? 3
|
||||
self.gateway = gateway
|
||||
@ -66,6 +67,14 @@ public struct IPv6Settings: Codable, CustomStringConvertible {
|
||||
/// The additional routes.
|
||||
public let routes: [Route]
|
||||
|
||||
/// :nodoc:
|
||||
public init(address: String, addressPrefixLength: UInt8, defaultGateway: String, routes: [Route]) {
|
||||
self.address = address
|
||||
self.addressPrefixLength = addressPrefixLength
|
||||
self.defaultGateway = defaultGateway
|
||||
self.routes = routes
|
||||
}
|
||||
|
||||
// MARK: CustomStringConvertible
|
||||
|
||||
/// :nodoc:
|
@ -36,13 +36,16 @@
|
||||
|
||||
import Foundation
|
||||
import Security.SecRandom
|
||||
import __TunnelKitCore
|
||||
import TunnelKitCoreObjC
|
||||
import InternalUtils
|
||||
|
||||
enum SecureRandomError: Error {
|
||||
/// :nodoc:
|
||||
public enum SecureRandomError: Error {
|
||||
case randomGenerator
|
||||
}
|
||||
|
||||
class SecureRandom {
|
||||
/// :nodoc:
|
||||
public class SecureRandom {
|
||||
@available(*, deprecated)
|
||||
static func uint32FromBuffer() throws -> UInt32 {
|
||||
var randomBuffer = [UInt8](repeating: 0, count: 4)
|
||||
@ -59,7 +62,7 @@ class SecureRandom {
|
||||
return randomNumber
|
||||
}
|
||||
|
||||
static func uint32() throws -> UInt32 {
|
||||
public static func uint32() throws -> UInt32 {
|
||||
var randomNumber: UInt32 = 0
|
||||
|
||||
try withUnsafeMutablePointer(to: &randomNumber) {
|
||||
@ -73,7 +76,7 @@ class SecureRandom {
|
||||
return randomNumber
|
||||
}
|
||||
|
||||
static func data(length: Int) throws -> Data {
|
||||
public static func data(length: Int) throws -> Data {
|
||||
var randomData = Data(count: length)
|
||||
|
||||
try randomData.withUnsafeMutableBytes {
|
||||
@ -86,7 +89,7 @@ class SecureRandom {
|
||||
return randomData
|
||||
}
|
||||
|
||||
static func safeData(length: Int) throws -> ZeroingData {
|
||||
public static func safeData(length: Int) throws -> ZeroingData {
|
||||
let randomBytes = UnsafeMutablePointer<UInt8>.allocate(capacity: length)
|
||||
defer {
|
||||
// randomBytes.initialize(to: 0, count: length)
|
@ -35,36 +35,36 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import __TunnelKitCore
|
||||
import TunnelKitCoreObjC
|
||||
|
||||
func Z() -> ZeroingData {
|
||||
public func Z() -> ZeroingData {
|
||||
return ZeroingData()
|
||||
}
|
||||
|
||||
func Z(count: Int) -> ZeroingData {
|
||||
public func Z(count: Int) -> ZeroingData {
|
||||
return ZeroingData(count: count)
|
||||
}
|
||||
|
||||
func Z(bytes: UnsafePointer<UInt8>, count: Int) -> ZeroingData {
|
||||
public func Z(bytes: UnsafePointer<UInt8>, count: Int) -> ZeroingData {
|
||||
return ZeroingData(bytes: bytes, count: count)
|
||||
}
|
||||
|
||||
func Z(_ uint8: UInt8) -> ZeroingData {
|
||||
public func Z(_ uint8: UInt8) -> ZeroingData {
|
||||
return ZeroingData(uInt8: uint8)
|
||||
}
|
||||
|
||||
func Z(_ uint16: UInt16) -> ZeroingData {
|
||||
public func Z(_ uint16: UInt16) -> ZeroingData {
|
||||
return ZeroingData(uInt16: uint16)
|
||||
}
|
||||
|
||||
func Z(_ data: Data) -> ZeroingData {
|
||||
public func Z(_ data: Data) -> ZeroingData {
|
||||
return ZeroingData(data: data)
|
||||
}
|
||||
|
||||
//func Z(_ data: Data, _ offset: Int, _ count: Int) -> ZeroingData {
|
||||
//public func Z(_ data: Data, _ offset: Int, _ count: Int) -> ZeroingData {
|
||||
// return ZeroingData(data: data, offset: offset, count: count)
|
||||
//}
|
||||
|
||||
func Z(_ string: String, nullTerminated: Bool) -> ZeroingData {
|
||||
public func Z(_ string: String, nullTerminated: Bool) -> ZeroingData {
|
||||
return ZeroingData(string: string, nullTerminated: nullTerminated)
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// LZO.m
|
||||
// LZOFactory.m
|
||||
// TunnelKit
|
||||
//
|
||||
// Created by Davide De Rosa on 3/18/19.
|
||||
@ -23,7 +23,7 @@
|
||||
// along with TunnelKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
#import "LZO.h"
|
||||
#import "LZOFactory.h"
|
||||
#import "ZeroingData.h"
|
||||
|
||||
static NSString *const LZOClassName = @"StandardLZO";
|
||||
@ -34,12 +34,16 @@ static Class LZOClass()
|
||||
return [bundle classNamed:LZOClassName];
|
||||
}
|
||||
|
||||
BOOL LZOIsSupported()
|
||||
@implementation LZOFactory
|
||||
|
||||
+ (BOOL)isSupported
|
||||
{
|
||||
return LZOClass() != nil;
|
||||
}
|
||||
|
||||
id<LZO> LZOCreate()
|
||||
+ (id<CompressionProvider>)create
|
||||
{
|
||||
return [[LZOClass() alloc] init];
|
||||
}
|
||||
|
||||
@end
|
@ -411,6 +411,7 @@ char *routename(uint32_t in)
|
||||
char *routename6(struct sockaddr_in6 *sa6)
|
||||
{
|
||||
static char line[MAXHOSTNAMELEN];
|
||||
int flag = NI_NUMERICHOST;
|
||||
/* use local variable for safety */
|
||||
struct sockaddr_in6 sa6_local = {sizeof(sa6_local), AF_INET6, };
|
||||
|
||||
@ -480,9 +481,10 @@ char *netname(uint32_t in, uint32_t mask)
|
||||
|
||||
char *netname6(struct sockaddr_in6 *sa6, struct sockaddr *sam)
|
||||
{
|
||||
char host[MAXHOSTNAMELEN];
|
||||
static char line[MAXHOSTNAMELEN + 10];
|
||||
u_char *lim;
|
||||
int masklen, illegal = 0;
|
||||
int masklen, illegal = 0, flag = NI_NUMERICHOST;
|
||||
struct in6_addr *mask = sam ? &((struct sockaddr_in6 *)sam)->sin6_addr : 0;
|
||||
|
||||
if (sam && sam->sa_len == 0) {
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// LZO.h
|
||||
// CompressionProvider.h
|
||||
// TunnelKit
|
||||
//
|
||||
// Created by Davide De Rosa on 3/18/19.
|
||||
@ -27,7 +27,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol LZO
|
||||
@protocol CompressionProvider
|
||||
|
||||
- (nullable NSData *)compressedDataWithData:(NSData *)data error:(NSError **)error;
|
||||
- (nullable NSData *)decompressedDataWithData:(NSData *)data error:(NSError **)error;
|
||||
@ -35,8 +35,4 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@end
|
||||
|
||||
//+ (NSString *)versionString;
|
||||
BOOL LZOIsSupported(void);
|
||||
id<LZO> LZOCreate(void);
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@ -1,8 +1,8 @@
|
||||
//
|
||||
// DNS.h
|
||||
// LZOFactory.h
|
||||
// TunnelKit
|
||||
//
|
||||
// Created by Davide De Rosa on 4/25/19.
|
||||
// Created by Davide De Rosa on 3/18/19.
|
||||
// Copyright (c) 2021 Davide De Rosa. All rights reserved.
|
||||
//
|
||||
// https://github.com/passepartoutvpn
|
||||
@ -24,13 +24,16 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "CompressionProvider.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DNS : NSObject
|
||||
@interface LZOFactory : NSObject
|
||||
|
||||
//+ (NSString *)versionString;
|
||||
+ (BOOL)isSupported;
|
||||
+ (id<CompressionProvider>)create;
|
||||
|
||||
- (NSArray<NSString *> *)systemServers;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@ -23,9 +23,8 @@
|
||||
// along with TunnelKit. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
#import "minilzo.h"
|
||||
#import "lib/minilzo.h"
|
||||
|
||||
#import "LZO.h"
|
||||
#import "Errors.h"
|
||||
|
||||
#define HEAP_ALLOC(var,size) \
|
||||
@ -35,7 +34,7 @@ lzo_align_t __LZO_MMODEL var [ ((size) + (sizeof(lzo_align_t) - 1)) / sizeof(lzo
|
||||
|
||||
static HEAP_ALLOC(wrkmem, LZO1X_1_MEM_COMPRESS);
|
||||
|
||||
@interface StandardLZO : NSObject <LZO>
|
||||
@interface StandardLZO : NSObject
|
||||
|
||||
@property (nonatomic, strong) NSMutableData *decompressedBuffer;
|
||||
|
1
Sources/TunnelKitLZO/include/Errors.h
Symbolic link
1
Sources/TunnelKitLZO/include/Errors.h
Symbolic link
@ -0,0 +1 @@
|
||||
../../TunnelKitCoreObjC/include/Errors.h
|
1
Sources/TunnelKitLZO/include/lzo/lzoconf.h
Symbolic link
1
Sources/TunnelKitLZO/include/lzo/lzoconf.h
Symbolic link
@ -0,0 +1 @@
|
||||
../../lib/lzoconf.h
|
1
Sources/TunnelKitLZO/include/lzo/lzodefs.h
Symbolic link
1
Sources/TunnelKitLZO/include/lzo/lzodefs.h
Symbolic link
@ -0,0 +1 @@
|
||||
../../lib/lzodefs.h
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user