Return connection info

This commit is contained in:
Sergey Abramchuk
2017-04-30 17:28:01 +03:00
parent 0c1ce5037f
commit c3be418936
2 changed files with 14 additions and 1 deletions
+7
View File
@@ -12,6 +12,7 @@
@class OpenVPNConfiguration; @class OpenVPNConfiguration;
@class OpenVPNProperties; @class OpenVPNProperties;
@class OpenVPNCredentials; @class OpenVPNCredentials;
@class OpenVPNConnectionInfo;
@class NEPacketTunnelNetworkSettings; @class NEPacketTunnelNetworkSettings;
// TODO: Add documentation to properties and methods // TODO: Add documentation to properties and methods
@@ -99,6 +100,12 @@ NS_SWIFT_NAME(handle(logMessage:));
*/ */
@property (weak, nonatomic, null_unspecified) id<OpenVPNAdapterDelegate> delegate; @property (weak, nonatomic, null_unspecified) id<OpenVPNAdapterDelegate> delegate;
/**
Return information about the most recent connection. Will be available
after an event of type "CONNECTED, otherwise return nil
*/
@property (nullable, readonly, nonatomic) OpenVPNConnectionInfo *connectionInfo;
/** /**
<#Description#> <#Description#>
+7 -1
View File
@@ -121,7 +121,7 @@ NSString * const OpenVPNAdapterErrorEventKey = @"me.ss-abramchuk.openvpn-adapter
@end @end
@implementation OpenVPNAdapter (Provider) @implementation OpenVPNAdapter (Public)
#pragma mark Properties #pragma mark Properties
@@ -133,6 +133,12 @@ NSString * const OpenVPNAdapterErrorEventKey = @"me.ss-abramchuk.openvpn-adapter
return _delegate; return _delegate;
} }
- (OpenVPNConnectionInfo *)connectionInfo {
// TODO: Check correctness of using "defined" property
ClientAPI::ConnectionInfo info = self.vpnClient->connection_info();
return info.defined ? [[OpenVPNConnectionInfo alloc] initWithConnectionInfo:info] : nil;
}
#pragma mark Client Configuration #pragma mark Client Configuration
- (OpenVPNProperties *)applyConfiguration:(nonnull OpenVPNConfiguration *)configuration error:(out NSError * __nullable * __nullable)error { - (OpenVPNProperties *)applyConfiguration:(nonnull OpenVPNConfiguration *)configuration error:(out NSError * __nullable * __nullable)error {