Put OpenVPN adapter into separate framework and add libraries compiled for simulator

This commit is contained in:
Sergey Abramchuk
2017-03-09 15:06:12 +03:00
parent cf50678dfc
commit 8903bb6fc6
912 changed files with 446 additions and 125 deletions

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View File

@@ -20,13 +20,13 @@
#import "TUNConfiguration.h"
#import "OpenVPNAdapter.h"
#import "OpenVPNAdapter+Client.h"
#import "OpenVPNAdapter+Provider.h"
#import "OpenVPNAdapter+Internal.h"
#import "OpenVPNAdapter+Public.h"
NSString * const OpenVPNClientErrorDomain = @"OpenVPNClientErrorDomain";
NSString * const OpenVPNAdapterErrorDomain = @"me.ss-abramchuk.openvpn-adapter.error-domain";
NSString * const OpenVPNClientErrorFatalKey = @"OpenVPNClientErrorFatalKey";
NSString * const OpenVPNClientErrorEventKey = @"OpenVPNClientErrorEventKey";
NSString * const OpenVPNAdapterErrorFatalKey = @"me.ss-abramchuk.openvpn-adapter.error-key.fatal";
NSString * const OpenVPNAdapterErrorEventKey = @"me.ss-abramchuk.openvpn-adapter.error-key.event";
@interface OpenVPNAdapter ()
@@ -225,14 +225,14 @@ static void socketCallback(CFSocketRef socket, CFSocketCallBackType type, CFData
if (event->error) {
NSMutableDictionary *userInfo = [NSMutableDictionary new];
[userInfo setObject:@(event->fatal) forKey:OpenVPNClientErrorFatalKey];
[userInfo setObject:@(eventIdentifier) forKey:OpenVPNClientErrorEventKey];
[userInfo setObject:@(event->fatal) forKey:OpenVPNAdapterErrorFatalKey];
[userInfo setObject:@(eventIdentifier) forKey:OpenVPNAdapterErrorEventKey];
if (eventMessage != nil && ![eventMessage isEqualToString:@""]) {
[userInfo setObject:eventMessage forKey:NSLocalizedDescriptionKey];
}
NSError *error = [NSError errorWithDomain:OpenVPNClientErrorDomain
NSError *error = [NSError errorWithDomain:OpenVPNAdapterErrorDomain
code:OpenVPNErrorClientFailure
userInfo:[userInfo copy]];
@@ -301,7 +301,7 @@ static void socketCallback(CFSocketRef socket, CFSocketCallBackType type, CFData
NSString *vpnConfiguration = [[NSString alloc] initWithData:settings encoding:NSUTF8StringEncoding];
if (vpnConfiguration == nil) {
if (error) *error = [NSError errorWithDomain:OpenVPNClientErrorDomain code:OpenVPNErrorConfigurationFailure userInfo:@{
if (error) *error = [NSError errorWithDomain:OpenVPNAdapterErrorDomain code:OpenVPNErrorConfigurationFailure userInfo:@{
NSLocalizedDescriptionKey: @"Failed to read VPN configuration"
}];
return NO;
@@ -315,19 +315,20 @@ static void socketCallback(CFSocketRef socket, CFSocketCallBackType type, CFData
ClientAPI::EvalConfig eval = self.vpnClient->eval_config(clientConfiguration);
if (eval.error) {
if (error) *error = [NSError errorWithDomain:OpenVPNClientErrorDomain code:OpenVPNErrorConfigurationFailure userInfo:@{
if (error) *error = [NSError errorWithDomain:OpenVPNAdapterErrorDomain code:OpenVPNErrorConfigurationFailure userInfo:@{
NSLocalizedDescriptionKey: [NSString stringWithUTF8String:eval.message.c_str()]
}];
return NO;
}
// TODO: Check whether nil values can be used for username and password or not
ClientAPI::ProvideCreds creds;
creds.username = [self.username UTF8String];
creds.password = [self.password UTF8String];
ClientAPI::Status creds_status = self.vpnClient->provide_creds(creds);
if (creds_status.error) {
if (error) *error = [NSError errorWithDomain:OpenVPNClientErrorDomain code:OpenVPNErrorConfigurationFailure userInfo:@{
if (error) *error = [NSError errorWithDomain:OpenVPNAdapterErrorDomain code:OpenVPNErrorConfigurationFailure userInfo:@{
NSLocalizedDescriptionKey: [NSString stringWithUTF8String:creds_status.message.c_str()]
}];
return NO;
@@ -340,7 +341,7 @@ static void socketCallback(CFSocketRef socket, CFSocketCallBackType type, CFData
- (void)connect {
// TODO: Describe why we use async invocation here
dispatch_queue_t connectQueue = dispatch_queue_create("me.ss-abramchuk.openvpn-ios-client.tunnel-provider.connection", NULL);
dispatch_queue_t connectQueue = dispatch_queue_create("me.ss-abramchuk.openvpn-ios-client.connection", NULL);
dispatch_async(connectQueue, ^{
self.tunConfiguration = [TUNConfiguration new];
OpenVPNClient::init_process();
@@ -348,19 +349,19 @@ static void socketCallback(CFSocketRef socket, CFSocketCallBackType type, CFData
try {
ClientAPI::Status status = self.vpnClient->connect();
if (status.error) {
NSError *error = [NSError errorWithDomain:OpenVPNClientErrorDomain
NSError *error = [NSError errorWithDomain:OpenVPNAdapterErrorDomain
code:OpenVPNErrorClientFailure
userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithUTF8String:status.message.c_str()],
OpenVPNClientErrorFatalKey: @(YES),
OpenVPNClientErrorEventKey: @(OpenVPNEventConnectionFailed) }];
OpenVPNAdapterErrorFatalKey: @(YES),
OpenVPNAdapterErrorEventKey: @(OpenVPNEventConnectionFailed) }];
[self.delegate handleError:error];
}
} catch(const std::exception& e) {
NSError *error = [NSError errorWithDomain:OpenVPNClientErrorDomain
NSError *error = [NSError errorWithDomain:OpenVPNAdapterErrorDomain
code:OpenVPNErrorClientFailure
userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithUTF8String:e.what()],
OpenVPNClientErrorFatalKey: @(YES),
OpenVPNClientErrorEventKey: @(OpenVPNEventConnectionFailed) }];
OpenVPNAdapterErrorFatalKey: @(YES),
OpenVPNAdapterErrorEventKey: @(OpenVPNEventConnectionFailed) }];
[self.delegate handleError:error];
}

View File

@@ -10,7 +10,7 @@
#import <Foundation/Foundation.h>
#import "OpenVPNAdapter+Client.h"
#import "OpenVPNAdapter+Internal.h"
#import "OpenVPNClient.h"

View File

@@ -8,10 +8,10 @@
#import <Foundation/Foundation.h>
extern NSString * __nonnull const OpenVPNClientErrorDomain;
extern NSString * __nonnull const OpenVPNAdapterErrorDomain;
extern NSString * __nonnull const OpenVPNClientErrorFatalKey;
extern NSString * __nonnull const OpenVPNClientErrorEventKey;
extern NSString * __nonnull const OpenVPNAdapterErrorFatalKey;
extern NSString * __nonnull const OpenVPNAdapterErrorEventKey;
typedef NS_ENUM(NSUInteger, OpenVPNError) {
OpenVPNErrorConfigurationFailure,

View File

@@ -0,0 +1,22 @@
//
// OpenVPNAdapter.h
// OpenVPNAdapter
//
// Created by Sergey Abramchuk on 09.03.17.
//
//
#import <UIKit/UIKit.h>
//! Project version number for OpenVPNAdapter.
FOUNDATION_EXPORT double OpenVPNAdapterVersionNumber;
//! Project version string for OpenVPNAdapter.
FOUNDATION_EXPORT const unsigned char OpenVPNAdapterVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <OpenVPNAdapter/PublicHeader.h>
#import <OpenVPNAdapter/OpenVPNError.h>
#import <OpenVPNAdapter/OpenVPNEvent.h>
#import <OpenVPNAdapter/OpenVPNAdapter.h>
#import <OpenVPNAdapter/OpenVPNAdapter+Public.h>

Some files were not shown because too many files have changed in this diff Show More