Flutter openvpn - A new Flutter plugin that uses OpenVpn

Overview

flutter_openvpn

A new Flutter plugin that uses OpenVpn.

Installation

  1. Depend on it Add this to your package's pubspec.yaml file:
dependencies:
  flutter_openvpn: ^0.2.0
  1. Install it You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

  1. Import it Now in your Dart code, you can use:
import 'package:flutter_openvpn/flutter_openvpn.dart';

Supported Platforms

  • 22 >= Android
  • 9.0 >= iOS

Build project first

  • After adding package to pubspec.yaml, Run build command
flutter build apk --debug //for android
flutter build ios --no-codesign //for ios

Ignore any build errors.

Android integration

  • Change minimum sdk to 22 :
  1. Open Your project in Android Studio.
  2. Open your MainActivity.java(or .kt for kotlin) file (Located in android/app/src/main/YOUR_PACKAGE_NAME/MainActivity)
  3. Override onActivityResult in your activity and add this code to function body
if (requestCode == 1) {
    if (resultCode == RESULT_OK) {
        FlutterOpenvpnPlugin.setPermission(true);
    } else {
        FlutterOpenvpnPlugin.setPermission(false);
    }
}
  1. Finally import FlutterOpenVpn with this import statement
import com.topfreelancerdeveloper.flutter_openvpn.FlutterOpenvpnPlugin;

iOS integration

  • Add VPN Entitlements
  1. Open ios/Runner.xcworkspace in xcode
  2. In Runner target -> Signing & Capabalities -> Click on "+ Capabality" button
  3. Add both "Network Extension" and "App Groups" capabalities
  4. Select ONLY "Packet Tunnel" form newly created Network Extension menu.
  5. Make sure your Bundle identifier is checked in App Groups.
  6. View This Screenshot for visual Guide
  • Add Network Extension Target
  1. Below Runner target click on "+" button to add new target
  2. Search for "Network Extension" in newly opened page and click on next
  3. Give it a name(Without space) and make sure to select Swift as Language and Packet Tunnel as Provider Type.
  4. Click on finish and agree to any message relating to "Activating Extension"
  5. Repeat "Add VPN Entitlements" for newly created target as well
  6. View This Screenshot for visual Guide
  • Change minimum platform target to iOS 9.0 :
  1. In Runner target -> Deployment Info -> change Target to iOS 9.0
  2. Repeat step 2 for your VPN Extension Target as well
  1. Open ios/PodFile
  2. Change your PodFile according to this:
	.
	.
	.
target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

//Add this part
target 'YOUR_TARGET_EXTENSION_NAME' do
  use_frameworks!
  use_modular_headers!
  pod 'OpenVPNAdapter', :git => 'https://github.com/ss-abramchuk/OpenVPNAdapter.git', :tag => '0.7.0'
end
	.
	.
	.
  1. Run 'pod install' command in /ios directory
  • Disable Bitcode
  1. In Vpn Extension Target -> Build Settings
  2. Search for "Bitcode" and set it to NO
  • Add code to PacketTunnelProvider
  1. Open VPNExtension folder/PacketTunnelProvider.swift in xcode.
  2. Replace all code with this and save

Dart/Flutter integration

  • Initilize plugin
FlutterOpenvpn.init(
          localizedDescription: "ExampleVPN", //this is required only on iOS
          providerBundleIdentifier: "com.topfreelancerdeveloper.flutterOpenvpnExample.RunnerExtension",//this is required only on iOS
	  //localizedDescription is the name of your VPN profile
	  //providerBundleIdentifier is the bundle id of your vpn extension
)
/* returns {"currentStatus" : "VPN_CURRENT_STATUS",
	   "expireAt" : "VPN_EXPIRE_DATE_STRING_IN_FORMAT(yyyy-MM-dd HH:mm:ss)",} if successful
 returns null if failed
*/

View this for more info on VPN status Strings

  • Add VPN Profile and connect
FlutterOpenvpn.lunchVpn(
          ovpnFileContent, //content of your .ovpn file
          (isProfileLoaded) => print('isProfileLoaded : $isProfileLoaded'),
          (newVpnStatus) => print('vpnActivated : $newVpnStatus'),
          expireAt: DateTime.now().add(Duration(seconds: 30)),
	  //(Optional) VPN automatically disconnects in next 30 seconds
         )

Publishing to Play Store and App Store

Android

. Recently I discovered an issue with plugin not working with appbundles . If you want to publish to play store use apks . view this issue to stay updated on the matter

iOS

. View Apple Guidelines Relating to VPN . This plugin DOES use Encryption BUT, It uses Exempt Encryptions

You might also like...
Metazoom - A virtual camera plugin to pixellatedly share your screen

MetaZoom A virtual camera plugin to pixellatedly share your screen. See LICENSE.

PerFolderResourcesPublishPlugin - Per-folder resources plugin for the Publish package

Per-folder resources for Publish A Publish plugin that copies per-folder resourc

Xcode plugin that moves the instruction pointer to the selected line
Xcode plugin that moves the instruction pointer to the selected line

SFJumpToLine Xcode plugin that moves the instruction pointer to the selected line. Install: Install via Alcatraz Or clone and build the project, then

Touch ID Plugin (Cordova) for iOS

cordova-plugin-gctouch-id Touch ID Plugin (Cordova) for iOS Author: Giulio Caruso aka rdn Index Description Technical Documentation Screenshots Adding

Xcode plugin that brings ⇧⌘T from AppCode over to Xcode

Aviator An Xcode Plugin that brings ⇧⌘T over to Xcode This minimal plugin allows you to use the key combo ⇧⌘T to toggle between source and test files.

An Xcode plugin for manually symbolicating crash logs
An Xcode plugin for manually symbolicating crash logs

CrashSymbal An Xcode plugin for manually symbolicating crash logs Install Build the project to install the plugin. The plugin gets installed in /Libra

Swift Package Manager command plugin for Swift-DocC

Swift-DocC Plugin The Swift-DocC plugin is a Swift Package Manager command plugin that supports building documentation for SwiftPM libraries and execu

XcodeColorSense - An Xcode plugin that makes working with color easier.
XcodeColorSense - An Xcode plugin that makes working with color easier.

XcodeColorSense An Xcode plugin that makes working with color easier. Inspired by ColorSense-for-Xcode with extra care for Hex color Features Show col

A Xcode plugin to add highlight to the instances of selected symbol.
A Xcode plugin to add highlight to the instances of selected symbol.

Auto Highlight Symbol About Xcode 8 Xcode 8 does't support plugins anymore, but there is a workaround, use at your own risk. Xcode can highlight insta

Owner
Ferdi Gökdemir
All in One Developer
Ferdi Gökdemir
Cordova-plugin-saveimage - This plugin helps you save images

cordova-plugin-saveimage This plugin helps you save images on iOS/Android Instal

Bernat 2 May 11, 2022
Inspired by HBO's Silicon Valley: SeeFood is an iOS app that uses CoreML to detect various dishes

SeeFood For a step by step guide on how to build SeeFood: How to train your own model for CoreML. . Video Demo Follw me on Twitter Prerequisites: Xcod

Reza Shirazian 448 Nov 17, 2022
Drop in GIF Collection View. Uses Tenor as default GIFs provider.

Drop in GIF Collection View. Uses Tenor as default GIFs provider. This will allow you to easily integrate GIF image search into your app or you can use this as a GIF keyboard for your messaging needs.

null 5 May 7, 2022
An app that uses Multipeer Connectivity to play a video across 6 different iOS screens with an additional phone acting as a Main/Control phone.

MultiScreenApp An app that uses Multipeer Connectivity to play a video across 6 different iOS screens with an additional phone acting as a Main/Contro

Vedant 113 Nov 21, 2022
FlickrSearchPhotos - Simple search photos application which uses Flickr REST API made in Swift

FlickrSearchPhotos - Simple search photos application which uses Flickr REST API made in Swift

 Mihai Erős 1 Jun 6, 2022
A VisionCamera Frame Processor plugin for fast buffer resizing

vision-camera-resize-plugin A VisionCamera Frame Processor Plugin for fast buffer resizing. By resizing buffers to a smaller resolution, you can achie

Marc Rousavy 16 Aug 10, 2022
This simple cordova plugin will download picture from an URL and save to IOS Photo Gallery.

Photo Viewer This plugin is intended to download a picture from an URL into IOS Photo library.. How to Install Cordova: cordova plugin add https://git

Alwin jose 1 Oct 23, 2021
Cordova plugin for detect screenshots and recordings

cordova-plugin-detect-screen-capture This plugin detects screen recording and screenshot events. The plugin will only work on devices with iOS >= 7 Su

Sasha 0 Nov 4, 2021
API surface for Swift plug-ins using the Swift Plugin Manager

SwiftPlugin The minimal API surface required for the Swift Plugin Manager to create instances from a loaded plugin. Additional documentation and refer

Joakim Hassila 2 Mar 25, 2022
Cordova plugin to display a native color-picker dialog

Color Picker Plugin for Cordova (cordova-plugin-color-picker) Description This plugin allows you to display a color-picker native dialog in iOS and An

Antonio Vargas 1 May 10, 2022