From 9e01791471e59ad80cdeab45e9c31366845c053b Mon Sep 17 00:00:00 2001 From: Anh Viet Date: Sun, 16 Apr 2023 23:16:01 +0700 Subject: [PATCH] 16/4 use cloak pt when connect vpn --- Configuration/amnezia.xcconfig | 16 ++++++------- OpenVPNAdapter.xcodeproj/project.pbxproj | 16 +++++-------- Sources/OpenVPN3/client/ovpncli.cpp | 2 +- .../OpenVPNAdapter/library/OpenVPNClient.mm | 1 + .../library/OpenVPNConfiguration.h | 3 ++- .../library/OpenVPNConfiguration.mm | 24 +++++++++++-------- 6 files changed, 32 insertions(+), 30 deletions(-) diff --git a/Configuration/amnezia.xcconfig b/Configuration/amnezia.xcconfig index c0e06c5..25bdd40 100644 --- a/Configuration/amnezia.xcconfig +++ b/Configuration/amnezia.xcconfig @@ -10,7 +10,7 @@ CLANG_CXX_LIBRARY = libc++ // // iOS-specific settings // -IPHONEOS_DEPLOYMENT_TARGET = 9.0 +IPHONEOS_DEPLOYMENT_TARGET = 10.0 SDKROOT[arch=arm64] = iphoneos //SDKROOT[arch=armv7] = iphoneos @@ -18,18 +18,18 @@ SDKROOT[arch=arm64] = iphoneos VALID_ARCHS[sdk=iphoneos*] = arm64 // armv7 armv7s -VALID_ARCHS[sdk=iphonesimulator*] = i386 x86_64 +//VALID_ARCHS[sdk=iphonesimulator*] = i386 x86_64 //////////////////////////////////////////////////////////////////////////////// // // macOS-specific settings // -MACOSX_DEPLOYMENT_TARGET = 10.11 - -SDKROOT[arch=i386] = macosx -SDKROOT[arch=x86_64] = macosx - -VALID_ARCHS[sdk=macosx*] = i386 x86_64 +//MACOSX_DEPLOYMENT_TARGET = 10.11 +// +//SDKROOT[arch=i386] = macosx +//SDKROOT[arch=x86_64] = macosx +// +//VALID_ARCHS[sdk=macosx*] = i386 x86_64 PROJECT_TEMP_DIR = /Users/anhviet/Documents/VPN/amnezia-client/client/3rd/OpenVPNAdapter/build/OpenVPNAdapter.build CONFIGURATION_BUILD_DIR = /Users/anhviet/Documents/VPN/amnezia-client/client/3rd/OpenVPNAdapter/build/Release-iphoneos BUILT_PRODUCTS_DIR = /Users/anhviet/Documents/VPN/amnezia-client/client/3rd/OpenVPNAdapter/build/Release-iphoneos diff --git a/OpenVPNAdapter.xcodeproj/project.pbxproj b/OpenVPNAdapter.xcodeproj/project.pbxproj index 63be50e..305024d 100644 --- a/OpenVPNAdapter.xcodeproj/project.pbxproj +++ b/OpenVPNAdapter.xcodeproj/project.pbxproj @@ -7,7 +7,7 @@ objects = { /* Begin PBXBuildFile section */ - 7BFD7A7E29E5BCE30066D7CC /* arm64.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7BFD7A7C29E5B9320066D7CC /* arm64.a */; }; + 7B7E1EA129E70FB400E76E6D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B7E1EA029E70FB400E76E6D /* UIKit.framework */; }; 7BFD7A8029E5BEF90066D7CC /* ovpncli.mm in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_73 /* ovpncli.mm */; }; 7BFD7ABB29E6F8290066D7CC /* ck-ovpn-plugin.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B7795A329DC896200D15D50 /* ck-ovpn-plugin.a */; }; C910EAE524EBB1DA0081AF13 /* OpenVPNReachabilityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C97E5FD624123F48005C2EBC /* OpenVPNReachabilityTests.swift */; }; @@ -230,10 +230,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 7B777E2229E1C75200718406 /* ck-ovpn-plugin-arm64.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = "ck-ovpn-plugin-arm64.a"; sourceTree = ""; }; 7B7795A329DC896200D15D50 /* ck-ovpn-plugin.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = "ck-ovpn-plugin.a"; sourceTree = ""; }; - 7BFD7A7A29E475F80066D7CC /* ck-ovpn-plugin-arm64s.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = "ck-ovpn-plugin-arm64s.a"; sourceTree = ""; }; - 7BFD7A7C29E5B9320066D7CC /* arm64.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = arm64.a; sourceTree = ""; }; + 7B7E1EA029E70FB400E76E6D /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; C910EAE624EBB5210081AF13 /* OpenVPNConfigurationEvaluation.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = OpenVPNConfigurationEvaluation.h; sourceTree = ""; }; C910EAEB24EBBFB60081AF13 /* client.crt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = client.crt; sourceTree = ""; }; C910EAEC24EBBFB60081AF13 /* ca.crt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ca.crt; sourceTree = ""; }; @@ -290,7 +288,6 @@ C9EABF3224110E7500D828D4 /* ovpnapi.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ovpnapi.hpp; sourceTree = ""; }; C9EABF3324110E7500D828D4 /* ovpncli.hpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; path = ovpncli.hpp; sourceTree = ""; }; C9EABF492411133400D828D4 /* Project.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Project.xcconfig; sourceTree = ""; }; - C9EABF642411189800D828D4 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; C9EABF7324111AEE00D828D4 /* OpenVPNClient.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = OpenVPNClient.xcconfig; sourceTree = ""; }; C9EABF7424111D6100D828D4 /* OpenVPNAdapter.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = OpenVPNAdapter.xcconfig; sourceTree = ""; }; C9EABF7524111E9C00D828D4 /* LZ4.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = LZ4.xcconfig; sourceTree = ""; }; @@ -513,6 +510,7 @@ buildActionMask = 0; files = ( OBJ_304 /* OpenVPNClient.framework in Frameworks */, + 7B7E1EA129E70FB400E76E6D /* UIKit.framework in Frameworks */, C9EABF3124110BE200D828D4 /* SystemConfiguration.framework in Frameworks */, C97E5FEC24124B73005C2EBC /* mbedTLS.framework in Frameworks */, C97E5FE724124B6F005C2EBC /* LZ4.framework in Frameworks */, @@ -524,7 +522,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 0; files = ( - 7BFD7A7E29E5BCE30066D7CC /* arm64.a in Frameworks */, OBJ_324 /* mbedTLS.framework in Frameworks */, OBJ_325 /* LZ4.framework in Frameworks */, ); @@ -568,11 +565,8 @@ C9EABF2F24110BE100D828D4 /* Frameworks */ = { isa = PBXGroup; children = ( - 7BFD7A7C29E5B9320066D7CC /* arm64.a */, - 7BFD7A7A29E475F80066D7CC /* ck-ovpn-plugin-arm64s.a */, - 7B777E2229E1C75200718406 /* ck-ovpn-plugin-arm64.a */, + 7B7E1EA029E70FB400E76E6D /* UIKit.framework */, 7B7795A329DC896200D15D50 /* ck-ovpn-plugin.a */, - C9EABF642411189800D828D4 /* UIKit.framework */, C9EABF3024110BE200D828D4 /* SystemConfiguration.framework */, ); name = Frameworks; @@ -1566,6 +1560,7 @@ "$(PROJECT_DIR)", ); MARKETING_VERSION = 0.8.0; + OPENVPN_PLUGGABLE_TRANSPORTS = 1; OTHER_SWIFT_FLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = OpenVPNAdapter; PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; @@ -1606,6 +1601,7 @@ "$(PROJECT_DIR)", ); MARKETING_VERSION = 0.8.0; + OPENVPN_PLUGGABLE_TRANSPORTS = 1; OTHER_SWIFT_FLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = OpenVPNAdapter; PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; diff --git a/Sources/OpenVPN3/client/ovpncli.cpp b/Sources/OpenVPN3/client/ovpncli.cpp index 54e41cb..79ed2c2 100644 --- a/Sources/OpenVPN3/client/ovpncli.cpp +++ b/Sources/OpenVPN3/client/ovpncli.cpp @@ -835,7 +835,7 @@ namespace openvpn { EvalConfig eval; OpenVPNClientHelper::parse_config(config, eval, state->options); if (eval.error) - return eval; + return eval; // handle extra settings in config parse_extras(config, eval); diff --git a/Sources/OpenVPNAdapter/library/OpenVPNClient.mm b/Sources/OpenVPNAdapter/library/OpenVPNClient.mm index c2d7ac6..7f2068c 100644 --- a/Sources/OpenVPNAdapter/library/OpenVPNClient.mm +++ b/Sources/OpenVPNAdapter/library/OpenVPNClient.mm @@ -26,6 +26,7 @@ OpenVPNClient::~OpenVPNClient() { ClientAPI::EvalConfig OpenVPNClient::apply_config(const ClientAPI::Config& config) { if (this->config != nullptr) { delete this->config; } +// this->config->usePluggableTransports = TRUE; this->config = new ClientAPI::Config(config); return eval_config(config); diff --git a/Sources/OpenVPNAdapter/library/OpenVPNConfiguration.h b/Sources/OpenVPNAdapter/library/OpenVPNConfiguration.h index b80f14f..c74dcc5 100644 --- a/Sources/OpenVPNAdapter/library/OpenVPNConfiguration.h +++ b/Sources/OpenVPNAdapter/library/OpenVPNConfiguration.h @@ -188,5 +188,6 @@ typedef NS_ENUM(NSInteger, OpenVPNTLSCertProfile); Set to 0 to disable. */ @property (nonatomic) NSUInteger clockTick; - +- (void)setFileContent:(NSData *_Nullable)fileContent; +- (void)setPTCloak; @end diff --git a/Sources/OpenVPNAdapter/library/OpenVPNConfiguration.mm b/Sources/OpenVPNAdapter/library/OpenVPNConfiguration.mm index d8c14a4..a548b51 100644 --- a/Sources/OpenVPNAdapter/library/OpenVPNConfiguration.mm +++ b/Sources/OpenVPNAdapter/library/OpenVPNConfiguration.mm @@ -67,7 +67,7 @@ NSString *const OpenVPNTLSCertProfileDefaultValue = @"default"; NSString *currentValue = [value length] == 0 ? OpenVPNTransportProtocolDefaultValue : value; NSNumber *transportProtocol = options[currentValue]; - NSAssert(transportProtocol != nil, @"Incorrect protocol value: %@", currentValue); + NSAssert(transportProtocol != nil, @"amnezia -> Incorrect protocol value: %@", currentValue); return (OpenVPNTransportProtocol)[transportProtocol integerValue]; } @@ -81,7 +81,7 @@ NSString *const OpenVPNTLSCertProfileDefaultValue = @"default"; }; NSString *value = options[@(protocol)]; - NSAssert(value != nil, @"Incorrect protocol value: %li", (long)protocol); + NSAssert(value != nil, @"amnezia -> Incorrect protocol value: %li", (long)protocol); return value; } @@ -96,7 +96,7 @@ NSString *const OpenVPNTLSCertProfileDefaultValue = @"default"; NSString *currentValue = [value length] == 0 ? OpenVPNIPv6PreferenceDefaultValue : value; NSNumber *ipv6 = options[currentValue]; - NSAssert(ipv6 != nil, @"Incorrect ipv6 value: %@", currentValue); + NSAssert(ipv6 != nil, @"amnezia -> Incorrect ipv6 value: %@", currentValue); return (OpenVPNIPv6Preference)[ipv6 integerValue]; } @@ -109,7 +109,7 @@ NSString *const OpenVPNTLSCertProfileDefaultValue = @"default"; }; NSString *value = options[@(preference)]; - NSAssert(value != nil, @"Incorrect ipv6 value: %li", (long)preference); + NSAssert(value != nil, @"amnezia -> Incorrect ipv6 value: %li", (long)preference); return value; } @@ -125,7 +125,7 @@ NSString *const OpenVPNTLSCertProfileDefaultValue = @"default"; NSString *currentValue = [value length] == 0 ? OpenVPNCompressionModeDefaultValue : value; NSNumber *compressionMode = options[currentValue]; - NSAssert(compressionMode != nil, @"Incorrect compressionMode value: %@", currentValue); + NSAssert(compressionMode != nil, @"amnezia -> Incorrect compressionMode value: %@", currentValue); return (OpenVPNCompressionMode)[compressionMode integerValue]; } @@ -139,7 +139,7 @@ NSString *const OpenVPNTLSCertProfileDefaultValue = @"default"; }; NSString *value = options[@(compressionMode)]; - NSAssert(value != nil, @"Incorrect compressionMode value: %li", (long)compressionMode); + NSAssert(value != nil, @"amnezia -> Incorrect compressionMode value: %li", (long)compressionMode); return value; } @@ -156,7 +156,7 @@ NSString *const OpenVPNTLSCertProfileDefaultValue = @"default"; NSString *currentValue = [value length] == 0 ? OpenVPNMinTLSVersionDefaultValue : value; NSNumber *minTLSVersion = options[currentValue]; - NSAssert(minTLSVersion != nil, @"Incorrect minTLS value: %@", currentValue); + NSAssert(minTLSVersion != nil, @"amnezia -> Incorrect minTLS value: %@", currentValue); return (OpenVPNMinTLSVersion)[minTLSVersion integerValue]; } @@ -171,7 +171,7 @@ NSString *const OpenVPNTLSCertProfileDefaultValue = @"default"; }; NSString *value = options[@(minTLS)]; - NSAssert(value != nil, @"Incorrect minTLS value: %li", (long)minTLS); + NSAssert(value != nil, @"amnezia -> Incorrect minTLS value: %li", (long)minTLS); return value; } @@ -189,7 +189,7 @@ NSString *const OpenVPNTLSCertProfileDefaultValue = @"default"; NSString *currentValue = [value length] == 0 ? OpenVPNTLSCertProfileDefaultValue : value; NSNumber *tlsCertProfile = options[currentValue]; - NSAssert(tlsCertProfile != nil, @"Incorrect tlsCertProfile value: %@", currentValue); + NSAssert(tlsCertProfile != nil, @"amnezia -> Incorrect tlsCertProfile value: %@", currentValue); return (OpenVPNTLSCertProfile)[tlsCertProfile integerValue]; } @@ -205,7 +205,7 @@ NSString *const OpenVPNTLSCertProfileDefaultValue = @"default"; }; NSString *value = options[@(tlsCertProfile)]; - NSAssert(value != nil, @"Incorrect tlsCertProfile value: %li", (long)tlsCertProfile); + NSAssert(value != nil, @"amnezia -> Incorrect tlsCertProfile value: %li", (long)tlsCertProfile); return value; } @@ -214,6 +214,10 @@ NSString *const OpenVPNTLSCertProfileDefaultValue = @"default"; @implementation OpenVPNConfiguration +- (void)setPTCloak { + _config.usePluggableTransports = TRUE; +} + - (NSData *)fileContent { return !_config.content.empty() ? [NSData dataWithBytes:_config.content.data() length:_config.content.size()] : nil; }