OpenConnect class

Engine that manages an OpenConnect (ocserv / Cisco AnyConnect-compatible) VPN connection lifecycle.

Usage

final oc = OpenConnect(
  onVpnStageChanged: (stage, raw) => print(stage),
  onVpnStatusChanged: (status) => print(status),
);
await oc.initialize();
await oc.connect(
  serverUrl: 'https://vpn.example.com',
  username: 'user',
  password: 'pass',
  name: 'My OpenConnect VPN',
);

Constructors

OpenConnect({dynamic onVpnStatusChanged(OpenConnectStatus? data)?, dynamic onVpnStageChanged(OCStage stage, String rawStage)?})

Properties

hashCode int
The hash code for this object.
no setterinherited
initialized bool
getter/setter pair
onVpnStageChanged → dynamic Function(OCStage stage, String rawStage)?
final
onVpnStatusChanged → dynamic Function(OpenConnectStatus? data)?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

connect({required String serverUrl, required String name, String? username, String? password, String? certPath, String? certPassword, String? caPath, String? authGroup, String? servercert, OCAuthMethod authMethod = OCAuthMethod.password, List<String>? bypassPackages}) Future<void>
Connect to an OpenConnect / ocserv gateway.
disconnect() Future<void>
Gracefully disconnect the active OpenConnect tunnel.
initialize({String? providerBundleIdentifier, String? localizedDescription, String? groupIdentifier, dynamic lastStatus(OpenConnectStatus status)?, dynamic lastStage(OCStage stage)?}) Future<void>
Initialize the engine. Must be called once before connect.
isServiceRunning() Future<bool>
Returns true if the native OC foreground service is still running. Useful on app restart to detect if a previous OC session is still active.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
stage() Future<OCStage>
Returns the current OCStage by querying the native side.
status() Future<OpenConnectStatus>
Returns the current OpenConnectStatus by querying the native side.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited