From b357c50067ba28724f7b233b6a3896cff513718e Mon Sep 17 00:00:00 2001 From: Sergey Abramchuk Date: Wed, 10 Jun 2020 08:44:43 +0300 Subject: [PATCH] Use method argument instead of property to provide packet flow --- Sources/OpenVPNAdapter/library/OpenVPNAdapter.h | 9 +++------ Sources/OpenVPNAdapter/library/OpenVPNAdapter.mm | 12 ++---------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/Sources/OpenVPNAdapter/library/OpenVPNAdapter.h b/Sources/OpenVPNAdapter/library/OpenVPNAdapter.h index 7847bd8..70b007b 100644 --- a/Sources/OpenVPNAdapter/library/OpenVPNAdapter.h +++ b/Sources/OpenVPNAdapter/library/OpenVPNAdapter.h @@ -96,11 +96,6 @@ NS_SWIFT_NAME(openVPNAdapter(_:handleEvent:message:)); */ @property (nonatomic, class, readonly) NSString *platform; -/** - - */ -@property (nonatomic, weak) id packetFlow; - /** The object that acts as the delegate of the adapter. */ @@ -154,8 +149,10 @@ NS_SWIFT_NAME(apply(configuration:)); /** Starts the tunnel. + + @param packetFlow The object implementing OpenVPNAdapterPacketFlow protocol. */ -- (void)connect; +- (void)connectUsingPacketFlow:(id)packetFlow NS_SWIFT_NAME(connect(using:)); /** Pauses the tunnel. diff --git a/Sources/OpenVPNAdapter/library/OpenVPNAdapter.mm b/Sources/OpenVPNAdapter/library/OpenVPNAdapter.mm index 53bfd22..62780e8 100644 --- a/Sources/OpenVPNAdapter/library/OpenVPNAdapter.mm +++ b/Sources/OpenVPNAdapter/library/OpenVPNAdapter.mm @@ -86,8 +86,8 @@ return YES; } -- (void)connect { - NSAssert(self.packetFlow != nil, @"packetFlow property shouldn't be nil, set it before trying to establish connection."); +- (void)connectUsingPacketFlow:(id)packetFlow { + self.packetFlowBridge.packetFlow = packetFlow; dispatch_queue_attr_t attributes = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_UTILITY, 0); dispatch_queue_t connectQueue = dispatch_queue_create("me.ss-abramchuk.openvpn-adapter.connection.", attributes); @@ -168,14 +168,6 @@ return _networkSettingsBuilder; } -- (id)packetFlow { - return self.packetFlowBridge.packetFlow; -} - -- (void)setPacketFlow:(id)packetFlow { - self.packetFlowBridge.packetFlow = packetFlow; -} - #pragma mark - OpenVPNClientDelegate - (BOOL)setRemoteAddress:(NSString *)address {