OpenVPN transport
Last updated
Last updated
If your Android project meets the following conditions:
Target SDK is 29 or higher
Uses Google App Bundle for application distribution
Then you need to add the following line to your gradle.properties
file to ensure OpenVPN transport works on Android 10 (Q) (API 29) and later versions:
If you are not using Google App Bundle for your application distribution, you can skip this step, as it is not required.
To add support for OpenVPN, you need to include both the core SDK and OpenVPN transport SDK in your build.gradle
file:
sdk-core
: This is the core VPN SDK.
sdk-openvpn
: This adds OpenVPN support to your app.
Next, you need to register OpenVPN as a supported transport protocol with the SDK. You can register both Hydra and OpenVPN, or just one, depending on your requirements:
HydraTransportConfig.create()
: Registers Hydra transport (default).
OpenVpnTransportConfig.tcp()
: Registers OpenVPN using TCP as the transport protocol.
UnifiedSDK.update()
: Updates the SDK with the registered transport protocols.
You can register both Hydra and OpenVPN transports or just one of them.
3. When starting a VPN session, you can specify which transport protocol to use (Hydra or OpenVPN). Here’s how to specify OpenVPN (TCP) when starting the VPN:
SessionConfig.Builder()
: Creates a configuration for the VPN session.
withLocation()
: Specifies the VPN location (e.g., COUNTRY_OPTIMAL selects the best available server).
withReason()
: Provides a reason for starting the VPN session (for analytics purposes).
withTransport()
: Specifies the transport protocol to be used (OpenVPN TCP in this case).
sdk.getVpn().start()
: Starts the VPN session with the specified configuration.