Wrap connection info

This commit is contained in:
Sergey Abramchuk
2017-04-26 13:53:38 +03:00
parent 102e617ad9
commit d6416eaece
4 changed files with 102 additions and 0 deletions
@@ -0,0 +1,19 @@
//
// OpenVPNConnectionInfo+Internal.h
// OpenVPN Adapter
//
// Created by Sergey Abramchuk on 26.04.17.
//
//
#import <client/ovpncli.hpp>
#import "OpenVPNConnectionInfo.h"
using namespace openvpn;
@interface OpenVPNConnectionInfo (Internal)
- (instancetype)initWithConnectionInfo:(ClientAPI::ConnectionInfo)info;
@end
+29
View File
@@ -0,0 +1,29 @@
//
// OpenVPNConnectionInfo.h
// OpenVPN Adapter
//
// Created by Sergey Abramchuk on 26.04.17.
//
//
#import <Foundation/Foundation.h>
/**
Class used to provide extra details about successful connection
*/
@interface OpenVPNConnectionInfo : NSObject
@property (readonly, nonatomic) BOOL defined;
@property (nullable, readonly, nonatomic) NSString *user;
@property (nullable, readonly, nonatomic) NSString *serverHost;
@property (nullable, readonly, nonatomic) NSString *serverPort;
@property (nullable, readonly, nonatomic) NSString *serverProto;
@property (nullable, readonly, nonatomic) NSString *serverIP;
@property (nullable, readonly, nonatomic) NSString *vpnIPv4;
@property (nullable, readonly, nonatomic) NSString *vpnIPv6;
@property (nullable, readonly, nonatomic) NSString *gatewayIPv4;
@property (nullable, readonly, nonatomic) NSString *gatewayIPv6;
@property (nullable, readonly, nonatomic) NSString *clientIP;
@property (nullable, readonly, nonatomic) NSString *tunName;
@end
+36
View File
@@ -0,0 +1,36 @@
//
// OpenVPNConnectionInfo.m
// OpenVPN Adapter
//
// Created by Sergey Abramchuk on 26.04.17.
//
//
#import "OpenVPNConnectionInfo.h"
#import "OpenVPNConnectionInfo+Internal.h"
using namespace openvpn;
@implementation OpenVPNConnectionInfo
- (instancetype)initWithConnectionInfo:(ClientAPI::ConnectionInfo)info
{
self = [super init];
if (self) {
_defined = info.defined;
_user = !info.user.empty() ? [NSString stringWithUTF8String:info.user.c_str()] : nil;
_serverHost = !info.serverHost.empty() ? [NSString stringWithUTF8String:info.serverHost.c_str()] : nil;
_serverPort = !info.serverPort.empty() ? [NSString stringWithUTF8String:info.serverPort.c_str()] : nil;
_serverProto = !info.serverProto.empty() ? [NSString stringWithUTF8String:info.serverProto.c_str()] : nil;
_serverIP = !info.serverIp.empty() ? [NSString stringWithUTF8String:info.serverIp.c_str()] : nil;
_vpnIPv4 = !info.vpnIp4.empty() ? [NSString stringWithUTF8String:info.vpnIp4.c_str()] : nil;
_vpnIPv6 = !info.vpnIp6.empty() ? [NSString stringWithUTF8String:info.vpnIp6.c_str()] : nil;
_gatewayIPv4 = !info.gw4.empty() ? [NSString stringWithUTF8String:info.gw4.c_str()] : nil;
_gatewayIPv6 = !info.gw6.empty() ? [NSString stringWithUTF8String:info.gw6.c_str()] : nil;
_clientIP = !info.clientIp.empty() ? [NSString stringWithUTF8String:info.clientIp.c_str()] : nil;
_tunName = !info.tunName.empty() ? [NSString stringWithUTF8String:info.tunName.c_str()] : nil;
}
return self;
}
@end