Coder Social home page Coder Social logo

jianshangquan / flutter_v2ray Goto Github PK

View Code? Open in Web Editor NEW

This project forked from blueboy-tm/flutter_v2ray

0.0 0.0 0.0 113.68 MB

A plugin that allow you to making v2ray connection

License: MIT License

Ruby 2.51% Objective-C 0.04% Java 54.48% Dart 41.02% Swift 1.95%

flutter_v2ray's Introduction

flutter_v2ray

Open Source Love

Table of contents

Change logs

1.0.7

  • fix v2rayBroadCastReceiver null exception
  • fix #35: registerReceiver error
  • update libv2ray to 1.8.7
  • fix #43: Adding DNS servers to the VPN service

Features

  • Run V2Ray Proxy & VPN Mode
  • Get Server Delay
  • Parsing V2Ray sharing links and making changes to them

Supported Platforms

Platform Status Info
Android Done ✅ Xray 1.8.7
IOS Soon ❎ -
Desktop Done ✅ For purchase: t.me/blueboy_tm

Get started

Add dependency

You can use the command to add flutter_v2ray as a dependency with the latest stable version:

$ flutter pub add flutter_v2ray

Or you can manually add flutter_v2ray into the dependencies section in your pubspec.yaml:

dependencies:
  flutter_v2ray: ^replace-with-latest-version

Examples

URL Parser

import 'package:flutter_v2ray/flutter_v2ray.dart';

// v2ray share link like vmess://, vless://, ...
String link = "link_here";
V2RayURL parser = FlutterV2ray.parseFromURL(link);

// Remark of the v2ray
print(parser.remark);

// generate full v2ray configuration (json)
print(parser.getFullConfiguration());

Edit Configuration

// Change v2ray listening port
parser.inbound['port'] = 10890;
// Change v2ray listening host
parser.inbound['listen'] = '0.0.0.0';
// Change v2ray log level
parser.log['loglevel'] = 'info';
// Change v2ray dns
parser.dns = {
    "servers": ["1.1.1.1"]
};
// and ...

// generate configuration with new settings
parser.getFullConfiguration()

Making V2Ray connection

import 'package:flutter_v2ray/flutter_v2ray.dart';

final FlutterV2ray flutterV2ray = FlutterV2ray(
    onStatusChanged: (status) {
        // do something
    },
);

// You must initialize V2Ray before using it.
await flutterV2ray.initializeV2Ray();



// v2ray share link like vmess://, vless://, ...
String link = "link_here";
V2RayURL parser = FlutterV2ray.parseFromURL(link);


// Get Server Delay
print('${flutterV2ray.getServerDelay(config: parser.getFullConfiguration())}ms');

// Permission is not required if you using proxy only
if (await flutterV2ray.requestPermission()){
    flutterV2ray.startV2Ray(
        remark: parser.remark,
        // The use of parser.getFullConfiguration() is not mandatory,
        // and you can enter the desired V2Ray configuration in JSON format
        config: parser.getFullConfiguration(),
        blockedApps: null,
        bypassSubnets: null,
        proxyOnly: false,
    );
}

// Disconnect
flutterV2ray.stopV2Ray();

Bypass LAN Traffic

final List<String> subnets = [
    "0.0.0.0/5",
    "8.0.0.0/7",
    "11.0.0.0/8",
    "12.0.0.0/6",
    "16.0.0.0/4",
    "32.0.0.0/3",
    "64.0.0.0/2",
    "128.0.0.0/3",
    "160.0.0.0/5",
    "168.0.0.0/6",
    "172.0.0.0/12",
    "172.32.0.0/11",
    "172.64.0.0/10",
    "172.128.0.0/9",
    "173.0.0.0/8",
    "174.0.0.0/7",
    "176.0.0.0/4",
    "192.0.0.0/9",
    "192.128.0.0/11",
    "192.160.0.0/13",
    "192.169.0.0/16",
    "192.170.0.0/15",
    "192.172.0.0/14",
    "192.176.0.0/12",
    "192.192.0.0/10",
    "193.0.0.0/8",
    "194.0.0.0/7",
    "196.0.0.0/6",
    "200.0.0.0/5",
    "208.0.0.0/4",
    "240.0.0.0/4",
];

flutterV2ray.startV2Ray(
    remark: parser.remark,
    config: parser.getFullConfiguration(),
    blockedApps: null,
    bypassSubnets: subnets,
    proxyOnly: false,
);

Android configuration before publish to Google Play🚀

gradle.preperties

  • add this line
android.bundle.enableUncompressedNativeLibs = false

build.gradle (app)

  • Find the buildTypes block:
buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
               signingConfig signingConfigs.release
        }
    }
  • And replace it with the following configuration info:
splits {
        abi {
            enable true
            reset()
            //noinspection ChromeOsAbiSupport
            include "x86_64", "armeabi-v7a", "arm64-v8a"

            universalApk true
        }
    }

   buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
               signingConfig signingConfigs.release
               ndk {
                //noinspection ChromeOsAbiSupport
                abiFilters "x86_64", "armeabi-v7a", "arm64-v8a"
                debugSymbolLevel 'FULL'
            }
        }
    }

More examples

Credits

badvpn (tun2socks) Copyright (C) Ambroz Bizjak

All rights reserved.

Donation

If you liked this package, you can support me with one of the following links.

Buy me a coffee

Buy Me A Coffee

Cryptocurrency

  • BTC:
    • bc1qrtq0ygmxw7meak3ukvxn03za2j7t7s4uxuujct
  • Tron
    • TVQQdim3pxa4XoZyRRVHQ8GsY42rEgB4ow
  • USDT
    • TRC20
      • TVQQdim3pxa4XoZyRRVHQ8GsY42rEgB4ow
    • ERC20
      • 0xD5d931BB40F02Ed45172faebD805B3f0ba70Fe73
  • DogeCoin
    • DNFaHFzmUfeUB6NFgQX1sLn9q8kknTmKd8

flutter_v2ray's People

Contributors

blueboy-tm avatar h3mnz avatar abbasnazari-0 avatar neruxov avatar pishguy 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.