diff --git a/OpenVPN Adapter/OpenVPNConnectionInfo+Internal.h b/OpenVPN Adapter/OpenVPNConnectionInfo+Internal.h index 829beea..c03fb21 100644 --- a/OpenVPN Adapter/OpenVPNConnectionInfo+Internal.h +++ b/OpenVPN Adapter/OpenVPNConnectionInfo+Internal.h @@ -6,10 +6,10 @@ // // -#import - #import "OpenVPNConnectionInfo.h" +#include + using namespace openvpn; @interface OpenVPNConnectionInfo (Internal) diff --git a/OpenVPN Adapter/OpenVPNConnectionInfo.mm b/OpenVPN Adapter/OpenVPNConnectionInfo.mm index e3eb83e..d4900a6 100644 --- a/OpenVPN Adapter/OpenVPNConnectionInfo.mm +++ b/OpenVPN Adapter/OpenVPNConnectionInfo.mm @@ -28,7 +28,7 @@ using namespace openvpn; @implementation OpenVPNConnectionInfo - (instancetype)initWithConnectionInfo:(ClientAPI::ConnectionInfo)info { - if ((self = [super init])) { + if (self = [super init]) { self.user = !info.user.empty() ? [NSString stringWithUTF8String:info.user.c_str()] : nil; self.serverHost = !info.serverHost.empty() ? [NSString stringWithUTF8String:info.serverHost.c_str()] : nil; self.serverPort = !info.serverPort.empty() ? [NSString stringWithUTF8String:info.serverPort.c_str()] : nil; @@ -75,7 +75,7 @@ using namespace openvpn; } - (nullable instancetype)initWithCoder:(nonnull NSCoder *)aDecoder { - if ((self = [self init])) { + if (self = [self init]) { self.user = [aDecoder decodeObjectOfClass:[NSString class] forKey:NSStringFromSelector(@selector(user))]; self.serverHost = [aDecoder decodeObjectOfClass:[NSString class] forKey:NSStringFromSelector(@selector(serverHost))]; self.serverPort = [aDecoder decodeObjectOfClass:[NSString class] forKey:NSStringFromSelector(@selector(serverPort))]; diff --git a/OpenVPN Adapter/OpenVPNCredentials+Internal.h b/OpenVPN Adapter/OpenVPNCredentials+Internal.h index bd6cb6f..8cb7831 100644 --- a/OpenVPN Adapter/OpenVPNCredentials+Internal.h +++ b/OpenVPN Adapter/OpenVPNCredentials+Internal.h @@ -5,11 +5,10 @@ // Created by Sergey Abramchuk on 24.04.17. // // - -#import - #import "OpenVPNCredentials.h" +#include + using namespace openvpn; @interface OpenVPNCredentials (Internal) diff --git a/OpenVPN Adapter/OpenVPNCredentials.mm b/OpenVPN Adapter/OpenVPNCredentials.mm index 5c7bbf6..4748785 100644 --- a/OpenVPN Adapter/OpenVPNCredentials.mm +++ b/OpenVPN Adapter/OpenVPNCredentials.mm @@ -52,7 +52,8 @@ using namespace openvpn; } - (NSString *)dynamicChallengeCookie { - return !_credentials.dynamicChallengeCookie.empty() ? [NSString stringWithUTF8String:_credentials.dynamicChallengeCookie.c_str()] : nil; + return !_credentials.dynamicChallengeCookie.empty() ? + [NSString stringWithUTF8String:_credentials.dynamicChallengeCookie.c_str()] : nil; } - (void)setDynamicChallengeCookie:(NSString *)dynamicChallengeCookie { diff --git a/OpenVPN Adapter/OpenVPNInterfaceStats+Internal.h b/OpenVPN Adapter/OpenVPNInterfaceStats+Internal.h index 9c58773..735e605 100644 --- a/OpenVPN Adapter/OpenVPNInterfaceStats+Internal.h +++ b/OpenVPN Adapter/OpenVPNInterfaceStats+Internal.h @@ -6,10 +6,10 @@ // // -#import - #import "OpenVPNInterfaceStats.h" +#include + using namespace openvpn; @interface OpenVPNInterfaceStats (Internal) diff --git a/OpenVPN Adapter/OpenVPNInterfaceStats.mm b/OpenVPN Adapter/OpenVPNInterfaceStats.mm index 003b2d9..2f9333a 100644 --- a/OpenVPN Adapter/OpenVPNInterfaceStats.mm +++ b/OpenVPN Adapter/OpenVPNInterfaceStats.mm @@ -21,7 +21,7 @@ @implementation OpenVPNInterfaceStats - (instancetype)initWithInterfaceStats:(ClientAPI::InterfaceStats)stats { - if ((self = [super init])) { + if (self = [super init]) { self.bytesIn = stats.bytesIn; self.bytesOut = stats.bytesOut; self.packetsIn = stats.packetsIn; @@ -53,7 +53,7 @@ } - (nullable instancetype)initWithCoder:(nonnull NSCoder *)aDecoder { - if ((self = [self init])) { + if (self = [self init]) { self.bytesIn = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(bytesIn))]; self.bytesOut = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(bytesOut))]; self.packetsIn = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(packetsIn))]; diff --git a/OpenVPN Adapter/OpenVPNPacket.mm b/OpenVPN Adapter/OpenVPNPacket.mm index f9344fb..0846016 100644 --- a/OpenVPN Adapter/OpenVPNPacket.mm +++ b/OpenVPN Adapter/OpenVPNPacket.mm @@ -21,7 +21,7 @@ @implementation OpenVPNPacket - (instancetype)initWithVPNData:(NSData *)data { - if ((self = [super init])) { + if (self = [super init]) { #if TARGET_OS_IPHONE // Get network protocol family from data prefix NSUInteger prefix_size = sizeof(uint32_t); @@ -59,7 +59,7 @@ } - (instancetype)initWithPacketFlowData:(NSData *)data protocolFamily:(NSNumber *)protocolFamily { - if ((self = [super init])) { + if (self = [super init]) { _data = data; _protocolFamily = protocolFamily; } diff --git a/OpenVPN Adapter/OpenVPNProperties+Internal.h b/OpenVPN Adapter/OpenVPNProperties+Internal.h index c4f0ea9..d6bee9a 100644 --- a/OpenVPN Adapter/OpenVPNProperties+Internal.h +++ b/OpenVPN Adapter/OpenVPNProperties+Internal.h @@ -6,10 +6,10 @@ // // -#import - #import "OpenVPNProperties.h" +#include + using namespace openvpn; @interface OpenVPNProperties (Internal) diff --git a/OpenVPN Adapter/OpenVPNProperties.h b/OpenVPN Adapter/OpenVPNProperties.h index 1182d2d..8a63975 100644 --- a/OpenVPN Adapter/OpenVPNProperties.h +++ b/OpenVPN Adapter/OpenVPNProperties.h @@ -8,8 +8,7 @@ #import -#import "OpenVPNTransportProtocol.h" - +typedef NS_ENUM(NSInteger, OpenVPNTransportProtocol); @class OpenVPNServerEntry; @interface OpenVPNProperties : NSObject @@ -47,7 +46,7 @@ /** YES if this profile requires a private key password */ -@property (readonly, nonatomic) BOOL privateKeyPasswordRequired; +@property (readonly, nonatomic, getter=isPrivateKeyPasswordRequired) BOOL privateKeyPasswordRequired; /** YES if user is allowed to save authentication password in UI @@ -74,6 +73,6 @@ */ @property (nullable, readonly, nonatomic) NSArray *servers; -- (nonnull instancetype) __unavailable init; +- (nonnull instancetype) init NS_UNAVAILABLE; @end diff --git a/OpenVPN Adapter/OpenVPNProperties.mm b/OpenVPN Adapter/OpenVPNProperties.mm index 2dca5e5..8a6cdf9 100644 --- a/OpenVPN Adapter/OpenVPNProperties.mm +++ b/OpenVPN Adapter/OpenVPNProperties.mm @@ -6,20 +6,20 @@ // // -#import +#import "OpenVPNProperties.h" +#import "OpenVPNProperties+Internal.h" + +#include #import "OpenVPNConfiguration+Internal.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) { + if (self = [super init]) { _username = !eval.userlockedUsername.empty() ? [NSString stringWithUTF8String:eval.userlockedUsername.c_str()] : nil; _profileName = !eval.profileName.empty() ? [NSString stringWithUTF8String:eval.profileName.c_str()] : nil; @@ -44,6 +44,7 @@ using namespace openvpn; _remoteProto = [OpenVPNConfiguration getTransportProtocolFromValue:currentProto]; _servers = nil; + if (!eval.serverList.empty()) { NSMutableArray *servers = [NSMutableArray new]; diff --git a/OpenVPN Adapter/OpenVPNServerEntry+Internal.h b/OpenVPN Adapter/OpenVPNServerEntry+Internal.h index e8685f5..b4e44fe 100644 --- a/OpenVPN Adapter/OpenVPNServerEntry+Internal.h +++ b/OpenVPN Adapter/OpenVPNServerEntry+Internal.h @@ -6,10 +6,10 @@ // // -#import - #import "OpenVPNServerEntry.h" +#include + using namespace openvpn; @interface OpenVPNServerEntry (Internal) diff --git a/OpenVPN Adapter/OpenVPNServerEntry.h b/OpenVPN Adapter/OpenVPNServerEntry.h index 75ecb40..4898f52 100644 --- a/OpenVPN Adapter/OpenVPNServerEntry.h +++ b/OpenVPN Adapter/OpenVPNServerEntry.h @@ -13,6 +13,6 @@ @property (nullable, readonly, nonatomic) NSString *server; @property (nullable, readonly, nonatomic) NSString *friendlyName; -- (nonnull instancetype) __unavailable init; +- (nonnull instancetype) init NS_UNAVAILABLE; @end diff --git a/OpenVPN Adapter/OpenVPNServerEntry.mm b/OpenVPN Adapter/OpenVPNServerEntry.mm index b87e7d0..13f74d8 100644 --- a/OpenVPN Adapter/OpenVPNServerEntry.mm +++ b/OpenVPN Adapter/OpenVPNServerEntry.mm @@ -12,8 +12,7 @@ @implementation OpenVPNServerEntry - (instancetype)initWithServerEntry:(ClientAPI::ServerEntry)entry { - self = [super init]; - if (self) { + if (self = [super init]) { _server = !entry.server.empty() ? [NSString stringWithUTF8String:entry.server.c_str()] : nil; _friendlyName = !entry.friendlyName.empty() ? [NSString stringWithUTF8String:entry.friendlyName.c_str()] : nil; } diff --git a/OpenVPN Adapter/OpenVPNSessionToken+Internal.h b/OpenVPN Adapter/OpenVPNSessionToken+Internal.h index 667bf3b..b1c9026 100644 --- a/OpenVPN Adapter/OpenVPNSessionToken+Internal.h +++ b/OpenVPN Adapter/OpenVPNSessionToken+Internal.h @@ -6,10 +6,10 @@ // // -#import - #import "OpenVPNSessionToken.h" +#include + using namespace openvpn; @interface OpenVPNSessionToken (Internal) diff --git a/OpenVPN Adapter/OpenVPNSessionToken.mm b/OpenVPN Adapter/OpenVPNSessionToken.mm index 462ffb7..9d2f298 100644 --- a/OpenVPN Adapter/OpenVPNSessionToken.mm +++ b/OpenVPN Adapter/OpenVPNSessionToken.mm @@ -6,6 +6,7 @@ // // +#import "OpenVPNSessionToken.h" #import "OpenVPNSessionToken+Internal.h" using namespace openvpn; @@ -18,7 +19,7 @@ using namespace openvpn; @implementation OpenVPNSessionToken - (instancetype)initWithSessionToken:(ClientAPI::SessionToken)token { - if ((self = [super init])) { + if (self = [super init]) { self.username = !token.username.empty() ? [NSString stringWithUTF8String:token.username.c_str()] : nil; self.session = !token.session_id.empty() ? [NSString stringWithUTF8String:token.session_id.c_str()] : nil; } @@ -38,7 +39,7 @@ using namespace openvpn; } - (nullable instancetype)initWithCoder:(nonnull NSCoder *)aDecoder { - if ((self = [self init])) { + if (self = [self init]) { self.username = [aDecoder decodeObjectOfClass:[NSString class] forKey:NSStringFromSelector(@selector(username))]; self.session = [aDecoder decodeObjectOfClass:[NSString class] forKey:NSStringFromSelector(@selector(session))]; } diff --git a/OpenVPN Adapter/OpenVPNTransportStats+Internal.h b/OpenVPN Adapter/OpenVPNTransportStats+Internal.h index 974d694..df7e129 100644 --- a/OpenVPN Adapter/OpenVPNTransportStats+Internal.h +++ b/OpenVPN Adapter/OpenVPNTransportStats+Internal.h @@ -6,10 +6,10 @@ // // -#import - #import "OpenVPNTransportStats.h" +#include + using namespace openvpn; @interface OpenVPNTransportStats (Internal) diff --git a/OpenVPN Adapter/OpenVPNTransportStats.mm b/OpenVPN Adapter/OpenVPNTransportStats.mm index 4dc4ad7..2a7c554 100644 --- a/OpenVPN Adapter/OpenVPNTransportStats.mm +++ b/OpenVPN Adapter/OpenVPNTransportStats.mm @@ -6,6 +6,7 @@ // // +#import "OpenVPNTransportStats.h" #import "OpenVPNTransportStats+Internal.h" using namespace openvpn; @@ -21,12 +22,13 @@ using namespace openvpn; @implementation OpenVPNTransportStats - (instancetype)initWithTransportStats:(ClientAPI::TransportStats)stats { - if ((self = [self init])) { + if (self = [self init]) { self.bytesIn = stats.bytesIn; self.bytesOut = stats.bytesOut; self.packetsIn = stats.packetsIn; self.packetsOut = stats.packetsOut; - self.lastPacketReceived = stats.lastPacketReceived >= 0 ? [NSDate dateWithTimeIntervalSinceNow:stats.lastPacketReceived / -1024.0] : nil; + self.lastPacketReceived = stats.lastPacketReceived >= 0 ? + [NSDate dateWithTimeIntervalSinceNow:stats.lastPacketReceived / -1024.0] : nil; } return self; } @@ -50,12 +52,13 @@ using namespace openvpn; } - (instancetype)initWithCoder:(NSCoder *)aDecoder { - if ((self = [super init])) { + if (self = [super init]) { self.bytesIn = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(bytesIn))]; self.bytesOut = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(bytesOut))]; self.packetsIn = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(packetsIn))]; self.packetsOut = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(packetsOut))]; - self.lastPacketReceived = [aDecoder decodeObjectOfClass:[NSDate class] forKey:NSStringFromSelector(@selector(lastPacketReceived))]; + self.lastPacketReceived = [aDecoder decodeObjectOfClass:[NSDate class] + forKey:NSStringFromSelector(@selector(lastPacketReceived))]; } return self; }