Git Product home page Git Product logo

nizvpn's Introduction

NizVPN

Flutter Android VPN based on OpenVPN Library.

Let's Code!

I made it so simple to connect to OpenVPN, everything is setup, all you need to do is do the layouting on this project (i don't recommanded you to create a new project).

Here, i'll show you how to deal with the "connection things"

Do this to Connect / Disconnect

Connect or Disconnect vpn with single line of code!

    ...
        _vpnStage = NizVpn.vpnDisconnected;
        _selectedVpn = VpnConfig(
            config: "OVPN CONFIG IS HERE", 
            name: "Japan", 
            username: "VPN Username", 
            password:"VPN Password"
        );
    ...

    ...
        if (_selectedVpn == null) return; //Stop right here if user not select a vpn
        if (_vpnStage == NizVpn.vpnDisconnected) {
            //Start if stage is disconnected
            NizVpn.startVpn(_selectedVpn);
        } else {
            //Stop if stage is "not" disconnected
            NizVpn.stopVpn();
        }
    ...

Listen to VPN Stage & Status

Don't forget to listen your vpn stage and status, you can simply show them with this.

    ...
        //Add listener to update vpnStage
        NizVpn.vpnStageSnapshot().listen((event) {
            setState(() {
                _vpnStage = event; //Look at stages detail below
            });
        });
    ... 
    ...
        //Add listener to update vpnStatus
        NizVpn.vpnStatusSnapshot().listen((event){
            setState((){ 
                _vpnStatus = event;
            });
        })
    ... 

VPN Stages

Let me be clearer, VPN Stage shows the connection indicator when connecting the VPN

static const String vpnConnected = "connected";
static const String vpnDisconnected = "disconnected";
static const String vpnWaitConnection = "wait_connection";
static const String vpnAuthenticating = "authenticating";
static const String vpnReconnect = "reconnect";
static const String vpnNoConnection = "no_connection";
static const String vpnConnecting = "connecting";
static const String vpnPrepare = "prepare";
static const String vpnDenied = "denied";

Note : To change notification's icon, you can go to vpnLib/main/res/drawable and replace ic_notification.png from there!

License

This project and the uses VPN library "ICS OpenVPN" both are under GPLv2 License.

nizvpn's People

Contributors

nizwar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.