mirror of
https://github.com/deneraraujo/OpenVPNAdapter.git
synced 2026-04-24 00:00:05 +08:00
Add extra spaces and empty lines
This commit is contained in:
@@ -11,8 +11,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
@class NEIPv4Route;
|
@class NEIPv4Route;
|
||||||
@class NEIPv6Route;
|
@class NEIPv6Route;
|
||||||
@class NEPacketTunnelNetworkSettings;
|
|
||||||
@class NEProxyServer;
|
@class NEProxyServer;
|
||||||
|
@class NEPacketTunnelNetworkSettings;
|
||||||
|
|
||||||
@interface OpenVPNNetworkSettingsBuilder : NSObject
|
@interface OpenVPNNetworkSettingsBuilder : NSObject
|
||||||
|
|
||||||
|
|||||||
@@ -5,21 +5,27 @@
|
|||||||
// Created by Jonathan Downing on 12/10/2017.
|
// Created by Jonathan Downing on 12/10/2017.
|
||||||
//
|
//
|
||||||
|
|
||||||
#import <NetworkExtension/NetworkExtension.h>
|
|
||||||
#import "OpenVPNNetworkSettingsBuilder.h"
|
#import "OpenVPNNetworkSettingsBuilder.h"
|
||||||
|
|
||||||
|
#import <NetworkExtension/NetworkExtension.h>
|
||||||
|
|
||||||
@interface OpenVPNNetworkSettingsBuilder ()
|
@interface OpenVPNNetworkSettingsBuilder ()
|
||||||
|
|
||||||
@property (nonatomic) NSMutableArray<NSString *> *ipv4LocalAddresses;
|
@property (nonatomic) NSMutableArray<NSString *> *ipv4LocalAddresses;
|
||||||
@property (nonatomic) NSMutableArray<NSString *> *ipv4SubnetMasks;
|
@property (nonatomic) NSMutableArray<NSString *> *ipv4SubnetMasks;
|
||||||
@property (nonatomic) NSMutableArray<NEIPv4Route *> *ipv4IncludedRoutes;
|
@property (nonatomic) NSMutableArray<NEIPv4Route *> *ipv4IncludedRoutes;
|
||||||
@property (nonatomic) NSMutableArray<NEIPv4Route *> *ipv4ExcludedRoutes;
|
@property (nonatomic) NSMutableArray<NEIPv4Route *> *ipv4ExcludedRoutes;
|
||||||
|
|
||||||
@property (nonatomic) NSMutableArray<NSString *> *ipv6LocalAddresses;
|
@property (nonatomic) NSMutableArray<NSString *> *ipv6LocalAddresses;
|
||||||
@property (nonatomic) NSMutableArray<NSNumber *> *ipv6NetworkPrefixLengths;
|
@property (nonatomic) NSMutableArray<NSNumber *> *ipv6NetworkPrefixLengths;
|
||||||
@property (nonatomic) NSMutableArray<NEIPv6Route *> *ipv6IncludedRoutes;
|
@property (nonatomic) NSMutableArray<NEIPv6Route *> *ipv6IncludedRoutes;
|
||||||
@property (nonatomic) NSMutableArray<NEIPv6Route *> *ipv6ExcludedRoutes;
|
@property (nonatomic) NSMutableArray<NEIPv6Route *> *ipv6ExcludedRoutes;
|
||||||
|
|
||||||
@property (nonatomic) NSMutableArray<NSString *> *dnsServers;
|
@property (nonatomic) NSMutableArray<NSString *> *dnsServers;
|
||||||
@property (nonatomic) NSMutableArray<NSString *> *searchDomains;
|
@property (nonatomic) NSMutableArray<NSString *> *searchDomains;
|
||||||
|
|
||||||
@property (nonatomic) NSMutableArray<NSString *> *proxyExceptionList;
|
@property (nonatomic) NSMutableArray<NSString *> *proxyExceptionList;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation OpenVPNNetworkSettingsBuilder
|
@implementation OpenVPNNetworkSettingsBuilder
|
||||||
@@ -27,23 +33,27 @@
|
|||||||
#pragma mark - NEPacketTunnelNetworkSettings Generation
|
#pragma mark - NEPacketTunnelNetworkSettings Generation
|
||||||
|
|
||||||
- (NEPacketTunnelNetworkSettings *)networkSettings {
|
- (NEPacketTunnelNetworkSettings *)networkSettings {
|
||||||
if (!self.remoteAddress.length) {
|
if (!self.remoteAddress.length) { return nil; }
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
NEPacketTunnelNetworkSettings *networkSettings = [[NEPacketTunnelNetworkSettings alloc] initWithTunnelRemoteAddress:self.remoteAddress];
|
NEPacketTunnelNetworkSettings *networkSettings = [[NEPacketTunnelNetworkSettings alloc] initWithTunnelRemoteAddress:self.remoteAddress];
|
||||||
|
|
||||||
if (self.ipv4LocalAddresses.count && (self.ipv4LocalAddresses.count == self.ipv4SubnetMasks.count)) {
|
if (self.ipv4LocalAddresses.count && (self.ipv4LocalAddresses.count == self.ipv4SubnetMasks.count)) {
|
||||||
NEIPv4Settings *ipv4Settings = [[NEIPv4Settings alloc] initWithAddresses:self.ipv4LocalAddresses subnetMasks:self.ipv4SubnetMasks];
|
NEIPv4Settings *ipv4Settings = [[NEIPv4Settings alloc] initWithAddresses:self.ipv4LocalAddresses
|
||||||
|
subnetMasks:self.ipv4SubnetMasks];
|
||||||
|
|
||||||
ipv4Settings.includedRoutes = self.ipv4IncludedRoutes;
|
ipv4Settings.includedRoutes = self.ipv4IncludedRoutes;
|
||||||
ipv4Settings.excludedRoutes = self.ipv4ExcludedRoutes;
|
ipv4Settings.excludedRoutes = self.ipv4ExcludedRoutes;
|
||||||
|
|
||||||
networkSettings.IPv4Settings = ipv4Settings;
|
networkSettings.IPv4Settings = ipv4Settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.ipv6LocalAddresses.count && (self.ipv6LocalAddresses.count == self.ipv6NetworkPrefixLengths.count)) {
|
if (self.ipv6LocalAddresses.count && (self.ipv6LocalAddresses.count == self.ipv6NetworkPrefixLengths.count)) {
|
||||||
NEIPv6Settings *ipv6Settings = [[NEIPv6Settings alloc] initWithAddresses:self.ipv6LocalAddresses networkPrefixLengths:self.ipv6NetworkPrefixLengths];
|
NEIPv6Settings *ipv6Settings = [[NEIPv6Settings alloc] initWithAddresses:self.ipv6LocalAddresses
|
||||||
|
networkPrefixLengths:self.ipv6NetworkPrefixLengths];
|
||||||
|
|
||||||
ipv6Settings.includedRoutes = self.ipv6IncludedRoutes;
|
ipv6Settings.includedRoutes = self.ipv6IncludedRoutes;
|
||||||
ipv6Settings.excludedRoutes = self.ipv6ExcludedRoutes;
|
ipv6Settings.excludedRoutes = self.ipv6ExcludedRoutes;
|
||||||
|
|
||||||
networkSettings.IPv6Settings = ipv6Settings;
|
networkSettings.IPv6Settings = ipv6Settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,6 +65,7 @@
|
|||||||
|
|
||||||
if (self.autoProxyConfigurationEnabled || self.httpProxyServerEnabled || self.httpsProxyServerEnabled) {
|
if (self.autoProxyConfigurationEnabled || self.httpProxyServerEnabled || self.httpsProxyServerEnabled) {
|
||||||
NEProxySettings *proxySettings = [[NEProxySettings alloc] init];
|
NEProxySettings *proxySettings = [[NEProxySettings alloc] init];
|
||||||
|
|
||||||
proxySettings.autoProxyConfigurationEnabled = self.autoProxyConfigurationEnabled;
|
proxySettings.autoProxyConfigurationEnabled = self.autoProxyConfigurationEnabled;
|
||||||
proxySettings.proxyAutoConfigurationURL = self.proxyAutoConfigurationURL;
|
proxySettings.proxyAutoConfigurationURL = self.proxyAutoConfigurationURL;
|
||||||
proxySettings.exceptionList = self.proxyExceptionList;
|
proxySettings.exceptionList = self.proxyExceptionList;
|
||||||
@@ -62,6 +73,7 @@
|
|||||||
proxySettings.HTTPEnabled = self.httpProxyServerEnabled;
|
proxySettings.HTTPEnabled = self.httpProxyServerEnabled;
|
||||||
proxySettings.HTTPSServer = self.httpsProxyServer;
|
proxySettings.HTTPSServer = self.httpsProxyServer;
|
||||||
proxySettings.HTTPSEnabled = self.httpsProxyServerEnabled;
|
proxySettings.HTTPSEnabled = self.httpsProxyServerEnabled;
|
||||||
|
|
||||||
networkSettings.proxySettings = proxySettings;
|
networkSettings.proxySettings = proxySettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,79 +85,57 @@
|
|||||||
#pragma mark - Lazy Initializers
|
#pragma mark - Lazy Initializers
|
||||||
|
|
||||||
- (NSMutableArray<NSString *> *)ipv4LocalAddresses {
|
- (NSMutableArray<NSString *> *)ipv4LocalAddresses {
|
||||||
if (!_ipv4LocalAddresses) {
|
if (!_ipv4LocalAddresses) { _ipv4LocalAddresses = [[NSMutableArray alloc] init]; }
|
||||||
_ipv4LocalAddresses = [[NSMutableArray alloc] init];
|
|
||||||
}
|
|
||||||
return _ipv4LocalAddresses;
|
return _ipv4LocalAddresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMutableArray<NSString *> *)ipv4SubnetMasks {
|
- (NSMutableArray<NSString *> *)ipv4SubnetMasks {
|
||||||
if (!_ipv4SubnetMasks) {
|
if (!_ipv4SubnetMasks) { _ipv4SubnetMasks = [[NSMutableArray alloc] init]; }
|
||||||
_ipv4SubnetMasks = [[NSMutableArray alloc] init];
|
|
||||||
}
|
|
||||||
return _ipv4SubnetMasks;
|
return _ipv4SubnetMasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMutableArray<NEIPv4Route *> *)ipv4IncludedRoutes {
|
- (NSMutableArray<NEIPv4Route *> *)ipv4IncludedRoutes {
|
||||||
if (!_ipv4IncludedRoutes) {
|
if (!_ipv4IncludedRoutes) { _ipv4IncludedRoutes = [[NSMutableArray alloc] init]; }
|
||||||
_ipv4IncludedRoutes = [[NSMutableArray alloc] init];
|
|
||||||
}
|
|
||||||
return _ipv4IncludedRoutes;
|
return _ipv4IncludedRoutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMutableArray<NEIPv4Route *> *)ipv4ExcludedRoutes {
|
- (NSMutableArray<NEIPv4Route *> *)ipv4ExcludedRoutes {
|
||||||
if (!_ipv4ExcludedRoutes) {
|
if (!_ipv4ExcludedRoutes) { _ipv4ExcludedRoutes = [[NSMutableArray alloc] init]; }
|
||||||
_ipv4ExcludedRoutes = [[NSMutableArray alloc] init];
|
|
||||||
}
|
|
||||||
return _ipv4ExcludedRoutes;
|
return _ipv4ExcludedRoutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMutableArray<NSString *> *)ipv6LocalAddresses {
|
- (NSMutableArray<NSString *> *)ipv6LocalAddresses {
|
||||||
if (!_ipv6LocalAddresses) {
|
if (!_ipv6LocalAddresses) { _ipv6LocalAddresses = [[NSMutableArray alloc] init]; }
|
||||||
_ipv6LocalAddresses = [[NSMutableArray alloc] init];
|
|
||||||
}
|
|
||||||
return _ipv6LocalAddresses;
|
return _ipv6LocalAddresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMutableArray<NSNumber *> *)ipv6NetworkPrefixLengths {
|
- (NSMutableArray<NSNumber *> *)ipv6NetworkPrefixLengths {
|
||||||
if (!_ipv6NetworkPrefixLengths) {
|
if (!_ipv6NetworkPrefixLengths) { _ipv6NetworkPrefixLengths = [[NSMutableArray alloc] init]; }
|
||||||
_ipv6NetworkPrefixLengths = [[NSMutableArray alloc] init];
|
|
||||||
}
|
|
||||||
return _ipv6NetworkPrefixLengths;
|
return _ipv6NetworkPrefixLengths;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMutableArray<NEIPv6Route *> *)ipv6IncludedRoutes {
|
- (NSMutableArray<NEIPv6Route *> *)ipv6IncludedRoutes {
|
||||||
if (!_ipv6IncludedRoutes) {
|
if (!_ipv6IncludedRoutes) { _ipv6IncludedRoutes = [[NSMutableArray alloc] init]; }
|
||||||
_ipv6IncludedRoutes = [[NSMutableArray alloc] init];
|
|
||||||
}
|
|
||||||
return _ipv6IncludedRoutes;
|
return _ipv6IncludedRoutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMutableArray<NEIPv6Route *> *)ipv6ExcludedRoutes {
|
- (NSMutableArray<NEIPv6Route *> *)ipv6ExcludedRoutes {
|
||||||
if (!_ipv6ExcludedRoutes) {
|
if (!_ipv6ExcludedRoutes) { _ipv6ExcludedRoutes = [[NSMutableArray alloc] init]; }
|
||||||
_ipv6ExcludedRoutes = [[NSMutableArray alloc] init];
|
|
||||||
}
|
|
||||||
return _ipv6ExcludedRoutes;
|
return _ipv6ExcludedRoutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMutableArray<NSString *> *)dnsServers {
|
- (NSMutableArray<NSString *> *)dnsServers {
|
||||||
if (!_dnsServers) {
|
if (!_dnsServers) { _dnsServers = [[NSMutableArray alloc] init]; }
|
||||||
_dnsServers = [[NSMutableArray alloc] init];
|
|
||||||
}
|
|
||||||
return _dnsServers;
|
return _dnsServers;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMutableArray<NSString *> *)searchDomains {
|
- (NSMutableArray<NSString *> *)searchDomains {
|
||||||
if (!_searchDomains) {
|
if (!_searchDomains) { _searchDomains = [[NSMutableArray alloc] init]; }
|
||||||
_searchDomains = [[NSMutableArray alloc] init];
|
|
||||||
}
|
|
||||||
return _searchDomains;
|
return _searchDomains;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMutableArray<NSString *> *)proxyExceptionList {
|
- (NSMutableArray<NSString *> *)proxyExceptionList {
|
||||||
if (!_proxyExceptionList) {
|
if (!_proxyExceptionList) { _proxyExceptionList = [[NSMutableArray alloc] init]; }
|
||||||
_proxyExceptionList = [[NSMutableArray alloc] init];
|
|
||||||
}
|
|
||||||
return _proxyExceptionList;
|
return _proxyExceptionList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user