패키지, 저장소 및 앱 카테고리 검색

패키지 상세v2.0.0

openvpn_flutter

Flutter에서 OpenVPN 서비스에 연결할 수 있도록 해주는 플러그인

AndroidiOS
30일 다운로드
1.3천
좋아요
134
Pub 점수
160

패키지 설치

flutter pub add openvpn_flutter

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

openvpn_flutter 패키지는 Flutter 애플리케이션에서 안드로이드 및 iOS 플랫폼에서 OpenVPN 서비스에 연결할 수 있도록 합니다. 사용자가 프로그래밍 방식으로 보안 네트워크 터널을 설정할 수 있도록 간단한 인터페이스를 제공합니다. 플러그인은 네이티브 OpenVPN 라이브러리를 통합하여 표준 OpenVPN 구성 및 .ovpn 파일과 호환되도록 합니다. 개인 네트워크 접근 또는 데이터 보호 강화와 같은 안전한 연결 기능을 앱에 추가하고자 하는 개발자를 위한 것입니다.

사용 사례

  • 안전한 앱에서 서버로의 통신
  • 기업 애플리케이션에서의 개인 네트워크 접근
  • 개선된 사용자 데이터 프라이버시
  • 지역 콘텐츠 제한 회피
  • 기업용 VPN 연결

주요 기능

  • Android 및 iOS 플랫폼을 지원합니다
  • 표준 .ovpn 구성 파일과의 통합
  • 프로그래머틱 연결 관리
  • 보안 터널 설정
  • 경량이며 통합이 쉬움

적합한 대상

  • 기업 모바일 애플리케이션
  • 안전한 네트워크 액세스가 필요한 앱
  • 개인정보 보호에 중점을 둔 도구를 개발하는 개발자
  • 원격 서버 연결이 필요한 애플리케이션
  • OpenVPN 인프라를 사용하는 프로젝트

고려 사항

  • 네이티브 OpenVPN 라이브러리 통합 필요
  • Android 및 iOS에서 추가 권한이 필요할 수 있습니다
  • 구성 파일 처리는 안전해야 합니다
  • OpenVPN 프로토콜만 사용 가능
  • 플랫폼별 설정이 필요할 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Connect to the OpenVPN service using Flutter. Contributions through issues and pull requests are highly appreciated!

Android Setup

1. Permission Handler
Java

Include the following code in the onActivityResult method of MainActivity.java (if you are using Java):

OpenVPNFlutterPlugin.connectWhileGranted(requestCode == 24 && resultCode == RESULT_OK);

The complete method should look like this:

...
import id.laskarmedia.openvpn_flutter.OpenVPNFlutterPlugin;
...

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    OpenVPNFlutterPlugin.connectWhileGranted(requestCode == 24 && resultCode == RESULT_OK);
    super.onActivityResult(requestCode, resultCode, data);
}
Kotlin

Include the following code in the onActivityResult method of MainActivity.kt (if you are using Kotlin):

OpenVPNFlutterPlugin.connectWhileGranted(requestCode == 24 && resultCode == RESULT_OK);

The complete method should look like this:

...
import id.laskarmedia.openvpn_flutter.OpenVPNFlutterPlugin
...
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    OpenVPNFlutterPlugin.connectWhileGranted(requestCode == 24 && resultCode == RESULT_OK)
    super.onActivityResult(requestCode, resultCode, data)
}
2. App Bundle Build Not Connecting

If you encounter issues with the app not connecting using the latest Flutter SDK, apply the following quick fix:

Ensure that you include the following attribute within the <application> tag in your AndroidManifest.xml file:

<application
    ...
    android:extractNativeLibs="true"
    ...>
</application>

iOS Setup

1. Add Capabilities

Add the App Groups and Network Extensions capabilities to the Runner's target. Refer to the image below for detailed instructions:

2. Add New Target

Click the + button on the bottom left, choose NETWORK EXTENSION, and follow the instructions in the image below:

Add the same capabilities to the VPNExtension as you did for the Runner's target:

3. Copy and Paste

Add the following lines to your Podfile (ios/Podfile):

target 'VPNExtension' do
  use_frameworks!
  pod 'OpenVPNAdapter', :git => 'https://github.com/ss-abramchuk/OpenVPNAdapter.git', :tag => '0.8.0'
end

Open VPNExtension > PacketTunnelProvider.swift and copy-paste the script from PacketTunnelProvider.swift.

Note

You must use iOS devices instead of the simulator to connect.

Recipe

Initialize

Before starting, initialize the OpenVPN plugin:

late OpenVPN openvpn;

@override
void initState() {
    openvpn = OpenVPN(onVpnStatusChanged: _onVpnStatusChanged, onVpnStageChanged: _onVpnStageChanged);
    openvpn.initialize(
        groupIdentifier: "GROUP_IDENTIFIER", ///Example 'group.com.laskarmedia.vpn'
        providerBundleIdentifier: "NETWORK_EXTENSION_IDENTIFIER", ///Example 'id.laskarmedia.openvpnFlutterExample.VPNExtension'
        localizedDescription: "LOCALIZED_DESCRIPTION" ///Example 'Laskarmedia VPN'
    );
}

void _onVpnStatusChanged(VPNStatus? vpnStatus){
    setState((){
        this.status = vpnStatus;
    });
}

void _onVpnStageChanged(VPNStage? stage){
    setState((){
        this.stage = stage;
    });
}
Connect to VPN
void connect() {
  openvpn.connect(
    config,
    name,
    username: username,
    password: password,
    bypassPackages: [],
    // In iOS connection can get stuck in "connecting" if this flag is "false". 
    // Solution is to switch it to "true".
    certIsRequired: false,
  );
}
Disconnect
void disconnect(){
    openvpn.disconnect();
}

Publishing to Play Store and App Store

Android
  1. You can use app bundles to publish the app.
  2. Add the following to your files in the android folder (special thanks to https://github.com/nizwar/openvpn_flutter/issues/10). Otherwise, the connection may not be established in some cases and will silently report "disconnected" when trying to connect. This is likely related to some symbols being stripped by Google Play.
gradle.properties > android.bundle.enableUncompressedNativeLibs=false
AndroidManifest > android:extractNativeLibs="true" in the application tag

Add the following inside the android tag in app/build.gradle:

android {
    ...
    //from here ======
    lintOptions {
        disable 'InvalidPackage'
        checkReleaseBuilds false
    }

    packagingOptions {
        jniLibs {
            useLegacyPackaging = true
        }
    }

    bundle {
        language {
            enableSplit = false
        }
        density {
            enableSplit = false
        }
        abi {
            enableSplit = false
        }
    }
    //to here
    ...
}
Notifications

As the plugin shows notifications for connection status and connection details, you must request permission using third-party packages.

Example using permission_handler:

///Put it anywhere you wish, like once you initialize the VPN or pre-connect to the server
Permission.notification.isGranted.then((_) {
  if (!_) Permission.notification.request();
});
iOS
  1. View Apple Guidelines relating to VPN.
  2. This plugin DOES use encryption, but it uses exempt encryptions.

Licenses

Support

If you appreciate my work, don't forget to give a thumbs up or support me with a cup of coffee.

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.