diff --git a/Sources/OpenVPNAdapter/library/OpenVPNAdapter.mm b/Sources/OpenVPNAdapter/library/OpenVPNAdapter.mm index 5064fb4..40cc860 100644 --- a/Sources/OpenVPNAdapter/library/OpenVPNAdapter.mm +++ b/Sources/OpenVPNAdapter/library/OpenVPNAdapter.mm @@ -319,7 +319,7 @@ void (^completionHandler)(id _Nullable) = ^(id flow) { __strong typeof(self) self = weakSelf; - if (flow) { + if (flow && (self.packetFlowBridge == nil || self.packetFlowBridge != flow)) { self.packetFlowBridge = [[OpenVPNPacketFlowBridge alloc] initWithPacketFlow:flow]; } @@ -403,7 +403,7 @@ } - (void)resetTun { - _packetFlowBridge = nil; + [_packetFlowBridge invalidateSocketsIfNeeded]; dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);