From b32f7e2496013ee418dc60cb2c5a1b82d3d7bd5d Mon Sep 17 00:00:00 2001 From: Sergey Abramchuk Date: Sun, 30 Apr 2017 18:00:58 +0300 Subject: [PATCH] Return transport stats and interface stats --- OpenVPN Adapter/OpenVPNAdapter+Public.h | 14 +++++++++++++- OpenVPN Adapter/OpenVPNAdapter.mm | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/OpenVPN Adapter/OpenVPNAdapter+Public.h b/OpenVPN Adapter/OpenVPNAdapter+Public.h index 60d0b30..d86baef 100644 --- a/OpenVPN Adapter/OpenVPNAdapter+Public.h +++ b/OpenVPN Adapter/OpenVPNAdapter+Public.h @@ -13,6 +13,8 @@ @class OpenVPNProperties; @class OpenVPNCredentials; @class OpenVPNConnectionInfo; +@class OpenVPNTransportStats; +@class OpenVPNInterfaceStats; @class NEPacketTunnelNetworkSettings; // TODO: Add documentation to properties and methods @@ -102,10 +104,20 @@ NS_SWIFT_NAME(handle(logMessage:)); /** Return information about the most recent connection. Will be available - after an event of type "CONNECTED, otherwise return nil + after an event of type "CONNECTED, otherwise return nil. */ @property (nullable, readonly, nonatomic) OpenVPNConnectionInfo *connectionInfo; +/** + Return transport stats + */ +@property (nonnull, readonly, nonatomic) OpenVPNTransportStats *transportStats; + +/** + Return tun stats + */ +@property (nonnull, readonly, nonatomic) OpenVPNInterfaceStats *interfaceStats; + /** <#Description#> diff --git a/OpenVPN Adapter/OpenVPNAdapter.mm b/OpenVPN Adapter/OpenVPNAdapter.mm index b600786..9f08cef 100644 --- a/OpenVPN Adapter/OpenVPNAdapter.mm +++ b/OpenVPN Adapter/OpenVPNAdapter.mm @@ -14,13 +14,15 @@ #import +#import "OpenVPNClient.h" #import "OpenVPNError.h" #import "OpenVPNEvent.h" #import "OpenVPNConfiguration+Internal.h" #import "OpenVPNCredentials+Internal.h" #import "OpenVPNProperties+Internal.h" #import "OpenVPNConnectionInfo+Internal.h" -#import "OpenVPNClient.h" +#import "OpenVPNTransportStats+Internal.h" +#import "OpenVPNInterfaceStats+Internal.h" #import "OpenVPNAdapter.h" #import "OpenVPNAdapter+Internal.h" #import "OpenVPNAdapter+Public.h" @@ -139,6 +141,16 @@ NSString * const OpenVPNAdapterErrorEventKey = @"me.ss-abramchuk.openvpn-adapter return info.defined ? [[OpenVPNConnectionInfo alloc] initWithConnectionInfo:info] : nil; } +- (OpenVPNTransportStats *)transportStats { + ClientAPI::TransportStats stats = self.vpnClient->transport_stats(); + return [[OpenVPNTransportStats alloc] initWithTransportStats:stats]; +} + +- (OpenVPNInterfaceStats *)interfaceStats { + ClientAPI::InterfaceStats stats = self.vpnClient->tun_stats(); + return [[OpenVPNInterfaceStats alloc] initWithInterfaceStats:stats]; +} + #pragma mark Client Configuration - (OpenVPNProperties *)applyConfiguration:(nonnull OpenVPNConfiguration *)configuration error:(out NSError * __nullable * __nullable)error {