mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Change in luci-app-openmptcprouter to use device setting
This commit is contained in:
parent
04b15901fa
commit
72f5756eb5
4 changed files with 58 additions and 23 deletions
|
@ -26,7 +26,11 @@ end
|
|||
function interface_from_device(dev)
|
||||
for _, iface in ipairs(net:get_networks()) do
|
||||
local ifacen = iface:name()
|
||||
local ifacename = ucic:get("network",ifacen,"ifname")
|
||||
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
|
||||
|
@ -113,7 +117,10 @@ function wizard_add()
|
|||
end)
|
||||
local defif = "eth0"
|
||||
if add_interface_ifname == "" then
|
||||
local defif1 = ucic:get("network","wan1_dev","ifname") or ""
|
||||
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
|
||||
|
@ -126,17 +133,29 @@ function wizard_add()
|
|||
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,"ifname",defif)
|
||||
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)
|
||||
end
|
||||
ucic:set("network","wan" .. i,"ip4table","wan")
|
||||
if multipath_master then
|
||||
|
@ -197,7 +216,10 @@ function wizard_add()
|
|||
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")
|
||||
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")
|
||||
|
@ -262,9 +284,14 @@ function wizard_add()
|
|||
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",masterinf)
|
||||
ucic:set("network",intf .. "_dev","mode","vepa")
|
||||
ucic:set("network",intf .. "_dev","name",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,"ifname",ifname)
|
||||
ucic:set("network",intf,"device",ifname)
|
||||
elseif typeintf == "" and device ~= "" and proto == "ncm" then
|
||||
ucic:set("network",intf,"device",device_ncm)
|
||||
elseif typeintf == "" and device ~= "" and proto == "qmi" then
|
||||
|
@ -342,7 +369,10 @@ function wizard_add()
|
|||
if not ucic:get("sqm",intf) ~= "" then
|
||||
local defif = get_device(intf)
|
||||
if defif == "" then
|
||||
defif = ucic:get("network",intf,"ifname") or ""
|
||||
defif = ucic:get("network",intf,"device") or ""
|
||||
if defif == "" then
|
||||
defif = ucic:get("network",intf,"ifname") or ""
|
||||
end
|
||||
end
|
||||
ucic:set("sqm",intf,"queue")
|
||||
ucic:set("sqm",intf,"interface",defif)
|
||||
|
@ -442,7 +472,7 @@ function wizard_add()
|
|||
ucic:set("network","omrvpn","proto","bonding")
|
||||
end
|
||||
if vpn_intf ~= "" then
|
||||
ucic:set("network","omrvpn","ifname",vpn_intf)
|
||||
ucic:set("network","omrvpn","device",vpn_intf)
|
||||
ucic:set("sqm","omrvpn","interface",vpn_intf)
|
||||
ucic:save("network")
|
||||
ucic:commit("network")
|
||||
|
@ -894,7 +924,7 @@ function wizard_add()
|
|||
-- Restart all
|
||||
menuentry = ucic:get("openmptcprouter","settings","menu") or "openmptcprouter"
|
||||
if gostatus == true then
|
||||
luci.sys.call("/etc/init.d/macvlan restart >/dev/null 2>/dev/null")
|
||||
--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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue