Skip to main content

Get the selected VPN profile (vpnconf.selected)

Declaration​

local vpnID = vpnconf.selected()  -- vpnconf 0.8+

Returns​

Returns the VPNID string of the regular VPN profile saved as enabled by the system. Compare it directly with a VPNID from vpnconf.list(). Returns nil if no profile is selected or the read fails.

Example​

When switching profiles in sequence, wait for each selection to take effect before making the next one. selected() reports the saved selection at the time of the query. A later save can change it. Use vpnconf.status() to check whether the tunnel is connected.

local function selectAndConfirm(vpnID)
if not vpnconf.select(vpnID) then return false end
local deadline = sys.mtime() + 3000
repeat
if vpnconf.selected() == vpnID then return true end
sys.msleep(100)
until sys.mtime() >= deadline
return false
end