|
|
|
@ -9,6 +9,21 @@ local function is_vpn_connected()
|
|
|
|
|
return (status == 0) and "Connected" or "Disconnected"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Function to get RX and TX statistics for tun0
|
|
|
|
|
local function get_vpn_traffic()
|
|
|
|
|
local rx, tx = "N/A", "N/A"
|
|
|
|
|
local f = io.popen("ifconfig tun0 | grep 'RX bytes' 2>/dev/null")
|
|
|
|
|
if f then
|
|
|
|
|
local output = f:read("*a")
|
|
|
|
|
f:close()
|
|
|
|
|
if output then
|
|
|
|
|
rx = output:match("RX bytes:(%d+)") or "N/A"
|
|
|
|
|
tx = output:match("TX bytes:(%d+)") or "N/A"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return rx, tx
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Define the model
|
|
|
|
|
m = Map("tgopenvpn_cfg", "TorGuard OpenVPN Setup")
|
|
|
|
|
|
|
|
|
@ -20,6 +35,14 @@ status_section.addremove = false
|
|
|
|
|
status = status_section:option(DummyValue, "_vpn_status", translate("VPN Status"))
|
|
|
|
|
status.value = is_vpn_connected()
|
|
|
|
|
|
|
|
|
|
-- VPN Traffic Stats
|
|
|
|
|
rx, tx = get_vpn_traffic()
|
|
|
|
|
rx_stat = status_section:option(DummyValue, "_vpn_rx", translate("RX Bytes"))
|
|
|
|
|
rx_stat.value = rx .. " Bytes"
|
|
|
|
|
|
|
|
|
|
tx_stat = status_section:option(DummyValue, "_vpn_tx", translate("TX Bytes"))
|
|
|
|
|
tx_stat.value = tx .. " Bytes"
|
|
|
|
|
|
|
|
|
|
-- Define the section for the OpenVPN settings
|
|
|
|
|
s = m:section(TypedSection, "ovpnconfig", "OpenVPN Settings")
|
|
|
|
|
s.anonymous = true
|
|
|
|
|