mirror of
https://github.com/deneraraujo/OpenVPNAdapter.git
synced 2026-04-24 00:00:05 +08:00
Wrap eval config
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// OpenVPNProperties.m
|
||||
// OpenVPN Adapter
|
||||
//
|
||||
// Created by Sergey Abramchuk on 26.04.17.
|
||||
//
|
||||
//
|
||||
|
||||
#import <openvpn/common/number.hpp>
|
||||
|
||||
#import "OpenVPNValuesConverter.h"
|
||||
#import "OpenVPNServerEntry+Internal.h"
|
||||
#import "OpenVPNProperties.h"
|
||||
#import "OpenVPNProperties+Internal.h"
|
||||
|
||||
using namespace openvpn;
|
||||
|
||||
@implementation OpenVPNProperties
|
||||
|
||||
- (instancetype)initWithEvalConfig:(ClientAPI::EvalConfig)eval {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_username = !eval.userlockedUsername.empty() ? [NSString stringWithUTF8String:eval.userlockedUsername.c_str()] : nil;
|
||||
|
||||
_profileName = !eval.profileName.empty() ? [NSString stringWithUTF8String:eval.profileName.c_str()] : nil;
|
||||
_friendlyName = !eval.friendlyName.empty() ? [NSString stringWithUTF8String:eval.friendlyName.c_str()] : nil;
|
||||
|
||||
_autologin = eval.autologin;
|
||||
|
||||
_staticChallenge = !eval.staticChallenge.empty() ? [NSString stringWithUTF8String:eval.staticChallenge.c_str()] : nil;
|
||||
_staticChallengeEcho = eval.staticChallengeEcho;
|
||||
|
||||
_privateKeyPasswordRequired = eval.privateKeyPasswordRequired;
|
||||
_allowPasswordSave = eval.allowPasswordSave;
|
||||
|
||||
_remoteHost = !eval.remoteHost.empty() ? [NSString stringWithUTF8String:eval.remoteHost.c_str()] : nil;
|
||||
|
||||
uint16_t port = 0;
|
||||
parse_number(eval.remotePort, port);
|
||||
|
||||
_remotePort = port;
|
||||
|
||||
NSString *currentProto = [NSString stringWithUTF8String:eval.remoteProto.c_str()];
|
||||
_remoteProto = [OpenVPNPropertyConverter getTransportProtocolFromString:currentProto];
|
||||
|
||||
_servers = nil;
|
||||
if (!eval.serverList.empty()) {
|
||||
NSMutableArray *servers = [NSMutableArray new];
|
||||
|
||||
for (ClientAPI::ServerEntry entry : eval.serverList) {
|
||||
OpenVPNServerEntry *serverEntry = [[OpenVPNServerEntry alloc] initWithServerEntry:entry];
|
||||
[servers addObject:serverEntry];
|
||||
}
|
||||
|
||||
_servers = servers;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user