├── darwin
├── Assets
│ └── .gitkeep
├── .gitignore
└── wireguard_flutter.podspec
├── example
├── linux
│ ├── .gitignore
│ ├── main.cc
│ ├── flutter
│ │ ├── generated_plugin_registrant.cc
│ │ ├── generated_plugin_registrant.h
│ │ ├── generated_plugins.cmake
│ │ └── CMakeLists.txt
│ ├── my_application.h
│ ├── my_application.cc
│ └── CMakeLists.txt
├── ios
│ ├── Runner
│ │ ├── Runner-Bridging-Header.h
│ │ ├── Assets.xcassets
│ │ │ ├── LaunchImage.imageset
│ │ │ │ ├── LaunchImage.png
│ │ │ │ ├── LaunchImage@2x.png
│ │ │ │ ├── LaunchImage@3x.png
│ │ │ │ ├── README.md
│ │ │ │ └── Contents.json
│ │ │ └── AppIcon.appiconset
│ │ │ │ ├── Icon-App-20x20@1x.png
│ │ │ │ ├── Icon-App-20x20@2x.png
│ │ │ │ ├── Icon-App-20x20@3x.png
│ │ │ │ ├── Icon-App-29x29@1x.png
│ │ │ │ ├── Icon-App-29x29@2x.png
│ │ │ │ ├── Icon-App-29x29@3x.png
│ │ │ │ ├── Icon-App-40x40@1x.png
│ │ │ │ ├── Icon-App-40x40@2x.png
│ │ │ │ ├── Icon-App-40x40@3x.png
│ │ │ │ ├── Icon-App-60x60@2x.png
│ │ │ │ ├── Icon-App-60x60@3x.png
│ │ │ │ ├── Icon-App-76x76@1x.png
│ │ │ │ ├── Icon-App-76x76@2x.png
│ │ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ │ ├── Icon-App-83.5x83.5@2x.png
│ │ │ │ └── Contents.json
│ │ ├── AppDelegate.swift
│ │ ├── Runner.entitlements
│ │ ├── Base.lproj
│ │ │ ├── Main.storyboard
│ │ │ └── LaunchScreen.storyboard
│ │ └── Info.plist
│ ├── Flutter
│ │ ├── Debug.xcconfig
│ │ ├── Release.xcconfig
│ │ └── AppFrameworkInfo.plist
│ ├── Runner.xcodeproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata
│ │ │ │ ├── WorkspaceSettings.xcsettings
│ │ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ │ └── swiftpm
│ │ │ │ └── Package.resolved
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── WorkspaceSettings.xcsettings
│ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ └── swiftpm
│ │ │ └── Package.resolved
│ ├── WGExtension
│ │ ├── Info.plist
│ │ └── WGExtension.entitlements
│ ├── .gitignore
│ ├── Podfile.lock
│ └── Podfile
├── android
│ ├── gradle.properties
│ ├── app
│ │ ├── src
│ │ │ ├── main
│ │ │ │ ├── res
│ │ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── values
│ │ │ │ │ │ ├── strings.xml
│ │ │ │ │ │ └── styles.xml
│ │ │ │ │ ├── drawable
│ │ │ │ │ │ └── launch_background.xml
│ │ │ │ │ ├── drawable-v21
│ │ │ │ │ │ └── launch_background.xml
│ │ │ │ │ └── values-night
│ │ │ │ │ │ └── styles.xml
│ │ │ │ ├── kotlin
│ │ │ │ │ └── network
│ │ │ │ │ │ └── mysterium
│ │ │ │ │ │ └── wireguard_dart_example
│ │ │ │ │ │ └── MainActivity.kt
│ │ │ │ └── AndroidManifest.xml
│ │ │ ├── debug
│ │ │ │ └── AndroidManifest.xml
│ │ │ └── profile
│ │ │ │ └── AndroidManifest.xml
│ │ └── build.gradle
│ ├── gradle
│ │ └── wrapper
│ │ │ └── gradle-wrapper.properties
│ ├── .gitignore
│ ├── settings.gradle
│ └── build.gradle
├── macos
│ ├── Runner
│ │ ├── Configs
│ │ │ ├── Debug.xcconfig
│ │ │ ├── Release.xcconfig
│ │ │ ├── Warnings.xcconfig
│ │ │ └── AppInfo.xcconfig
│ │ ├── Assets.xcassets
│ │ │ └── AppIcon.appiconset
│ │ │ │ ├── app_icon_128.png
│ │ │ │ ├── app_icon_16.png
│ │ │ │ ├── app_icon_256.png
│ │ │ │ ├── app_icon_32.png
│ │ │ │ ├── app_icon_512.png
│ │ │ │ ├── app_icon_64.png
│ │ │ │ ├── app_icon_1024.png
│ │ │ │ └── Contents.json
│ │ ├── AppDelegate.swift
│ │ ├── MainFlutterWindow.swift
│ │ ├── Release.entitlements
│ │ ├── DebugProfile.entitlements
│ │ └── Info.plist
│ ├── .gitignore
│ ├── Flutter
│ │ ├── Flutter-Debug.xcconfig
│ │ ├── Flutter-Release.xcconfig
│ │ └── GeneratedPluginRegistrant.swift
│ ├── Runner.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ └── swiftpm
│ │ │ └── Package.resolved
│ ├── Runner.xcodeproj
│ │ ├── project.xcworkspace
│ │ │ └── xcshareddata
│ │ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ │ └── swiftpm
│ │ │ │ └── Package.resolved
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── WGExtension
│ │ ├── Info.plist
│ │ └── WGExtension.entitlements
│ ├── Podfile.lock
│ └── Podfile
├── windows
│ ├── runner
│ │ ├── resources
│ │ │ └── app_icon.ico
│ │ ├── resource.h
│ │ ├── utils.h
│ │ ├── runner.exe.manifest
│ │ ├── flutter_window.h
│ │ ├── main.cpp
│ │ ├── CMakeLists.txt
│ │ ├── utils.cpp
│ │ ├── flutter_window.cpp
│ │ ├── Runner.rc
│ │ ├── win32_window.h
│ │ └── win32_window.cpp
│ ├── .gitignore
│ ├── flutter
│ │ ├── generated_plugin_registrant.h
│ │ ├── generated_plugin_registrant.cc
│ │ ├── generated_plugins.cmake
│ │ └── CMakeLists.txt
│ └── CMakeLists.txt
├── README.md
├── .gitignore
├── analysis_options.yaml
├── pubspec.yaml
└── lib
│ └── main.dart
├── android
├── settings.gradle
├── .idea
│ ├── .gitignore
│ ├── kotlinc.xml
│ ├── migrations.xml
│ └── jarRepositories.xml
├── src
│ └── main
│ │ └── AndroidManifest.xml
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
├── build.gradle
├── gradlew.bat
├── .gitignore
└── gradlew
├── .idea
├── .gitignore
├── vcs.xml
├── libraries
│ ├── Flutter_Plugins.xml
│ └── Dart_SDK.xml
├── modules.xml
└── wireguard_dart.iml
├── .vscode
└── settings.json
├── windows
├── lib
│ ├── tunnel
│ │ ├── amd64
│ │ │ ├── tunnel.dll
│ │ │ ├── tunnel.exp
│ │ │ ├── tunnel.lib
│ │ │ └── tunnel.def
│ │ ├── arm64
│ │ │ ├── tunnel.dll
│ │ │ ├── tunnel.exp
│ │ │ ├── tunnel.lib
│ │ │ └── tunnel.def
│ │ └── include
│ │ │ └── tunnel.h
│ ├── wireguard
│ │ ├── amd64
│ │ │ ├── wireguard.dll
│ │ │ ├── wireguard.exp
│ │ │ ├── wireguard.lib
│ │ │ └── wireguard.def
│ │ └── arm64
│ │ │ ├── wireguard.dll
│ │ │ ├── wireguard.exp
│ │ │ ├── wireguard.lib
│ │ │ └── wireguard.def
│ └── wireguard_svc
│ │ └── amd64
│ │ └── wireguard_svc.exe
├── config_writer.h
├── .gitignore
├── external
│ └── CMakeLists.txt
├── wireguard_flutter_plugin_c_api.cpp
├── include
│ └── wireguard_flutter
│ │ └── wireguard_flutter_plugin_c_api.h
├── utils.h
├── service_control.h
├── config_writer.cpp
├── wireguard_flutter_plugin.h
├── utils.cpp
├── CMakeLists.txt
└── wireguard_flutter_plugin.cpp
├── analysis_options.yaml
├── CHANGELOG.md
├── CppProperties.json
├── .gitignore
├── pubspec.yaml
├── lib
├── wireguard_flutter_platform_interface.dart
├── wireguard_flutter.dart
├── wireguard_flutter_method_channel.dart
└── linux
│ └── wireguard_flutter_linux.dart
├── LICENSE
├── CONTRIBUTING.md
└── README.md
/darwin/Assets/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/example/linux/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral
2 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'wireguard_dart'
2 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/android/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/example/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
2 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "files.associations": {
3 | "iosfwd": "cpp"
4 | }
5 | }
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 |
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Debug.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Release.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/windows/lib/tunnel/amd64/tunnel.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/windows/lib/tunnel/amd64/tunnel.dll
--------------------------------------------------------------------------------
/windows/lib/tunnel/amd64/tunnel.exp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/windows/lib/tunnel/amd64/tunnel.exp
--------------------------------------------------------------------------------
/windows/lib/tunnel/amd64/tunnel.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/windows/lib/tunnel/amd64/tunnel.lib
--------------------------------------------------------------------------------
/windows/lib/tunnel/arm64/tunnel.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/windows/lib/tunnel/arm64/tunnel.dll
--------------------------------------------------------------------------------
/windows/lib/tunnel/arm64/tunnel.exp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/windows/lib/tunnel/arm64/tunnel.exp
--------------------------------------------------------------------------------
/windows/lib/tunnel/arm64/tunnel.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/windows/lib/tunnel/arm64/tunnel.lib
--------------------------------------------------------------------------------
/example/macos/.gitignore:
--------------------------------------------------------------------------------
1 | # Flutter-related
2 | **/Flutter/ephemeral/
3 | **/Pods/
4 |
5 | # Xcode-related
6 | **/dgph
7 | **/xcuserdata/
8 |
--------------------------------------------------------------------------------
/windows/lib/wireguard/amd64/wireguard.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/windows/lib/wireguard/amd64/wireguard.dll
--------------------------------------------------------------------------------
/windows/lib/wireguard/amd64/wireguard.exp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/windows/lib/wireguard/amd64/wireguard.exp
--------------------------------------------------------------------------------
/windows/lib/wireguard/amd64/wireguard.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/windows/lib/wireguard/amd64/wireguard.lib
--------------------------------------------------------------------------------
/windows/lib/wireguard/arm64/wireguard.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/windows/lib/wireguard/arm64/wireguard.dll
--------------------------------------------------------------------------------
/windows/lib/wireguard/arm64/wireguard.exp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/windows/lib/wireguard/arm64/wireguard.exp
--------------------------------------------------------------------------------
/windows/lib/wireguard/arm64/wireguard.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/windows/lib/wireguard/arm64/wireguard.lib
--------------------------------------------------------------------------------
/example/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/windows/runner/resources/app_icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/windows/runner/resources/app_icon.ico
--------------------------------------------------------------------------------
/windows/lib/tunnel/amd64/tunnel.def:
--------------------------------------------------------------------------------
1 | LIBRARY TUNNEL
2 | EXPORTS
3 | WireGuardGenerateKeypair
4 | WireGuardTunnelService
5 | _cgo_dummy_export
6 |
--------------------------------------------------------------------------------
/windows/lib/tunnel/arm64/tunnel.def:
--------------------------------------------------------------------------------
1 | LIBRARY TUNNEL
2 | EXPORTS
3 | WireGuardGenerateKeypair
4 | WireGuardTunnelService
5 | _cgo_dummy_export
6 |
--------------------------------------------------------------------------------
/windows/lib/wireguard_svc/amd64/wireguard_svc.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/windows/lib/wireguard_svc/amd64/wireguard_svc.exe
--------------------------------------------------------------------------------
/windows/config_writer.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | namespace wireguard_flutter
4 | {
5 |
6 | std::wstring WriteConfigToTempFile(std::string config);
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/example/macos/Flutter/Flutter-Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "ephemeral/Flutter-Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/macos/Flutter/Flutter-Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "ephemeral/Flutter-Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | include: package:flutter_lints/flutter.yaml
2 |
3 | # Additional information about this file can be found at
4 | # https://dart.dev/guides/language/analysis-options
5 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Caqil/wireguard_flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/android/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/example/linux/main.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 |
3 | int main(int argc, char** argv) {
4 | g_autoptr(MyApplication) app = my_application_new();
5 | return g_application_run(G_APPLICATION(app), argc, argv);
6 | }
7 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/app/src/main/kotlin/network/mysterium/wireguard_dart_example/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package billion.group.wireguard_flutter_example
2 |
3 | import io.flutter.embedding.android.FlutterActivity
4 |
5 | class MainActivity: FlutterActivity() {
6 | }
7 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/example/linux/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 |
10 | void fl_register_plugins(FlPluginRegistry* registry) {
11 | }
12 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 0.1.0
2 |
3 | * Fixed android connection state.
4 |
5 | ## 0.0.9
6 |
7 | * Remove unused code.
8 |
9 | ## 0.0.7
10 |
11 | * Remove unused permission.
12 |
13 | ## 0.0.4
14 |
15 | * Add example.
16 |
17 | ## 0.0.3
18 |
19 | * Initial Open Source release.
20 |
--------------------------------------------------------------------------------
/.idea/libraries/Flutter_Plugins.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/macos/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | @NSApplicationMain
5 | class AppDelegate: FlutterAppDelegate {
6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
7 | return true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jun 07 13:06:09 CEST 2023
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android/.idea/migrations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | control WireGuard tunnels, enabling and disabling tunnels at will, potentially misdirecting Internet traffic
4 | control WireGuard tunnels
5 |
--------------------------------------------------------------------------------
/example/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
9 | # Remember to never publicly share your keystore.
10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11 | key.properties
12 | **/*.keystore
13 | **/*.jks
14 |
--------------------------------------------------------------------------------
/windows/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/
2 |
3 | # Visual Studio user-specific files.
4 | *.suo
5 | *.user
6 | *.userosscache
7 | *.sln.docstates
8 |
9 | # Visual Studio build-related files.
10 | x64/
11 | x86/
12 |
13 | # Visual Studio cache files
14 | # files ending in .cache can be ignored
15 | *.[Cc]ache
16 | # but keep track of directories ending in .cache
17 | !*.[Cc]ache/
18 |
--------------------------------------------------------------------------------
/example/windows/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral/
2 |
3 | # Visual Studio user-specific files.
4 | *.suo
5 | *.user
6 | *.userosscache
7 | *.sln.docstates
8 |
9 | # Visual Studio build-related files.
10 | x64/
11 | x86/
12 |
13 | # Visual Studio cache files
14 | # files ending in .cache can be ignored
15 | *.[Cc]ache
16 | # but keep track of directories ending in .cache
17 | !*.[Cc]ache/
18 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/example/linux/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void fl_register_plugins(FlPluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/example/windows/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void RegisterPlugins(flutter::PluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/windows/external/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.14)
2 |
3 | include(FetchContent)
4 |
5 | FetchContent_Declare(
6 | base64
7 | GIT_REPOSITORY https://github.com/aklomp/base64
8 | GIT_TAG v0.5.0
9 | )
10 |
11 | FetchContent_GetProperties(base64)
12 | if(NOT base64_POPULATED)
13 | FetchContent_Populate(base64)
14 | add_subdirectory(${base64_SOURCE_DIR} ${base64_BINARY_DIR} EXCLUDE_FROM_ALL)
15 | endif()
--------------------------------------------------------------------------------
/windows/lib/wireguard/amd64/wireguard.def:
--------------------------------------------------------------------------------
1 | LIBRARY WIREGUARD
2 | EXPORTS
3 | WireGuardCloseAdapter
4 | WireGuardCreateAdapter
5 | WireGuardDeleteDriver
6 | WireGuardGetAdapterLUID
7 | WireGuardGetAdapterState
8 | WireGuardGetConfiguration
9 | WireGuardGetRunningDriverVersion
10 | WireGuardOpenAdapter
11 | WireGuardSetAdapterLogging
12 | WireGuardSetAdapterState
13 | WireGuardSetConfiguration
14 | WireGuardSetLogger
15 |
--------------------------------------------------------------------------------
/windows/lib/wireguard/arm64/wireguard.def:
--------------------------------------------------------------------------------
1 | LIBRARY WIREGUARD
2 | EXPORTS
3 | WireGuardCloseAdapter
4 | WireGuardCreateAdapter
5 | WireGuardDeleteDriver
6 | WireGuardGetAdapterLUID
7 | WireGuardGetAdapterState
8 | WireGuardGetConfiguration
9 | WireGuardGetRunningDriverVersion
10 | WireGuardOpenAdapter
11 | WireGuardSetAdapterLogging
12 | WireGuardSetAdapterState
13 | WireGuardSetConfiguration
14 | WireGuardSetLogger
15 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolved:
--------------------------------------------------------------------------------
1 | {
2 | "pins" : [
3 | {
4 | "identity" : "wireguard-apple",
5 | "kind" : "remoteSourceControl",
6 | "location" : "https://github.com/passepartoutvpn/wireguard-apple",
7 | "state" : {
8 | "revision" : "73d9152fa0cb661db0348a1ac11dbbf998422a50",
9 | "version" : "1.0.17"
10 | }
11 | }
12 | ],
13 | "version" : 2
14 | }
15 |
--------------------------------------------------------------------------------
/example/windows/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 | #include
10 |
11 | void RegisterPlugins(flutter::PluginRegistry* registry) {
12 | WireguardFlutterPluginCApiRegisterWithRegistrar(
13 | registry->GetRegistrarForPlugin("WireguardFlutterPluginCApi"));
14 | }
15 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved:
--------------------------------------------------------------------------------
1 | {
2 | "pins" : [
3 | {
4 | "identity" : "wireguard-apple",
5 | "kind" : "remoteSourceControl",
6 | "location" : "https://github.com/passepartoutvpn/wireguard-apple",
7 | "state" : {
8 | "revision" : "73d9152fa0cb661db0348a1ac11dbbf998422a50",
9 | "version" : "1.0.17"
10 | }
11 | }
12 | ],
13 | "version" : 2
14 | }
15 |
--------------------------------------------------------------------------------
/CppProperties.json:
--------------------------------------------------------------------------------
1 | {
2 | "configurations": [
3 | {
4 | "inheritEnvironments": [
5 | "msvc_x86"
6 | ],
7 | "name": "x86-Debug",
8 | "includePath": [
9 | "${env.INCLUDE}",
10 | "${workspaceRoot}\\**"
11 | ],
12 | "defines": [
13 | "WIN32",
14 | "_DEBUG",
15 | "UNICODE",
16 | "_UNICODE"
17 | ],
18 | "intelliSenseMode": "windows-msvc-x86"
19 | }
20 | ]
21 | }
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import Flutter
3 |
4 | @UIApplicationMain
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | GeneratedPluginRegistrant.register(with: self)
11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/example/macos/Runner/MainFlutterWindow.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | class MainFlutterWindow: NSWindow {
5 | override func awakeFromNib() {
6 | let flutterViewController = FlutterViewController()
7 | let windowFrame = self.frame
8 | self.contentViewController = flutterViewController
9 | self.setFrame(windowFrame, display: true)
10 |
11 | RegisterGeneratedPlugins(registry: flutterViewController)
12 |
13 | super.awakeFromNib()
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/example/linux/my_application.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_MY_APPLICATION_H_
2 | #define FLUTTER_MY_APPLICATION_H_
3 |
4 | #include
5 |
6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
7 | GtkApplication)
8 |
9 | /**
10 | * my_application_new:
11 | *
12 | * Creates a new Flutter-based application.
13 | *
14 | * Returns: a new #MyApplication.
15 | */
16 | MyApplication* my_application_new();
17 |
18 | #endif // FLUTTER_MY_APPLICATION_H_
19 |
--------------------------------------------------------------------------------
/example/macos/Flutter/GeneratedPluginRegistrant.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | import FlutterMacOS
6 | import Foundation
7 |
8 | import path_provider_foundation
9 | import wireguard_flutter
10 |
11 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
12 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
13 | WireguardFlutterPlugin.register(with: registry.registrar(forPlugin: "WireguardFlutterPlugin"))
14 | }
15 |
--------------------------------------------------------------------------------
/example/ios/WGExtension/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSExtension
6 |
7 | NSExtensionPointIdentifier
8 | com.apple.networkextension.packet-tunnel
9 | NSExtensionPrincipalClass
10 | $(PRODUCT_MODULE_NAME).PacketTunnelProvider
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/example/macos/WGExtension/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSExtension
6 |
7 | NSExtensionPointIdentifier
8 | com.apple.networkextension.packet-tunnel
9 | NSExtensionPrincipalClass
10 | $(PRODUCT_MODULE_NAME).PacketTunnelProvider
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/example/ios/WGExtension/WGExtension.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.developer.networking.networkextension
6 |
7 | packet-tunnel-provider
8 |
9 | com.apple.security.application-groups
10 |
11 | group.com.billion.wireguardvpn
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/example/windows/runner/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by Runner.rc
4 | //
5 | #define IDI_APP_ICON 101
6 |
7 | // Next default values for new objects
8 | //
9 | #ifdef APSTUDIO_INVOKED
10 | #ifndef APSTUDIO_READONLY_SYMBOLS
11 | #define _APS_NEXT_RESOURCE_VALUE 102
12 | #define _APS_NEXT_COMMAND_VALUE 40001
13 | #define _APS_NEXT_CONTROL_VALUE 1001
14 | #define _APS_NEXT_SYMED_VALUE 101
15 | #endif
16 | #endif
17 |
--------------------------------------------------------------------------------
/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4 | def properties = new Properties()
5 |
6 | assert localPropertiesFile.exists()
7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
8 |
9 | def flutterSdkPath = properties.getProperty("flutter.sdk")
10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
12 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/windows/wireguard_flutter_plugin_c_api.cpp:
--------------------------------------------------------------------------------
1 | #include "include/wireguard_flutter/wireguard_flutter_plugin_c_api.h"
2 |
3 | #include
4 |
5 | #include "wireguard_flutter_plugin.h"
6 |
7 | void WireguardFlutterPluginCApiRegisterWithRegistrar(
8 | FlutterDesktopPluginRegistrarRef registrar) {
9 | wireguard_flutter::WireguardFlutterPlugin::RegisterWithRegistrar(
10 | flutter::PluginRegistrarManager::GetInstance()
11 | ->GetRegistrar(registrar));
12 | }
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable-v21/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/example/ios/Runner/Runner.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | aps-environment
6 | development
7 | com.apple.developer.networking.networkextension
8 |
9 | packet-tunnel-provider
10 |
11 | com.apple.security.application-groups
12 |
13 | group.com.billion.wireguardvpn
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/darwin/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .vagrant/
3 | .sconsign.dblite
4 | .svn/
5 |
6 | .DS_Store
7 | *.swp
8 | profile
9 |
10 | DerivedData/
11 | build/
12 | GeneratedPluginRegistrant.h
13 | GeneratedPluginRegistrant.m
14 |
15 | .generated/
16 |
17 | *.pbxuser
18 | *.mode1v3
19 | *.mode2v3
20 | *.perspectivev3
21 |
22 | !default.pbxuser
23 | !default.mode1v3
24 | !default.mode2v3
25 | !default.perspectivev3
26 |
27 | xcuserdata
28 |
29 | *.moved-aside
30 |
31 | *.pyc
32 | *sync/
33 | Icon?
34 | .tags*
35 |
36 | /Flutter/Generated.xcconfig
37 | /Flutter/ephemeral/
38 | /Flutter/flutter_export_environment.sh
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/Warnings.xcconfig:
--------------------------------------------------------------------------------
1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
2 | GCC_WARN_UNDECLARED_SELECTOR = YES
3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
6 | CLANG_WARN_PRAGMA_PACK = YES
7 | CLANG_WARN_STRICT_PROTOTYPES = YES
8 | CLANG_WARN_COMMA = YES
9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES
10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
12 | GCC_WARN_SHADOW = YES
13 | CLANG_WARN_UNREACHABLE_CODE = YES
14 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | # wireguard_flutter_example
2 |
3 | Demonstrates how to use the wireguard_flutter plugin.
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter application.
8 |
9 | A few resources to get you started if this is your first Flutter project:
10 |
11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
13 |
14 | For help getting started with Flutter development, view the
15 | [online documentation](https://docs.flutter.dev/), which offers tutorials,
16 | samples, guidance on mobile development, and a full API reference.
17 |
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/AppInfo.xcconfig:
--------------------------------------------------------------------------------
1 | // Application-level settings for the Runner target.
2 | //
3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the
4 | // future. If not, the values below would default to using the project name when this becomes a
5 | // 'flutter create' template.
6 |
7 | // The application's name. By default this is also the title of the Flutter window.
8 | PRODUCT_NAME = example_flutter
9 |
10 | // The application's bundle identifier
11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.exampleFlutter
12 |
13 | // The copyright displayed in application information
14 | PRODUCT_COPYRIGHT = Copyright © 2023 com.example. All rights reserved.
15 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://www.dartlang.org/guides/libraries/private-files
2 |
3 | # Files and directories created by pub
4 | .dart_tool/
5 | .packages
6 | build/
7 | # If you're building an application, you may want to check-in your pubspec.lock
8 | pubspec.lock
9 | # Directory created by dartdoc
10 | # If you don't generate documentation locally you can remove this line.
11 | doc/api/
12 | # Avoid committing generated Javascript files:
13 | *.dart.js
14 | *.info.json # Produced by the --dump-info flag.
15 | *.js # When generated by dart2js. Don't specify *.js if your
16 | # project includes source files written in JavaScript.
17 | *.js_
18 | *.js.deps
19 | *.js.map
20 |
21 | .DS_Store
22 |
--------------------------------------------------------------------------------
/example/ios/.gitignore:
--------------------------------------------------------------------------------
1 | **/dgph
2 | *.mode1v3
3 | *.mode2v3
4 | *.moved-aside
5 | *.pbxuser
6 | *.perspectivev3
7 | **/*sync/
8 | .sconsign.dblite
9 | .tags*
10 | **/.vagrant/
11 | **/DerivedData/
12 | Icon?
13 | **/Pods/
14 | **/.symlinks/
15 | profile
16 | xcuserdata
17 | **/.generated/
18 | Flutter/App.framework
19 | Flutter/Flutter.framework
20 | Flutter/Flutter.podspec
21 | Flutter/Generated.xcconfig
22 | Flutter/ephemeral/
23 | Flutter/app.flx
24 | Flutter/app.zip
25 | Flutter/flutter_assets/
26 | Flutter/flutter_export_environment.sh
27 | ServiceDefinitions.json
28 | Runner/GeneratedPluginRegistrant.*
29 |
30 | # Exceptions to above rules.
31 | !default.mode1v3
32 | !default.mode2v3
33 | !default.pbxuser
34 | !default.perspectivev3
35 |
--------------------------------------------------------------------------------
/example/macos/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - FlutterMacOS (1.0.0)
3 | - wireguard_flutter (0.0.1):
4 | - Flutter
5 | - FlutterMacOS
6 |
7 | DEPENDENCIES:
8 | - FlutterMacOS (from `Flutter/ephemeral`)
9 | - wireguard_flutter (from `Flutter/ephemeral/.symlinks/plugins/wireguard_flutter/darwin`)
10 |
11 | EXTERNAL SOURCES:
12 | FlutterMacOS:
13 | :path: Flutter/ephemeral
14 | wireguard_flutter:
15 | :path: Flutter/ephemeral/.symlinks/plugins/wireguard_flutter/darwin
16 |
17 | SPEC CHECKSUMS:
18 | FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
19 | wireguard_flutter: 1e75469eaf86ae553566b6847bce070e3b3c315b
20 |
21 | PODFILE CHECKSUM: a78e73d4f3e93deb971b05a14aaf288280563573
22 |
23 | COCOAPODS: 1.13.0
24 |
--------------------------------------------------------------------------------
/windows/include/wireguard_flutter/wireguard_flutter_plugin_c_api.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_PLUGIN_WIREGUARD_FLUTTER_PLUGIN_C_API_H_
2 | #define FLUTTER_PLUGIN_WIREGUARD_FLUTTER_PLUGIN_C_API_H_
3 |
4 | #include
5 |
6 | #ifdef FLUTTER_PLUGIN_IMPL
7 | #define FLUTTER_PLUGIN_EXPORT __declspec(dllexport)
8 | #else
9 | #define FLUTTER_PLUGIN_EXPORT __declspec(dllimport)
10 | #endif
11 |
12 | #if defined(__cplusplus)
13 | extern "C" {
14 | #endif
15 |
16 | FLUTTER_PLUGIN_EXPORT void WireguardFlutterPluginCApiRegisterWithRegistrar(
17 | FlutterDesktopPluginRegistrarRef registrar);
18 |
19 | #if defined(__cplusplus)
20 | } // extern "C"
21 | #endif
22 |
23 | #endif // FLUTTER_PLUGIN_WIREGUARD_FLUTTER_PLUGIN_C_API_H_
24 |
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.8.10'
3 | repositories {
4 | google()
5 | mavenCentral()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:7.4.2'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | mavenCentral()
18 | }
19 | }
20 |
21 | rootProject.buildDir = '../build'
22 | subprojects {
23 | project.buildDir = "${rootProject.buildDir}/${project.name}"
24 | }
25 | subprojects {
26 | project.evaluationDependsOn(':app')
27 | }
28 |
29 | tasks.register("clean", Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/example/windows/runner/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_UTILS_H_
2 | #define RUNNER_UTILS_H_
3 |
4 | #include
5 | #include
6 |
7 | // Creates a console for the process, and redirects stdout and stderr to
8 | // it for both the runner and the Flutter library.
9 | void CreateAndAttachConsole();
10 |
11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
12 | // encoded in UTF-8. Returns an empty std::string on failure.
13 | std::string Utf8FromUtf16(const wchar_t* utf16_string);
14 |
15 | // Gets the command line arguments passed in as a std::vector,
16 | // encoded in UTF-8. Returns an empty std::vector on failure.
17 | std::vector GetCommandLineArguments();
18 |
19 | #endif // RUNNER_UTILS_H_
20 |
--------------------------------------------------------------------------------
/example/macos/Runner/Release.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.developer.networking.networkextension
6 |
7 | app-proxy-provider
8 | content-filter-provider
9 | packet-tunnel-provider
10 |
11 | com.apple.security.app-sandbox
12 |
13 | com.apple.security.application-groups
14 |
15 | $(TeamIdentifierPrefix)
16 |
17 | com.apple.security.network.client
18 |
19 | com.apple.security.network.server
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/example/macos/WGExtension/WGExtension.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.developer.networking.networkextension
6 |
7 | packet-tunnel-provider
8 | app-proxy-provider
9 | content-filter-provider
10 |
11 | com.apple.security.app-sandbox
12 |
13 | com.apple.security.application-groups
14 |
15 | $(TeamIdentifierPrefix)
16 |
17 | com.apple.security.network.client
18 |
19 | com.apple.security.network.server
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/windows/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef WIREGUARD_FLUTTER_UTILS_H
2 | #define WIREGUARD_FLUTTER_UTILS_H
3 |
4 | #include
5 | #include
6 |
7 | #include
8 | #include
9 |
10 | namespace wireguard_flutter {
11 |
12 | const flutter::EncodableValue *ValueOrNull(const flutter::EncodableMap &map, const char *key);
13 |
14 | std::string ErrorWithCode(const char *msg, unsigned long error_code);
15 |
16 | std::string WideToUtf8(const std::wstring &wstr);
17 |
18 | std::wstring Utf8ToWide(const std::string &str);
19 |
20 | std::string WideToAnsi(const std::wstring &wstr);
21 |
22 | std::wstring AnsiToWide(const std::string &str);
23 |
24 | // Pops a message box (useful for debugging native code)
25 | void DebugMessageBox(const char* msg);
26 |
27 | } // namespace wireguard_flutter
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/example/macos/Runner/DebugProfile.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.developer.networking.networkextension
6 |
7 | app-proxy-provider
8 | content-filter-provider
9 | packet-tunnel-provider
10 |
11 | com.apple.security.app-sandbox
12 |
13 | com.apple.security.application-groups
14 |
15 | $(TeamIdentifierPrefix)
16 |
17 | com.apple.security.cs.allow-jit
18 |
19 | com.apple.security.network.client
20 |
21 | com.apple.security.network.server
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/example/linux/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | )
7 |
8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
9 | )
10 |
11 | set(PLUGIN_BUNDLED_LIBRARIES)
12 |
13 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
18 | endforeach(plugin)
19 |
20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
23 | endforeach(ffi_plugin)
24 |
--------------------------------------------------------------------------------
/example/windows/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | wireguard_flutter
7 | )
8 |
9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
10 | )
11 |
12 | set(PLUGIN_BUNDLED_LIBRARIES)
13 |
14 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
19 | endforeach(plugin)
20 |
21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
24 | endforeach(ffi_plugin)
25 |
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 | migrate_working_dir/
12 |
13 | # IntelliJ related
14 | *.iml
15 | *.ipr
16 | *.iws
17 | .idea/
18 |
19 | # The .vscode folder contains launch configuration and tasks you configure in
20 | # VS Code which you may wish to be included in version control, so this line
21 | # is commented out by default.
22 | #.vscode/
23 |
24 | # Flutter/Dart/Pub related
25 | **/doc/api/
26 | **/ios/Flutter/.last_build_id
27 | .dart_tool/
28 | .flutter-plugins
29 | .flutter-plugins-dependencies
30 | .packages
31 | .pub-cache/
32 | .pub/
33 | /build/
34 |
35 | # Symbolication related
36 | app.*.symbols
37 |
38 | # Obfuscation related
39 | app.*.map.json
40 |
41 | # Android Studio will place build artifacts here
42 | /android/app/debug
43 | /android/app/profile
44 | /android/app/release
45 |
--------------------------------------------------------------------------------
/example/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 12.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/.idea/wireguard_dart.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/example/windows/runner/runner.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PerMonitorV2
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/example/ios/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Flutter (1.0.0)
3 | - path_provider_foundation (0.0.1):
4 | - Flutter
5 | - FlutterMacOS
6 | - wireguard_flutter (0.0.1):
7 | - Flutter
8 | - FlutterMacOS
9 |
10 | DEPENDENCIES:
11 | - Flutter (from `Flutter`)
12 | - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
13 | - wireguard_flutter (from `.symlinks/plugins/wireguard_flutter/darwin`)
14 |
15 | EXTERNAL SOURCES:
16 | Flutter:
17 | :path: Flutter
18 | path_provider_foundation:
19 | :path: ".symlinks/plugins/path_provider_foundation/darwin"
20 | wireguard_flutter:
21 | :path: ".symlinks/plugins/wireguard_flutter/darwin"
22 |
23 | SPEC CHECKSUMS:
24 | Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
25 | path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
26 | wireguard_flutter: 1e75469eaf86ae553566b6847bce070e3b3c315b
27 |
28 | PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011
29 |
30 | COCOAPODS: 1.15.2
31 |
--------------------------------------------------------------------------------
/darwin/wireguard_flutter.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
3 | # Run `pod lib lint wireguard_flutter.podspec` to validate before publishing.
4 | #
5 | Pod::Spec.new do |s|
6 | s.name = "wireguard_flutter"
7 | s.version = "0.0.1"
8 | s.summary = "Wireguard (darwin)"
9 | s.description = <<-DESC
10 | Wireguard flutter SDK for iOS/macOS
11 | DESC
12 | s.homepage = "https://flutterflux.com"
13 | s.license = { :file => "../LICENSE" }
14 | s.author = { "flutterflux.com" => "support@billiongroup.net" }
15 |
16 | s.source = { :path => "." }
17 | s.source_files = "Classes/**/*"
18 |
19 | # s.platform = :ios, "15.0"
20 |
21 | s.pod_target_xcconfig = { "DEFINES_MODULE" => "YES", "EXCLUDED_ARCHS[sdk=iphonesimulator*]" => "i386" }
22 | s.swift_version = "5.7"
23 |
24 | s.ios.dependency "Flutter"
25 | s.osx.dependency "FlutterMacOS"
26 | s.ios.deployment_target = "15.0"
27 | s.osx.deployment_target = "12.0"
28 |
29 | end
30 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: wireguard_flutter
2 | description: Wireguard Flutter SDK
3 | version: 0.1.0
4 | homepage: https://flutterflux.com
5 | repository: https://github.com/Caqil/wireguard_flutter
6 |
7 | environment:
8 | sdk: '>=3.0.0 <4.0.0'
9 | flutter: '>=3.13.7'
10 |
11 | dependencies:
12 | flutter:
13 | sdk: flutter
14 | path_provider: ^2.1.2
15 | plugin_platform_interface: ^2.0.2
16 | process_run: ^0.14.0+1
17 |
18 | dev_dependencies:
19 | flutter_test:
20 | sdk: flutter
21 | flutter_lints: ^2.0.0
22 |
23 | flutter:
24 | plugin:
25 | platforms:
26 | android:
27 | package: billion.group.wireguard_flutter
28 | pluginClass: WireguardFlutterPlugin
29 | ios:
30 | pluginClass: WireguardFlutterPlugin
31 | sharedDarwinSource: true
32 | macos:
33 | pluginClass: WireguardFlutterPlugin
34 | sharedDarwinSource: true
35 | windows:
36 | pluginClass: WireguardFlutterPluginCApi
37 | linux:
38 | dartPluginClass: WireGuardFlutter
39 |
--------------------------------------------------------------------------------
/lib/wireguard_flutter_platform_interface.dart:
--------------------------------------------------------------------------------
1 | abstract class WireGuardFlutterInterface {
2 | Stream get vpnStageSnapshot;
3 |
4 | Future initialize({required String interfaceName});
5 |
6 | Future startVpn({
7 | required String serverAddress,
8 | required String wgQuickConfig,
9 | required String providerBundleIdentifier,
10 | });
11 |
12 | Future stopVpn();
13 |
14 | Future refreshStage();
15 | Future stage();
16 | Future isConnected() =>
17 | stage().then((stage) => stage == VpnStage.connected);
18 | }
19 |
20 | enum VpnStage {
21 | connected('connected'),
22 | connecting('connecting'),
23 | disconnecting('disconnecting'),
24 | disconnected('disconnected'),
25 | waitingConnection('wait_connection'),
26 | authenticating('authenticating'),
27 | reconnect('reconnect'),
28 | noConnection('no_connection'),
29 | preparing('prepare'),
30 | denied('denied'),
31 | exiting('exiting');
32 |
33 | final String code;
34 |
35 | const VpnStage(this.code);
36 | }
37 |
--------------------------------------------------------------------------------
/example/windows/runner/flutter_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_FLUTTER_WINDOW_H_
2 | #define RUNNER_FLUTTER_WINDOW_H_
3 |
4 | #include
5 | #include
6 |
7 | #include
8 |
9 | #include "win32_window.h"
10 |
11 | // A window that does nothing but host a Flutter view.
12 | class FlutterWindow : public Win32Window {
13 | public:
14 | // Creates a new FlutterWindow hosting a Flutter view running |project|.
15 | explicit FlutterWindow(const flutter::DartProject& project);
16 | virtual ~FlutterWindow();
17 |
18 | protected:
19 | // Win32Window:
20 | bool OnCreate() override;
21 | void OnDestroy() override;
22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
23 | LPARAM const lparam) noexcept override;
24 |
25 | private:
26 | // The project to run.
27 | flutter::DartProject project_;
28 |
29 | // The Flutter instance hosted by this window.
30 | std::unique_ptr flutter_controller_;
31 | };
32 |
33 | #endif // RUNNER_FLUTTER_WINDOW_H_
34 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 PT BILLION JAYA GROUP
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/windows/service_control.h:
--------------------------------------------------------------------------------
1 | #ifndef WIREGUARD_FLUTTER_SERVICE_CONTROL_H
2 | #define WIREGUARD_FLUTTER_SERVICE_CONTROL_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | #include
11 | #include
12 |
13 | namespace wireguard_flutter {
14 |
15 | struct CreateArgs {
16 | std::wstring description, executable_and_args, dependencies;
17 | bool first_time;
18 | };
19 |
20 | class ServiceControl {
21 | public:
22 | std::wstring service_name_;
23 | std::unique_ptr> events_;
24 |
25 | ServiceControl(const std::wstring service_name) : service_name_(service_name) {}
26 |
27 | void CreateAndStart(CreateArgs args);
28 | void Stop();
29 | std::string GetStatus();
30 | void RegisterListener(std::unique_ptr> &&events);
31 | void UnregisterListener();
32 | void EmitState(std::string state);
33 | };
34 |
35 | } // namespace wireguard_flutter
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/android/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/example/macos/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | $(PRODUCT_COPYRIGHT)
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolved:
--------------------------------------------------------------------------------
1 | {
2 | "originHash" : "22fe370d7e3e35420aca8972ac685852f6fc72e9325b3f95ae25b04abe7bd2ba",
3 | "pins" : [
4 | {
5 | "identity" : "openssl-apple",
6 | "kind" : "remoteSourceControl",
7 | "location" : "https://github.com/passepartoutvpn/openssl-apple",
8 | "state" : {
9 | "revision" : "0edc07c7a0e4ec2ca0f448dd68314241ccc925b3",
10 | "version" : "3.2.107"
11 | }
12 | },
13 | {
14 | "identity" : "swiftybeaver",
15 | "kind" : "remoteSourceControl",
16 | "location" : "https://github.com/SwiftyBeaver/SwiftyBeaver",
17 | "state" : {
18 | "revision" : "8cba041db09596183331d123f337d0eb2e6e8e91",
19 | "version" : "2.1.1"
20 | }
21 | },
22 | {
23 | "identity" : "tunnelkit-master",
24 | "kind" : "remoteSourceControl",
25 | "location" : "https://github.com/Caqil/tunnelkit-master.git",
26 | "state" : {
27 | "branch" : "main",
28 | "revision" : "2a99f7c57471551905c4102b4d44cf190ecb5f55"
29 | }
30 | },
31 | {
32 | "identity" : "wireguard-apple",
33 | "kind" : "remoteSourceControl",
34 | "location" : "https://github.com/passepartoutvpn/wireguard-apple",
35 | "state" : {
36 | "revision" : "b79f0f150356d8200a64922ecf041dd020140aa0"
37 | }
38 | }
39 | ],
40 | "version" : 3
41 | }
42 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved:
--------------------------------------------------------------------------------
1 | {
2 | "originHash" : "22fe370d7e3e35420aca8972ac685852f6fc72e9325b3f95ae25b04abe7bd2ba",
3 | "pins" : [
4 | {
5 | "identity" : "openssl-apple",
6 | "kind" : "remoteSourceControl",
7 | "location" : "https://github.com/passepartoutvpn/openssl-apple",
8 | "state" : {
9 | "revision" : "0edc07c7a0e4ec2ca0f448dd68314241ccc925b3",
10 | "version" : "3.2.107"
11 | }
12 | },
13 | {
14 | "identity" : "swiftybeaver",
15 | "kind" : "remoteSourceControl",
16 | "location" : "https://github.com/SwiftyBeaver/SwiftyBeaver",
17 | "state" : {
18 | "revision" : "8cba041db09596183331d123f337d0eb2e6e8e91",
19 | "version" : "2.1.1"
20 | }
21 | },
22 | {
23 | "identity" : "tunnelkit-master",
24 | "kind" : "remoteSourceControl",
25 | "location" : "https://github.com/Caqil/tunnelkit-master.git",
26 | "state" : {
27 | "branch" : "main",
28 | "revision" : "2a99f7c57471551905c4102b4d44cf190ecb5f55"
29 | }
30 | },
31 | {
32 | "identity" : "wireguard-apple",
33 | "kind" : "remoteSourceControl",
34 | "location" : "https://github.com/passepartoutvpn/wireguard-apple",
35 | "state" : {
36 | "revision" : "b79f0f150356d8200a64922ecf041dd020140aa0"
37 | }
38 | }
39 | ],
40 | "version" : 3
41 | }
42 |
--------------------------------------------------------------------------------
/example/windows/runner/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "flutter_window.h"
6 | #include "utils.h"
7 |
8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
9 | _In_ wchar_t *command_line, _In_ int show_command) {
10 | // Attach to console when present (e.g., 'flutter run') or create a
11 | // new console when running with a debugger.
12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
13 | CreateAndAttachConsole();
14 | }
15 |
16 | // Initialize COM, so that it is available for use in the library and/or
17 | // plugins.
18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
19 |
20 | flutter::DartProject project(L"data");
21 |
22 | std::vector command_line_arguments =
23 | GetCommandLineArguments();
24 |
25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
26 |
27 | FlutterWindow window(project);
28 | Win32Window::Point origin(10, 10);
29 | Win32Window::Size size(1280, 720);
30 | if (!window.CreateAndShow(L"wireguard_dart_example", origin, size)) {
31 | return EXIT_FAILURE;
32 | }
33 | window.SetQuitOnClose(true);
34 |
35 | ::MSG msg;
36 | while (::GetMessage(&msg, nullptr, 0, 0)) {
37 | ::TranslateMessage(&msg);
38 | ::DispatchMessage(&msg);
39 | }
40 |
41 | ::CoUninitialize();
42 | return EXIT_SUCCESS;
43 | }
44 |
--------------------------------------------------------------------------------
/example/macos/Podfile:
--------------------------------------------------------------------------------
1 | platform :osx, '12.0'
2 |
3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true'
5 |
6 | project 'Runner', {
7 | 'Debug' => :debug,
8 | 'Profile' => :release,
9 | 'Release' => :release,
10 | }
11 |
12 | def flutter_root
13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
14 | unless File.exist?(generated_xcode_build_settings_path)
15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
16 | end
17 |
18 | File.foreach(generated_xcode_build_settings_path) do |line|
19 | matches = line.match(/FLUTTER_ROOT\=(.*)/)
20 | return matches[1].strip if matches
21 | end
22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
23 | end
24 |
25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
26 |
27 | flutter_macos_podfile_setup
28 |
29 | target 'Runner' do
30 | use_frameworks!
31 | use_modular_headers!
32 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
33 |
34 | end
35 |
36 | post_install do |installer|
37 | installer.pods_project.targets.each do |target|
38 | flutter_additional_macos_build_settings(target)
39 | end
40 | end
41 |
--------------------------------------------------------------------------------
/example/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment this line to define a global platform for your project
2 | # platform :ios, '12.0'
3 |
4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6 |
7 | project 'Runner', {
8 | 'Debug' => :debug,
9 | 'Profile' => :release,
10 | 'Release' => :release,
11 | }
12 |
13 | def flutter_root
14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
15 | unless File.exist?(generated_xcode_build_settings_path)
16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
17 | end
18 |
19 | File.foreach(generated_xcode_build_settings_path) do |line|
20 | matches = line.match(/FLUTTER_ROOT\=(.*)/)
21 | return matches[1].strip if matches
22 | end
23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
24 | end
25 |
26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
27 |
28 | flutter_ios_podfile_setup
29 |
30 | target 'Runner' do
31 | use_frameworks!
32 | use_modular_headers!
33 |
34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
35 | end
36 |
37 | post_install do |installer|
38 | installer.pods_project.targets.each do |target|
39 | flutter_additional_ios_build_settings(target)
40 | end
41 | end
42 |
--------------------------------------------------------------------------------
/example/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the analyzer, which statically analyzes Dart code to
2 | # check for errors, warnings, and lints.
3 | #
4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6 | # invoked from the command line by running `flutter analyze`.
7 |
8 | # The following line activates a set of recommended lints for Flutter apps,
9 | # packages, and plugins designed to encourage good coding practices.
10 | include: package:flutter_lints/flutter.yaml
11 |
12 | linter:
13 | # The lint rules applied to this project can be customized in the
14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml`
15 | # included above or to enable additional rules. A list of all available lints
16 | # and their documentation is published at
17 | # https://dart-lang.github.io/linter/lints/index.html.
18 | #
19 | # Instead of disabling a lint rule for the entire project in the
20 | # section below, it can also be suppressed for a single line of code
21 | # or a specific dart file by using the `// ignore: name_of_lint` and
22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file
23 | # producing the lint.
24 | rules:
25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule
26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27 |
28 | # Additional information about this file can be found at
29 | # https://dart.dev/guides/language/analysis-options
30 |
--------------------------------------------------------------------------------
/windows/config_writer.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | namespace wireguard_flutter
8 | {
9 |
10 | std::wstring WriteConfigToTempFile(std::string config)
11 | {
12 | WCHAR temp_path[MAX_PATH];
13 | DWORD temp_path_len = GetTempPath(MAX_PATH, temp_path);
14 | if (temp_path_len > MAX_PATH || temp_path_len == 0)
15 | {
16 | throw std::runtime_error("could not get temporary dir: " + GetLastError());
17 | }
18 |
19 | WCHAR temp_filename[MAX_PATH];
20 | UINT temp_filename_result = GetTempFileName(temp_path, L"wg_conf", 0, temp_filename);
21 | wcscat_s(temp_filename, L".conf");
22 | if (temp_filename_result == 0)
23 | {
24 | throw std::runtime_error("could not get temporary file name: " + GetLastError());
25 | }
26 |
27 | HANDLE temp_file = CreateFile(temp_filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
28 | if (temp_file == INVALID_HANDLE_VALUE)
29 | {
30 | throw std::runtime_error("unable to create temporary file: " + GetLastError());
31 | }
32 |
33 | DWORD bytes_written;
34 | if (!WriteFile(temp_file, config.c_str(), static_cast(config.length()), &bytes_written, NULL))
35 | {
36 | throw std::runtime_error("could not write temporary config file:" + GetLastError());
37 | }
38 |
39 | if (!CloseHandle(temp_file))
40 | {
41 | throw std::runtime_error("unable to close temporary file:" + GetLastError());
42 | }
43 | return temp_filename;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "16x16",
5 | "idiom" : "mac",
6 | "filename" : "app_icon_16.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "16x16",
11 | "idiom" : "mac",
12 | "filename" : "app_icon_32.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "32x32",
17 | "idiom" : "mac",
18 | "filename" : "app_icon_32.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "32x32",
23 | "idiom" : "mac",
24 | "filename" : "app_icon_64.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "128x128",
29 | "idiom" : "mac",
30 | "filename" : "app_icon_128.png",
31 | "scale" : "1x"
32 | },
33 | {
34 | "size" : "128x128",
35 | "idiom" : "mac",
36 | "filename" : "app_icon_256.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "256x256",
41 | "idiom" : "mac",
42 | "filename" : "app_icon_256.png",
43 | "scale" : "1x"
44 | },
45 | {
46 | "size" : "256x256",
47 | "idiom" : "mac",
48 | "filename" : "app_icon_512.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "512x512",
53 | "idiom" : "mac",
54 | "filename" : "app_icon_512.png",
55 | "scale" : "1x"
56 | },
57 | {
58 | "size" : "512x512",
59 | "idiom" : "mac",
60 | "filename" : "app_icon_1024.png",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | group 'billion.group.wireguard_flutter'
2 | version '1.0-SNAPSHOT'
3 |
4 | buildscript {
5 | ext.kotlin_version = '1.8.10'
6 | repositories {
7 | google()
8 | mavenCentral()
9 | }
10 |
11 | dependencies {
12 | classpath 'com.android.tools.build:gradle:7.1.3'
13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | mavenCentral()
21 | }
22 | }
23 |
24 | apply plugin: 'com.android.library'
25 | apply plugin: 'kotlin-android'
26 |
27 | android {
28 | compileSdkVersion 31
29 |
30 | compileOptions {
31 | sourceCompatibility JavaVersion.VERSION_1_8
32 | targetCompatibility JavaVersion.VERSION_1_8
33 | }
34 |
35 | kotlinOptions {
36 | jvmTarget = '1.8'
37 | }
38 |
39 | sourceSets {
40 | main.java.srcDirs += 'src/main/kotlin'
41 | }
42 |
43 | defaultConfig {
44 | minSdkVersion 21
45 | }
46 |
47 | namespace 'billion.group.wireguard_flutter'
48 | }
49 |
50 | dependencies {
51 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
52 | implementation 'com.wireguard.android:tunnel:1.0.20230427'
53 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.2'
54 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.2"
55 | implementation 'com.beust:klaxon:5.5'
56 | implementation 'androidx.appcompat:appcompat:1.6.1'
57 |
58 | /// to run wireguard on Android 25 or lower
59 | coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.0.3"
60 | }
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CADisableMinimumFrameDurationOnPhone
6 |
7 | CFBundleDevelopmentRegion
8 | $(DEVELOPMENT_LANGUAGE)
9 | CFBundleDisplayName
10 | Example Flutter
11 | CFBundleExecutable
12 | $(EXECUTABLE_NAME)
13 | CFBundleIdentifier
14 | $(PRODUCT_BUNDLE_IDENTIFIER)
15 | CFBundleInfoDictionaryVersion
16 | 6.0
17 | CFBundleName
18 | example_flutter
19 | CFBundlePackageType
20 | APPL
21 | CFBundleShortVersionString
22 | $(FLUTTER_BUILD_NAME)
23 | CFBundleSignature
24 | ????
25 | CFBundleVersion
26 | $(FLUTTER_BUILD_NUMBER)
27 | LSRequiresIPhoneOS
28 |
29 | UIApplicationSupportsIndirectInputEvents
30 |
31 | UILaunchStoryboardName
32 | LaunchScreen
33 | UIMainStoryboardFile
34 | Main
35 | UISupportedInterfaceOrientations
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationLandscapeLeft
39 | UIInterfaceOrientationLandscapeRight
40 |
41 | UISupportedInterfaceOrientations~ipad
42 |
43 | UIInterfaceOrientationPortrait
44 | UIInterfaceOrientationPortraitUpsideDown
45 | UIInterfaceOrientationLandscapeLeft
46 | UIInterfaceOrientationLandscapeRight
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/example/windows/runner/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.14)
2 | project(runner LANGUAGES CXX)
3 |
4 | # Define the application target. To change its name, change BINARY_NAME in the
5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
6 | # work.
7 | #
8 | # Any new source files that you add to the application should be added here.
9 | add_executable(${BINARY_NAME} WIN32
10 | "flutter_window.cpp"
11 | "main.cpp"
12 | "utils.cpp"
13 | "win32_window.cpp"
14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
15 | "Runner.rc"
16 | "runner.exe.manifest"
17 | )
18 |
19 | # Apply the standard set of build settings. This can be removed for applications
20 | # that need different build settings.
21 | apply_standard_settings(${BINARY_NAME})
22 |
23 | # Add preprocessor definitions for the build version.
24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")
29 |
30 | # Disable Windows macros that collide with C++ standard library functions.
31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
32 |
33 | # Add dependency libraries and include directories. Add any application-specific
34 | # dependencies here.
35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
36 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
37 |
38 | # Run the Flutter tool portions of the build. This must not be removed.
39 | add_dependencies(${BINARY_NAME} flutter_assemble)
40 |
--------------------------------------------------------------------------------
/.idea/libraries/Dart_SDK.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/windows/wireguard_flutter_plugin.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_PLUGIN_WIREGUARD_FLUTTER_PLUGIN_H_
2 | #define FLUTTER_PLUGIN_WIREGUARD_FLUTTER_PLUGIN_H_
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | #include
13 |
14 | #include "service_control.h"
15 |
16 | namespace wireguard_flutter
17 | {
18 |
19 | class WireguardFlutterPlugin : public flutter::Plugin
20 | {
21 | public:
22 | static void RegisterWithRegistrar(flutter::PluginRegistrarWindows *registrar);
23 |
24 | WireguardFlutterPlugin();
25 |
26 | virtual ~WireguardFlutterPlugin();
27 |
28 | // Disallow copy and assign.
29 | WireguardFlutterPlugin(const WireguardFlutterPlugin &) = delete;
30 | WireguardFlutterPlugin &operator=(const WireguardFlutterPlugin &) = delete;
31 |
32 | private:
33 | // Called when a method is called on this plugin's channel from Dart.
34 | void HandleMethodCall(const flutter::MethodCall &method_call,
35 | std::unique_ptr> result);
36 |
37 | std::unique_ptr tunnel_service_;
38 | std::unique_ptr> events_;
39 |
40 | std::unique_ptr> OnListen(
41 | const flutter::EncodableValue *arguments,
42 | std::unique_ptr> &&events);
43 | std::unique_ptr> OnCancel(
44 | const flutter::EncodableValue *arguments);
45 | };
46 |
47 | } // namespace wireguard_flutter
48 |
49 | #endif // FLUTTER_PLUGIN_WIREGUARD_FLUTTER_PLUGIN_H_
50 |
--------------------------------------------------------------------------------
/lib/wireguard_flutter.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:flutter/foundation.dart';
4 | import 'package:wireguard_flutter/linux/wireguard_flutter_linux.dart';
5 | import 'package:wireguard_flutter/wireguard_flutter_method_channel.dart';
6 |
7 | import 'wireguard_flutter_platform_interface.dart';
8 |
9 | export 'wireguard_flutter_platform_interface.dart' show VpnStage;
10 |
11 | class WireGuardFlutter extends WireGuardFlutterInterface {
12 | static WireGuardFlutterInterface? __instance;
13 | static WireGuardFlutterInterface get _instance => __instance!;
14 | static WireGuardFlutterInterface get instance {
15 | registerWith();
16 | return _instance;
17 | }
18 |
19 | static void registerWith() {
20 | if (__instance == null) {
21 | if (kIsWeb) {
22 | throw UnsupportedError('The web platform is not supported');
23 | } else if (Platform.isLinux) {
24 | __instance = WireGuardFlutterLinux();
25 | } else {
26 | __instance = WireGuardFlutterMethodChannel();
27 | }
28 | }
29 | }
30 |
31 | WireGuardFlutter._();
32 |
33 | @override
34 | Stream get vpnStageSnapshot => _instance.vpnStageSnapshot;
35 |
36 | @override
37 | Future initialize({required String interfaceName}) {
38 | return _instance.initialize(interfaceName: interfaceName);
39 | }
40 |
41 | @override
42 | Future startVpn({
43 | required String serverAddress,
44 | required String wgQuickConfig,
45 | required String providerBundleIdentifier,
46 | }) async {
47 | return _instance.startVpn(
48 | serverAddress: serverAddress,
49 | wgQuickConfig: wgQuickConfig,
50 | providerBundleIdentifier: providerBundleIdentifier,
51 | );
52 | }
53 |
54 | @override
55 | Future stopVpn() => _instance.stopVpn();
56 |
57 | @override
58 | Future refreshStage() => _instance.refreshStage();
59 |
60 | @override
61 | Future stage() => _instance.stage();
62 | }
63 |
--------------------------------------------------------------------------------
/example/windows/runner/utils.cpp:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include
9 |
10 | void CreateAndAttachConsole() {
11 | if (::AllocConsole()) {
12 | FILE *unused;
13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
14 | _dup2(_fileno(stdout), 1);
15 | }
16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
17 | _dup2(_fileno(stdout), 2);
18 | }
19 | std::ios::sync_with_stdio();
20 | FlutterDesktopResyncOutputStreams();
21 | }
22 | }
23 |
24 | std::vector GetCommandLineArguments() {
25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
26 | int argc;
27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
28 | if (argv == nullptr) {
29 | return std::vector();
30 | }
31 |
32 | std::vector command_line_arguments;
33 |
34 | // Skip the first argument as it's the binary name.
35 | for (int i = 1; i < argc; i++) {
36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i]));
37 | }
38 |
39 | ::LocalFree(argv);
40 |
41 | return command_line_arguments;
42 | }
43 |
44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) {
45 | if (utf16_string == nullptr) {
46 | return std::string();
47 | }
48 | int target_length = ::WideCharToMultiByte(
49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
50 | -1, nullptr, 0, nullptr, nullptr);
51 | std::string utf8_string;
52 | if (target_length == 0 || target_length > utf8_string.max_size()) {
53 | return utf8_string;
54 | }
55 | utf8_string.resize(target_length);
56 | int converted_length = ::WideCharToMultiByte(
57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
58 | -1, utf8_string.data(),
59 | target_length, nullptr, nullptr);
60 | if (converted_length == 0) {
61 | return std::string();
62 | }
63 | return utf8_string;
64 | }
65 |
--------------------------------------------------------------------------------
/windows/lib/tunnel/include/tunnel.h:
--------------------------------------------------------------------------------
1 | /* Code generated by cmd/cgo; DO NOT EDIT. */
2 |
3 | /* package golang.zx2c4.com/wireguard/windows/embeddable-dll-service */
4 |
5 |
6 | #line 1 "cgo-builtin-export-prolog"
7 |
8 | #include /* for ptrdiff_t below */
9 |
10 | #ifndef GO_CGO_EXPORT_PROLOGUE_H
11 | #define GO_CGO_EXPORT_PROLOGUE_H
12 |
13 | #ifndef GO_CGO_GOSTRING_TYPEDEF
14 | typedef struct { const char *p; ptrdiff_t n; } _GoString_;
15 | #endif
16 |
17 | #endif
18 |
19 | /* Start of preamble from import "C" comments. */
20 |
21 |
22 |
23 |
24 | /* End of preamble from import "C" comments. */
25 |
26 |
27 | /* Start of boilerplate cgo prologue. */
28 | #line 1 "cgo-gcc-export-header-prolog"
29 |
30 | #ifndef GO_CGO_PROLOGUE_H
31 | #define GO_CGO_PROLOGUE_H
32 |
33 | typedef signed char GoInt8;
34 | typedef unsigned char GoUint8;
35 | typedef short GoInt16;
36 | typedef unsigned short GoUint16;
37 | typedef int GoInt32;
38 | typedef unsigned int GoUint32;
39 | typedef long long GoInt64;
40 | typedef unsigned long long GoUint64;
41 | typedef GoInt64 GoInt;
42 | typedef GoUint64 GoUint;
43 | typedef float GoFloat32;
44 | typedef double GoFloat64;
45 |
46 | /*
47 | static assertion to make sure the file is being used on architecture
48 | at least with matching size of GoInt.
49 | */
50 | typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
51 |
52 | #ifndef GO_CGO_GOSTRING_TYPEDEF
53 | typedef _GoString_ GoString;
54 | #endif
55 | typedef void *GoMap;
56 | typedef void *GoChan;
57 | typedef struct { void *t; void *v; } GoInterface;
58 | typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
59 |
60 | #endif
61 |
62 | /* End of boilerplate cgo prologue. */
63 |
64 | #ifdef __cplusplus
65 | extern "C" {
66 | #endif
67 |
68 | extern __declspec(dllexport) GoUint8 WireGuardTunnelService(GoUint16* confFile16);
69 | extern __declspec(dllexport) void WireGuardGenerateKeypair(GoUint8* publicKey, GoUint8* privateKey);
70 |
71 | #ifdef __cplusplus
72 | }
73 | #endif
74 |
--------------------------------------------------------------------------------
/example/windows/runner/flutter_window.cpp:
--------------------------------------------------------------------------------
1 | #include "flutter_window.h"
2 |
3 | #include
4 |
5 | #include "flutter/generated_plugin_registrant.h"
6 |
7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project)
8 | : project_(project) {}
9 |
10 | FlutterWindow::~FlutterWindow() {}
11 |
12 | bool FlutterWindow::OnCreate() {
13 | if (!Win32Window::OnCreate()) {
14 | return false;
15 | }
16 |
17 | RECT frame = GetClientArea();
18 |
19 | // The size here must match the window dimensions to avoid unnecessary surface
20 | // creation / destruction in the startup path.
21 | flutter_controller_ = std::make_unique(
22 | frame.right - frame.left, frame.bottom - frame.top, project_);
23 | // Ensure that basic setup of the controller was successful.
24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) {
25 | return false;
26 | }
27 | RegisterPlugins(flutter_controller_->engine());
28 | SetChildContent(flutter_controller_->view()->GetNativeWindow());
29 | return true;
30 | }
31 |
32 | void FlutterWindow::OnDestroy() {
33 | if (flutter_controller_) {
34 | flutter_controller_ = nullptr;
35 | }
36 |
37 | Win32Window::OnDestroy();
38 | }
39 |
40 | LRESULT
41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
42 | WPARAM const wparam,
43 | LPARAM const lparam) noexcept {
44 | // Give Flutter, including plugins, an opportunity to handle window messages.
45 | if (flutter_controller_) {
46 | std::optional result =
47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
48 | lparam);
49 | if (result) {
50 | return *result;
51 | }
52 | }
53 |
54 | switch (message) {
55 | case WM_FONTCHANGE:
56 | flutter_controller_->engine()->ReloadSystemFonts();
57 | break;
58 | }
59 |
60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
61 | }
62 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to wireguard_flutter
2 |
3 | Thank you for your interest in contributing to wireguard_flutter! We appreciate your help in making this project better.
4 |
5 | Before you start contributing, please take a moment to read the following guidelines.
6 |
7 | ## How to Contribute
8 |
9 | 1. Fork the repository to your GitHub account.
10 | 2. Clone the forked repository to your local machine.
11 | 3. Create a new branch for your contribution:
12 | ```bash
13 | git checkout -b feature/your-feature-name
14 | ```
15 | 4. Make your changes and ensure that the code follows the project's coding standards.
16 | 5. Commit your changes with a descriptive commit message:
17 | ```bash
18 | git commit -m "Add your descriptive message here"
19 | ```
20 | 6. Push your changes to your forked repository:
21 | ```bash
22 | git push origin feature/your-feature-name
23 | ```
24 | 7. Open a pull request in the original repository and provide a detailed description of your changes.
25 |
26 | ## Code Style
27 |
28 | Please follow the coding style used in the project. If there are specific style guidelines, document them here.
29 |
30 | ## Testing
31 |
32 | If your contribution involves code changes, please make sure to test your changes thoroughly before submitting a pull request. If applicable, provide information on how to test your changes.
33 |
34 | ## Issue Reporting
35 |
36 | If you encounter any issues with the project, please check the existing issues to see if the problem has already been reported. If not, open a new issue with a detailed description of the problem, including steps to reproduce it.
37 |
38 | ## Feature Requests
39 |
40 | If you have a feature request, please open a new issue with a clear description of the feature you'd like to see. Discuss the feature with the maintainers and other contributors before submitting a pull request.
41 |
42 | ## Licensing
43 |
44 | By contributing to this project, you agree that your contributions will be licensed under the [LICENSE NAME](https://github.com/Caqil/wireguard_flutter/blob/main/LICENSE) license used for the project.
45 |
46 | Thank you for your contribution!
47 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
14 |
22 |
26 |
30 |
31 |
32 |
33 |
34 |
35 |
37 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/lib/wireguard_flutter_method_channel.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/services.dart';
2 |
3 | import 'wireguard_flutter_platform_interface.dart';
4 |
5 | class WireGuardFlutterMethodChannel extends WireGuardFlutterInterface {
6 | static const _methodChannelVpnControl =
7 | "billion.group.wireguard_flutter/wgcontrol";
8 | static const _methodChannel = MethodChannel(_methodChannelVpnControl);
9 | static const _eventChannelVpnStage =
10 | 'billion.group.wireguard_flutter/wgstage';
11 | static const _eventChannel = EventChannel(_eventChannelVpnStage);
12 |
13 | @override
14 | Stream get vpnStageSnapshot =>
15 | _eventChannel.receiveBroadcastStream().map(
16 | (event) => event == VpnStage.denied.code
17 | ? VpnStage.disconnected
18 | : VpnStage.values.firstWhere(
19 | (stage) => stage.code == event,
20 | orElse: () => VpnStage.noConnection,
21 | ),
22 | );
23 |
24 | @override
25 | Future initialize({required String interfaceName}) {
26 | return _methodChannel.invokeMethod("initialize", {
27 | "localizedDescription": interfaceName,
28 | "win32ServiceName": interfaceName,
29 | });
30 | }
31 |
32 | @override
33 | Future startVpn({
34 | required String serverAddress,
35 | required String wgQuickConfig,
36 | required String providerBundleIdentifier,
37 | }) async {
38 | return _methodChannel.invokeMethod("start", {
39 | "serverAddress": serverAddress,
40 | "wgQuickConfig": wgQuickConfig,
41 | "providerBundleIdentifier": providerBundleIdentifier,
42 | });
43 | }
44 |
45 | @override
46 | Future stopVpn() => _methodChannel.invokeMethod('stop');
47 |
48 | @override
49 | Future refreshStage() => _methodChannel.invokeMethod("refresh");
50 |
51 | @override
52 | Future stage() => _methodChannel.invokeMethod("stage").then(
53 | (value) => value != null
54 | ? VpnStage.values.firstWhere(
55 | (stage) => stage.code == value.toString(),
56 | orElse: () => VpnStage.disconnected,
57 | )
58 | : VpnStage.disconnected,
59 | );
60 | }
61 |
--------------------------------------------------------------------------------
/windows/utils.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include
5 | #include
6 |
7 | namespace wireguard_flutter
8 | {
9 |
10 | const flutter::EncodableValue *ValueOrNull(const flutter::EncodableMap &map, const char *key)
11 | {
12 | auto it = map.find(flutter::EncodableValue(key));
13 | if (it == map.end())
14 | {
15 | return nullptr;
16 | }
17 | return &(it->second);
18 | }
19 |
20 | std::string ErrorWithCode(const char *msg, unsigned long error_code)
21 | {
22 | std::ostringstream builder;
23 | builder << msg << " (" << error_code << ")";
24 | return builder.str();
25 | }
26 |
27 | std::string WideToUtf8(const std::wstring &wstr)
28 | {
29 | int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
30 | std::string strTo(size_needed, 0);
31 | WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
32 | return strTo;
33 | }
34 |
35 | std::wstring Utf8ToWide(const std::string &str)
36 | {
37 | int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
38 | std::wstring wstrTo(size_needed, 0);
39 | MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], size_needed);
40 | return wstrTo;
41 | }
42 |
43 | std::string WideToAnsi(const std::wstring &wstr)
44 | {
45 | int size_needed = WideCharToMultiByte(CP_ACP, 0, &wstr[0], -1, NULL, 0, NULL, NULL);
46 | std::string strTo(size_needed, 0);
47 | WideCharToMultiByte(CP_ACP, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
48 | return strTo;
49 | }
50 |
51 | std::wstring AnsiToWide(const std::string &str)
52 | {
53 | int size_needed = MultiByteToWideChar(CP_ACP, 0, &str[0], (int)str.size(), NULL, 0);
54 | std::wstring wstrTo(size_needed, 0);
55 | MultiByteToWideChar(CP_ACP, 0, &str[0], (int)str.size(), &wstrTo[0], size_needed);
56 | return wstrTo;
57 | }
58 |
59 | void DebugMessageBox(const char *msg)
60 | {
61 | std::string s(msg);
62 | std::wstring ws = Utf8ToWide(s);
63 | MessageBox(NULL, &ws[0], L"Debug", MB_OK);
64 | }
65 |
66 | } // namespace wireguard_flutter
67 |
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 | if (flutterVersionCode == null) {
16 | flutterVersionCode = '1'
17 | }
18 |
19 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
20 | if (flutterVersionName == null) {
21 | flutterVersionName = '1.0'
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply plugin: 'kotlin-android'
26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27 |
28 | android {
29 | compileSdkVersion flutter.compileSdkVersion
30 | ndkVersion flutter.ndkVersion
31 |
32 | compileOptions {
33 | sourceCompatibility JavaVersion.VERSION_1_8
34 | targetCompatibility JavaVersion.VERSION_1_8
35 | }
36 |
37 | kotlinOptions {
38 | jvmTarget = '1.8'
39 | }
40 |
41 | sourceSets {
42 | main.java.srcDirs += 'src/main/kotlin'
43 | }
44 |
45 | defaultConfig {
46 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
47 | applicationId "billion.group.wireguard_flutter_example"
48 | // You can update the following values to match your application needs.
49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
50 | minSdkVersion 21
51 | targetSdkVersion flutter.targetSdkVersion
52 | versionCode flutterVersionCode.toInteger()
53 | versionName flutterVersionName
54 | }
55 |
56 | buildTypes {
57 | release {
58 | // TODO: Add your own signing config for the release build.
59 | // Signing with the debug keys for now, so `flutter run --release` works.
60 | signingConfig signingConfigs.debug
61 | }
62 | }
63 | namespace 'billion.group.wireguard_flutter_example'
64 | }
65 |
66 | flutter {
67 | source '../..'
68 | }
69 |
70 | dependencies {
71 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
72 | }
73 |
--------------------------------------------------------------------------------
/example/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: wireguard_dart_example
2 | description: Demonstrates how to use the wireguard_dart plugin.
3 |
4 | environment:
5 | sdk: '^3.0.0'
6 |
7 | # Dependencies specify other packages that your package needs in order to work.
8 | # To automatically upgrade your package dependencies to the latest versions
9 | # consider running `flutter pub upgrade --major-versions`. Alternatively,
10 | # dependencies can be manually updated by changing the version numbers below to
11 | # the latest version available on pub.dev. To see which dependencies have newer
12 | # versions available, run `flutter pub outdated`.
13 | dependencies:
14 | flutter:
15 | sdk: flutter
16 | wireguard_flutter:
17 | path: ../
18 | cupertino_icons: ^1.0.5
19 | http: ^1.1.0
20 |
21 | dev_dependencies:
22 | flutter_test:
23 | sdk: flutter
24 |
25 | # The "flutter_lints" package below contains a set of recommended lints to
26 | # encourage good coding practices. The lint set provided by the package is
27 | # activated in the `analysis_options.yaml` file located at the root of your
28 | # package. See that file for information about deactivating specific lint
29 | # rules and activating additional ones.
30 | flutter_lints: ^2.0.0
31 |
32 | # For information on the generic Dart part of this file, see the
33 | # following page: https://dart.dev/tools/pub/pubspec
34 |
35 | # The following section is specific to Flutter packages.
36 | flutter:
37 |
38 | # The following line ensures that the Material Icons font is
39 | # included with your application, so that you can use the icons in
40 | # the material Icons class.
41 | uses-material-design: true
42 |
43 | # To add assets to your application, add an assets section, like this:
44 | # assets:
45 | # - images/a_dot_burr.jpeg
46 | # - images/a_dot_ham.jpeg
47 |
48 | # An image asset can refer to one or more resolution-specific "variants", see
49 | # https://flutter.dev/assets-and-images/#resolution-aware
50 |
51 | # For details regarding adding assets from package dependencies, see
52 | # https://flutter.dev/assets-and-images/#from-packages
53 |
54 | # To add custom fonts to your application, add a fonts section here,
55 | # in this "flutter" section. Each entry in this list should have a
56 | # "family" key with the font family name, and a "fonts" key with a
57 | # list giving the asset and other descriptors for the font. For
58 | # example:
59 | # fonts:
60 | # - family: Schyler
61 | # fonts:
62 | # - asset: fonts/Schyler-Regular.ttf
63 | # - asset: fonts/Schyler-Italic.ttf
64 | # style: italic
65 | # - family: Trajan Pro
66 | # fonts:
67 | # - asset: fonts/TrajanPro.ttf
68 | # - asset: fonts/TrajanPro_Bold.ttf
69 | # weight: 700
70 | #
71 | # For details regarding fonts from package dependencies,
72 | # see https://flutter.dev/custom-fonts/#from-packages
73 |
--------------------------------------------------------------------------------
/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/example/linux/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # This file controls Flutter-level build steps. It should not be edited.
2 | cmake_minimum_required(VERSION 3.10)
3 |
4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
5 |
6 | # Configuration provided via flutter tool.
7 | include(${EPHEMERAL_DIR}/generated_config.cmake)
8 |
9 | # TODO: Move the rest of this into files in ephemeral. See
10 | # https://github.com/flutter/flutter/issues/57146.
11 |
12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...),
13 | # which isn't available in 3.10.
14 | function(list_prepend LIST_NAME PREFIX)
15 | set(NEW_LIST "")
16 | foreach(element ${${LIST_NAME}})
17 | list(APPEND NEW_LIST "${PREFIX}${element}")
18 | endforeach(element)
19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
20 | endfunction()
21 |
22 | # === Flutter Library ===
23 | # System-level dependencies.
24 | find_package(PkgConfig REQUIRED)
25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
28 |
29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
30 |
31 | # Published to parent scope for install step.
32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
36 |
37 | list(APPEND FLUTTER_LIBRARY_HEADERS
38 | "fl_basic_message_channel.h"
39 | "fl_binary_codec.h"
40 | "fl_binary_messenger.h"
41 | "fl_dart_project.h"
42 | "fl_engine.h"
43 | "fl_json_message_codec.h"
44 | "fl_json_method_codec.h"
45 | "fl_message_codec.h"
46 | "fl_method_call.h"
47 | "fl_method_channel.h"
48 | "fl_method_codec.h"
49 | "fl_method_response.h"
50 | "fl_plugin_registrar.h"
51 | "fl_plugin_registry.h"
52 | "fl_standard_message_codec.h"
53 | "fl_standard_method_codec.h"
54 | "fl_string_codec.h"
55 | "fl_value.h"
56 | "fl_view.h"
57 | "flutter_linux.h"
58 | )
59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
60 | add_library(flutter INTERFACE)
61 | target_include_directories(flutter INTERFACE
62 | "${EPHEMERAL_DIR}"
63 | )
64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
65 | target_link_libraries(flutter INTERFACE
66 | PkgConfig::GTK
67 | PkgConfig::GLIB
68 | PkgConfig::GIO
69 | )
70 | add_dependencies(flutter flutter_assemble)
71 |
72 | # === Flutter tool backend ===
73 | # _phony_ is a non-existent file to force this command to run every time,
74 | # since currently there's no way to get a full input/output list from the
75 | # flutter tool.
76 | add_custom_command(
77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_
79 | COMMAND ${CMAKE_COMMAND} -E env
80 | ${FLUTTER_TOOL_ENVIRONMENT}
81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
83 | VERBATIM
84 | )
85 | add_custom_target(flutter_assemble DEPENDS
86 | "${FLUTTER_LIBRARY}"
87 | ${FLUTTER_LIBRARY_HEADERS}
88 | )
89 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/example/windows/runner/Runner.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #pragma code_page(65001)
4 | #include "resource.h"
5 |
6 | #define APSTUDIO_READONLY_SYMBOLS
7 | /////////////////////////////////////////////////////////////////////////////
8 | //
9 | // Generated from the TEXTINCLUDE 2 resource.
10 | //
11 | #include "winres.h"
12 |
13 | /////////////////////////////////////////////////////////////////////////////
14 | #undef APSTUDIO_READONLY_SYMBOLS
15 |
16 | /////////////////////////////////////////////////////////////////////////////
17 | // English (United States) resources
18 |
19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21 |
22 | #ifdef APSTUDIO_INVOKED
23 | /////////////////////////////////////////////////////////////////////////////
24 | //
25 | // TEXTINCLUDE
26 | //
27 |
28 | 1 TEXTINCLUDE
29 | BEGIN
30 | "resource.h\0"
31 | END
32 |
33 | 2 TEXTINCLUDE
34 | BEGIN
35 | "#include ""winres.h""\r\n"
36 | "\0"
37 | END
38 |
39 | 3 TEXTINCLUDE
40 | BEGIN
41 | "\r\n"
42 | "\0"
43 | END
44 |
45 | #endif // APSTUDIO_INVOKED
46 |
47 |
48 | /////////////////////////////////////////////////////////////////////////////
49 | //
50 | // Icon
51 | //
52 |
53 | // Icon with lowest ID value placed first to ensure application icon
54 | // remains consistent on all systems.
55 | IDI_APP_ICON ICON "resources\\app_icon.ico"
56 |
57 |
58 | /////////////////////////////////////////////////////////////////////////////
59 | //
60 | // Version
61 | //
62 |
63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
65 | #else
66 | #define VERSION_AS_NUMBER 1,0,0,0
67 | #endif
68 |
69 | #if defined(FLUTTER_VERSION)
70 | #define VERSION_AS_STRING FLUTTER_VERSION
71 | #else
72 | #define VERSION_AS_STRING "1.0.0"
73 | #endif
74 |
75 | VS_VERSION_INFO VERSIONINFO
76 | FILEVERSION VERSION_AS_NUMBER
77 | PRODUCTVERSION VERSION_AS_NUMBER
78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
79 | #ifdef _DEBUG
80 | FILEFLAGS VS_FF_DEBUG
81 | #else
82 | FILEFLAGS 0x0L
83 | #endif
84 | FILEOS VOS__WINDOWS32
85 | FILETYPE VFT_APP
86 | FILESUBTYPE 0x0L
87 | BEGIN
88 | BLOCK "StringFileInfo"
89 | BEGIN
90 | BLOCK "040904e4"
91 | BEGIN
92 | VALUE "CompanyName", "BlockDev AG" "\0"
93 | VALUE "FileDescription", "wireguard_dart_example" "\0"
94 | VALUE "FileVersion", VERSION_AS_STRING "\0"
95 | VALUE "InternalName", "wireguard_dart_example" "\0"
96 | VALUE "LegalCopyright", "Copyright (C) 2023 BlockDev AG. All rights reserved." "\0"
97 | VALUE "OriginalFilename", "wireguard_dart_example.exe" "\0"
98 | VALUE "ProductName", "wireguard_dart_example" "\0"
99 | VALUE "ProductVersion", VERSION_AS_STRING "\0"
100 | END
101 | END
102 | BLOCK "VarFileInfo"
103 | BEGIN
104 | VALUE "Translation", 0x409, 1252
105 | END
106 | END
107 |
108 | #endif // English (United States) resources
109 | /////////////////////////////////////////////////////////////////////////////
110 |
111 |
112 |
113 | #ifndef APSTUDIO_INVOKED
114 | /////////////////////////////////////////////////////////////////////////////
115 | //
116 | // Generated from the TEXTINCLUDE 3 resource.
117 | //
118 |
119 |
120 | /////////////////////////////////////////////////////////////////////////////
121 | #endif // not APSTUDIO_INVOKED
122 |
--------------------------------------------------------------------------------
/example/windows/runner/win32_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_WIN32_WINDOW_H_
2 | #define RUNNER_WIN32_WINDOW_H_
3 |
4 | #include
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be
11 | // inherited from by classes that wish to specialize with custom
12 | // rendering and input handling
13 | class Win32Window {
14 | public:
15 | struct Point {
16 | unsigned int x;
17 | unsigned int y;
18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {}
19 | };
20 |
21 | struct Size {
22 | unsigned int width;
23 | unsigned int height;
24 | Size(unsigned int width, unsigned int height)
25 | : width(width), height(height) {}
26 | };
27 |
28 | Win32Window();
29 | virtual ~Win32Window();
30 |
31 | // Creates and shows a win32 window with |title| and position and size using
32 | // |origin| and |size|. New windows are created on the default monitor. Window
33 | // sizes are specified to the OS in physical pixels, hence to ensure a
34 | // consistent size to will treat the width height passed in to this function
35 | // as logical pixels and scale to appropriate for the default monitor. Returns
36 | // true if the window was created successfully.
37 | bool CreateAndShow(const std::wstring& title,
38 | const Point& origin,
39 | const Size& size);
40 |
41 | // Release OS resources associated with window.
42 | void Destroy();
43 |
44 | // Inserts |content| into the window tree.
45 | void SetChildContent(HWND content);
46 |
47 | // Returns the backing Window handle to enable clients to set icon and other
48 | // window properties. Returns nullptr if the window has been destroyed.
49 | HWND GetHandle();
50 |
51 | // If true, closing this window will quit the application.
52 | void SetQuitOnClose(bool quit_on_close);
53 |
54 | // Return a RECT representing the bounds of the current client area.
55 | RECT GetClientArea();
56 |
57 | protected:
58 | // Processes and route salient window messages for mouse handling,
59 | // size change and DPI. Delegates handling of these to member overloads that
60 | // inheriting classes can handle.
61 | virtual LRESULT MessageHandler(HWND window,
62 | UINT const message,
63 | WPARAM const wparam,
64 | LPARAM const lparam) noexcept;
65 |
66 | // Called when CreateAndShow is called, allowing subclass window-related
67 | // setup. Subclasses should return false if setup fails.
68 | virtual bool OnCreate();
69 |
70 | // Called when Destroy is called.
71 | virtual void OnDestroy();
72 |
73 | private:
74 | friend class WindowClassRegistrar;
75 |
76 | // OS callback called by message pump. Handles the WM_NCCREATE message which
77 | // is passed when the non-client area is being created and enables automatic
78 | // non-client DPI scaling so that the non-client area automatically
79 | // responsponds to changes in DPI. All other messages are handled by
80 | // MessageHandler.
81 | static LRESULT CALLBACK WndProc(HWND const window,
82 | UINT const message,
83 | WPARAM const wparam,
84 | LPARAM const lparam) noexcept;
85 |
86 | // Retrieves a class instance pointer for |window|
87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept;
88 |
89 | bool quit_on_close_ = false;
90 |
91 | // window handle for top level window.
92 | HWND window_handle_ = nullptr;
93 |
94 | // window handle for hosted content.
95 | HWND child_content_ = nullptr;
96 | };
97 |
98 | #endif // RUNNER_WIN32_WINDOW_H_
99 |
--------------------------------------------------------------------------------
/lib/linux/wireguard_flutter_linux.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 | import 'dart:io';
3 |
4 | import 'package:flutter/foundation.dart';
5 | import 'package:path_provider/path_provider.dart';
6 | import 'package:process_run/shell.dart';
7 |
8 | import '../wireguard_flutter_platform_interface.dart';
9 |
10 | class WireGuardFlutterLinux extends WireGuardFlutterInterface {
11 | String? name;
12 | File? configFile;
13 |
14 | VpnStage _stage = VpnStage.noConnection;
15 | final _stageController = StreamController.broadcast();
16 | void _setStage(VpnStage stage) {
17 | _stage = stage;
18 | _stageController.add(stage);
19 | }
20 |
21 | final shell = Shell(runInShell: true, verbose: kDebugMode);
22 |
23 | @override
24 | Future initialize({required String interfaceName}) async {
25 | name = interfaceName.replaceAll(' ', '_');
26 | await refreshStage();
27 | }
28 |
29 | Future get filePath async {
30 | final tempDir = await getTemporaryDirectory();
31 | return '${tempDir.path}${Platform.pathSeparator}$name.conf';
32 | }
33 |
34 | @override
35 | Future startVpn({
36 | required String serverAddress,
37 | required String wgQuickConfig,
38 | required String providerBundleIdentifier,
39 | }) async {
40 | final isAlreadyConnected = await isConnected();
41 | if (!isAlreadyConnected) {
42 | _setStage(VpnStage.preparing);
43 | } else {
44 | debugPrint('Already connected');
45 | }
46 |
47 | try {
48 | configFile = await File(await filePath).create();
49 | await configFile!.writeAsString(wgQuickConfig);
50 | } on PathAccessException {
51 | debugPrint('Denied to write file. Trying to start interface');
52 | if (isAlreadyConnected) {
53 | return _setStage(VpnStage.connected);
54 | }
55 |
56 | try {
57 | await shell.run('sudo wg-quick up $name');
58 | } catch (_) {
59 | } finally {
60 | _setStage(VpnStage.denied);
61 | }
62 | }
63 |
64 | if (!isAlreadyConnected) {
65 | _setStage(VpnStage.connecting);
66 | await shell.run('sudo wg-quick up ${configFile?.path ?? await filePath}');
67 | _setStage(VpnStage.connected);
68 | }
69 | }
70 |
71 | @override
72 | Future stopVpn() async {
73 | assert(
74 | (await isConnected()),
75 | 'Bad state: vpn has not been started. Call startVpn',
76 | );
77 | _setStage(VpnStage.disconnecting);
78 | try {
79 | await shell
80 | .run('sudo wg-quick down ${configFile?.path ?? (await filePath)}');
81 | } catch (e) {
82 | await refreshStage();
83 | rethrow;
84 | }
85 | await refreshStage();
86 | }
87 |
88 | @override
89 | Future stage() async => _stage;
90 |
91 | @override
92 | Stream get vpnStageSnapshot => _stageController.stream;
93 |
94 | @override
95 | Future refreshStage() async {
96 | if (await isConnected()) {
97 | _setStage(VpnStage.connected);
98 | } else if (name == null) {
99 | _setStage(VpnStage.waitingConnection);
100 | } else if (configFile == null) {
101 | _setStage(VpnStage.noConnection);
102 | } else {
103 | _setStage(VpnStage.disconnected);
104 | }
105 | }
106 |
107 | @override
108 | Future isConnected() async {
109 | assert(
110 | name != null,
111 | 'Bad state: not initialized. Call "initialize" before calling this command',
112 | );
113 | final processResultList = await shell.run('sudo wg');
114 | final process = processResultList.first;
115 | return process.outLines.any((line) => line.trim() == 'interface: $name');
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
43 |
49 |
50 |
51 |
52 |
53 |
63 |
65 |
71 |
72 |
73 |
74 |
80 |
82 |
88 |
89 |
90 |
91 |
93 |
94 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
43 |
49 |
50 |
51 |
52 |
53 |
63 |
65 |
71 |
72 |
73 |
74 |
80 |
82 |
88 |
89 |
90 |
91 |
93 |
94 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/windows/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # The Flutter tooling requires that developers have a version of Visual Studio
2 | # installed that includes CMake 3.14 or later. You should not increase this
3 | # version, as doing so will cause the plugin to fail to compile for some
4 | # customers of the plugin.
5 | cmake_minimum_required(VERSION 3.14)
6 |
7 | # get_cmake_property(_variableNames VARIABLES)
8 | # list (SORT _variableNames)
9 | # foreach (_variableName ${_variableNames})
10 | # message(STATUS "${_variableName}=${${_variableName}}")
11 | # endforeach()
12 |
13 | # Project-level configuration.
14 | set(PROJECT_NAME "wireguard_flutter")
15 | project(${PROJECT_NAME} LANGUAGES CXX)
16 |
17 | # This value is used when generating builds using this plugin, so it must
18 | # not be changed
19 | set(PLUGIN_NAME "wireguard_flutter_plugin")
20 |
21 | # Any new source files that you add to the plugin should be added here.
22 | list(APPEND PLUGIN_SOURCES
23 | "wireguard_flutter_plugin.cpp"
24 | "wireguard_flutter_plugin.h"
25 | "config_writer.cpp"
26 | "config_writer.h"
27 | "service_control.cpp"
28 | "service_control.h"
29 | "utils.cpp"
30 | "utils.h"
31 | )
32 |
33 | # Define the plugin library target. Its name must not be changed (see comment
34 | # on PLUGIN_NAME above).
35 | add_library(${PLUGIN_NAME} SHARED
36 | "include/wireguard_flutter/wireguard_flutter_plugin_c_api.h"
37 | "wireguard_flutter_plugin_c_api.cpp"
38 | ${PLUGIN_SOURCES}
39 | )
40 |
41 | # Apply a standard set of build settings that are configured in the
42 | # application-level CMakeLists.txt. This can be removed for plugins that want
43 | # full control over build settings.
44 | apply_standard_settings(${PLUGIN_NAME})
45 |
46 | # Symbols are hidden by default to reduce the chance of accidental conflicts
47 | # between plugins. This should not be removed; any symbols that should be
48 | # exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro.
49 | set_target_properties(${PLUGIN_NAME} PROPERTIES
50 | CXX_VISIBILITY_PRESET hidden)
51 | target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
52 |
53 | # Source include directories and library dependencies. Add any plugin-specific
54 | # dependencies here.
55 | add_subdirectory(external)
56 | target_link_libraries(${PLUGIN_NAME} PRIVATE base64)
57 |
58 | add_compile_definitions(WIN32_LEAN_AND_MEAN) # for Wireguard winsock/windows conflict
59 |
60 | add_library(tunnel SHARED IMPORTED GLOBAL)
61 | set_target_properties(tunnel PROPERTIES
62 | IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/tunnel/amd64/tunnel.dll"
63 | IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/lib/tunnel/amd64/tunnel.lib"
64 | )
65 | target_include_directories(tunnel INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/lib/tunnel/include")
66 | target_link_libraries(${PLUGIN_NAME} PRIVATE tunnel)
67 |
68 | add_library(wireguard SHARED IMPORTED GLOBAL)
69 | set_target_properties(wireguard PROPERTIES
70 | IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/wireguard/amd64/wireguard.dll"
71 | IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/lib/wireguard/amd64/wireguard.lib"
72 | )
73 | target_include_directories(wireguard INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/lib/wireguard/include")
74 | target_link_libraries(${PLUGIN_NAME} PRIVATE wireguard)
75 |
76 | target_include_directories(${PLUGIN_NAME} INTERFACE
77 | "${CMAKE_CURRENT_SOURCE_DIR}/include"
78 | "${CMAKE_CURRENT_SOURCE_DIR}/lib/tunnel/include"
79 | "${CMAKE_CURRENT_SOURCE_DIR}/lib/wireguard/include"
80 | )
81 | target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)
82 |
83 | # List of absolute paths to libraries that should be bundled with the plugin.
84 | # This list could contain prebuilt libraries, or libraries created by an
85 | # external build triggered from this build file.
86 | set(wireguard_flutter_bundled_libraries
87 | "${CMAKE_CURRENT_SOURCE_DIR}/lib/wireguard/amd64/wireguard.dll"
88 | "${CMAKE_CURRENT_SOURCE_DIR}/lib/tunnel/amd64/tunnel.dll"
89 | "${CMAKE_CURRENT_SOURCE_DIR}/lib/wireguard_svc/amd64/wireguard_svc.exe"
90 | PARENT_SCOPE
91 | )
92 |
93 | SET_TARGET_PROPERTIES(${BINARY_NAME} PROPERTIES LINK_FLAGS "/MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\" /SUBSYSTEM:WINDOWS")
--------------------------------------------------------------------------------
/example/linux/my_application.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 |
3 | #include
4 | #ifdef GDK_WINDOWING_X11
5 | #include
6 | #endif
7 |
8 | #include "flutter/generated_plugin_registrant.h"
9 |
10 | struct _MyApplication {
11 | GtkApplication parent_instance;
12 | char** dart_entrypoint_arguments;
13 | };
14 |
15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
16 |
17 | // Implements GApplication::activate.
18 | static void my_application_activate(GApplication* application) {
19 | MyApplication* self = MY_APPLICATION(application);
20 | GtkWindow* window =
21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
22 |
23 | // Use a header bar when running in GNOME as this is the common style used
24 | // by applications and is the setup most users will be using (e.g. Ubuntu
25 | // desktop).
26 | // If running on X and not using GNOME then just use a traditional title bar
27 | // in case the window manager does more exotic layout, e.g. tiling.
28 | // If running on Wayland assume the header bar will work (may need changing
29 | // if future cases occur).
30 | gboolean use_header_bar = TRUE;
31 | #ifdef GDK_WINDOWING_X11
32 | GdkScreen* screen = gtk_window_get_screen(window);
33 | if (GDK_IS_X11_SCREEN(screen)) {
34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
36 | use_header_bar = FALSE;
37 | }
38 | }
39 | #endif
40 | if (use_header_bar) {
41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
42 | gtk_widget_show(GTK_WIDGET(header_bar));
43 | gtk_header_bar_set_title(header_bar, "wireguard_dart_example");
44 | gtk_header_bar_set_show_close_button(header_bar, TRUE);
45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
46 | } else {
47 | gtk_window_set_title(window, "wireguard_dart_example");
48 | }
49 |
50 | gtk_window_set_default_size(window, 1280, 720);
51 | gtk_widget_show(GTK_WIDGET(window));
52 |
53 | g_autoptr(FlDartProject) project = fl_dart_project_new();
54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
55 |
56 | FlView* view = fl_view_new(project);
57 | gtk_widget_show(GTK_WIDGET(view));
58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
59 |
60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view));
61 |
62 | gtk_widget_grab_focus(GTK_WIDGET(view));
63 | }
64 |
65 | // Implements GApplication::local_command_line.
66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) {
67 | MyApplication* self = MY_APPLICATION(application);
68 | // Strip out the first argument as it is the binary name.
69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
70 |
71 | g_autoptr(GError) error = nullptr;
72 | if (!g_application_register(application, nullptr, &error)) {
73 | g_warning("Failed to register: %s", error->message);
74 | *exit_status = 1;
75 | return TRUE;
76 | }
77 |
78 | g_application_activate(application);
79 | *exit_status = 0;
80 |
81 | return TRUE;
82 | }
83 |
84 | // Implements GObject::dispose.
85 | static void my_application_dispose(GObject* object) {
86 | MyApplication* self = MY_APPLICATION(object);
87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
89 | }
90 |
91 | static void my_application_class_init(MyApplicationClass* klass) {
92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate;
93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
95 | }
96 |
97 | static void my_application_init(MyApplication* self) {}
98 |
99 | MyApplication* my_application_new() {
100 | return MY_APPLICATION(g_object_new(my_application_get_type(),
101 | "application-id", APPLICATION_ID,
102 | "flags", G_APPLICATION_NON_UNIQUE,
103 | nullptr));
104 | }
105 |
--------------------------------------------------------------------------------
/example/windows/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # This file controls Flutter-level build steps. It should not be edited.
2 | cmake_minimum_required(VERSION 3.14)
3 |
4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
5 |
6 | # Configuration provided via flutter tool.
7 | include(${EPHEMERAL_DIR}/generated_config.cmake)
8 |
9 | # TODO: Move the rest of this into files in ephemeral. See
10 | # https://github.com/flutter/flutter/issues/57146.
11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
12 |
13 | # Set fallback configurations for older versions of the flutter tool.
14 | if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
15 | set(FLUTTER_TARGET_PLATFORM "windows-x64")
16 | endif()
17 |
18 | # === Flutter Library ===
19 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
20 |
21 | # Published to parent scope for install step.
22 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
23 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
24 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
25 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
26 |
27 | list(APPEND FLUTTER_LIBRARY_HEADERS
28 | "flutter_export.h"
29 | "flutter_windows.h"
30 | "flutter_messenger.h"
31 | "flutter_plugin_registrar.h"
32 | "flutter_texture_registrar.h"
33 | )
34 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
35 | add_library(flutter INTERFACE)
36 | target_include_directories(flutter INTERFACE
37 | "${EPHEMERAL_DIR}"
38 | )
39 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
40 | add_dependencies(flutter flutter_assemble)
41 |
42 | # === Wrapper ===
43 | list(APPEND CPP_WRAPPER_SOURCES_CORE
44 | "core_implementations.cc"
45 | "standard_codec.cc"
46 | )
47 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
48 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
49 | "plugin_registrar.cc"
50 | )
51 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
52 | list(APPEND CPP_WRAPPER_SOURCES_APP
53 | "flutter_engine.cc"
54 | "flutter_view_controller.cc"
55 | )
56 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
57 |
58 | # Wrapper sources needed for a plugin.
59 | add_library(flutter_wrapper_plugin STATIC
60 | ${CPP_WRAPPER_SOURCES_CORE}
61 | ${CPP_WRAPPER_SOURCES_PLUGIN}
62 | )
63 | apply_standard_settings(flutter_wrapper_plugin)
64 | set_target_properties(flutter_wrapper_plugin PROPERTIES
65 | POSITION_INDEPENDENT_CODE ON)
66 | set_target_properties(flutter_wrapper_plugin PROPERTIES
67 | CXX_VISIBILITY_PRESET hidden)
68 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
69 | target_include_directories(flutter_wrapper_plugin PUBLIC
70 | "${WRAPPER_ROOT}/include"
71 | )
72 | add_dependencies(flutter_wrapper_plugin flutter_assemble)
73 |
74 | # Wrapper sources needed for the runner.
75 | add_library(flutter_wrapper_app STATIC
76 | ${CPP_WRAPPER_SOURCES_CORE}
77 | ${CPP_WRAPPER_SOURCES_APP}
78 | )
79 | apply_standard_settings(flutter_wrapper_app)
80 | target_link_libraries(flutter_wrapper_app PUBLIC flutter)
81 | target_include_directories(flutter_wrapper_app PUBLIC
82 | "${WRAPPER_ROOT}/include"
83 | )
84 | add_dependencies(flutter_wrapper_app flutter_assemble)
85 |
86 | # === Flutter tool backend ===
87 | # _phony_ is a non-existent file to force this command to run every time,
88 | # since currently there's no way to get a full input/output list from the
89 | # flutter tool.
90 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
91 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
92 | add_custom_command(
93 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
94 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
95 | ${CPP_WRAPPER_SOURCES_APP}
96 | ${PHONY_OUTPUT}
97 | COMMAND ${CMAKE_COMMAND} -E env
98 | ${FLUTTER_TOOL_ENVIRONMENT}
99 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
100 | ${FLUTTER_TARGET_PLATFORM} $
101 | VERBATIM
102 | )
103 | add_custom_target(flutter_assemble DEPENDS
104 | "${FLUTTER_LIBRARY}"
105 | ${FLUTTER_LIBRARY_HEADERS}
106 | ${CPP_WRAPPER_SOURCES_CORE}
107 | ${CPP_WRAPPER_SOURCES_PLUGIN}
108 | ${CPP_WRAPPER_SOURCES_APP}
109 | )
110 |
--------------------------------------------------------------------------------
/example/windows/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Project-level configuration.
2 | cmake_minimum_required(VERSION 3.14)
3 | project(wireguard_dart_example LANGUAGES CXX)
4 |
5 | # The name of the executable created for the application. Change this to change
6 | # the on-disk name of your application.
7 | set(BINARY_NAME "wireguard_dart_example")
8 |
9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent
10 | # versions of CMake.
11 | cmake_policy(SET CMP0063 NEW)
12 |
13 | # Define build configuration option.
14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
15 | if(IS_MULTICONFIG)
16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
17 | CACHE STRING "" FORCE)
18 | else()
19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
20 | set(CMAKE_BUILD_TYPE "Debug" CACHE
21 | STRING "Flutter build mode" FORCE)
22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
23 | "Debug" "Profile" "Release")
24 | endif()
25 | endif()
26 | # Define settings for the Profile build mode.
27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
31 |
32 | # Use Unicode for all projects.
33 | add_definitions(-DUNICODE -D_UNICODE)
34 |
35 | # Compilation settings that should be applied to most targets.
36 | #
37 | # Be cautious about adding new options here, as plugins use this function by
38 | # default. In most cases, you should add new options to specific targets instead
39 | # of modifying this function.
40 | function(APPLY_STANDARD_SETTINGS TARGET)
41 | target_compile_features(${TARGET} PUBLIC cxx_std_17)
42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
43 | target_compile_options(${TARGET} PRIVATE /EHsc)
44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>")
46 | endfunction()
47 |
48 | # Flutter library and tool build rules.
49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
50 | add_subdirectory(${FLUTTER_MANAGED_DIR})
51 |
52 | # Application build; see runner/CMakeLists.txt.
53 | add_subdirectory("runner")
54 |
55 | # Generated plugin build rules, which manage building the plugins and adding
56 | # them to the application.
57 | include(flutter/generated_plugins.cmake)
58 |
59 |
60 | # === Installation ===
61 | # Support files are copied into place next to the executable, so that it can
62 | # run in place. This is done instead of making a separate bundle (as on Linux)
63 | # so that building and running from within Visual Studio will work.
64 | set(BUILD_BUNDLE_DIR "$")
65 | # Make the "install" step default, as it's required to run.
66 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
67 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
68 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
69 | endif()
70 |
71 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
72 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
73 |
74 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
75 | COMPONENT Runtime)
76 |
77 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
78 | COMPONENT Runtime)
79 |
80 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
81 | COMPONENT Runtime)
82 |
83 | if(PLUGIN_BUNDLED_LIBRARIES)
84 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
85 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
86 | COMPONENT Runtime)
87 | endif()
88 |
89 | # Fully re-copy the assets directory on each build to avoid having stale files
90 | # from a previous install.
91 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
92 | install(CODE "
93 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
94 | " COMPONENT Runtime)
95 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
96 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
97 |
98 | # Install the AOT library on non-Debug builds only.
99 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
100 | CONFIGURATIONS Profile;Release
101 | COMPONENT Runtime)
102 |
--------------------------------------------------------------------------------
/example/linux/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Project-level configuration.
2 | cmake_minimum_required(VERSION 3.10)
3 | project(runner LANGUAGES CXX)
4 |
5 | # The name of the executable created for the application. Change this to change
6 | # the on-disk name of your application.
7 | set(BINARY_NAME "wireguard_dart_example")
8 | # The unique GTK application identifier for this application. See:
9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID
10 | set(APPLICATION_ID "network.mysterium.wireguard_dart")
11 |
12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent
13 | # versions of CMake.
14 | cmake_policy(SET CMP0063 NEW)
15 |
16 | # Load bundled libraries from the lib/ directory relative to the binary.
17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
18 |
19 | # Root filesystem for cross-building.
20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT)
21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
27 | endif()
28 |
29 | # Define build configuration options.
30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
31 | set(CMAKE_BUILD_TYPE "Debug" CACHE
32 | STRING "Flutter build mode" FORCE)
33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
34 | "Debug" "Profile" "Release")
35 | endif()
36 |
37 | # Compilation settings that should be applied to most targets.
38 | #
39 | # Be cautious about adding new options here, as plugins use this function by
40 | # default. In most cases, you should add new options to specific targets instead
41 | # of modifying this function.
42 | function(APPLY_STANDARD_SETTINGS TARGET)
43 | target_compile_features(${TARGET} PUBLIC cxx_std_14)
44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror)
45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>")
46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>")
47 | endfunction()
48 |
49 | # Flutter library and tool build rules.
50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
51 | add_subdirectory(${FLUTTER_MANAGED_DIR})
52 |
53 | # System-level dependencies.
54 | find_package(PkgConfig REQUIRED)
55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
56 |
57 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
58 |
59 | # Define the application target. To change its name, change BINARY_NAME above,
60 | # not the value here, or `flutter run` will no longer work.
61 | #
62 | # Any new source files that you add to the application should be added here.
63 | add_executable(${BINARY_NAME}
64 | "main.cc"
65 | "my_application.cc"
66 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
67 | )
68 |
69 | # Apply the standard set of build settings. This can be removed for applications
70 | # that need different build settings.
71 | apply_standard_settings(${BINARY_NAME})
72 |
73 | # Add dependency libraries. Add any application-specific dependencies here.
74 | target_link_libraries(${BINARY_NAME} PRIVATE flutter)
75 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
76 |
77 | # Run the Flutter tool portions of the build. This must not be removed.
78 | add_dependencies(${BINARY_NAME} flutter_assemble)
79 |
80 | # Only the install-generated bundle's copy of the executable will launch
81 | # correctly, since the resources must in the right relative locations. To avoid
82 | # people trying to run the unbundled copy, put it in a subdirectory instead of
83 | # the default top-level location.
84 | set_target_properties(${BINARY_NAME}
85 | PROPERTIES
86 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
87 | )
88 |
89 | # Generated plugin build rules, which manage building the plugins and adding
90 | # them to the application.
91 | include(flutter/generated_plugins.cmake)
92 |
93 |
94 | # === Installation ===
95 | # By default, "installing" just makes a relocatable bundle in the build
96 | # directory.
97 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
98 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
99 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
100 | endif()
101 |
102 | # Start with a clean build bundle directory every time.
103 | install(CODE "
104 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
105 | " COMPONENT Runtime)
106 |
107 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
108 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
109 |
110 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
111 | COMPONENT Runtime)
112 |
113 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
114 | COMPONENT Runtime)
115 |
116 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
117 | COMPONENT Runtime)
118 |
119 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
120 | install(FILES "${bundled_library}"
121 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
122 | COMPONENT Runtime)
123 | endforeach(bundled_library)
124 |
125 | # Fully re-copy the assets directory on each build to avoid having stale files
126 | # from a previous install.
127 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
128 | install(CODE "
129 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
130 | " COMPONENT Runtime)
131 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
132 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
133 |
134 | # Install the AOT library on non-Debug builds only.
135 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
136 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
137 | COMPONENT Runtime)
138 | endif()
139 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # wireguard_flutter
2 |
3 | A flutter plugin to setup and control VPN connection via [Wireguard](https://www.wireguard.com/) tunnel.
4 |
5 | - [Usage](#usage)
6 | - [Initialize](#initialize)
7 | - [Connect](#connect)
8 | - [Disconnect](#disconnect)
9 | - [Stage](#stage)
10 | - [Supported Platforms](#supported-platforms)
11 | - [FAQ & Troubleshooting](#faq--troubleshooting)
12 |
13 | # Contributing to wireguard_flutter
14 |
15 | Thank you for your interest in contributing to wireguard_flutter! We appreciate your help in making this project better.
16 |
17 | Before you start contributing, please take a moment to read the following guidelines.
18 |
19 | ## How to Contribute
20 |
21 | 1. Fork the repository to your GitHub account.
22 | 2. Clone the forked repository to your local machine.
23 | 3. Create a new branch for your contribution:
24 | ```bash
25 | git checkout -b feature/your-feature-name
26 | ```
27 | 4. Make your changes and ensure that the code follows the project's coding standards.
28 | 5. Commit your changes with a descriptive commit message:
29 | ```bash
30 | git commit -m "Add your descriptive message here"
31 | ```
32 | 6. Push your changes to your forked repository:
33 | ```bash
34 | git push origin feature/your-feature-name
35 | ```
36 | 7. Open a pull request in the original repository and provide a detailed description of your changes.
37 |
38 |
39 | ## Usage
40 |
41 | To use this plugin, add `wireguard_flutter` or visit [Flutter Tutorial](https://flutterflux.com/).
42 |
43 | ```
44 | flutter pub add wireguard_flutter
45 | ```
46 |
47 | ### Initialize
48 |
49 | Initialize a wireguard instance with a valid name using `initialize`:
50 |
51 | ```dart
52 | final wireguard = WireGuardFlutter.instance;
53 |
54 | // initialize the interface
55 | await wireguard.initialize(interfaceName: 'wg0');
56 | ```
57 |
58 | and declare the `.conf` data:
59 | ```dart
60 | const String conf = '''[Interface]
61 | PrivateKey = 0IZmHsxiNQ54TsUs0EQ71JNsa5f70zVf1LmDvON1CXc=
62 | Address = 10.8.0.4/32
63 | DNS = 1.1.1.1
64 |
65 |
66 | [Peer]
67 | PublicKey = 6uZg6T0J1bHuEmdqPx8OmxQ2ebBJ8TnVpnCdV8jHliQ=
68 | PresharedKey = As6JiXcYcqwjSHxSOrmQT13uGVlBG90uXZWmtaezZVs=
69 | AllowedIPs = 0.0.0.0/0, ::/0
70 | PersistentKeepalive = 0
71 | Endpoint = 38.180.13.85:51820''';
72 | ```
73 |
74 | For more info on the configuration data, see [the documentation](https://man7.org/linux/man-pages/man8/wg-quick.8.html) with examples.
75 |
76 | ### Connect
77 |
78 | After initializing, connect using `startVpn`:
79 |
80 | ```dart
81 | await wireguard.startVpn(
82 | serverAddress: address, // the server address (e.g 'demo.wireguard.com:51820')
83 | wgQuickConfig: conf, // the quick-config file
84 | providerBundleIdentifier: 'com.example', // your app identifier
85 | );
86 | ```
87 |
88 | ### Disconnect
89 |
90 | After connecting, disconnect using `stopVpn`:
91 |
92 | ```dart
93 | await wireguard.stopVpn();
94 | ```
95 |
96 | ### Stage
97 |
98 | Listen to stage change using `vpnStageSnapshot`:
99 |
100 | ```dart
101 | wireguard.vpnStageSnapshot.listen((event) {
102 | debugPrint("status changed $event");
103 | });
104 | ```
105 |
106 | Or get the current stage using `getStage`:
107 |
108 | ```dart
109 | final stage = await wireguard.stage();
110 | ```
111 |
112 | The available stages are:
113 |
114 | | Code | Description |
115 | | ---- | ----------- |
116 | | connecting | The interface is connecting |
117 | | connected | The interface is connected |
118 | | disconnecting | The interface is disconnecting |
119 | | disconnected | The interface is disconnected |
120 | | waitingConnection | Waiting for a user interaction |
121 | | authenticating | Authenticating with the server |
122 | | reconnect | Reconnecting the the interface |
123 | | noConnection | Any connection has not been made |
124 | | preparing | Preparing to connect |
125 | | denied | The connection has been denied by the system, usually by refused permissions |
126 | | exiting | Exiting the interface |
127 |
128 | ## Supported Platforms
129 |
130 | | | Android | iOS | macOS | Windows | Linux |
131 | | ----------- | ------- | ----- | ----- | ------- | ----- |
132 | | **Version** | SDK 21+ | 15.0+ | 12+ | 7+ | Any |
133 |
134 |
135 | ### Windows
136 |
137 | On Windows, the app must be run as administrator to be able to create and manipulate the tunnel. To debug the app, run `flutter run` from an elevated command prompt. To run the app normally, the system will request your app to be run as administrator. No code changes or external dependencies are required.
138 |
139 | ### Linux
140 |
141 | #### Install dependencies
142 |
143 | The required dependencies need to be installed: `wireguard` and `wireguard-tools`.
144 |
145 | On Ubuntu/Debian, use the following command to install the dependencies:
146 |
147 | ```bash
148 | sudo apt install wireguard wireguard-tools openresolv
149 | ```
150 |
151 | For other Linux distros, see [this](https://www.wireguard.com/install/).
152 |
153 | > [!NOTE]
154 | >
155 | > If `openresolv` is not installed in the system, configuration files with a DNS provided may not connect. See [this issue](#linux-error-resolvconf-command-not-found) for more information.
156 |
157 | #### Initializing
158 |
159 | When `wireguard.initialize` is called, the application will request your user password (`[sudo] password for :`). This is necessary because wireguard must run as a root to be able to create AND manipulate the tunnels. This is true for either debug and release modes or a distributed executable.
160 |
161 | > [!CAUTION]
162 | >
163 | > Do not run the app in root mode (e.g `sudo ./executable`, `sudo flutter run`), otherwise the connection will not be established.
164 |
165 | ## FAQ & Troubleshooting
166 |
167 | ### Linux error `resolvconf: command not found`
168 |
169 | On Linux, you may receive the error `resolvconf: command not found`. This is because wireguard tried to adjust the nameserver. Make sure to install `openresolv` or not provide the "DNS" field.
170 |
171 | ---
172 |
173 | "WireGuard" is a registered trademark of Jason A. Donenfeld.
174 |
175 | Fork from [mysteriumnetwork](https://github.com/mysteriumnetwork/wireguard_dart/) tunnel.
176 |
177 | Many Thanks for [Bruno D'Luka](https://github.com/bdlukaa) for help me.
178 |
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/java,linux,macos,windows,android,intellij,androidstudio
3 | # Edit at https://www.gitignore.io/?templates=java,linux,macos,windows,android,intellij,androidstudio
4 |
5 | ### Android ###
6 | # Built application files
7 | *.apk
8 | *.ap_
9 | *.aab
10 |
11 | # Files for the ART/Dalvik VM
12 | *.dex
13 |
14 | # Java class files
15 | *.class
16 |
17 | # Generated files
18 | bin/
19 | gen/
20 | out/
21 |
22 | # Gradle files
23 | .gradle/
24 | build/
25 |
26 | # Local configuration file (sdk path, etc)
27 | local.properties
28 |
29 | # Proguard folder generated by Eclipse
30 | proguard/
31 |
32 | # Log Files
33 | *.log
34 |
35 | # Android Studio Navigation editor temp files
36 | .navigation/
37 |
38 | # Android Studio captures folder
39 | captures/
40 |
41 | # IntelliJ
42 | *.iml
43 | .idea/workspace.xml
44 | .idea/tasks.xml
45 | .idea/gradle.xml
46 | .idea/assetWizardSettings.xml
47 | .idea/dictionaries
48 | .idea/libraries
49 | .idea/caches
50 |
51 | # Keystore files
52 | # Uncomment the following lines if you do not want to check your keystore files in.
53 | #*.jks
54 | #*.keystore
55 |
56 | # External native build folder generated in Android Studio 2.2 and later
57 | .externalNativeBuild
58 |
59 | # Google Services (e.g. APIs or Firebase)
60 | google-services.json
61 |
62 | # Freeline
63 | freeline.py
64 | freeline/
65 | freeline_project_description.json
66 |
67 | # fastlane
68 | fastlane/report.xml
69 | fastlane/Preview.html
70 | fastlane/screenshots
71 | fastlane/test_output
72 | fastlane/readme.md
73 |
74 | ### Android Patch ###
75 | gen-external-apklibs
76 |
77 | ### AndroidStudio ###
78 | # Covers files to be ignored for android development using Android Studio.
79 |
80 | # Built application files
81 |
82 | # Files for the ART/Dalvik VM
83 |
84 | # Java class files
85 |
86 | # Generated files
87 |
88 | # Gradle files
89 | .gradle
90 |
91 | # Signing files
92 | .signing/
93 |
94 | # Local configuration file (sdk path, etc)
95 |
96 | # Proguard folder generated by Eclipse
97 |
98 | # Log Files
99 |
100 | # Android Studio
101 | /*/build/
102 | /*/local.properties
103 | /*/out
104 | /*/*/build
105 | /*/*/production
106 | *.ipr
107 | *~
108 | *.swp
109 |
110 | # Android Patch
111 |
112 | # External native build folder generated in Android Studio 2.2 and later
113 |
114 | # NDK
115 | obj/
116 |
117 | # IntelliJ IDEA
118 | *.iws
119 | /out/
120 |
121 | # User-specific configurations
122 | .idea/caches/
123 | .idea/libraries/
124 | .idea/shelf/
125 | .idea/.name
126 | .idea/compiler.xml
127 | .idea/copyright/profiles_settings.xml
128 | .idea/encodings.xml
129 | .idea/misc.xml
130 | .idea/modules.xml
131 | .idea/scopes/scope_settings.xml
132 | .idea/vcs.xml
133 | .idea/jsLibraryMappings.xml
134 | .idea/datasources.xml
135 | .idea/dataSources.ids
136 | .idea/sqlDataSources.xml
137 | .idea/dynamic.xml
138 | .idea/uiDesigner.xml
139 |
140 | # OS-specific files
141 | .DS_Store
142 | .DS_Store?
143 | ._*
144 | .Spotlight-V100
145 | .Trashes
146 | ehthumbs.db
147 | Thumbs.db
148 |
149 | # Legacy Eclipse project files
150 | .classpath
151 | .project
152 | .cproject
153 | .settings/
154 |
155 | # Mobile Tools for Java (J2ME)
156 | .mtj.tmp/
157 |
158 | # Package Files #
159 | *.war
160 | *.ear
161 |
162 | # virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
163 | hs_err_pid*
164 |
165 | ## Plugin-specific files:
166 |
167 | # mpeltonen/sbt-idea plugin
168 | .idea_modules/
169 |
170 | # JIRA plugin
171 | atlassian-ide-plugin.xml
172 |
173 | # Mongo Explorer plugin
174 | .idea/mongoSettings.xml
175 |
176 | # Crashlytics plugin (for Android Studio and IntelliJ)
177 | com_crashlytics_export_strings.xml
178 | crashlytics.properties
179 | crashlytics-build.properties
180 | fabric.properties
181 |
182 | ### AndroidStudio Patch ###
183 |
184 | !/gradle/wrapper/gradle-wrapper.jar
185 |
186 | ### Intellij ###
187 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
188 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
189 |
190 | # User-specific stuff
191 | .idea/**/workspace.xml
192 | .idea/**/tasks.xml
193 | .idea/**/usage.statistics.xml
194 | .idea/**/dictionaries
195 | .idea/**/shelf
196 |
197 | # Generated files
198 | .idea/**/contentModel.xml
199 |
200 | # Sensitive or high-churn files
201 | .idea/**/dataSources/
202 | .idea/**/dataSources.ids
203 | .idea/**/dataSources.local.xml
204 | .idea/**/sqlDataSources.xml
205 | .idea/**/dynamic.xml
206 | .idea/**/uiDesigner.xml
207 | .idea/**/dbnavigator.xml
208 |
209 | # Gradle
210 | .idea/**/gradle.xml
211 | .idea/**/libraries
212 |
213 | # Gradle and Maven with auto-import
214 | # When using Gradle or Maven with auto-import, you should exclude module files,
215 | # since they will be recreated, and may cause churn. Uncomment if using
216 | # auto-import.
217 | # .idea/modules.xml
218 | # .idea/*.iml
219 | # .idea/modules
220 |
221 | # CMake
222 | cmake-build-*/
223 |
224 | # Mongo Explorer plugin
225 | .idea/**/mongoSettings.xml
226 |
227 | # File-based project format
228 |
229 | # IntelliJ
230 |
231 | # mpeltonen/sbt-idea plugin
232 |
233 | # JIRA plugin
234 |
235 | # Cursive Clojure plugin
236 | .idea/replstate.xml
237 |
238 | # Crashlytics plugin (for Android Studio and IntelliJ)
239 |
240 | # Editor-based Rest Client
241 | .idea/httpRequests
242 |
243 | # Android studio 3.1+ serialized cache file
244 | .idea/caches/build_file_checksums.ser
245 |
246 | ### Intellij Patch ###
247 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
248 |
249 | # *.iml
250 | # modules.xml
251 | # .idea/misc.xml
252 | # *.ipr
253 |
254 | # Sonarlint plugin
255 | .idea/sonarlint
256 |
257 | ### Java ###
258 | # Compiled class file
259 |
260 | # Log file
261 |
262 | # BlueJ files
263 | *.ctxt
264 |
265 | # Mobile Tools for Java (J2ME)
266 |
267 | # Package Files #
268 | *.jar
269 | *.nar
270 | *.zip
271 | *.tar.gz
272 | *.rar
273 |
274 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
275 |
276 | ### Linux ###
277 |
278 | # temporary files which can be created if a process still has a handle open of a deleted file
279 | .fuse_hidden*
280 |
281 | # KDE directory preferences
282 | .directory
283 |
284 | # Linux trash folder which might appear on any partition or disk
285 | .Trash-*
286 |
287 | # .nfs files are created when an open file is removed but is still being accessed
288 | .nfs*
289 |
290 | ### macOS ###
291 | # General
292 | .AppleDouble
293 | .LSOverride
294 |
295 | # Icon must end with two \r
296 | Icon
297 |
298 | # Thumbnails
299 |
300 | # Files that might appear in the root of a volume
301 | .DocumentRevisions-V100
302 | .fseventsd
303 | .TemporaryItems
304 | .VolumeIcon.icns
305 | .com.apple.timemachine.donotpresent
306 |
307 | # Directories potentially created on remote AFP share
308 | .AppleDB
309 | .AppleDesktop
310 | Network Trash Folder
311 | Temporary Items
312 | .apdisk
313 |
314 | ### Windows ###
315 | # Windows thumbnail cache files
316 | ehthumbs_vista.db
317 |
318 | # Dump file
319 | *.stackdump
320 |
321 | # Folder config file
322 | [Dd]esktop.ini
323 |
324 | # Recycle Bin used on file shares
325 | $RECYCLE.BIN/
326 |
327 | # Windows Installer files
328 | *.cab
329 | *.msi
330 | *.msix
331 | *.msm
332 | *.msp
333 |
334 | # Windows shortcuts
335 | *.lnk
336 |
337 | # End of https://www.gitignore.io/api/java,linux,macos,windows,android,intellij,androidstudio
--------------------------------------------------------------------------------
/windows/wireguard_flutter_plugin.cpp:
--------------------------------------------------------------------------------
1 | #include "wireguard_flutter_plugin.h"
2 |
3 | // This must be included before many other Windows headers.
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | #include
15 | #include
16 |
17 | #include "config_writer.h"
18 | #include "service_control.h"
19 | #include "utils.h"
20 |
21 | using namespace flutter;
22 | using namespace std;
23 |
24 | namespace wireguard_flutter
25 | {
26 |
27 | // static
28 | void WireguardFlutterPlugin::RegisterWithRegistrar(PluginRegistrarWindows *registrar)
29 | {
30 | auto channel = make_unique>(
31 | registrar->messenger(), "billion.group.wireguard_flutter/wgcontrol", &StandardMethodCodec::GetInstance());
32 | auto eventChannel = make_unique>(
33 | registrar->messenger(), "billion.group.wireguard_flutter/wgstage", &StandardMethodCodec::GetInstance());
34 |
35 | auto plugin = make_unique();
36 |
37 | channel->SetMethodCallHandler([plugin_pointer = plugin.get()](const auto &call, auto result)
38 | { plugin_pointer->HandleMethodCall(call, move(result)); });
39 |
40 | auto eventsHandler = make_unique>(
41 | [plugin_pointer = plugin.get()](
42 | const EncodableValue *arguments,
43 | unique_ptr> &&events)
44 | -> unique_ptr>
45 | {
46 | return plugin_pointer->OnListen(arguments, move(events));
47 | },
48 | [plugin_pointer = plugin.get()](const EncodableValue *arguments)
49 | -> unique_ptr>
50 | {
51 | return plugin_pointer->OnCancel(arguments);
52 | });
53 |
54 | eventChannel->SetStreamHandler(move(eventsHandler));
55 |
56 | registrar->AddPlugin(move(plugin));
57 | }
58 |
59 | WireguardFlutterPlugin::WireguardFlutterPlugin() {}
60 |
61 | WireguardFlutterPlugin::~WireguardFlutterPlugin() {}
62 |
63 | void WireguardFlutterPlugin::HandleMethodCall(const MethodCall &call,
64 | unique_ptr> result)
65 | {
66 | const auto *args = get_if(call.arguments());
67 |
68 | if (call.method_name() == "initialize")
69 | {
70 | const auto *arg_service_name = get_if(ValueOrNull(*args, "win32ServiceName"));
71 | if (arg_service_name == NULL)
72 | {
73 | result->Error("Argument 'win32ServiceName' is required");
74 | return;
75 | }
76 | if (this->tunnel_service_ != nullptr)
77 | {
78 | this->tunnel_service_->service_name_ = Utf8ToWide(*arg_service_name);
79 | }
80 | else
81 | {
82 | this->tunnel_service_ = make_unique(Utf8ToWide(*arg_service_name));
83 | this->tunnel_service_->RegisterListener(move(events_));
84 | }
85 |
86 | result->Success();
87 | return;
88 | }
89 | else if (call.method_name() == "start")
90 | {
91 | auto tunnel_service = this->tunnel_service_.get();
92 | if (tunnel_service == nullptr)
93 | {
94 | result->Error("Invalid state: call 'initialize' first");
95 | return;
96 | }
97 | const auto *wgQuickConfig = get_if(ValueOrNull(*args, "wgQuickConfig"));
98 | if (wgQuickConfig == NULL)
99 | {
100 | result->Error("Argument 'wgQuickConfig' is required");
101 | return;
102 | }
103 |
104 | this->tunnel_service_->EmitState("prepare");
105 |
106 | wstring wg_config_filename;
107 | try
108 | {
109 | wg_config_filename = WriteConfigToTempFile(*wgQuickConfig);
110 | }
111 | catch (exception &e)
112 | {
113 | this->tunnel_service_->EmitState("no_connection");
114 | result->Error(string("Could not write wireguard config: ").append(e.what()));
115 | return;
116 | }
117 |
118 | wchar_t module_filename[MAX_PATH];
119 | GetModuleFileName(NULL, module_filename, MAX_PATH);
120 | auto current_exec_dir = wstring(module_filename);
121 | current_exec_dir = current_exec_dir.substr(0, current_exec_dir.find_last_of(L"\\/"));
122 | wostringstream service_exec_builder;
123 | service_exec_builder << current_exec_dir << "\\wireguard_svc.exe" << L" -service"
124 | << L" -config-file=\"" << wg_config_filename << "\"";
125 | wstring service_exec = service_exec_builder.str();
126 | cout << "Starting service with command line: " << WideToAnsi(service_exec) << endl;
127 | try
128 | {
129 | CreateArgs csa;
130 | csa.description = tunnel_service->service_name_ + L" WireGuard tunnel";
131 | csa.executable_and_args = service_exec;
132 | csa.dependencies = L"Nsi\0TcpIp\0";
133 | csa.first_time = true;
134 |
135 | tunnel_service->CreateAndStart(csa);
136 | }
137 | catch (exception &e)
138 | {
139 | result->Error(string(e.what()));
140 | return;
141 | }
142 |
143 | result->Success();
144 | return;
145 | }
146 | else if (call.method_name() == "stop")
147 | {
148 | auto tunnel_service = this->tunnel_service_.get();
149 | if (tunnel_service == nullptr)
150 | {
151 | result->Error("Invalid state: call 'initialize' first");
152 | return;
153 | }
154 |
155 | try
156 | {
157 | tunnel_service->Stop();
158 | }
159 | catch (exception &e)
160 | {
161 | result->Error(string(e.what()));
162 | }
163 |
164 | result->Success();
165 | return;
166 | }
167 | else if (call.method_name() == "stage")
168 | {
169 | auto tunnel_service = this->tunnel_service_.get();
170 | if (tunnel_service == nullptr)
171 | {
172 | result->Error("Invalid state: call 'initialize' first");
173 | return;
174 | }
175 |
176 | result->Success(tunnel_service->GetStatus());
177 | return;
178 | }
179 |
180 | result->NotImplemented();
181 | }
182 |
183 | unique_ptr> WireguardFlutterPlugin::OnListen(
184 | const EncodableValue *arguments,
185 | unique_ptr> &&events)
186 | {
187 | events_ = move(events);
188 | auto tunnel_service = this->tunnel_service_.get();
189 | if (tunnel_service != nullptr)
190 | {
191 | tunnel_service->RegisterListener(move(events_));
192 | return nullptr;
193 | }
194 |
195 | return nullptr;
196 | }
197 |
198 | unique_ptr> WireguardFlutterPlugin::OnCancel(
199 | const EncodableValue *arguments)
200 | {
201 | events_ = nullptr;
202 | auto tunnel_service = this->tunnel_service_.get();
203 | if (tunnel_service != nullptr)
204 | {
205 | tunnel_service->UnregisterListener();
206 | return nullptr;
207 | }
208 |
209 | return nullptr;
210 | }
211 |
212 | } // namespace wireguard_flutter
213 |
--------------------------------------------------------------------------------
/example/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 |
3 | import 'package:flutter/material.dart';
4 | import 'package:flutter/services.dart';
5 | import 'package:wireguard_flutter/wireguard_flutter.dart';
6 |
7 | void main() {
8 | runApp(
9 | MaterialApp(
10 | home: Scaffold(
11 | appBar: AppBar(
12 | title: const Text('WireGuard Example App'),
13 | ),
14 | body: const MyApp(),
15 | ),
16 | ),
17 | );
18 | }
19 |
20 | class MyApp extends StatefulWidget {
21 | const MyApp({super.key});
22 |
23 | @override
24 | State createState() => _MyAppState();
25 | }
26 |
27 | class _MyAppState extends State {
28 | final wireguard = WireGuardFlutter.instance;
29 | final WireguardService _wireguardService = WireguardService();
30 | String _downloadCount = 'N/A';
31 | String _uploadCount = 'N/A';
32 | late String name;
33 |
34 | @override
35 | void initState() {
36 | super.initState();
37 | _getWireGuardDataCounts();
38 | wireguard.vpnStageSnapshot.listen((event) {
39 | debugPrint("status changed $event");
40 | if (mounted) {
41 | ScaffoldMessenger.of(context).clearSnackBars();
42 | ScaffoldMessenger.of(context).showSnackBar(SnackBar(
43 | content: Text('status changed: $event'),
44 | ));
45 | }
46 | });
47 | name = 'my_wg_vpn';
48 | }
49 |
50 | Future initialize() async {
51 | try {
52 | await wireguard.initialize(interfaceName: name);
53 | debugPrint("initialize success $name");
54 | } catch (error, stack) {
55 | debugPrint("failed to initialize: $error\n$stack");
56 | }
57 | }
58 |
59 | void _getWireGuardDataCounts() async {
60 | try {
61 | final dataCounts = await _wireguardService.getDataCounts();
62 | setState(() {
63 | _downloadCount = dataCounts['download'].toString();
64 | _uploadCount = dataCounts['upload'].toString();
65 | });
66 | } catch (e) {
67 | print('Failed to get data counts: $e');
68 | }
69 | }
70 |
71 | void startVpn() async {
72 | try {
73 | await wireguard.startVpn(
74 | serverAddress: '167.235.55.239:51820',
75 | wgQuickConfig: conf,
76 | providerBundleIdentifier: 'com.billion.wireguardvpn.WGExtension',
77 | );
78 | } catch (error, stack) {
79 | debugPrint("failed to start $error\n$stack");
80 | }
81 | }
82 |
83 | void disconnect() async {
84 | try {
85 | await wireguard.stopVpn();
86 | } catch (e, str) {
87 | debugPrint('Failed to disconnect $e\n$str');
88 | }
89 | }
90 |
91 | void getStatus() async {
92 | debugPrint("getting stage");
93 | final stage = await wireguard.stage();
94 | debugPrint("stage: $stage");
95 |
96 | if (mounted) {
97 | ScaffoldMessenger.of(context).showSnackBar(SnackBar(
98 | content: Text('stage: $stage'),
99 | ));
100 | }
101 | }
102 |
103 | @override
104 | Widget build(BuildContext context) {
105 | return Container(
106 | constraints: const BoxConstraints.expand(),
107 | padding: const EdgeInsets.all(16),
108 | child: Column(
109 | mainAxisAlignment: MainAxisAlignment.center,
110 | crossAxisAlignment: CrossAxisAlignment.center,
111 | children: [
112 | const SizedBox(height: 20),
113 | TextButton(
114 | onPressed: initialize,
115 | style: ButtonStyle(
116 | minimumSize: WidgetStateProperty.all(const Size(100, 50)),
117 | padding: WidgetStateProperty.all(
118 | const EdgeInsets.fromLTRB(20, 15, 20, 15)),
119 | backgroundColor:
120 | WidgetStateProperty.all(Colors.blueAccent),
121 | overlayColor: MaterialStateProperty.all(
122 | Colors.white.withOpacity(0.1))),
123 | child: const Text(
124 | 'initialize',
125 | style: TextStyle(color: Colors.white),
126 | ),
127 | ),
128 | const SizedBox(height: 20),
129 | TextButton(
130 | onPressed: startVpn,
131 | style: ButtonStyle(
132 | minimumSize:
133 | MaterialStateProperty.all(const Size(100, 50)),
134 | padding: MaterialStateProperty.all(
135 | const EdgeInsets.fromLTRB(20, 15, 20, 15)),
136 | backgroundColor:
137 | MaterialStateProperty.all(Colors.blueAccent),
138 | overlayColor: MaterialStateProperty.all(
139 | Colors.white.withOpacity(0.1))),
140 | child: const Text(
141 | 'Connect',
142 | style: TextStyle(color: Colors.white),
143 | ),
144 | ),
145 | const SizedBox(height: 20),
146 | TextButton(
147 | onPressed: disconnect,
148 | style: ButtonStyle(
149 | minimumSize: WidgetStateProperty.all(const Size(100, 50)),
150 | padding: WidgetStateProperty.all(
151 | const EdgeInsets.fromLTRB(20, 15, 20, 15)),
152 | backgroundColor:
153 | WidgetStateProperty.all(Colors.blueAccent),
154 | overlayColor: WidgetStateProperty.all(
155 | Colors.white.withOpacity(0.1))),
156 | child: const Text(
157 | 'Disconnect',
158 | style: TextStyle(color: Colors.white),
159 | ),
160 | ),
161 | const SizedBox(height: 20),
162 | TextButton(
163 | onPressed: getStatus,
164 | style: ButtonStyle(
165 | minimumSize: WidgetStateProperty.all(const Size(100, 50)),
166 | padding: WidgetStateProperty.all(
167 | const EdgeInsets.fromLTRB(20, 15, 20, 15)),
168 | backgroundColor:
169 | WidgetStateProperty.all(Colors.blueAccent),
170 | overlayColor: WidgetStateProperty.all(
171 | Colors.white.withOpacity(0.1))),
172 | child: const Text(
173 | 'Get status',
174 | style: TextStyle(color: Colors.white),
175 | ),
176 | ),
177 | Column(
178 | mainAxisAlignment: MainAxisAlignment.center,
179 | crossAxisAlignment: CrossAxisAlignment.center,
180 | children: [
181 | Text('Download: $_downloadCount'),
182 | Text('Upload: $_uploadCount'),
183 | ElevatedButton(
184 | onPressed: _getWireGuardDataCounts,
185 | child: const Text('Refresh Data Counts'),
186 | ),
187 | ],
188 | )
189 | ],
190 | ),
191 | );
192 | }
193 | }
194 |
195 | const String conf = '''[Interface]
196 | Address = 192.168.6.163/32
197 | DNS = 1.1.1.1,8.8.8.8
198 | PrivateKey = mBVsI8hk7a1JPJqXuVELOTnSSI2tL6Q4HamW5gxEgEk=
199 | [Peer]
200 | publickey=MKxF3963hjD/MLGSIcGRLaco/N5uDN/Dslt/k675Knc=
201 | AllowedIPs = 0.0.0.0/0, ::/0
202 | Endpoint = indo7.vpnjantit.com:1024
203 | ''';
204 |
205 | class WireguardService {
206 | static const platform =
207 | MethodChannel('billion.group.wireguard_flutter/wgcontrol');
208 |
209 | Future