# Package com.codename1.vpn

package com.codename1.vpn

Installing and controlling a VPN configuration.

##### What is realistic here, and what is not

There are two very different things called "VPN support", and conflating them wastes a lot of time:

- Asking the operating system to run a standard tunnel -- an IKEv2 or IPsec configuration the platform itself implements. Portable, needs a capability any paid developer account can switch on, and is what almost every app that says "connect to VPN" actually wants. That is `com.codename1.vpn.profile`.
- Shipping a tunnel of your own, which receives raw IP packets and decides what to do with them. That is a much larger commitment: on iOS it runs in a Network Extension, a separate process with its own bundle, and its entitlement -- `com.apple.developer.networking.networkextension` -- is one Apple grants case by case rather than one a paid account switches on; on Android it is a `VpnService` in the app's own process. The two platforms hand packets over differently, so any portable shape has to expose that difference rather than hide it.

##### Detecting a VPN is a different question and already answered

`com.codename1.io.NetworkManager#isVPNActive()` reports whether any VPN is carrying this device's traffic, works on far more platforms than can install one, and needs no entitlement. An app that only wants to refuse to run behind a VPN, or to warn about one, should use that and reference nothing here.

This package itself holds only the shared value types -- `VpnStatus`, `VpnError`, `VpnException` and `VpnProtocol`. Referencing it alone costs nothing.

- Related Packages
  Package
  Description
  com.codename1.vpn.profile
  Asking the operating system to run a standard VPN tunnel.
  com.codename1.vpn.spi
  The seam between the portable `com.codename1.vpn` API and each platform's native VPN machinery.
  com.codename1.vpn.tunnel
  Writing the tunnel itself, rather than asking the system to run one.
- Class
  Description
  VpnError
  Typed error codes carried by `VpnException`.
  VpnException
  Thrown through the failure path of every `AsyncResource` returned by the `com.codename1.vpn` APIs.
  VpnProtocol
  The tunnelling protocol a configuration uses.
  VpnStatus
  Where a VPN connection is in its life.