From 7a278dba69b29edb39be0553f3601e36d575650d Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sat, 23 May 2020 17:07:59 +0200 Subject: [PATCH] Fix nullability of partitioned route --- TunnelKit/Sources/Core/RoutingTableEntry.h | 2 +- TunnelKit/Sources/Core/RoutingTableEntry.m | 2 +- .../OpenVPN/AppExtension/OpenVPNTunnelProvider.swift | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/TunnelKit/Sources/Core/RoutingTableEntry.h b/TunnelKit/Sources/Core/RoutingTableEntry.h index 2a30754..8c6910f 100644 --- a/TunnelKit/Sources/Core/RoutingTableEntry.h +++ b/TunnelKit/Sources/Core/RoutingTableEntry.h @@ -41,7 +41,7 @@ NS_ASSUME_NONNULL_BEGIN - (BOOL)isDefault; - (BOOL)matchesDestination:(NSString *)destination; -- (NSArray *)partitioned; +- (nullable NSArray *)partitioned; @end diff --git a/TunnelKit/Sources/Core/RoutingTableEntry.m b/TunnelKit/Sources/Core/RoutingTableEntry.m index febe7e2..211889f 100644 --- a/TunnelKit/Sources/Core/RoutingTableEntry.m +++ b/TunnelKit/Sources/Core/RoutingTableEntry.m @@ -249,7 +249,7 @@ static NSString *RoutingTableEntryName(struct sockaddr *sa, struct sockaddr *mas } } -- (NSArray *)partitioned +- (nullable NSArray *)partitioned { NSMutableArray *segments = [[NSMutableArray alloc] init]; const int halfPrefix = (int)(self.prefix + 1); diff --git a/TunnelKit/Sources/Protocols/OpenVPN/AppExtension/OpenVPNTunnelProvider.swift b/TunnelKit/Sources/Protocols/OpenVPN/AppExtension/OpenVPNTunnelProvider.swift index 0c46660..43e6606 100644 --- a/TunnelKit/Sources/Protocols/OpenVPN/AppExtension/OpenVPNTunnelProvider.swift +++ b/TunnelKit/Sources/Protocols/OpenVPN/AppExtension/OpenVPNTunnelProvider.swift @@ -741,7 +741,7 @@ extension OpenVPNTunnelProvider: OpenVPNSessionDelegate { let gateway = table.defaultGateway4()?.gateway(), let route = table.broadestRoute4(matchingDestination: gateway) { - route.partitioned().forEach { + route.partitioned()?.forEach { let destination = $0.network() guard let netmask = $0.networkMask() else { return @@ -758,7 +758,7 @@ extension OpenVPNTunnelProvider: OpenVPNSessionDelegate { let gateway = table.defaultGateway6()?.gateway(), let route = table.broadestRoute6(matchingDestination: gateway) { - route.partitioned().forEach { + route.partitioned()?.forEach { let destination = $0.network() let prefix = $0.prefix()