V2Ray class
Engine that manages a V2Ray / Xray VPN connection.
Usage
final engine = V2Ray(
onVpnStageChanged: (stage, raw) => print(stage),
onVpnStatusChanged: (status) => print(status),
);
await engine.initialize();
await engine.connect(configJson, 'My Server');
Constructors
- V2Ray({dynamic onVpnStatusChanged(V2RayStatus? data)?, dynamic onVpnStageChanged(V2RayStage stage, String rawStage)?})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- initialized ↔ bool
-
getter/setter pair
- onVpnStageChanged → dynamic Function(V2RayStage stage, String rawStage)?
-
final
- onVpnStatusChanged → dynamic Function(V2RayStatus? data)?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
connect(
String configJson, String name, {V2RaySubProtocol subProtocol = V2RaySubProtocol.vless, List< String> ? bypassPackages}) → Future<void> - Connect using a V2Ray/Xray JSON configuration string.
-
disconnect(
) → Future< void> - Disconnect the active V2Ray tunnel.
-
initialize(
{String? providerBundleIdentifier, String? localizedDescription, String? groupIdentifier, dynamic lastStatus(V2RayStatus status)?, dynamic lastStage(V2RayStage stage)?}) → Future< void> - Initialize the engine. Must be called before connect.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
stage(
) → Future< V2RayStage> - Returns the current V2RayStage by querying the native side.
-
status(
) → Future< V2RayStatus> - Returns the current V2RayStatus by querying the native side.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
buildShadowsocksConfig(
{required String address, required int port, required String password, String method = 'aes-256-gcm'}) → String - Build a Shadowsocks JSON config string.
-
buildTrojanConfig(
{required String address, required int port, required String password, String? serverName, bool allowInsecure = false}) → String - Build a minimal Trojan JSON config string.
-
buildVlessConfig(
{required String address, required int port, required String uuid, String flow = 'xtls-rprx-vision', String network = 'tcp', String security = 'reality', String? serverName, String? publicKey, String? shortId}) → String - Build a minimal VLESS-over-Reality JSON config string.
-
buildVmessConfig(
{required String address, required int port, required String uuid, int alterId = 0, String network = 'tcp', String security = 'tls', String? serverName, String? path}) → String - Build a minimal VMess JSON config string.