Add port property and test get/set its value

This commit is contained in:
Sergey Abramchuk
2019-01-13 14:24:25 +03:00
parent b578e282f5
commit fa25b668e0
3 changed files with 38 additions and 0 deletions
@@ -43,6 +43,12 @@ typedef NS_ENUM(NSInteger, OpenVPNTLSCertProfile);
*/
@property (nullable, nonatomic) NSString *server;
/**
Use a different port than that specified in "remote"
option of profile
*/
@property (nonatomic) NSUInteger port;
/**
Force a given transport protocol
*/
@@ -268,6 +268,18 @@ NSString *const OpenVPNTLSCertProfileDefaultValue = @"default";
_config.serverOverride = serverOverride ? std::string([serverOverride UTF8String]) : "";
}
- (NSUInteger)port {
try {
return std::stoul(_config.portOverride, NULL);
} catch (...) {
return 0;
}
}
- (void)setPort:(NSUInteger)port {
_config.portOverride = std::to_string(port);
}
- (OpenVPNTransportProtocol)proto {
NSString *currentValue = [NSString stringWithUTF8String:_config.protoOverride.c_str()];
return [OpenVPNConfiguration getTransportProtocolFromValue:currentValue];