VPN Client Controller Flutter is a Flutter wrapper for managing VPN connections with an intuitive API. It provides seamless integration with various platforms, allowing developers to control VPN connections efficiently.
- iOS 15+ (iPhone, iPad, MacOS M)
- Android
- ποΈ MacOS Intel (coming soon)
- ποΈ Windows (coming soon)
- ποΈ Ubuntu (coming soon)
To start using VPN Client Controller Flutter, ensure you have Flutter installed and set up your project accordingly.
flutter pub add vpnclient_controller
// Initialize the controller
vpnController.initialize();
// Load subscription
vpnController.loadSubscription(
subscriptionLink: "https://pastebin.com/raw/ZCYiJ98W"
);
// Connect to a VPN server
vpnController.connect(index: 1);
// Listen for connection status changes
vpnController.onConnectionStatusChanged.listen((status) {
print("Connection status: $status");
});
// Set routing rules
vpnController.setRoutingRules(
rules: [
RoutingRule(appName: "YouTube", action: "routeThroughVPN"),
RoutingRule(domain: "ads.com", action: "block"),
],
);
// Ping a server
vpnController.pingServer(index: 1);
vpnController.onPingResult.listen((result) {
print("Ping result: ${result.latencyInMs} ms");
});
Initializes the VPN controller. This should be called before using any other method.
Connects to the specified VPN server.
index
: Index of the server fromgetServerList()
.
Disconnects the active VPN connection.
Returns the current connection status (connected
, disconnected
, connecting
, error
).
Fetches the list of available VPN servers.
Pings a specific server to check latency.
index
: Index of the server fromgetServerList()
.- Returns: Latency in milliseconds.
Configures routing rules for apps or domains.
rules
: List of routing rules (e.g., route YouTube traffic through VPN, block ads.com).
Loads a VPN subscription from the provided link.
subscriptionLink
: The subscription file URL.
Returns statistics for the current VPN session (e.g., data usage, session duration).
Enables or disables auto-connect functionality.
enable
:true
to enable,false
to disable.
Enables or disables the kill switch.
enable
:true
to enable,false
to disable.
Triggered when VPN connection status changes.
- Payload:
ConnectionStatus
(e.g.,connected
,disconnected
,error
).
Triggered when an error occurs.
- Payload:
ErrorCode
andErrorMessage
.
Triggered when the VPN server is switched.
- Payload:
newServerAddress
.
Triggered when a ping operation completes.
- Payload:
serverIndex
andlatencyInMs
.
Triggered when a subscription is loaded successfully.
- Payload:
subscriptionDetails
.
Triggered periodically with updated data usage statistics.
- Payload:
dataUsed
anddataRemaining
.
Triggered when routing rules are applied.
- Payload:
List<RoutingRule>
.
Triggered when the kill switch is activated.
Enum: connecting
, connected
, disconnected
, error
.
address
latency
location
isPreferred
appName
domain
action
(block
,allow
,routeThroughVPN
).
type
(socks5
,http
)address
port
credentials
Enum: invalidCredentials
, serverUnavailable
, subscriptionExpired
, unknownError
.
expiryDate
dataLimit
usedData
Contributions are welcome! Feel free to submit issues and pull requests.
This project is licensed under ...