1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

luci-app-status first modifications

This commit is contained in:
Ycarus (Yannick Chabanois) 2022-09-28 19:50:50 +02:00
parent 09977d0f5a
commit 2112c8c9be
3 changed files with 1193 additions and 2 deletions

View file

@ -9,9 +9,9 @@ module("luci.controller.status", package.seeall)
function index()
entry({"admin", "system", "status"}, alias("admin", "system", "status", "server"), _("Settings"), 1)
entry({"admin", "system", "status","server"}, template("status/server"),_('Settings'),1).leaf = true
-- entry({"admin", "system", "status","server"}, template("status/server"),_('Settings'),1).leaf = true
entry({"admin", "system", "status","status"}, template("status/wanstatus"),_('Status'),2).leaf = true
entry({"admin", "system", "status","server_add"}, post("server_add"))
-- entry({"admin", "system", "status","server_add"}, post("server_add"))
entry({"admin", "system", "status", "interfaces_status"}, call("interfaces_status")).leaf = true
entry({"admin", "system", "status", "multipath_bandwidth"}, call("multipath_bandwidth")).leaf = true
entry({"admin", "system", "status", "interface_bandwidth"}, call("interface_bandwidth")).leaf = true

View file

@ -0,0 +1,551 @@
local math = require "math"
local sys = require "luci.sys"
local json = require("luci.json")
local fs = require("nixio.fs")
local net = require "luci.model.network".init()
local ucic = luci.model.uci.cursor()
local ipc = require "luci.ip"
module("luci.controller.wan", package.seeall)
function index()
local ucic = luci.model.uci.cursor()
menuentry = "status"
entry({"admin", "system", menuentry:lower()}, alias("admin", "system", menuentry:lower(), "wizard"), _(menuentry), 1)
entry({"admin", "system", menuentry:lower(), "wizard"}, template("status/wan"), _("Settings Wizard"), 1)
entry({"admin", "system", menuentry:lower(), "wizard_add"}, post("wizard_add"))
-- entry({"admin", "system", menuentry:lower(), "status"}, template("status/wanstatus"), _("Status"), 2).leaf = true
-- entry({"admin", "system", menuentry:lower(), "interfaces_status"}, call("interfaces_status")).leaf = true
-- entry({"admin", "system", menuentry:lower(), "settings"}, template("openmptcprouter/settings"), _("Advanced Settings"), 3).leaf = true
-- entry({"admin", "system", menuentry:lower(), "settings_add"}, post("settings_add"))
-- entry({"admin", "system", menuentry:lower(), "update_vps"}, post("update_vps"))
-- entry({"admin", "system", menuentry:lower(), "backup"}, template("openmptcprouter/backup"), _("Backup on server"), 3).leaf = true
-- entry({"admin", "system", menuentry:lower(), "backupgr"}, post("backupgr"))
-- entry({"admin", "system", menuentry:lower(), "debug"}, template("openmptcprouter/debug"), _("Show all settings"), 5).leaf = true
end
function interface_from_device(dev)
for _, iface in ipairs(net:get_networks()) do
local ifacen = iface:name()
local ifacename = ""
ifacename = ucic:get("network",ifacen,"device")
if ifacename == "" then
ifacename = ucic:get("network",ifacen,"ifname")
end
if ifacename == dev then
return ifacen
end
end
return ""
end
function uci_device_from_interface(intf)
intfname = ucic:get("network",intf,"device")
deviceuci = ""
ucic:foreach("network", "device", function(s)
if intfname == ucic:get("network",s[".name"],"name") then
deviceuci = s[".name"]
end
end)
return deviceuci
end
function wizard_add()
local gostatus = true
-- Force WAN zone firewall members to be a list
local fwwan = sys.exec("uci -q get firewall.zone_wan.network")
luci.sys.call("uci -q delete firewall.zone_wan.network")
for interface in fwwan:gmatch("%S+") do
luci.sys.call("uci -q add_list firewall.zone_wan.network=" .. interface)
end
ucic:save("firewall")
-- Add new interface
local add_interface = luci.http.formvalue("add_interface") or ""
local add_interface_ifname = luci.http.formvalue("add_interface_ifname") or ""
if add_interface ~= "" then
local i = 1
local multipath_master = false
ucic:foreach("network", "interface", function(s)
local sectionname = s[".name"]
if sectionname:match("^wan(%d+)$") then
if i <= tonumber(string.match(sectionname, '%d+')) then
i = tonumber(string.match(sectionname, '%d+')) + 1
end
end
if ucic:get("network",sectionname,"multipath") == "master" then
multipath_master = true
end
end)
local defif = "eth0"
if add_interface_ifname == "" then
local defif1 = ucic:get("network","wan1_dev","device") or ""
if defif1 == "" then
defif1 = ucic:get("network","wan1_dev","ifname") or ""
end
if defif1 ~= "" then
defif = defif1
end
else
defif = add_interface_ifname
end
local ointf = interface_from_device(defif) or ""
local wanif = defif
if ointf ~= "" then
if ucic:get("network",ointf,"type") == "" then
ucic:set("network",ointf,"type","macvlan")
ucic:set("network",ointf,"device",ointf)
ucic:set("network",ointf .. "_dev","device")
ucic:set("network",ointf .. "_dev","type","macvlan")
ucic:set("network",ointf .. "_dev","mode","vepa")
ucic:set("network",ointf .. "_dev","ifname",defif)
ucic:set("network",ointf .. "_dev","name",ointf)
end
wanif = "wan" .. i
end
ucic:set("network","wan" .. i,"interface")
ucic:set("network","wan" .. i,"device",defif)
ucic:set("network","wan" .. i,"proto","static")
ucic:set("openmptcprouter","wan" .. i,"interface")
if ointf ~= "" then
ucic:set("network","wan" .. i,"type","macvlan")
ucic:set("network","wan" .. i,"device","wan" .. i)
ucic:set("network","wan" .. i,"masterintf",defif)
ucic:set("network","wan" .. i .. "_dev","device")
ucic:set("network","wan" .. i .. "_dev","type","macvlan")
ucic:set("network","wan" .. i .. "_dev","mode","vepa")
ucic:set("network","wan" .. i .. "_dev","ifname",defif)
ucic:set("network","wan" .. i .. "_dev","name","wan" .. i)
ucic:set("network","wan" .. i .. "_dev","txqueuelen","20")
end
ucic:set("network","wan" .. i,"ip4table","wan")
if multipath_master then
ucic:set("network","wan" .. i,"multipath","on")
ucic:set("openmptcprouter","wan" .. i,"multipath","on")
else
ucic:set("network","wan" .. i,"multipath","master")
ucic:set("openmptcprouter","wan" .. i,"multipath","master")
end
ucic:set("network","wan" .. i,"defaultroute","0")
ucic:reorder("network","wan" .. i, i + 2)
ucic:save("network")
ucic:commit("network")
ucic:save("openmptcprouter")
ucic:commit("openmptcprouter")
ucic:set("qos","wan" .. i,"interface")
ucic:set("qos","wan" .. i,"classgroup","Default")
ucic:set("qos","wan" .. i,"enabled","0")
ucic:set("qos","wan" .. i,"upload","4000")
ucic:set("qos","wan" .. i,"download","100000")
ucic:save("qos")
ucic:commit("qos")
ucic:set("sqm","wan" .. i,"queue")
if ointf ~= "" then
ucic:set("sqm","wan" .. i,"interface","wan" .. i)
else
ucic:set("sqm","wan" .. i,"interface",defif)
end
ucic:set("sqm","wan" .. i,"qdisc","fq_codel")
ucic:set("sqm","wan" .. i,"script","simple.qos")
ucic:set("sqm","wan" .. i,"qdisc_advanced","0")
ucic:set("sqm","wan" .. i,"linklayer","none")
ucic:set("sqm","wan" .. i,"enabled","1")
ucic:set("sqm","wan" .. i,"debug_logging","0")
ucic:set("sqm","wan" .. i,"verbosity","5")
ucic:set("sqm","wan" .. i,"download","0")
ucic:set("sqm","wan" .. i,"upload","0")
ucic:set("sqm","wan" .. i,"iqdisc_opts","autorate-ingress dual-dsthost")
ucic:set("sqm","wan" .. i,"eqdisc_opts","dual-srchost")
ucic:save("sqm")
ucic:commit("sqm")
luci.sys.call("uci -q add_list vnstat.@vnstat[-1].interface=" .. wanif)
luci.sys.call("uci -q commit vnstat")
-- Dirty way to add new interface to firewall...
luci.sys.call("uci -q add_list firewall.zone_wan.network=wan" .. i)
luci.sys.call("uci -q commit firewall")
luci.sys.call("/etc/init.d/macvlan restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/vnstat restart >/dev/null 2>/dev/null")
gostatus = false
end
-- Remove existing interface
local delete_intf = luci.http.formvaluetable("delete") or ""
if delete_intf ~= "" then
for intf, _ in pairs(delete_intf) do
local defif = ucic:get("network",intf,"ifname") or ""
if defif == "" then
defif = ucic:get("network",intf,"ifname")
end
ucic:delete("network",intf)
if ucic:get("network",intf .. "_dev") ~= "" then
ucic:delete("network",intf .. "_dev")
end
ucic:save("network")
ucic:commit("network")
ucic:delete("sqm",intf)
ucic:save("sqm")
ucic:commit("sqm")
ucic:delete("qos",intf)
ucic:save("qos")
ucic:commit("qos")
ucic:delete("openmptcprouter",intf)
ucic:save("openmptcprouter")
ucic:commit("openmptcprouter")
if defif ~= nil and defif ~= "" then
luci.sys.call("uci -q del_list vnstat.@vnstat[-1].interface=" .. defif)
end
luci.sys.call("uci -q commit vnstat")
luci.sys.call("uci -q del_list firewall.zone_wan.network=" .. intf)
luci.sys.call("uci -q commit firewall")
gostatus = false
end
end
-- Set interfaces settings
local interfaces = luci.http.formvaluetable("intf")
for intf, _ in pairs(interfaces) do
local label = luci.http.formvalue("cbid.network.%s.label" % intf) or ""
local proto = luci.http.formvalue("cbid.network.%s.proto" % intf) or "static"
local typeintf = luci.http.formvalue("cbid.network.%s.type" % intf) or ""
local masterintf = luci.http.formvalue("cbid.network.%s.masterintf" % intf) or ""
local ifname = luci.http.formvalue("cbid.network.%s.intf" % intf) or ""
local vlan = luci.http.formvalue("cbid.network.%s.vlan" % intf) or ""
local device_ncm = luci.http.formvalue("cbid.network.%s.device.ncm" % intf) or ""
local device_qmi = luci.http.formvalue("cbid.network.%s.device.qmi" % intf) or ""
local device_modemmanager = luci.http.formvalue("cbid.network.%s.device.modemmanager" % intf) or ""
local ipaddr = luci.http.formvalue("cbid.network.%s.ipaddr" % intf) or ""
local ip6addr = luci.http.formvalue("cbid.network.%s.ip6addr" % intf) or ""
local netmask = luci.http.formvalue("cbid.network.%s.netmask" % intf) or ""
local gateway = luci.http.formvalue("cbid.network.%s.gateway" % intf) or ""
local ip6gw = luci.http.formvalue("cbid.network.%s.ip6gw" % intf) or ""
local ipv6 = luci.http.formvalue("cbid.network.%s.ipv6" % intf) or "0"
local apn = luci.http.formvalue("cbid.network.%s.apn" % intf) or ""
local pincode = luci.http.formvalue("cbid.network.%s.pincode" % intf) or ""
local delay = luci.http.formvalue("cbid.network.%s.delay" % intf) or ""
local username = luci.http.formvalue("cbid.network.%s.username" % intf) or ""
local password = luci.http.formvalue("cbid.network.%s.password" % intf) or ""
local auth = luci.http.formvalue("cbid.network.%s.auth" % intf) or ""
local mode = luci.http.formvalue("cbid.network.%s.mode" % intf) or ""
local sqmenabled = luci.http.formvalue("cbid.sqm.%s.enabled" % intf) or "0"
local sqmautorate = luci.http.formvalue("cbid.sqm.%s.autorate" % intf) or "0"
local qosenabled = luci.http.formvalue("cbid.qos.%s.enabled" % intf) or "0"
local multipath = luci.http.formvalue("cbid.network.%s.multipath" % intf) or "on"
local lan = luci.http.formvalue("cbid.network.%s.lan" % intf) or "0"
local ttl = luci.http.formvalue("cbid.network.%s.ttl" % intf) or ""
if typeintf ~= "" then
if typeintf == "normal" then
typeintf = ""
end
ucic:set("network",intf,"type",typeintf)
end
if vlan ~= "" then
ifname = ifname .. '.' .. vlan
end
if typeintf == "macvlan" and masterintf ~= "" then
ucic:set("network",intf,"type","macvlan")
ucic:set("network",intf .. "_dev","device")
ucic:set("network",intf .. "_dev","type","macvlan")
ucic:set("network",intf .. "_dev","ifname",masterintf)
ucic:set("network",intf .. "_dev","mode","vepa")
ucic:set("network",intf .. "_dev","name",intf)
ucic:set("network",intf,"device",intf)
ucic:set("network",intf,"masterintf",masterintf)
elseif typeintf == "" and ifname ~= "" and (proto == "static" or proto == "dhcp" or proto == "dhcpv6") then
ucic:set("network",intf,"device",ifname)
if uci_device_from_interface(intf) == "" then
ucic:set("network",intf .. "_dev","device")
ucic:set("network",intf .. "_dev","name",ifname)
end
elseif typeintf == "" and device ~= "" and proto == "ncm" then
ucic:set("network",intf,"device",device_ncm)
if uci_device_from_interface(intf) == "" then
ucic:set("network",intf .. "_dev","device")
ucic:set("network",intf .. "_dev","name",device_ncm)
end
elseif typeintf == "" and device ~= "" and proto == "qmi" then
ucic:set("network",intf,"device",device_qmi)
if uci_device_from_interface(intf) == "" then
ucic:set("network",intf .. "_dev","device")
ucic:set("network",intf .. "_dev","name",device_qmi)
end
elseif typeintf == "" and device ~= "" and proto == "modemmanager" then
ucic:set("network",intf,"device",device_manager)
if uci_device_from_interface(intf) == "" then
ucic:set("network",intf .. "_dev","device")
ucic:set("network",intf .. "_dev","name",device_manager)
end
elseif typeintf == "" and ifname ~= "" and proto == "static" then
ucic:set("network",intf,"device",ifname)
if uci_device_from_interface(intf) == "" then
ucic:set("network",intf .. "_dev","device")
ucic:set("network",intf .. "_dev","name",ifname)
end
end
if typeintf ~= "macvlan" then
if ucic:get("network",intf .. "_dev","type") == "macvlan" then
ucic:delete("network",intf .. "_dev","type")
ucic:delete("network",intf .. "_dev","mode")
ucic:delete("network",intf .. "_dev","ifname")
ucic:delete("network",intf .. "_dev","macaddr")
end
ucic:delete("network",intf,"masterintf")
end
if proto == "pppoe" then
ucic:set("network",intf,"pppd_options","persist maxfail 0")
end
if proto ~= "other" then
ucic:set("network",intf,"proto",proto)
end
uci_device = uci_device_from_interface(intf)
if uci_device == "" then
uci_device = intf .. "_dev"
end
ucic:set("network",uci_device,"ttl",ttl)
--ucic:set("network",intf,"apn",apn)
--ucic:set("network",intf,"pincode",pincode)
--ucic:set("network",intf,"delay",delay)
--ucic:set("network",intf,"username",username)
--ucic:set("network",intf,"password",password)
--ucic:set("network",intf,"auth",auth)
--ucic:set("network",intf,"mode",mode)
--ucic:set("network",intf,"label",label)
--ucic:set("network",intf,"ipv6",ipv6)
if lan == "1" then
ucic:set("network",intf,"multipath","off")
else
ucic:set("network",intf,"multipath",multipath)
ucic:set("openmptcprouter",intf,"multipath",multipath)
end
ucic:set("network",intf,"defaultroute",0)
ucic:set("network",intf,"peerdns",0)
if ipaddr ~= "" then
ucic:set("network",intf,"ipaddr",ipaddr:gsub("%s+", ""))
ucic:set("network",intf,"netmask",netmask:gsub("%s+", ""))
ucic:set("network",intf,"gateway",gateway:gsub("%s+", ""))
else
ucic:set("network",intf,"ipaddr","")
ucic:set("network",intf,"netmask","")
ucic:set("network",intf,"gateway","")
end
if ip6addr ~= "" then
ucic:set("network",intf,"ip6addr",ip6addr:gsub("%s+", ""))
ucic:set("network",intf,"ip6gw",ip6gw:gsub("%s+", ""))
else
ucic:set("network",intf,"ip6addr","")
ucic:set("network",intf,"ip6gw","")
end
if proto == "dhcpv6" then
ucic:set("network",intf,"reqaddress","try")
ucic:set("network",intf,"reqprefix","no")
ucic:set("network",intf,"iface_map","0")
ucic:set("network",intf,"iface_dslite","0")
ucic:set("network",intf,"iface_464xlate","0")
ucic:set("network",intf,"ipv6","1")
end
ucic:delete("openmptcprouter",intf,"lc")
ucic:save("openmptcprouter")
--local multipathvpn = luci.http.formvalue("multipathvpn.%s.enabled" % intf) or "0"
--ucic:set("openmptcprouter",intf,"multipathvpn",multipathvpn)
--ucic:save("openmptcprouter")
end
-- Disable multipath on LAN, VPN and loopback
ucic:set("network","loopback","multipath","off")
ucic:set("network","lan","multipath","off")
ucic:set("network","omr6in4","multipath","off")
ucic:set("network","omrvpn","multipath","off")
ucic:save("network")
ucic:commit("network")
ucic:save("network")
ucic:commit("network")
ucic:save("openmptcprouter")
ucic:commit("openmptcprouter")
-- Restart all
menuentry = "status"
if gostatus == true then
--luci.sys.call("/etc/init.d/macvlan restart >/dev/null 2>/dev/null")
luci.sys.call("(env -i /bin/ubus call network reload) >/dev/null 2>/dev/null")
luci.sys.call("ip addr flush dev tun0 >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/omr-tracker stop >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/mptcp restart >/dev/null 2>/dev/null")
--if openmptcprouter_vps_key ~= "" then
-- luci.sys.call("/etc/init.d/openmptcprouter-vps restart >/dev/null 2>/dev/null")
-- luci.sys.call("sleep 2")
--end
luci.sys.call("/etc/init.d/shadowsocks-libev restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/glorytun restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/glorytun-udp restart >/dev/null 2>/dev/null")
--luci.sys.call("/etc/init.d/mlvpn restart >/dev/null 2>/dev/null")
--luci.sys.call("/etc/init.d/ubond restart >/dev/null 2>/dev/null")
--luci.sys.call("/etc/init.d/mptcpovervpn restart >/dev/null 2>/dev/null")
--luci.sys.call("/etc/init.d/openvpn restart >/dev/null 2>/dev/null")
--luci.sys.call("/etc/init.d/openvpnbonding restart >/dev/null 2>/dev/null")
--luci.sys.call("/etc/init.d/dsvpn restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/omr-tracker start >/dev/null 2>/dev/null")
--luci.sys.call("/etc/init.d/omr-6in4 restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/vnstat restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/v2ray restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/sqm-autorate restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/sysntpd restart >/dev/null 2>/dev/null")
luci.http.redirect(luci.dispatcher.build_url("admin/system/" .. menuentry:lower() .. "/status"))
else
luci.http.redirect(luci.dispatcher.build_url("admin/system/" .. menuentry:lower() .. "/wizard"))
end
return
end
function get_device(interface)
local dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {})
if dump ~= nil then
if dump['l3_device'] ~= nil then
return dump['l3_device']
elseif dump['device'] ~= nil then
return dump['device']
else
return ""
end
else
return ""
end
end
-- This function come from modules/luci-bbase/luasrc/tools/status.lua from old OpenWrt
-- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
-- Licensed to the public under the Apache License 2.0.
local function dhcp_leases_common(family)
local rv = { }
local nfs = require "nixio.fs"
local sys = require "luci.sys"
local leasefile = "/tmp/dhcp.leases"
ucic:foreach("dhcp", "dnsmasq",
function(s)
if s.leasefile and nfs.access(s.leasefile) then
leasefile = s.leasefile
return false
end
end)
local fd = io.open(leasefile, "r")
if fd then
while true do
local ln = fd:read("*l")
if not ln then
break
else
local ts, mac, ip, name, duid = ln:match("^(%d+) (%S+) (%S+) (%S+) (%S+)")
local expire = tonumber(ts) or 0
if ts and mac and ip and name and duid then
if family == 4 and not ip:match(":") then
rv[#rv+1] = {
expires = (expire ~= 0) and os.difftime(expire, os.time()),
macaddr = ipc.checkmac(mac) or "00:00:00:00:00:00",
ipaddr = ip,
hostname = (name ~= "*") and name
}
elseif family == 6 and ip:match(":") then
rv[#rv+1] = {
expires = (expire ~= 0) and os.difftime(expire, os.time()),
ip6addr = ip,
duid = (duid ~= "*") and duid,
hostname = (name ~= "*") and name
}
end
end
end
end
fd:close()
end
local lease6file = "/tmp/hosts/odhcpd"
ucic:foreach("dhcp", "odhcpd",
function(t)
if t.leasefile and nfs.access(t.leasefile) then
lease6file = t.leasefile
return false
end
end)
local fd = io.open(lease6file, "r")
if fd then
while true do
local ln = fd:read("*l")
if not ln then
break
else
local iface, duid, iaid, name, ts, id, length, ip = ln:match("^# (%S+) (%S+) (%S+) (%S+) (-?%d+) (%S+) (%S+) (.*)")
local expire = tonumber(ts) or 0
if ip and iaid ~= "ipv4" and family == 6 then
rv[#rv+1] = {
expires = (expire >= 0) and os.difftime(expire, os.time()),
duid = duid,
ip6addr = ip,
hostname = (name ~= "-") and name
}
elseif ip and iaid == "ipv4" and family == 4 then
rv[#rv+1] = {
expires = (expire >= 0) and os.difftime(expire, os.time()),
macaddr = sys.net.duid_to_mac(duid) or "00:00:00:00:00:00",
ipaddr = ip,
hostname = (name ~= "-") and name
}
end
end
end
fd:close()
end
if family == 6 then
local _, lease
local hosts = sys.net.host_hints()
for _, lease in ipairs(rv) do
local mac = sys.net.duid_to_mac(lease.duid)
local host = mac and hosts[mac]
if host then
if not lease.name then
lease.host_hint = host.name or host.ipv4 or host.ipv6
elseif host.name and lease.hostname ~= host.name then
lease.host_hint = host.name
end
end
end
end
return rv
end
function interfaces_status()
local ut = require "luci.util"
--local mArray = ut.ubus("openmptcprouter", "status", {}) or {_=0}
local mArray = luci.json.decode(ut.trim(sys.exec("/bin/ubus -t 600 -S call openmptcprouter status 2>/dev/null")))
if mArray ~= nil and mArray.openmptcprouter ~= nil then
mArray.openmptcprouter["remote_addr"] = luci.http.getenv("REMOTE_ADDR") or ""
mArray.openmptcprouter["remote_from_lease"] = false
local leases=dhcp_leases_common(4)
for _, value in pairs(leases) do
if value["ipaddr"] == mArray.openmptcprouter["remote_addr"] then
mArray.openmptcprouter["remote_from_lease"] = true
mArray.openmptcprouter["remote_hostname"] = value["hostname"]
end
end
end
luci.http.prepare_content("application/json")
luci.http.write_json(mArray)
end

View file

@ -0,0 +1,640 @@
<%+header%>
<%
local uci = require("luci.model.uci").cursor()
local net = require "luci.model.network".init()
local fs = require "nixio.fs"
local sys = require "luci.sys"
local ut = require "luci.util"
local ifaces = sys.net:devices()
local ifttyu = nixio.fs.glob("/dev/ttyUSB*")
local ifttyc = nixio.fs.glob("/dev/cdc-wdm*")
local sqm = luci.sys.exec("opkg list-installed | grep -q luci-app-sqm && echo -n '1' || echo -n '0'")
local qos = luci.sys.exec("opkg list-installed | grep -q luci-app-qos && echo -n '1' || echo -n '0'")
menuentry = "status"
function device_notvirtual(dev)
if dev:match("^eth.*") or dev:match("^wwan.*") or dev:match("^tun.*") or dev:match("/") then
return true
end
networks = net:get_networks()
for _, iface in ipairs(networks) do
local ifacen = iface:name()
local ifacename = uci:get("network",ifacen,"device")
local ifacetype = uci:get("network",ifacen,"type") or ""
local ifaceproto = uci:get("network",ifacen,"proto") or ""
--if ifacename == dev and (ifacetype == "macvlan" or ifacetype == "bridge" or ifaceproto == "6in4") then
if ifacename == dev and (ifacetype == "macvlan" or ifaceproto == "6in4") then
return false
end
end
return true
end
function splitstring(inputstr, sep)
if inputstr == nil then
return ""
end
if sep == nil then
sep = "%s"
end
local t={}
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
table.insert(t, str)
end
return t
end
alltty = {}
iftty = luci.sys.exec("timeout 1 /usr/bin/mmcli -L")
for listtty in iftty:gmatch("([^\r\n]*)[\r\n]") do
modemid = luci.util.trim(luci.sys.exec("echo '" .. listtty .. "' | awk -F' ' '{print $1}' | awk -F/ '{print $6}'"))
if modemid ~= '' then
modeminfo = luci.sys.exec("timeout 1 /usr/bin/mmcli -m " .. modemid .. " --output-keyvalue")
tty = luci.util.trim(luci.sys.exec("echo '" .. modeminfo .. "' | grep 'modem.generic.device ' | awk -F': ' '{print $2}'"))
table.insert(alltty, tty)
end
end
%>
<script type="text/javascript" src="<%=resource%>/cbi.js?v=git-18.243.49640-2f13420" data-strings="{&#34;path&#34;:{&#34;resource&#34;:&#34;\/luci-static\/resources&#34;,&#34;browser&#34;:&#34;\/cgi-bin\/luci\/admin\/filebrowser&#34;}}"></script>
<script src="/luci-static/resources/xhr.js?v=git-18.324.48426-65adb4e"></script>
<script>
function jsshowadv() {
if(document.getElementById('showadv').checked){
document.getElementById('advancedsettings').style.display='inline';
} else {
document.getElementById('advancedsettings').style.display='none';
}
}
</script>
<% if stderr and #stderr > 0 then %><pre class="error"><%=pcdata(stderr)%></pre><% end %>
<form class="inline" method="post" action="<%=url('admin/system/status/wizard_add')%>" enctype="multipart/form-data" onkeydown="return event.key != 'Enter';">
<div class="cbi-map">
<h2 name="content"><%:Wizard%></h2>
<fieldset class="cbi-section" id="interfaces">
<legend><%:Interfaces settings%></legend>
<!-- <div class="cbi-section-descr"><%:You must disable DHCP on your modems and set IP in different networks.%></div> -->
<%
for _, iface in ipairs(net:get_networks()) do
local ifname = iface:name()
local firewall_wan = luci.util.trim(luci.sys.exec("uci -q get firewall.zone_wan.network | tr ' ' '\n' | grep \'^" .. ifname .. "$\'"))
if firewall_wan ~= "" and ifname:match("^wan.*") then
-- local multipath = uci:get("network",ifname,"multipath")
-- local multipathvpn = uci:get("openmptcprouter",ifname,"multipathvpn")
-- local vpn = uci:get("openmptcprouter",ifname,"vpn")
-- if (multipath ~= nil and multipath ~= "off" and vpn ~= "1") or multipathvpn == "1" then
%>
<div class="cbi-section-remove right">
<input type="submit" name="delete.<%=ifname%>" value="<%:Delete%>" class="cbi-button" />
</div>
<h3><%=ifname%></h3>
<fieldset class="cbi-section-node" id="cbi-openmptcprouter-<%=ifname%>">
<input type="hidden" name="intf.<%=ifname%>" value="<%=ifname%>" />
<div class="cbi-value" id="cbi-network-<%=ifname%>-label" data-index="1">
<label class="cbi-value-title"><%:Label%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.label" name="cbid.network.<%=ifname%>.label" class="cbi-input-text" value="<%=uci:get("network",ifname,"label")%>">
<br />
<div class="cbi-value-description">
<%:Label for the interface%>
</div>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-type" data-index="2" style="display:none;">
<label class="cbi-value-title"><%:Type%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.type" name="cbid.network.<%=ifname%>.type" size="1">
<option id="cbid.network.<%=ifname%>.type-normal" value="normal"<% if uci:get("network",ifname,"type") ~= "macvlan" and uci:get("network",ifname,"type") ~= "bridge" then %> selected="selected"<% end %>><%:Normal%></option>
<option id="cbid.network.<%=ifname%>.type-macvlan" value="macvlan"<% if uci:get("network",ifname,"type") == "macvlan" then %> selected="selected"<% end %>><%:MacVLAN%></option>
<option id="cbid.network.<%=ifname%>.type-bridge" value="bridge"<% if uci:get("network",ifname,"type") == "bridge" then %> selected="selected"<% end %>><%:Bridge%></option>
</select>
<br />
<div class="cbi-value-description">
<%:Choose MacVLAN if you want to create a virtual interface based on a physical interface.%>
</div>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-masterintf" data-depends="[{&#34;cbid.network.<%=ifname%>.type&#34;:&#34;macvlan&#34;}]" data-index="3" style="display:none;">
<label class="cbi-value-title"><%:Physical interface%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.masterintf" name="cbid.network.<%=ifname%>.masterintf" size="1">
<%
for _, ifacea in ipairs(ifaces) do
if not (ifacea == "lo" or ifacea == "6in4-omr6in4" or ifacea:match("^ifb.*") or ifacea:match("^sit.*") or ifacea:match("^gre.*") or ifacea:match("^ip6.*") or ifacea:match("^teql.*") or ifacea:match("^erspan.*") or ifacea:match("^tun.*") or ifacea:match("^bond.*")) and device_notvirtual(ifacea) then
%>
<option value="<%=ifacea%>"<% if uci:get("network",ifname,"masterintf") == ifacea then %> selected="selected"<% end %>><%=ifacea%></option>
<%
end
end
%>
</select>
<br />
<div class="cbi-value-description">
<%:Choose physical interface.%>
</div>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-proto" data-depends="[{&#34;cbid.network.<%=ifname%>.type&#34;:&#34;normal&#34;},{&#34;cbid.network.<%=ifname%>.type&#34;:&#34;bridge&#34;}]" data-index="3">
<label class="cbi-value-title"><%:Protocol%></label>
<div class="cbi-value-field">
<% findproto = 0 %>
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.proto" name="cbid.network.<%=ifname%>.proto" size="1">
<option id="cbid.network.<%=ifname%>.proto-static" value="static"<% if uci:get("network",ifname,"proto") == "static" or uci:get("network",ifname,"proto") == nil then findproto = 1 %> selected="selected"<% end %>><%:Static address%></option>
<option id="cbid.network.<%=ifname%>.proto-dhcp" value="dhcp"<% if uci:get("network",ifname,"proto") == "dhcp" then findproto = 1 %> selected="selected"<% end %>><%:DHCP%></option>
<!-- <option id="cbid.network.<%=ifname%>.proto-dhcpv6" value="dhcpv6"<% if uci:get("network",ifname,"proto") == "dhcpv6" then findproto = 1 %> selected="selected"<% end %>><%:DHCPv6%></option>
<option id="cbid.network.<%=ifname%>.proto-modemmanager" value="modemmanager"<% if uci:get("network",ifname,"proto") == "modemmanager" then findproto = 1 %> selected="selected"<% end %>><%:ModemManager%></option>
<option id="cbid.network.<%=ifname%>.proto-ncm" value="ncm"<% if uci:get("network",ifname,"proto") == "ncm" then findproto = 1 %> selected="selected"<% end %>><%:NCM%></option>
<option id="cbid.network.<%=ifname%>.proto-pppoe" value="pppoe"<% if uci:get("network",ifname,"proto") == "pppoe" then findproto = 1 %> selected="selected"<% end %>><%:PPPoE%></option>
<option id="cbid.network.<%=ifname%>.proto-qmi" value="qmi"<% if uci:get("network",ifname,"proto") == "qmi" then findproto = 1 %> selected="selected"<% end %>><%:QMI%></option>
<option id="cbid.network.<%=ifname%>.proto-other" value="other"<% if uci:get("network",ifname,"proto") ~= nil and findproto ~= 1 then %> selected="selected"<% end %>><%:Other%></option>
-->
</select>
<br />
<div class="cbi-value-description">
<%:You can use DHCP if you have multiple real ethernet ports. Select other if you want to use another protocol available in Network Interfaces page.%>
</div>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-intf" data-depends="[{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;static&#34;},{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;dhcp&#34;},{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;dhcpv6&#34;}]" data-index="4" style="display:none;">
<label class="cbi-value-title"><%:Physical interface%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.intf" name="cbid.network.<%=ifname%>.intf" size="1">
<%
iffind=0
uciifname=uci:get("network",ifname,"device")
if uciifname ~= nil then
if uciifname:match("/") then
realifname=uciifname
vlan=""
else
realifname=splitstring(uciifname,'.')[1] or ""
vlan=splitstring(uciifname,'.')[2] or ""
end
end
for _, ifacea in ipairs(ifaces) do
if not (ifacea == "lo" or ifacea == "6in4-omr6in4" or ifacea == "mlvpn0" or ifacea:match("^ifb.*") or ifacea:match("^sit.*") or ifacea:match("^gre.*") or ifacea:match("^ip6.*") or ifacea:match("^teql.*") or ifacea:match("^erspan.*") or ifacea:match("^tun.*") or ifacea:match("^bond.*")) and device_notvirtual(ifacea) then
%>
<option value="<%=ifacea%>"<% if realifname == ifacea then iffind = 1 %> selected="selected"<% end %>><%=ifacea%></option>
<%
end
end
if iffind == 0 and uciifname ~= nil then
%>
<option value="<%=uciifname%>" selected="selected"><%=uciifname%></option>
<%
end
%>
</select>
<label><%:VLAN%></label>
<input type="text" id="cbid.network.<%=ifname%>.vlan" name="cbid.network.<%=ifname%>.vlan" class="cbi-input-text" placeholder="<%:VLAN%>" value="<%=vlan%>" data-optional="true">
<br />
<div class="cbi-value-description">
<%:Choose physical interface.%>
</div>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-address" data-depends="[{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;static&#34;},{&#34;cbid.network.<%=ifname%>.type&#34;:&#34;macvlan&#34;}]" data-index="5">
<label class="cbi-value-title"><%:IPv4 address%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.ipaddr" name="cbid.network.<%=ifname%>.ipaddr" class="cbi-input-text" value="<%=uci:get("network",ifname,"ipaddr")%>" data-type="ip4addr">
<br />
<div class="cbi-value-description">
<%:Set an IP in the same network as the modem%>
</div>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-netmask" data-depends="[{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;static&#34;},{&#34;cbid.network.<%=ifname%>.type&#34;:&#34;macvlan&#34;}]" data-index="6">
<label class="cbi-value-title"><%:IPv4 netmask%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.netmask" name="cbid.network.<%=ifname%>.netmask" class="cbi-input-text" value="<%=uci:get("network",ifname,"netmask") or "255.255.255.0"%>" data-type="ip4addr">
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-gateway" data-depends="[{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;static&#34;},{&#34;cbid.network.<%=ifname%>.type&#34;:&#34;macvlan&#34;}]" data-index="7">
<label class="cbi-value-title"><%:IPv4 gateway%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.gateway" name="cbid.network.<%=ifname%>.gateway" class="cbi-input-text" value="<%=uci:get("network",ifname,"gateway")%>" data-type="ip4addr">
<br />
<div class="cbi-value-description">
<%:Set here IP of the modem%>
</div>
</div>
</div>
<%
ipv6list = uci:get_list("network",ifname,"ip6addr")
for key, value in pairs(ipv6list) do
%>
<div class="cbi-value" id="cbi-network-<%=ifname%>-ipv6address" data-index="8">
<label class="cbi-value-title"><%:IPv6 address%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.ip6addr" name="cbid.network.<%=ifname%>.ip6addr" class="cbi-input-text" value="<%=value%>" data-type="ip6addr" data-optional="true">
<br />
<div class="cbi-value-description">
<%:Set an IP in the same network as the modem%>
</div>
</div>
</div>
<%
end
if table.getn(ipv6list) ~= 0 then
%>
<div class="cbi-value" id="cbi-network-<%=ifname%>-ip6gw" data-index="9">
<label class="cbi-value-title"><%:IPv6 gateway%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.ip6gw" name="cbid.network.<%=ifname%>.ip6gw" class="cbi-input-text" value="<%=uci:get("network",ifname,"ip6gw")%>" data-type="ip6addr" data-optional="true">
<br />
<div class="cbi-value-description">
<%:Set here IP of the modem%>
</div>
</div>
</div>
<%
else
%>
<div class="cbi-value" id="cbi-network-<%=ifname%>-ipv6address" data-depends="[{&#34;enableipv6&#34;:&#34;0&#34;,&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;static&#34;},{&#34;enableipv6&#34;:&#34;0&#34;,&#34;cbid.network.<%=ifname%>.type&#34;:&#34;macvlan&#34;}]" data-index="8">
<label class="cbi-value-title"><%:IPv6 address%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.ip6addr" name="cbid.network.<%=ifname%>.ip6addr" class="cbi-input-text" value="" data-type="ip6addr">
<br />
<div class="cbi-value-description">
<%:Set an IP in the same network as the modem%>
</div>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-ip6gw" data-depends="[{&#34;enableipv6&#34;:&#34;0&#34;,&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;static&#34;},{&#34;enableipv6&#34;:&#34;0&#34;,&#34;cbid.network.<%=ifname%>.type&#34;:&#34;macvlan&#34;}]" data-index="9">
<label class="cbi-value-title"><%:IPv6 gateway%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.ip6gw" name="cbid.network.<%=ifname%>.ip6gw" class="cbi-input-text" value="<%=uci:get("network",ifname,"ip6gw")%>" data-type="ip6addr">
<br />
<div class="cbi-value-description">
<%:Set here IP of the modem%>
</div>
</div>
</div>
<%
end
%>
<!--
<div class="cbi-value" id="cbi-network-<%=ifname%>-ip6" data-depends="[{&#34;enableipv6&#34;:&#34;0&#34;,&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;static&#34;}]" data-index="10">
<label class="cbi-value-title"><%:Accept IPv6 RA%></label>
<div class="cbi-value-field">
<input type="checkbox" id="cbid.network.<%=ifname%>.ipv6" name="cbid.network.<%=ifname%>.ipv6" value="1" <% if uci:get("network",ifname,"ipv6") == "1" then %>checked<% end %> />
</div>
</div>
-->
<div class="cbi-value" id="cbi-network-<%=ifname%>-device-ncm" data-depends="[{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;ncm&#34;}]" data-index="5" style="display:none;">
<label class="cbi-value-title"><%:Device%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.device.ncm" name="cbid.network.<%=ifname%>.device.ncm" size="1">
<%
iffind=0
for tty in ifttyu do
%>
<option value="<%=tty%>"<% if uci:get("network",ifname,"device") == tty then iffind = 1 %> selected="selected"<% end %>><%=tty%></option>
<%
end
for tty in ifttyc do
%>
<option value="<%=tty%>"<% if uci:get("network",ifname,"device") == tty then iffind = 1 %> selected="selected"<% end %>><%=tty%></option>
<%
end
if iffind == 0 and uci:get("network",ifname,"device") ~= nil then
%>
<option value="<%=uci:get("network",ifname,"device")%>" selected="selected"><%=uci:get("network",ifname,"device")%></option>
<%
end
%>
</select>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-device-qmi" data-depends="[{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;qmi&#34;}]" data-index="5">
<label class="cbi-value-title"><%:Device%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.device.qmi" name="cbid.network.<%=ifname%>.device.qmi" size="1">
<%
iffind=0
for tty in ifttyc do
%>
<option value="<%=tty%>"<% if uci:get("network",ifname,"device") == tty then iffind = 1 %> selected="selected"<% end %>><%=tty%></option>
<%
end
if iffind == 0 and uci:get("network",ifname,"device") ~= nil then
%>
<option value="<%=uci:get("network",ifname,"device")%>" selected="selected"><%=uci:get("network",ifname,"device")%></option>
<%
end
%>
</select>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-device-modemmanager" data-depends="[{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;modemmanager&#34;}]" data-index="5">
<label class="cbi-value-title"><%:Device%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.device.modemmanager" name="cbid.network.<%=ifname%>.device.modemmanager" size="1">
<%
iffind=0
for _, tty in ipairs(alltty) do
%>
<option value="<%=tty%>"<% if uci:get("network",ifname,"device") == tty then iffind = 1 %> selected="selected"<% end %>><%=tty%></option>
<%
end
if iffind == 0 and uci:get("network",ifname,"device") ~= nil then
%>
<option value="<%=uci:get("network",ifname,"device")%>" selected="selected"><%=uci:get("network",ifname,"device")%></option>
<%
end
%>
</select>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-apn" data-depends="[{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;ncm&#34;},{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;qmi&#34;},{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;modemmanager&#34;}]" data-index="6">
<label class="cbi-value-title"><%:APN%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.apn" name="cbid.network.<%=ifname%>.apn" class="cbi-input-text" value="<%=uci:get("network",ifname,"apn")%>">
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-pincode" data-depends="[{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;ncm&#34;},{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;qmi&#34;},{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;modemmanager&#34;}]" data-index="7">
<label class="cbi-value-title"><%:PIN code%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.pincode" name="cbid.network.<%=ifname%>.pincode" class="cbi-input-text" value="<%=uci:get("network",ifname,"pincode")%>">
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-mode" data-depends="[{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;ncm&#34;}]" data-index="8">
<label class="cbi-value-title"><%:Service Type%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.mode" name="cbid.network.<%=ifname%>.mode" size="1">
<option value=""<% if uci:get("network",ifname,"mode") == "" then %> selected="selected"<% end %>><%:Modem default%></option>
<option value="preferlte"<% if uci:get("network",ifname,"auth") == "preferlte" then %> selected="selected"<% end %>><%:Prefer LTE%></option>
<option value="preferumts"<% if uci:get("network",ifname,"auth") == "preferumts" then %> selected="selected"<% end %>><%:Prefer UMTS%></option>
<option value="lte"<% if uci:get("network",ifname,"auth") == "lte" then %> selected="selected"<% end %>><%:LTE%></option>
<option value="umts"<% if uci:get("network",ifname,"auth") == "umts" then %> selected="selected"<% end %>><%:UMTS/GPRS%></option>
<option value="gsm"<% if uci:get("network",ifname,"auth") == "gsm" then %> selected="selected"<% end %>><%:GPRS only%></option>
<option value="auto"<% if uci:get("network",ifname,"auth") == "auto" then %> selected="selected"<% end %>><%:auto%></option>
</select>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-auth" data-depends="[{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;qmi&#34;},{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;pppoe&#34;}]" data-index="9">
<label class="cbi-value-title"><%:Authentication Type%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.auth" name="cbid.network.<%=ifname%>.auth" size="1">
<option value="none"<% if uci:get("network",ifname,"auth") == "none" then %> selected="selected"<% end %>><%:NONE%></option>
<option value="pap"<% if uci:get("network",ifname,"auth") == "pap" then %> selected="selected"<% end %>><%:PAP%></option>
<option value="chap"<% if uci:get("network",ifname,"auth") == "chap" then %> selected="selected"<% end %>><%:CHAP%></option>
<option value="both"<% if uci:get("network",ifname,"auth") == "both" then %> selected="selected"<% end %>><%:PAP/CHAP%></option>
</select>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-username" data-depends="[{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;ncm&#34;},{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;qmi&#34;},{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;pppoe&#34;}]" data-index="10">
<label class="cbi-value-title"><%:PAP/CHAP username%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.username" name="cbid.network.<%=ifname%>.username" class="cbi-input-text" value="<%=uci:get("network",ifname,"username")%>">
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-password" data-depends="[{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;ncm&#34;},{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;qmi&#34;},{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;pppoe&#34;}]" data-index="11">
<label class="cbi-value-title"><%:PAP/CHAP password%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.password" name="cbid.network.<%=ifname%>.password" class="cbi-input-text" value="<%=uci:get("network",ifname,"password")%>">
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-delay" data-depends="[{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;ncm&#34;},{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;qmi&#34;}]" data-index="12">
<label class="cbi-value-title"><%:Modem init timeout%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.delay" name="cbid.network.<%=ifname%>.delay" class="cbi-input-text" value="<%=uci:get("network",ifname,"delay")%>">
</div>
</div>
<%
if uci:get("openmptcprouter",ifname,"multipathvpn") == "1" then
%>
<div class="cbi-value" id="cbi-network-<%=ifname%>-multipath" data-index="13">
<label class="cbi-value-title"><%:Multipath TCP%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.multipath" name="cbid.network.<%=ifname%>.multipath" size="1">
<option value="on"<% if uci:get("network","ovpn" .. ifname,"multipath") == "on" then %> selected="selected"<% end %>><%:Enabled%></option>
<option value="off"<% if uci:get("network","ovpn" .. ifname,"multipath") == "off" then %> selected="selected"<% end %>><%:Disabled%></option>
<option value="master"<% if uci:get("network","ovpn" .. ifname,"multipath") == "master" then %> selected="selected"<% end %>><%:Master%></option>
<option value="backup"<% if uci:get("network","ovpn" .. ifname,"multipath") == "backup" then %> selected="selected"<% end %>><%:Backup%></option>
</select>
<br />
<div class="cbi-value-description">
<%:Only one interface must be set as "Master", this should be the most stable interface.%>
</div>
</div>
</div>
<% else %>
<div class="cbi-value" id="cbi-network-<%=ifname%>-multipath" data-index="13">
<label class="cbi-value-title"><%:Multipath TCP%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.multipath" name="cbid.network.<%=ifname%>.multipath" size="1">
<option value="on"<% if uci:get("network",ifname,"multipath") == "on" then %> selected="selected"<% end %>><%:Enabled%></option>
<option value="off"<% if uci:get("network",ifname,"multipath") == "off" then %> selected="selected"<% end %>><%:Disabled%></option>
<option value="master"<% if uci:get("network",ifname,"multipath") == "master" then %> selected="selected"<% end %>><%:Master%></option>
<option value="backup"<% if uci:get("network",ifname,"multipath") == "backup" then %> selected="selected"<% end %>><%:Backup%></option>
</select>
</div>
</div>
<%
end
%>
<div class="cbi-value" data-index="14" style="display:none;">
<label class="cbi-value-title"><%:Force TTL%></label>
<div class="cbi-value-field">
<input type="text" name="cbid.network.<%=ifname%>.ttl" class="cbi-input-text" value="<%=ttl%>" data-type="uinteger" data-optional="true">
<br />
<div class="cbi-value-description">
<%:You can force a TTL. Some LTE provider detect tethering by inpecting packet TTL value, setting it to 65 often solve the issue.%>
</div>
</div>
</div>
<%
local download = "0"
local upload = "0"
download = uci:get("network",ifname,"downloadspeed") or "0"
upload = uci:get("network",ifname,"uploadspeed") or "0"
cake = uci:get("sqm",ifname,"qdisc") or "cake"
--if download == "0" or upload == "0" then
-- if nixio.fs.access("/etc/init.d/sqm") then
-- download = uci:get("sqm",ifname,"download")
-- upload = uci:get("sqm",ifname,"upload")
-- else
-- download = uci:get("qos",ifname,"download")
-- upload = uci:get("qos",ifname,"upload")
-- end
--end
%>
<div class="cbi-value" data-index="15" style="display:none;">
<label class="cbi-value-title"><%:MPTCP over VPN%></label>
<div class="cbi-value-field">
<input class="cbi-input-checkbox" type="checkbox" name="multipathvpn.<%=ifname%>.enabled" value="1" <% if uci:get("openmptcprouter",ifname,"multipathvpn") == "1" then %>checked<% end %> />
<br />
<div class="cbi-value-description">
<%:You can enable MPTCP over VPN if your provider filter Multipath TCP.%>
</div>
</div>
</div>
<%
if sqm == "1" then
%>
<div class="cbi-value" data-index="16" style="display:none;">
<label class="cbi-value-title"><%:Enable SQM%></label>
<div class="cbi-value-field">
<input class="cbi-input-checkbox" type="checkbox" name="cbid.sqm.<%=ifname%>.enabled" id="cbid.sqm.<%=ifname%>.enabled" value="1" <% if uci:get("sqm",ifname,"enabled") == "1" then %>checked<% end %> />
<br />
<div class="cbi-value-description">
<%:SQM control bufferloat: the undesirable latency that arises when the router buffers too much data.%>
</div>
</div>
</div>
<div class="cbi-value" data-index="17" style="display:none;">
<label class="cbi-value-title"><%:Enable SQM autorate%></label>
<div class="cbi-value-field">
<input class="cbi-input-checkbox" type="checkbox" name="cbid.sqm.<%=ifname%>.autorate" id="cbid.sqm.<%=ifname%>.autorate" value="1" <% if uci:get("sqm",ifname,"autorate") == "1" then %>checked<% end %> />
<br />
<div class="cbi-value-description">
<%:SQM autorate is for LTE and connection without a stable speed.%>
<%
if cake ~= "cake" then
%>
<%:Cake queue discipline is not set, autorate will only work after a reboot if enabled here.%>
<%
end
%>
</div>
</div>
</div>
<%
end
%>
<%
if qos == "1" then
%>
<div class="cbi-value" data-index="18" style="display:none;">
<label class="cbi-value-title"><%:Enable QoS%></label>
<div class="cbi-value-field">
<input class="cbi-input-checkbox" type="checkbox" name="cbid.qos.<%=ifname%>.enabled" value="1" <% if uci:get("qos",ifname,"enabled") == "1" then %>checked<% end %> />
<br />
<div class="cbi-value-description">
<%:QoS permit to prioritize any upload traffic.%>
</div>
</div>
</div>
<%
end
%>
<div class="cbi-value" data-index="19" style="display:none;">
<label class="cbi-value-title"><%:Download speed (Kb/s)%></label>
<div class="cbi-value-field">
<input type="text" name="cbid.sqm.<%=ifname%>.download" class="cbi-input-text" value="<%=download%>" data-type="uinteger">
<br />
<div class="cbi-value-description">
<%:Used by Glorytun UDP and SQM/QoS if enabled. 0 to use default value.%>
</div>
<!--
<br />
<div class="cbi-value-description">
<%:Set value between 80-95% of max download speed link. 0 to disable SQM/QoS.%>
</div>
-->
</div>
</div>
<div class="cbi-value" data-index="20" style="display:none;">
<label class="cbi-value-title"><%:Upload speed (Kb/s)%></label>
<div class="cbi-value-field">
<input type="text" name="cbid.sqm.<%=ifname%>.upload" class="cbi-input-text" value="<%=upload%>" data-type="uinteger">
<br />
<div class="cbi-value-description">
<%:Used by Glorytun UDP and SQM/QoS if enabled. 0 to use default value.%>
</div>
<!--
<br />
<div class="cbi-value-description">
<%:Set value between 80-95% of max upload speed link. 0 to disable SQM/QoS.%>
</div>
-->
</div>
</div>
</fieldset>
<%
end
end
%>
<div class="cbi-section-create" style="display:none;">
<select class="cbi-section-create-name" name="add_interface_ifname">
<%
for _, ifacea in ipairs(ifaces) do
if not (ifacea == "lo" or ifacea == "6in4-omr6in4" or ifacea == "mlvpn0" or iface == "bond0" or ifacea:match("^ifb.*") or ifacea:match("^sit.*") or ifacea:match("^gre.*") or ifacea:match("^ip6.*") or ifacea:match("^teql.*") or ifacea:match("^erspan.*")) and device_notvirtual(ifacea) then
%>
<option value="<%=ifacea%>"><%=ifacea%></option>
<%
end
end
for _, ifacea in ipairs(net:get_networks()) do
if not (ifacea:name() == "loopback" or ifacea:name() == "lan" or ifacea:name() == "omr6in4" or ifacea:name() == "omrvpn" or ifacea:name():match("^oip.*")) then
%>
<option value="<%='@' .. ifacea:name()%>"><%='@' .. ifacea:name() .. ' (alias)'%></option>
<%
end
end
%>
</select>
<input class="cbi-button cbi-button-add" type="submit" name="add_interface" value="<%:Add an interface%>" title="<%:Add an interface%>" />
</div>
<div class="cbi-value-description" style="display:none;">
<%:Select the device you want to base the interface on.%>
</div>
</fieldset>
</div>
<%
if uci:get('wireless','default_radio0') == 'wifi-iface' and uci:get('wireless','default_radio0','disabled') ~= '1' then
%>
<div class="cbi-map">
<h2 name="content"><%:Wifi%></h2>
<fieldset class="cbi-section" id="wifi">
<div class="cbi-value" data-index="30">
<label class="cbi-value-title"><%:Wifi channel%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.wifi.channel" name="cbid.wifi.channel" size="1">
<option value="auto"<% if uci:get("wireless","radio0","channel") == "auto" then %> selected="selected"<% end %>><%:Auto%></option>
<%
local dump = require("luci.util").ubus("iwinfo", "freqlist", { device = "radio0" }) or {}
if dump['results'] ~= nil then
for _, value in pairs(dump['results']) do
%>
<option value="<%=value['channel']%>"<% if uci:get("wireless","radio0","channel") == value['channel'] then %> selected="selected"<% end %>><%=value['channel']%></option>
<%
end
end
%>
</select>
</div>
</div>
<div class="cbi-value" data-index="31">
<label class="cbi-value-title"><%:Wifi name%></label>
<div class="cbi-value-field">
<input type="text" name="cbid.wifi.name" class="cbi-input-text" value="<%=uci:get('wireless','default_radio','ssid')%>">
</div>
</div>
<div class="cbi-value" data-index="32">
<label class="cbi-value-title"><%:Key%></label>
<div class="cbi-value-field">
<input type="text" name="cbid.wifi.key" class="cbi-input-text" value="<%=uci:get('wireless','default_radio','key')%>">
</div>
</div>
</fieldset>
</div>
<%
end
%>
<div class="cbi-page-actions control-group">
<input type="hidden" name="token" value="<%=token%>" />
<button class="cbi-button cbi-button-apply"><%:Save & Apply%></button>
<button class="cbi-button cbi-button-reset"><%:Reset%></button>
</div>
</form>
<script type="text/javascript">cbi_init();</script>
<%+footer%>