Skip to content

Commit

Permalink
Use CharonErrorState instead of CharonVpnState
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrysbita committed Nov 23, 2019
1 parent 9e54ded commit c8a7ec9
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 39 deletions.
52 changes: 31 additions & 21 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
## 0.6.0
- Update to StrongSwan 5.8.1.
- Use original notification from StrongSwan frontend.
- Automatically retry when a error occured.

**BreakingChange**

- In order to compatible with original `VpnStateService`, `CharonVpnState` has been changed to `CharonErrorState` that shows detail kind of error when a generic error is received.

## 0.5.0
Fix (#15) event handler for android (Flutter 1.6+).
- Fix (#15) event handler for android (Flutter 1.6+).

## 0.4.0
Fix state error if disconnect while connecting.
Add iOS state handler.
- Fix state error if disconnect while connecting.
- Add iOS state handler.

## 0.3.0
Add `getVpnState` for iOS.
- Add `getVpnState` for iOS.

## 0.2.0
Add `getVpnState` and `getCharonState` for Android.
**Breaking Change**
Old `FlutterVpnState` has been renamed to `CharonVpnState`. This method is for Android only.
New `FlutterVpnState` is designed for both Android and iOS platform.
- Add `getVpnState` and `getCharonState` for Android.

**Breaking Change**

- Old `FlutterVpnState` has been renamed to `CharonVpnState` which is for Android only. New `FlutterVpnState` is designed for both Android and iOS platform.

## 0.1.0
### Support `arm64-v8a` for android
We have added the libraries for `arm64-v8a`.
Please follow `README` to configure abiFilter for NDK.
### Migrate to AndroidX
**Breaking Change**
Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to also migrate if they're using the original support library.
Follow [Official documents](https://developer.android.com/jetpack/androidx/migrate) to migrate.
- Support `arm64-v8a` for android. Please follow `README` to configure abiFilter for NDK.

**Breaking Change**

- Migrate to AndroidX

> Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to also migrate if they're using the original support library.
> Follow [Official documents](https://developer.android.com/jetpack/androidx/migrate) to migrate.
## 0.0.4
Add iOS support without status broadcast.
- Add iOS support without status broadcast.

## 0.0.3
Add `onStateChanged` to receive state changes from charon.
- Add `onStateChanged` to receive state changes from charon.

## 0.0.2
(Deprecated)
Implemented simplest IkeV2-eap VPN service.
Automatically download native libs before building.
## 0.0.2 (Deprecated)
- Implemented simplest IkeV2-eap VPN service.
- Automatically download native libs before building.
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class _MyAppState extends State<MyApp> {
final _passwordController = TextEditingController();

var state = FlutterVpnState.disconnected;
var charonState = CharonVpnErrorState.NO_ERROR;
var charonState = CharonErrorState.NO_ERROR;

@override
void initState() {
Expand Down
31 changes: 15 additions & 16 deletions lib/flutter_vpn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ enum FlutterVpnState {
genericError
}

/// The VPN state for `CharonVpnService`.
/// The error state from `VpnStateService`.
/// Only available for Android device.
enum CharonVpnErrorState {
enum CharonErrorState {
NO_ERROR,
AUTH_FAILED,
PEER_AUTH_FAILED,
Expand All @@ -42,7 +42,7 @@ enum CharonVpnErrorState {
}

class FlutterVpn {
/// Receive state change from charon VPN service.
/// Receive state change from VPN service.
///
/// Can only be listened once.
/// If have more than one subscription, only the last subscription can receive
Expand All @@ -52,17 +52,16 @@ class FlutterVpn {
.map((e) => FlutterVpnState.values[e]);

/// Get current state.
static Future<FlutterVpnState> get currentState async {
var state = await _channel.invokeMethod<int>('getCurrentState');
return FlutterVpnState.values[state];
}
static Future<FlutterVpnState> get currentState async => FlutterVpnState
.values[await _channel.invokeMethod<int>('getCurrentState')];

/// Get current error state from `CharonVpnStateService`.
/// Only available for Android devices.
static Future<CharonVpnErrorState> get charonErrorState async {
/// Get current error state from `VpnStateService`. (Android only)
/// When [FlutterVpnState.genericError] is received, details of error can be
/// inspected by [CharonErrorState].
static Future<CharonErrorState> get charonErrorState async {
if (!Platform.isAndroid) throw Exception('Unsupport Platform');
var state = await _channel.invokeMethod<int>('getCharonErrorState');
return CharonVpnErrorState.values[state];
return CharonErrorState.values[state];
}

/// Prepare for vpn connection. (Android only)
Expand All @@ -77,6 +76,11 @@ class FlutterVpn {
return await _channel.invokeMethod('prepare');
}

/// Disconnect and stop VPN service.
static Future<Null> disconnect() async {
await _channel.invokeMethod('disconnect');
}

/// Connect to VPN.
///
/// Use given credentials to connect VPN (ikev2-eap).
Expand All @@ -86,9 +90,4 @@ class FlutterVpn {
await _channel.invokeMethod('connect',
{'address': address, 'username': username, 'password': password});
}

/// Disconnect will stop current VPN service.
static Future<Null> disconnect() async {
await _channel.invokeMethod('disconnect');
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_vpn
description: Plugin for developers to access VPN service in their flutter app.
version: 0.5.0
version: 0.6.0
authors:
- Jason C.H <[email protected]>
- Jerry Wang <[email protected]>
Expand Down

0 comments on commit c8a7ec9

Please sign in to comment.