From da23cfb9c11b90d2be447b70bc7ef89a842f98dc Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 28 Apr 2023 09:50:56 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BC=98=E5=8C=96]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Classes/SwiftOpenVPNFlutterPlugin.swift | 5 +---- lib/src/vpn_engine.dart | 9 ++++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/ios/Classes/SwiftOpenVPNFlutterPlugin.swift b/ios/Classes/SwiftOpenVPNFlutterPlugin.swift index 838e365..d5fdf57 100644 --- a/ios/Classes/SwiftOpenVPNFlutterPlugin.swift +++ b/ios/Classes/SwiftOpenVPNFlutterPlugin.swift @@ -250,10 +250,7 @@ class VPNUtils { } }) } else { - guard let err = error else { return } - if err.localizedDescription == "permission denied" { - completion(error); - } + completion(error); } }) } diff --git a/lib/src/vpn_engine.dart b/lib/src/vpn_engine.dart index b6fdb68..d2e29d8 100644 --- a/lib/src/vpn_engine.dart +++ b/lib/src/vpn_engine.dart @@ -121,17 +121,17 @@ class OpenVPN { ///username & password : set your username and password if your config file has auth-user-pass /// ///bypassPackages : exclude some apps to access/use the VPN Connection, it was List of applications package's name (Android Only) - Future connect(String config, String name, + Future connect(String config, String name, {String? username, String? password, List? bypassPackages, - bool certIsRequired = false}) async { + bool certIsRequired = false}) { if (!initialized) throw ("OpenVPN need to be initialized"); if (!certIsRequired) config += "client-cert-not-required"; _tempDateTime = DateTime.now(); try { - return await _channelControl.invokeMethod("connect", { + return _channelControl.invokeMethod("connect", { "config": config, "name": name, "username": username, @@ -139,8 +139,7 @@ class OpenVPN { "bypass_packages": bypassPackages ?? [] }); } on PlatformException catch (e) { - return e.message; - // throw FlutterError('${e.message}}'); + throw ArgumentError(e.message); } }