mirror of
https://github.com/deneraraujo/OpenVPNAdapter.git
synced 2026-02-11 00:00:08 +08:00
Refactor OpenVPNAdapter, update tests
This commit is contained in:
@@ -109,11 +109,11 @@ class OpenVPNAdapterTests: XCTestCase {
|
||||
|
||||
extension OpenVPNAdapterTests: OpenVPNAdapterDelegate {
|
||||
|
||||
func configureTunnel(settings: NEPacketTunnelNetworkSettings, callback: @escaping (OpenVPNAdapterPacketFlow?) -> Void) {
|
||||
callback(self)
|
||||
func openVPNAdapter(_ openVPNAdapter: OpenVPNAdapter, configureTunnelWithNetworkSettings networkSettings: NEPacketTunnelNetworkSettings, completionHandler: @escaping (NEPacketTunnelFlow?) -> Void) {
|
||||
completionHandler(NEPacketTunnelFlow())
|
||||
}
|
||||
|
||||
func handle(event: OpenVPNAdapterEvent, message: String?) {
|
||||
func openVPNAdapter(_ openVPNAdapter: OpenVPNAdapter, handleEvent event: OpenVPNAdapterEvent, message: String?) {
|
||||
switch event {
|
||||
case .connected:
|
||||
guard let connectionExpectation = expectations[.connection] else { return }
|
||||
@@ -127,23 +127,15 @@ extension OpenVPNAdapterTests: OpenVPNAdapterDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
func handle(error: Error) {
|
||||
func openVPNAdapter(_ openVPNAdapter: OpenVPNAdapter, handleError error: Error) {
|
||||
if let connectionExpectation = expectations[.connection] {
|
||||
XCTFail("Failed to establish conection. \(error.localizedDescription)")
|
||||
connectionExpectation.fulfill()
|
||||
}
|
||||
}
|
||||
|
||||
func handle(logMessage: String) {
|
||||
print("\(logMessage)")
|
||||
func openVPNAdapter(_ openVPNAdapter: OpenVPNAdapter, handleLogMessage logMessage: String) {
|
||||
print(logMessage)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension OpenVPNAdapterTests: OpenVPNAdapterPacketFlow {
|
||||
|
||||
func readPackets(completionHandler: @escaping ([Data], [NSNumber]) -> Void) { }
|
||||
|
||||
func writePackets(_ packets: [Data], withProtocols protocols: [NSNumber]) -> Bool { return true }
|
||||
|
||||
}
|
||||
|
||||
@@ -99,11 +99,7 @@
|
||||
C9BB47601E71663A00F3F98C /* Umbrella-Header.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BB475E1E71663A00F3F98C /* Umbrella-Header.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
C9BB47711E7171A100F3F98C /* OpenVPNError.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BB476F1E7171A100F3F98C /* OpenVPNError.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
C9BB47721E7171A100F3F98C /* OpenVPNAdapterEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BB47701E7171A100F3F98C /* OpenVPNAdapterEvent.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
C9BB47791E7171ED00F3F98C /* OpenVPNClient.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BB47771E7171ED00F3F98C /* OpenVPNClient.h */; };
|
||||
C9BB477A1E7171ED00F3F98C /* OpenVPNClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9BB47781E7171ED00F3F98C /* OpenVPNClient.mm */; };
|
||||
C9BB477F1E7173C700F3F98C /* OpenVPNAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BB477B1E7173C700F3F98C /* OpenVPNAdapter.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
C9BB47801E7173C700F3F98C /* OpenVPNAdapter+Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BB477C1E7173C700F3F98C /* OpenVPNAdapter+Internal.h */; };
|
||||
C9BB47811E7173C700F3F98C /* OpenVPNAdapter+Public.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BB477D1E7173C700F3F98C /* OpenVPNAdapter+Public.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
C9BB47821E7173C700F3F98C /* OpenVPNAdapter.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9BB477E1E7173C700F3F98C /* OpenVPNAdapter.mm */; };
|
||||
C9BB47911E71821A00F3F98C /* OpenVPNAdapterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9BB47901E71821A00F3F98C /* OpenVPNAdapterTests.swift */; };
|
||||
C9BB47931E71821A00F3F98C /* OpenVPNAdapter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9BB475C1E71663A00F3F98C /* OpenVPNAdapter.framework */; };
|
||||
@@ -114,10 +110,6 @@
|
||||
C9BCE25B1EB3C0D9009D6AC1 /* OpenVPNSessionToken.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9BCE2571EB3C0D9009D6AC1 /* OpenVPNSessionToken.mm */; };
|
||||
C9BCE25E1EB3C201009D6AC1 /* OpenVPNSessionToken+Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BCE25C1EB3C201009D6AC1 /* OpenVPNSessionToken+Internal.h */; };
|
||||
C9BCE25F1EB3C201009D6AC1 /* OpenVPNSessionToken+Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BCE25C1EB3C201009D6AC1 /* OpenVPNSessionToken+Internal.h */; };
|
||||
C9BDB1351EBCC3B900C204FF /* OpenVPNTunnelSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BDB1331EBCC3B900C204FF /* OpenVPNTunnelSettings.h */; };
|
||||
C9BDB1361EBCC3B900C204FF /* OpenVPNTunnelSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BDB1331EBCC3B900C204FF /* OpenVPNTunnelSettings.h */; };
|
||||
C9BDB1371EBCC3B900C204FF /* OpenVPNTunnelSettings.m in Sources */ = {isa = PBXBuildFile; fileRef = C9BDB1341EBCC3B900C204FF /* OpenVPNTunnelSettings.m */; };
|
||||
C9BDB1381EBCC3B900C204FF /* OpenVPNTunnelSettings.m in Sources */ = {isa = PBXBuildFile; fileRef = C9BDB1341EBCC3B900C204FF /* OpenVPNTunnelSettings.m */; };
|
||||
C9CA4DD31F602F7B00C4F184 /* OpenVPNCertificate.h in Headers */ = {isa = PBXBuildFile; fileRef = C9CA4DD11F602F7B00C4F184 /* OpenVPNCertificate.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
C9CA4DD41F602F7B00C4F184 /* OpenVPNCertificate.h in Headers */ = {isa = PBXBuildFile; fileRef = C9CA4DD11F602F7B00C4F184 /* OpenVPNCertificate.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
C9CA4DD51F602F7B00C4F184 /* OpenVPNCertificate.m in Sources */ = {isa = PBXBuildFile; fileRef = C9CA4DD21F602F7B00C4F184 /* OpenVPNCertificate.m */; };
|
||||
@@ -125,17 +117,13 @@
|
||||
C9CA4DE11F603A5300C4F184 /* OpenVPNCertificateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9CA4DE01F603A5300C4F184 /* OpenVPNCertificateTests.swift */; };
|
||||
C9CA4DE21F603A5300C4F184 /* OpenVPNCertificateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9CA4DE01F603A5300C4F184 /* OpenVPNCertificateTests.swift */; };
|
||||
C9D2ABDB1EA20F99007EDF9D /* OpenVPNAdapter.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9BB477E1E7173C700F3F98C /* OpenVPNAdapter.mm */; };
|
||||
C9D2ABDC1EA20F99007EDF9D /* OpenVPNClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9BB47781E7171ED00F3F98C /* OpenVPNClient.mm */; };
|
||||
C9D2ABDE1EA20F99007EDF9D /* ovpncli.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C9FD92191E9A667600374FC4 /* ovpncli.cpp */; };
|
||||
C9D2ABE01EA20F99007EDF9D /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C912BB241E7C3339002B9414 /* NetworkExtension.framework */; };
|
||||
C9D2ABE11EA20F99007EDF9D /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C90BAD301E73FF6C00DEFB32 /* SystemConfiguration.framework */; };
|
||||
C9D2ABE31EA20F99007EDF9D /* OpenVPNClient.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BB47771E7171ED00F3F98C /* OpenVPNClient.h */; };
|
||||
C9D2ABE41EA20F99007EDF9D /* OpenVPNAdapterEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BB47701E7171A100F3F98C /* OpenVPNAdapterEvent.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
C9D2ABE51EA20F99007EDF9D /* OpenVPNAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BB477B1E7173C700F3F98C /* OpenVPNAdapter.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
C9D2ABE61EA20F99007EDF9D /* Umbrella-Header.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BB475E1E71663A00F3F98C /* Umbrella-Header.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
C9D2ABE71EA20F99007EDF9D /* OpenVPNAdapter+Public.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BB477D1E7173C700F3F98C /* OpenVPNAdapter+Public.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
C9D2ABE81EA20F99007EDF9D /* OpenVPNError.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BB476F1E7171A100F3F98C /* OpenVPNError.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
C9D2ABE91EA20F99007EDF9D /* OpenVPNAdapter+Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = C9BB477C1E7173C700F3F98C /* OpenVPNAdapter+Internal.h */; };
|
||||
C9D2ABEA1EA20F99007EDF9D /* ovpncli.hpp in Headers */ = {isa = PBXBuildFile; fileRef = C9FD92181E9A667600374FC4 /* ovpncli.hpp */; };
|
||||
C9D2ABF61EA212A3007EDF9D /* OpenVPNAdapterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9BB47901E71821A00F3F98C /* OpenVPNAdapterTests.swift */; };
|
||||
C9D2ABF71EA212A3007EDF9D /* Bundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9BB47A11E7183DB00F3F98C /* Bundle.swift */; };
|
||||
@@ -223,11 +211,7 @@
|
||||
C9BB475E1E71663A00F3F98C /* Umbrella-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Umbrella-Header.h"; sourceTree = "<group>"; };
|
||||
C9BB476F1E7171A100F3F98C /* OpenVPNError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = OpenVPNError.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||
C9BB47701E7171A100F3F98C /* OpenVPNAdapterEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpenVPNAdapterEvent.h; sourceTree = "<group>"; };
|
||||
C9BB47771E7171ED00F3F98C /* OpenVPNClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpenVPNClient.h; sourceTree = "<group>"; };
|
||||
C9BB47781E7171ED00F3F98C /* OpenVPNClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OpenVPNClient.mm; sourceTree = "<group>"; };
|
||||
C9BB477B1E7173C700F3F98C /* OpenVPNAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpenVPNAdapter.h; sourceTree = "<group>"; };
|
||||
C9BB477C1E7173C700F3F98C /* OpenVPNAdapter+Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "OpenVPNAdapter+Internal.h"; sourceTree = "<group>"; };
|
||||
C9BB477D1E7173C700F3F98C /* OpenVPNAdapter+Public.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "OpenVPNAdapter+Public.h"; sourceTree = "<group>"; };
|
||||
C9BB477E1E7173C700F3F98C /* OpenVPNAdapter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = OpenVPNAdapter.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||
C9BB478E1E71821A00F3F98C /* OpenVPNAdapterTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OpenVPNAdapterTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C9BB47901E71821A00F3F98C /* OpenVPNAdapterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenVPNAdapterTests.swift; sourceTree = "<group>"; };
|
||||
@@ -235,8 +219,6 @@
|
||||
C9BCE2561EB3C0D9009D6AC1 /* OpenVPNSessionToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpenVPNSessionToken.h; sourceTree = "<group>"; };
|
||||
C9BCE2571EB3C0D9009D6AC1 /* OpenVPNSessionToken.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OpenVPNSessionToken.mm; sourceTree = "<group>"; };
|
||||
C9BCE25C1EB3C201009D6AC1 /* OpenVPNSessionToken+Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "OpenVPNSessionToken+Internal.h"; sourceTree = "<group>"; };
|
||||
C9BDB1331EBCC3B900C204FF /* OpenVPNTunnelSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpenVPNTunnelSettings.h; sourceTree = "<group>"; };
|
||||
C9BDB1341EBCC3B900C204FF /* OpenVPNTunnelSettings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OpenVPNTunnelSettings.m; sourceTree = "<group>"; };
|
||||
C9CA4DD11F602F7B00C4F184 /* OpenVPNCertificate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpenVPNCertificate.h; sourceTree = "<group>"; };
|
||||
C9CA4DD21F602F7B00C4F184 /* OpenVPNCertificate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OpenVPNCertificate.m; sourceTree = "<group>"; };
|
||||
C9CA4DE01F603A5300C4F184 /* OpenVPNCertificateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpenVPNCertificateTests.swift; sourceTree = "<group>"; };
|
||||
@@ -334,8 +316,6 @@
|
||||
C9235AC41EB24F0100C7D303 /* Configuration */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C9BDB1331EBCC3B900C204FF /* OpenVPNTunnelSettings.h */,
|
||||
C9BDB1341EBCC3B900C204FF /* OpenVPNTunnelSettings.m */,
|
||||
C98467A41EAA5B7700272A9A /* OpenVPNConfiguration.h */,
|
||||
C98467AA1EAA5BB500272A9A /* OpenVPNConfiguration+Internal.h */,
|
||||
C98467A51EAA5B7700272A9A /* OpenVPNConfiguration.mm */,
|
||||
@@ -434,11 +414,7 @@
|
||||
C9BB47671E7169F000F3F98C /* Adapter */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C9BB47771E7171ED00F3F98C /* OpenVPNClient.h */,
|
||||
C9BB47781E7171ED00F3F98C /* OpenVPNClient.mm */,
|
||||
C9BB477B1E7173C700F3F98C /* OpenVPNAdapter.h */,
|
||||
C9BB477C1E7173C700F3F98C /* OpenVPNAdapter+Internal.h */,
|
||||
C9BB477D1E7173C700F3F98C /* OpenVPNAdapter+Public.h */,
|
||||
C9BB477E1E7173C700F3F98C /* OpenVPNAdapter.mm */,
|
||||
);
|
||||
name = Adapter;
|
||||
@@ -556,7 +532,6 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C9CA4DD31F602F7B00C4F184 /* OpenVPNCertificate.h in Headers */,
|
||||
C9BB47791E7171ED00F3F98C /* OpenVPNClient.h in Headers */,
|
||||
C9657A3A1EB0BAAB00EFF210 /* OpenVPNInterfaceStats+Internal.h in Headers */,
|
||||
C9354F451F1E4A4500F4C935 /* OpenVPNReachabilityStatus.h in Headers */,
|
||||
C9BCE25E1EB3C201009D6AC1 /* OpenVPNSessionToken+Internal.h in Headers */,
|
||||
@@ -567,7 +542,6 @@
|
||||
C9657A571EB0CDFB00EFF210 /* OpenVPNProperties+Internal.h in Headers */,
|
||||
C9BCE2581EB3C0D9009D6AC1 /* OpenVPNSessionToken.h in Headers */,
|
||||
C9657A341EB0BA3900EFF210 /* OpenVPNInterfaceStats.h in Headers */,
|
||||
C9BDB1351EBCC3B900C204FF /* OpenVPNTunnelSettings.h in Headers */,
|
||||
C9657A401EB0CAC200EFF210 /* OpenVPNServerEntry.h in Headers */,
|
||||
C98467AB1EAA5BE100272A9A /* OpenVPNConfiguration+Internal.h in Headers */,
|
||||
C98467A61EAA5B7700272A9A /* OpenVPNConfiguration.h in Headers */,
|
||||
@@ -579,10 +553,8 @@
|
||||
C9B7955E1F1D16AA00CF35FE /* OpenVPNReachability.h in Headers */,
|
||||
C915F1F41F612F3300B3DF23 /* OpenVPNPrivateKey.h in Headers */,
|
||||
C9657A171EB0A7F800EFF210 /* OpenVPNConnectionInfo.h in Headers */,
|
||||
C9BB47811E7173C700F3F98C /* OpenVPNAdapter+Public.h in Headers */,
|
||||
C9BB47711E7171A100F3F98C /* OpenVPNError.h in Headers */,
|
||||
C9B795641F1D182500CF35FE /* OpenVPNReachabilityTracker.h in Headers */,
|
||||
C9BB47801E7173C700F3F98C /* OpenVPNAdapter+Internal.h in Headers */,
|
||||
C9E4401D1F6086A1001D7C41 /* NSError+Message.h in Headers */,
|
||||
C9657A611EB0D64E00EFF210 /* OpenVPNIPv6Preference.h in Headers */,
|
||||
C9657A671EB0D73200EFF210 /* OpenVPNMinTLSVersion.h in Headers */,
|
||||
@@ -601,7 +573,6 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C9CA4DD41F602F7B00C4F184 /* OpenVPNCertificate.h in Headers */,
|
||||
C9D2ABE31EA20F99007EDF9D /* OpenVPNClient.h in Headers */,
|
||||
C9657A3B1EB0BAAB00EFF210 /* OpenVPNInterfaceStats+Internal.h in Headers */,
|
||||
C9354F461F1E4A4600F4C935 /* OpenVPNReachabilityStatus.h in Headers */,
|
||||
C9BCE25F1EB3C201009D6AC1 /* OpenVPNSessionToken+Internal.h in Headers */,
|
||||
@@ -612,7 +583,6 @@
|
||||
C9657A561EB0CDFA00EFF210 /* OpenVPNProperties+Internal.h in Headers */,
|
||||
C9BCE2591EB3C0D9009D6AC1 /* OpenVPNSessionToken.h in Headers */,
|
||||
C9657A351EB0BA3900EFF210 /* OpenVPNInterfaceStats.h in Headers */,
|
||||
C9BDB1361EBCC3B900C204FF /* OpenVPNTunnelSettings.h in Headers */,
|
||||
C9657A411EB0CAC200EFF210 /* OpenVPNServerEntry.h in Headers */,
|
||||
C98467AC1EAA5BE200272A9A /* OpenVPNConfiguration+Internal.h in Headers */,
|
||||
C98467A71EAA5B7700272A9A /* OpenVPNConfiguration.h in Headers */,
|
||||
@@ -624,10 +594,8 @@
|
||||
C9B7955F1F1D16AA00CF35FE /* OpenVPNReachability.h in Headers */,
|
||||
C915F1F51F612F3300B3DF23 /* OpenVPNPrivateKey.h in Headers */,
|
||||
C9657A181EB0A7F800EFF210 /* OpenVPNConnectionInfo.h in Headers */,
|
||||
C9D2ABE71EA20F99007EDF9D /* OpenVPNAdapter+Public.h in Headers */,
|
||||
C9D2ABE81EA20F99007EDF9D /* OpenVPNError.h in Headers */,
|
||||
C9B795651F1D182500CF35FE /* OpenVPNReachabilityTracker.h in Headers */,
|
||||
C9D2ABE91EA20F99007EDF9D /* OpenVPNAdapter+Internal.h in Headers */,
|
||||
C9E4401E1F6086A1001D7C41 /* NSError+Message.h in Headers */,
|
||||
C9657A621EB0D64E00EFF210 /* OpenVPNIPv6Preference.h in Headers */,
|
||||
C9657A681EB0D73200EFF210 /* OpenVPNMinTLSVersion.h in Headers */,
|
||||
@@ -848,13 +816,11 @@
|
||||
C9BB47821E7173C700F3F98C /* OpenVPNAdapter.mm in Sources */,
|
||||
C98467A81EAA5B7700272A9A /* OpenVPNConfiguration.mm in Sources */,
|
||||
C9E4401F1F6086A1001D7C41 /* NSError+Message.m in Sources */,
|
||||
C9BDB1371EBCC3B900C204FF /* OpenVPNTunnelSettings.m in Sources */,
|
||||
C9657A311EB0B7A900EFF210 /* OpenVPNTransportStats.mm in Sources */,
|
||||
C9B795661F1D182500CF35FE /* OpenVPNReachabilityTracker.mm in Sources */,
|
||||
C9657A581EB0CE1300EFF210 /* OpenVPNProperties.mm in Sources */,
|
||||
C9CA4DD51F602F7B00C4F184 /* OpenVPNCertificate.m in Sources */,
|
||||
C915F1F61F612F3300B3DF23 /* OpenVPNPrivateKey.m in Sources */,
|
||||
C9BB477A1E7171ED00F3F98C /* OpenVPNClient.mm in Sources */,
|
||||
C9FD921B1E9A667600374FC4 /* ovpncli.cpp in Sources */,
|
||||
C9657A361EB0BA3900EFF210 /* OpenVPNInterfaceStats.mm in Sources */,
|
||||
C9657A211EB0ACAE00EFF210 /* OpenVPNConnectionInfo.mm in Sources */,
|
||||
@@ -886,13 +852,11 @@
|
||||
C9D2ABDB1EA20F99007EDF9D /* OpenVPNAdapter.mm in Sources */,
|
||||
C98467A91EAA5B7700272A9A /* OpenVPNConfiguration.mm in Sources */,
|
||||
C9E440201F6086A1001D7C41 /* NSError+Message.m in Sources */,
|
||||
C9BDB1381EBCC3B900C204FF /* OpenVPNTunnelSettings.m in Sources */,
|
||||
C9657A301EB0B7A600EFF210 /* OpenVPNTransportStats.mm in Sources */,
|
||||
C9B795671F1D182500CF35FE /* OpenVPNReachabilityTracker.mm in Sources */,
|
||||
C9657A591EB0CE1400EFF210 /* OpenVPNProperties.mm in Sources */,
|
||||
C9CA4DD61F602F7B00C4F184 /* OpenVPNCertificate.m in Sources */,
|
||||
C915F1F71F612F3300B3DF23 /* OpenVPNPrivateKey.m in Sources */,
|
||||
C9D2ABDC1EA20F99007EDF9D /* OpenVPNClient.mm in Sources */,
|
||||
C9D2ABDE1EA20F99007EDF9D /* ovpncli.cpp in Sources */,
|
||||
C9657A371EB0BA3900EFF210 /* OpenVPNInterfaceStats.mm in Sources */,
|
||||
C9657A221EB0ACAE00EFF210 /* OpenVPNConnectionInfo.mm in Sources */,
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
//
|
||||
// OpenVPNAdapter+Internal.h
|
||||
// OpenVPN Adapter
|
||||
//
|
||||
// Created by Sergey Abramchuk on 11.02.17.
|
||||
//
|
||||
//
|
||||
|
||||
#import <client/ovpncli.hpp>
|
||||
|
||||
#import "OpenVPNAdapter.h"
|
||||
|
||||
using namespace openvpn;
|
||||
|
||||
@interface OpenVPNAdapter (Internal)
|
||||
|
||||
- (BOOL)configureSockets;
|
||||
|
||||
- (BOOL)setRemoteAddress:(NSString *)address isIPv6:(BOOL)isIPv6;
|
||||
|
||||
- (BOOL)addLocalAddress:(NSString *)address prefixLength:(NSNumber *)prefixLength gateway:(NSString *)gateway isIPv6:(BOOL)isIPv6;
|
||||
|
||||
- (BOOL)defaultGatewayRerouteIPv4:(BOOL)rerouteIPv4 rerouteIPv6:(BOOL)rerouteIPv6;
|
||||
- (BOOL)addRoute:(NSString *)route prefixLength:(NSNumber *)prefixLength isIPv6:(BOOL)isIPv6;
|
||||
- (BOOL)excludeRoute:(NSString *)route prefixLength:(NSNumber *)prefixLength isIPv6:(BOOL)isIPv6;
|
||||
|
||||
- (BOOL)addDNSAddress:(NSString *)address isIPv6:(BOOL)isIPv6;
|
||||
- (BOOL)addSearchDomain:(NSString *)domain;
|
||||
|
||||
- (BOOL)setMTU:(NSNumber *)mtu;
|
||||
|
||||
- (CFSocketNativeHandle)establishTunnel;
|
||||
- (void)teardownTunnel:(BOOL)disconnect;
|
||||
|
||||
- (void)handleEvent:(const ClientAPI::Event *)event;
|
||||
- (void)handleLog:(const ClientAPI::LogInfo *)log;
|
||||
|
||||
- (void)tick;
|
||||
|
||||
@end
|
||||
@@ -1,191 +0,0 @@
|
||||
//
|
||||
// OpenVPNAdapter+Public.h
|
||||
// OpenVPN Adapter
|
||||
//
|
||||
// Created by Sergey Abramchuk on 11.02.17.
|
||||
//
|
||||
//
|
||||
|
||||
#import "OpenVPNAdapterEvent.h"
|
||||
#import "OpenVPNAdapter.h"
|
||||
|
||||
@class OpenVPNConfiguration;
|
||||
@class OpenVPNProperties;
|
||||
@class OpenVPNCredentials;
|
||||
@class OpenVPNConnectionInfo;
|
||||
@class OpenVPNSessionToken;
|
||||
@class OpenVPNTransportStats;
|
||||
@class OpenVPNInterfaceStats;
|
||||
@class NEPacketTunnelNetworkSettings;
|
||||
|
||||
// TODO: Add documentation to properties and methods
|
||||
|
||||
/**
|
||||
<#Description#>
|
||||
*/
|
||||
@protocol OpenVPNAdapterPacketFlow <NSObject>
|
||||
|
||||
/**
|
||||
<#Description#>
|
||||
|
||||
@param completionHandler <#completionHandler description#>
|
||||
*/
|
||||
- (void)readPacketsWithCompletionHandler:(nonnull void (^)(NSArray<NSData *> * _Nonnull packets, NSArray<NSNumber *> * _Nonnull protocols))completionHandler;
|
||||
|
||||
/**
|
||||
<#Description#>
|
||||
|
||||
@param packets <#packets description#>
|
||||
@param protocols <#protocols description#>
|
||||
@return <#return value description#>
|
||||
*/
|
||||
- (BOOL)writePackets:(nonnull NSArray<NSData *> *)packets withProtocols:(nonnull NSArray<NSNumber *> *)protocols;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
<#Description#>
|
||||
*/
|
||||
@protocol OpenVPNAdapterDelegate <NSObject>
|
||||
|
||||
/**
|
||||
<#Description#>
|
||||
|
||||
@param settings <#settings description#>
|
||||
@param callback <#callback description#>
|
||||
*/
|
||||
- (void)configureTunnelWithSettings:(nonnull NEPacketTunnelNetworkSettings *)settings
|
||||
callback:(nonnull void (^)(id<OpenVPNAdapterPacketFlow> _Nullable flow))callback
|
||||
NS_SWIFT_NAME(configureTunnel(settings:callback:));
|
||||
|
||||
/**
|
||||
<#Description#>
|
||||
|
||||
@param event <#event description#>
|
||||
@param message <#message description#>
|
||||
*/
|
||||
- (void)handleEvent:(OpenVPNAdapterEvent)event
|
||||
message:(nullable NSString *)message
|
||||
NS_SWIFT_NAME(handle(event:message:));
|
||||
|
||||
/**
|
||||
<#Description#>
|
||||
|
||||
@param error <#error description#>
|
||||
*/
|
||||
- (void)handleError:(nonnull NSError *)error
|
||||
NS_SWIFT_NAME(handle(error:));
|
||||
|
||||
@optional
|
||||
|
||||
/**
|
||||
<#Description#>
|
||||
|
||||
@param logMessage <#logMessage description#>
|
||||
*/
|
||||
- (void)handleLog:(nonnull NSString *)logMessage
|
||||
NS_SWIFT_NAME(handle(logMessage:));
|
||||
|
||||
/**
|
||||
<#Description#>
|
||||
*/
|
||||
- (void)tick;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
<#Description#>
|
||||
*/
|
||||
@interface OpenVPNAdapter (Public)
|
||||
|
||||
/**
|
||||
Return core copyright
|
||||
*/
|
||||
@property (class, nonnull, readonly, nonatomic) NSString *copyright;
|
||||
|
||||
/**
|
||||
Return platform description
|
||||
*/
|
||||
@property (class, nonnull, readonly, nonatomic) NSString *platform;
|
||||
|
||||
/**
|
||||
<#Description#>
|
||||
*/
|
||||
@property (weak, nonatomic, null_unspecified) id<OpenVPNAdapterDelegate> delegate;
|
||||
|
||||
/**
|
||||
Return information about the most recent connection. Will be available
|
||||
after an event of type "OpenVPNAdapterEventConnected, otherwise return nil.
|
||||
*/
|
||||
@property (nullable, readonly, nonatomic) OpenVPNConnectionInfo *connectionInfo;
|
||||
|
||||
/**
|
||||
Return current session token or nil if session token is unavailable
|
||||
*/
|
||||
@property (nullable, readonly, nonatomic) OpenVPNSessionToken *sessionToken;
|
||||
|
||||
/**
|
||||
Return transport stats
|
||||
*/
|
||||
@property (nonnull, readonly, nonatomic) OpenVPNTransportStats *transportStats;
|
||||
|
||||
/**
|
||||
Return tun stats
|
||||
*/
|
||||
@property (nonnull, readonly, nonatomic) OpenVPNInterfaceStats *interfaceStats;
|
||||
|
||||
/**
|
||||
<#Description#>
|
||||
|
||||
@param configuration <#configuration description#>
|
||||
@param error <#error description#>
|
||||
@return <#return value description#>
|
||||
*/
|
||||
- (nullable OpenVPNProperties *)applyConfiguration:(nonnull OpenVPNConfiguration *)configuration
|
||||
error:(out NSError * __nullable * __nullable)error
|
||||
NS_SWIFT_NAME(apply(configuration:));
|
||||
|
||||
/**
|
||||
<#Description#>
|
||||
|
||||
@param credentials <#credentials description#>
|
||||
@param error <#error description#>
|
||||
@return <#return value description#>
|
||||
*/
|
||||
- (BOOL)provideCredentials:(nonnull OpenVPNCredentials *)credentials
|
||||
error:(out NSError * __nullable * __nullable)error
|
||||
NS_SWIFT_NAME(provide(credentials:));
|
||||
|
||||
/**
|
||||
Establish connection with the VPN server
|
||||
*/
|
||||
- (void)connect;
|
||||
|
||||
/**
|
||||
Pause the client –- useful to avoid continuous reconnection attempts
|
||||
when network is down
|
||||
|
||||
@param pauseReason <#reason description#>
|
||||
*/
|
||||
- (void)pauseWithReason:(nullable NSString *)pauseReason
|
||||
NS_SWIFT_NAME(pause(reason:));
|
||||
|
||||
/**
|
||||
Resume the client after it has been paused
|
||||
*/
|
||||
- (void)resume;
|
||||
|
||||
/**
|
||||
Do a disconnect/reconnect cycle after given amount of seconds from now
|
||||
|
||||
@param interval <#interval description#>
|
||||
*/
|
||||
- (void)reconnectAfterTimeInterval:(NSInteger)interval
|
||||
NS_SWIFT_NAME(reconnect(interval:));
|
||||
|
||||
/**
|
||||
Close connection with the VPN server
|
||||
*/
|
||||
- (void)disconnect;
|
||||
|
||||
@end
|
||||
@@ -7,7 +7,163 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "OpenVPNAdapterEvent.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class NEPacketTunnelFlow;
|
||||
@class NEPacketTunnelNetworkSettings;
|
||||
@class OpenVPNAdapter;
|
||||
@class OpenVPNConfiguration;
|
||||
@class OpenVPNConnectionInfo;
|
||||
@class OpenVPNCredentials;
|
||||
@class OpenVPNInterfaceStats;
|
||||
@class OpenVPNProperties;
|
||||
@class OpenVPNTransportStats;
|
||||
@class OpenVPNSessionToken;
|
||||
|
||||
@protocol OpenVPNAdapterDelegate <NSObject>
|
||||
|
||||
/**
|
||||
This method is called once the network settings to be used have been established.
|
||||
The receiver should call the completion handler once these settings have been set, returning a NEPacketTunnelFlow object for the TUN interface, or nil if an error occurred.
|
||||
|
||||
@param openVPNAdapter The OpenVPNAdapter instance requesting this information.
|
||||
@param networkSettings The NEPacketTunnelNetworkSettings to be used for the tunnel.
|
||||
@param completionHandler The completion handler to be called with a NEPacketTunnelFlow object, or nil if an error occurred.
|
||||
*/
|
||||
- (void)openVPNAdapter:(OpenVPNAdapter *)openVPNAdapter configureTunnelWithNetworkSettings:(NEPacketTunnelNetworkSettings *)networkSettings completionHandler:(void (^)(NEPacketTunnelFlow * _Nullable packetFlow))completionHandler NS_SWIFT_NAME(openVPNAdapter(_:configureTunnelWithNetworkSettings:completionHandler:));
|
||||
|
||||
|
||||
/**
|
||||
Informs the receiver that an OpenVPN error has occurred.
|
||||
Some errors are fatal and should trigger the diconnection of the tunnel, check for fatal errors with the OpenVPNAdapterErrorFatalKey.
|
||||
|
||||
@param openVPNAdapter The OpenVPNAdapter instance which encountered the error.
|
||||
@param error The error which has occurred.
|
||||
*/
|
||||
- (void)openVPNAdapter:(OpenVPNAdapter *)openVPNAdapter handleError:(NSError *)error;
|
||||
|
||||
|
||||
/**
|
||||
Informs the receiver that an OpenVPN event has occurred.
|
||||
|
||||
@param openVPNAdapter The OpenVPNAdapter instance which encountered the event.
|
||||
@param event The event which has occurred.
|
||||
@param message An accompanying message, may be nil.
|
||||
*/
|
||||
- (void)openVPNAdapter:(OpenVPNAdapter *)openVPNAdapter handleEvent:(OpenVPNAdapterEvent)event message:(nullable NSString *)message NS_SWIFT_NAME(openVPNAdapter(_:handleEvent:message:));
|
||||
|
||||
@optional
|
||||
|
||||
/**
|
||||
Informs the receiver that an OpenVPN message has been logged.
|
||||
|
||||
@param openVPNAdapter The OpenVPNAdapter instance which encountered the log message.
|
||||
@param logMessage The log message.
|
||||
*/
|
||||
- (void)openVPNAdapter:(OpenVPNAdapter *)openVPNAdapter handleLogMessage:(NSString *)logMessage;
|
||||
|
||||
/**
|
||||
Informs the receiver that a clock tick has occurred.
|
||||
Clock ticks can be configured with an OpenVPNConfiguration object.
|
||||
|
||||
@param openVPNAdapter The OpenVPNAdapter instance which encountered the clock tick.
|
||||
*/
|
||||
- (void)openVPNAdapterDidReceiveClockTick:(OpenVPNAdapter *)openVPNAdapter;
|
||||
|
||||
@end
|
||||
|
||||
@interface OpenVPNAdapter : NSObject
|
||||
|
||||
/**
|
||||
The OpenVPN core copyright message.
|
||||
*/
|
||||
@property (nonatomic, class, readonly) NSString *copyright;
|
||||
|
||||
/**
|
||||
The OpenVPN platform.
|
||||
*/
|
||||
@property (nonatomic, class, readonly) NSString *platform;
|
||||
|
||||
/**
|
||||
The object that acts as the delegate of the adapter.
|
||||
*/
|
||||
@property (nonatomic, weak) id<OpenVPNAdapterDelegate> delegate;
|
||||
|
||||
/**
|
||||
The session name, nil unless the tunnel is connected.
|
||||
*/
|
||||
@property (nonatomic, nullable, readonly) NSString *sessionName;
|
||||
|
||||
/**
|
||||
The connection information, nil unless the tunnel is connected.
|
||||
*/
|
||||
@property (nonatomic, nullable, readonly) OpenVPNConnectionInfo *connectionInformation;
|
||||
|
||||
/**
|
||||
The interface statistics.
|
||||
*/
|
||||
@property (nonatomic, readonly) OpenVPNInterfaceStats *interfaceStatistics;
|
||||
|
||||
/**
|
||||
The session token, nil unless the tunnel is connected.
|
||||
*/
|
||||
@property (nonatomic, nullable, readonly) OpenVPNSessionToken *sessionToken;
|
||||
|
||||
/**
|
||||
The transport statistics.
|
||||
*/
|
||||
@property (nonatomic, readonly) OpenVPNTransportStats *transportStatistics;
|
||||
|
||||
/**
|
||||
Applies the given configuration object.
|
||||
Call this method prior to connecting, this method has no effect after calling connect.
|
||||
|
||||
@param configuration The configuration object.
|
||||
@param error If there is an error applying the configuration, upon return contains an error object that describes the problem.
|
||||
@return A properties object describing the configuration which has been applied.
|
||||
*/
|
||||
- (nullable OpenVPNProperties *)applyConfiguration:(OpenVPNConfiguration *)configuration error:(NSError **)error NS_SWIFT_NAME(apply(configuration:));
|
||||
|
||||
/**
|
||||
Provides credentials to the receiver.
|
||||
|
||||
@param credentials The credentials object.
|
||||
@param error If there is an error providing the credentials, upon return contains an error object that describes the problem.
|
||||
@return Returns YES if this method was successful, otherwise NO.
|
||||
*/
|
||||
- (BOOL)provideCredentials:(OpenVPNCredentials *)credentials error:(NSError **)error NS_SWIFT_NAME(provide(credentials:));
|
||||
|
||||
/**
|
||||
Starts the tunnel.
|
||||
*/
|
||||
- (void)connect;
|
||||
|
||||
/**
|
||||
Pauses the tunnel.
|
||||
|
||||
@param reason The reason for pausing the tunnel.
|
||||
*/
|
||||
- (void)pauseWithReason:(NSString *)reason NS_SWIFT_NAME(pause(withReason:));
|
||||
|
||||
/**
|
||||
Resumes the connection.
|
||||
*/
|
||||
- (void)resume;
|
||||
|
||||
/**
|
||||
Reconnects after a given time period, perhaps due to an interface change.
|
||||
|
||||
@param timeInterval The time interval to wait before reconnecting.
|
||||
*/
|
||||
- (void)reconnectAfterTimeInterval:(NSTimeInterval)timeInterval NS_SWIFT_NAME(reconnect(afterTimeInterval:));
|
||||
|
||||
/**
|
||||
Disconnect from the tunnel.
|
||||
*/
|
||||
- (void)disconnect;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,69 +0,0 @@
|
||||
//
|
||||
// OpenVPNClient.h
|
||||
// OpenVPN Adapter
|
||||
//
|
||||
// Created by Sergey Abramchuk on 11.02.17.
|
||||
//
|
||||
//
|
||||
|
||||
#import <openvpn/tun/client/tunbase.hpp>
|
||||
#import <client/ovpncli.hpp>
|
||||
|
||||
using namespace openvpn;
|
||||
|
||||
class OpenVPNClient : public ClientAPI::OpenVPNClient
|
||||
{
|
||||
public:
|
||||
OpenVPNClient(void * adapter);
|
||||
|
||||
virtual bool tun_builder_new() override;
|
||||
|
||||
virtual bool tun_builder_set_remote_address(const std::string& address, bool ipv6) override;
|
||||
virtual bool tun_builder_add_address(const std::string& address,
|
||||
int prefix_length,
|
||||
const std::string& gateway,
|
||||
bool ipv6,
|
||||
bool net30) override;
|
||||
virtual bool tun_builder_reroute_gw(bool ipv4,
|
||||
bool ipv6,
|
||||
unsigned int flags) override;
|
||||
virtual bool tun_builder_add_route(const std::string& address,
|
||||
int prefix_length,
|
||||
int metric,
|
||||
bool ipv6) override;
|
||||
virtual bool tun_builder_exclude_route(const std::string& address,
|
||||
int prefix_length,
|
||||
int metric,
|
||||
bool ipv6) override;
|
||||
virtual bool tun_builder_add_dns_server(const std::string& address, bool ipv6) override;
|
||||
virtual bool tun_builder_add_search_domain(const std::string& domain) override;
|
||||
virtual bool tun_builder_set_mtu(int mtu) override;
|
||||
virtual bool tun_builder_set_session_name(const std::string& name) override;
|
||||
virtual bool tun_builder_add_proxy_bypass(const std::string& bypass_host) override;
|
||||
virtual bool tun_builder_set_proxy_auto_config_url(const std::string& url) override;
|
||||
virtual bool tun_builder_set_proxy_http(const std::string& host, int port) override;
|
||||
virtual bool tun_builder_set_proxy_https(const std::string& host, int port) override;
|
||||
virtual bool tun_builder_add_wins_server(const std::string& address) override;
|
||||
|
||||
virtual int tun_builder_establish() override;
|
||||
|
||||
virtual bool tun_builder_persist() override;
|
||||
virtual void tun_builder_establish_lite() override;
|
||||
|
||||
virtual void tun_builder_teardown(bool disconnect) override;
|
||||
|
||||
virtual bool socket_protect(int socket) override;
|
||||
|
||||
virtual bool pause_on_connection_timeout() override;
|
||||
|
||||
virtual void external_pki_cert_request(ClientAPI::ExternalPKICertRequest& certreq) override;
|
||||
virtual void external_pki_sign_request(ClientAPI::ExternalPKISignRequest& signreq) override;
|
||||
|
||||
virtual void event(const ClientAPI::Event& ev) override;
|
||||
virtual void log(const ClientAPI::LogInfo& log) override;
|
||||
|
||||
virtual void clock_tick() override;
|
||||
|
||||
private:
|
||||
void* adapter;
|
||||
};
|
||||
@@ -1,121 +0,0 @@
|
||||
//
|
||||
// OpenVPNClient.m
|
||||
// OpenVPN Adapter
|
||||
//
|
||||
// Created by Sergey Abramchuk on 11.02.17.
|
||||
//
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "OpenVPNAdapter+Internal.h"
|
||||
#import "OpenVPNClient.h"
|
||||
|
||||
OpenVPNClient::OpenVPNClient(void *adapter) : ClientAPI::OpenVPNClient() {
|
||||
this->adapter = adapter;
|
||||
}
|
||||
|
||||
bool OpenVPNClient::tun_builder_new() {
|
||||
return [(__bridge OpenVPNAdapter *)adapter configureSockets];
|
||||
}
|
||||
|
||||
bool OpenVPNClient::tun_builder_set_remote_address(const std::string &address, bool ipv6) {
|
||||
NSString *remoteAddress = [NSString stringWithUTF8String:address.c_str()];
|
||||
return [(__bridge OpenVPNAdapter *)adapter setRemoteAddress:remoteAddress isIPv6:ipv6];
|
||||
}
|
||||
|
||||
bool OpenVPNClient::tun_builder_add_address(const std::string &address, int prefix_length, const std::string &gateway, bool ipv6, bool net30) {
|
||||
NSString *localAddress = [NSString stringWithUTF8String:address.c_str()];
|
||||
NSString *gatewayAddress = [NSString stringWithUTF8String:gateway.c_str()];
|
||||
|
||||
return [(__bridge OpenVPNAdapter *)adapter addLocalAddress:localAddress prefixLength:@(prefix_length) gateway:gatewayAddress isIPv6:ipv6];
|
||||
}
|
||||
|
||||
bool OpenVPNClient::tun_builder_reroute_gw(bool ipv4, bool ipv6, unsigned int flags) {
|
||||
return [(__bridge OpenVPNAdapter *)adapter defaultGatewayRerouteIPv4:ipv4 rerouteIPv6:ipv6];
|
||||
}
|
||||
|
||||
bool OpenVPNClient::tun_builder_add_route(const std::string& address, int prefix_length, int metric, bool ipv6) {
|
||||
NSString *route = [NSString stringWithUTF8String:address.c_str()];
|
||||
return [(__bridge OpenVPNAdapter *)adapter addRoute:route prefixLength:@(prefix_length) isIPv6:ipv6];
|
||||
}
|
||||
|
||||
bool OpenVPNClient::tun_builder_exclude_route(const std::string& address, int prefix_length, int metric, bool ipv6) {
|
||||
NSString *route = [NSString stringWithUTF8String:address.c_str()];
|
||||
return [(__bridge OpenVPNAdapter *)adapter excludeRoute:route prefixLength:@(prefix_length) isIPv6:ipv6];
|
||||
}
|
||||
|
||||
bool OpenVPNClient::tun_builder_add_dns_server(const std::string& address, bool ipv6) {
|
||||
NSString *dnsAddress = [NSString stringWithUTF8String:address.c_str()];
|
||||
return [(__bridge OpenVPNAdapter *)adapter addDNSAddress:dnsAddress isIPv6:ipv6];
|
||||
}
|
||||
|
||||
bool OpenVPNClient::tun_builder_add_search_domain(const std::string& domain) {
|
||||
NSString *searchDomain = [NSString stringWithUTF8String:domain.c_str()];
|
||||
return [(__bridge OpenVPNAdapter *)adapter addSearchDomain:searchDomain];
|
||||
}
|
||||
|
||||
bool OpenVPNClient::tun_builder_set_mtu(int mtu) {
|
||||
return [(__bridge OpenVPNAdapter *)adapter setMTU:@(mtu)];
|
||||
}
|
||||
|
||||
bool OpenVPNClient::tun_builder_set_session_name(const std::string& name) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenVPNClient::tun_builder_add_proxy_bypass(const std::string& bypass_host) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenVPNClient::tun_builder_set_proxy_auto_config_url(const std::string& url) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenVPNClient::tun_builder_set_proxy_http(const std::string& host, int port) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenVPNClient::tun_builder_set_proxy_https(const std::string& host, int port) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenVPNClient::tun_builder_add_wins_server(const std::string& address) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int OpenVPNClient::tun_builder_establish() {
|
||||
return (int)[(__bridge OpenVPNAdapter *)adapter establishTunnel];
|
||||
}
|
||||
|
||||
bool OpenVPNClient::tun_builder_persist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenVPNClient::tun_builder_establish_lite() { }
|
||||
|
||||
void OpenVPNClient::tun_builder_teardown(bool disconnect) {
|
||||
[(__bridge OpenVPNAdapter *)adapter teardownTunnel:disconnect];
|
||||
}
|
||||
|
||||
bool OpenVPNClient::socket_protect(int socket) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenVPNClient::pause_on_connection_timeout() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void OpenVPNClient::external_pki_cert_request(ClientAPI::ExternalPKICertRequest& certreq) { }
|
||||
void OpenVPNClient::external_pki_sign_request(ClientAPI::ExternalPKISignRequest& signreq) { }
|
||||
|
||||
void OpenVPNClient::event(const ClientAPI::Event& ev) {
|
||||
[(__bridge OpenVPNAdapter* )adapter handleEvent:&ev];
|
||||
}
|
||||
|
||||
void OpenVPNClient::log(const ClientAPI::LogInfo& log) {
|
||||
[(__bridge OpenVPNAdapter* )adapter handleLog:&log];
|
||||
}
|
||||
|
||||
void OpenVPNClient::clock_tick() {
|
||||
[(__bridge OpenVPNAdapter* )adapter tick];
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
//
|
||||
// OpenVPNTunnelSettings.h
|
||||
// OpenVPN Adapter
|
||||
//
|
||||
// Created by Sergey Abramchuk on 26.02.17.
|
||||
//
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface OpenVPNTunnelSettings : NSObject
|
||||
|
||||
@property (nonatomic) BOOL initialized;
|
||||
|
||||
@property (readonly, strong, nonatomic) NSMutableArray *localAddresses;
|
||||
@property (readonly, strong, nonatomic) NSMutableArray *prefixLengths;
|
||||
|
||||
@property (readonly, strong, nonatomic) NSMutableArray *includedRoutes;
|
||||
@property (readonly, strong, nonatomic) NSMutableArray *excludedRoutes;
|
||||
|
||||
@property (readonly, strong, nonatomic) NSMutableArray *dnsAddresses;
|
||||
|
||||
@end
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// OpenVPNTunnelSettings.m
|
||||
// OpenVPN Adapter
|
||||
//
|
||||
// Created by Sergey Abramchuk on 26.02.17.
|
||||
//
|
||||
//
|
||||
|
||||
#import "OpenVPNTunnelSettings.h"
|
||||
|
||||
@implementation OpenVPNTunnelSettings
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_initialized = NO;
|
||||
|
||||
_localAddresses = [NSMutableArray new];
|
||||
_prefixLengths = [NSMutableArray new];
|
||||
|
||||
_includedRoutes = [NSMutableArray new];
|
||||
_excludedRoutes = [NSMutableArray new];
|
||||
|
||||
_dnsAddresses = [NSMutableArray new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -32,7 +32,6 @@ FOUNDATION_EXPORT const unsigned char OpenVPNAdapterVersionString[];
|
||||
#import <OpenVPNAdapter/OpenVPNTransportStats.h>
|
||||
#import <OpenVPNAdapter/OpenVPNInterfaceStats.h>
|
||||
#import <OpenVPNAdapter/OpenVPNAdapter.h>
|
||||
#import <OpenVPNAdapter/OpenVPNAdapter+Public.h>
|
||||
#import <OpenVPNAdapter/OpenVPNKeyType.h>
|
||||
#import <OpenVPNAdapter/OpenVPNCertificate.h>
|
||||
#import <OpenVPNAdapter/OpenVPNPrivateKey.h>
|
||||
|
||||
Reference in New Issue
Block a user