API
βοΈ Methods
πΉ 1. initialize()
Initializes the VPN controller. This should be called before using any other method.
πΉ 2. connect({required int index})
Connects to the specified VPN server.
index: Index of the server fromgetServerList().
πΉ 3. disconnect()
Disconnects the active VPN connection.
πΉ 4. getConnectionStatus()
Returns the current connection status (connected, disconnected, connecting, error).
πΉ 5. getServerList()
Fetches the list of available VPN servers.
πΉ 6. pingServer({required int index})
Pings a specific server to check latency.
index: Index of the server fromgetServerList().Returns: Latency in milliseconds.
πΉ 7. setRoutingRules({required List rules})
Configures routing rules for apps or domains.
rules: List of routing rules (e.g., route YouTube traffic through VPN, block ads.com).
πΉ 8. loadSubscription({required String subscriptionLink})
Loads a VPN subscription from the provided link.
subscriptionLink: The subscription file URL.
πΉ 9. getSessionStatistics()
Returns statistics for the current VPN session (e.g., data usage, session duration).
πΉ 10. setAutoConnect({required bool enable})
Enables or disables auto-connect functionality.
enable:trueto enable,falseto disable.
πΉ 11. setKillSwitch({required bool enable})
Enables or disables the kill switch.
enable:trueto enable,falseto disable.
π Events
π‘ 1. onConnectionStatusChanged
Triggered when VPN connection status changes.
Payload:
ConnectionStatus(e.g.,connected,disconnected,error).
β οΈ 2. onError
Triggered when an error occurs.
Payload:
ErrorCodeandErrorMessage.
π 3. onServerSwitched
Triggered when the VPN server is switched.
Payload:
newServerAddress.
π 4. onPingResult
Triggered when a ping operation completes.
Payload:
serverIndexandlatencyInMs.
π 5. onSubscriptionLoaded
Triggered when a subscription is loaded successfully.
Payload:
subscriptionDetails.
π 6. onDataUsageUpdated
Triggered periodically with updated data usage statistics.
Payload:
dataUsedanddataRemaining.
π 7. onRoutingRulesApplied
Triggered when routing rules are applied.
Payload:
List<RoutingRule>.
π¨ 8. onKillSwitchTriggered
Triggered when the kill switch is activated.
π Data Models
πΉ 1. ConnectionStatus
Enum: connecting, connected, disconnected, error.
πΉ 2. Server
addresslatencylocationisPreferred
πΉ 3. RoutingRule
appNamedomainaction(block,allow,routeThroughVPN).
πΉ 4. ProxyConfig
type(socks5,http)addressportcredentials
πΉ 5. ErrorCode
Enum: invalidCredentials, serverUnavailable, subscriptionExpired, unknownError.
πΉ 6. SubscriptionDetails
expiryDatedataLimitusedData
Last updated