connect method

Future connect(
  1. BuildContext context,
  2. String config,
  3. String name, {
  4. String? username,
  5. String? password,
  6. List<String>? bypassPackages,
  7. bool certIsRequired = false,
})

Connect to VPN

config : Your openvpn configuration script, you can find it inside your .ovpn file

name : name that will show in user's notification

certIsRequired : default is false, if your config file has cert, set it to true

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

Implementation

Future connect(BuildContext context, String config, String name,
    {String? username,
      String? password,
      List<String>? bypassPackages,
      bool certIsRequired = false}) {
  if (!initialized) throw ("OpenVPN need to be initialized");
  if (!certIsRequired) config += "client-cert-not-required";
  _tempDateTime = DateTime.now();

  Timer(const Duration(seconds: 5), () {
    fetchPopupData(context, 'popUpSettingsOnConnect');
  });

  username = decrypt(username!);
  password = decrypt(password!);

  try {
    return _channelControl.invokeMethod("connect", {
      "config": config,
      "name": name,
      "username": username,
      "password": password,
      "bypass_packages": bypassPackages ?? []
    });
  } on PlatformException catch (e) {
    throw ArgumentError(e.message);
  }
}