X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Fniu%2Fluasrc%2Fmodel%2Fcbi%2Fniu%2Fnetwork%2Fwan.lua;h=b7351ff19bfbcedacd157ebdb2cbf360ee5fe489;hp=6c23738eb6b7bd4157e5b767fc2d1ca8470b52df;hb=0784b7b9d512602f519aa7c0e826f97ef5ca25ff;hpb=43820b99ecac96b1f5c3abe44eb446cdea5d41b4 diff --git a/modules/niu/luasrc/model/cbi/niu/network/wan.lua b/modules/niu/luasrc/model/cbi/niu/network/wan.lua index 6c23738eb..b7351ff19 100644 --- a/modules/niu/luasrc/model/cbi/niu/network/wan.lua +++ b/modules/niu/luasrc/model/cbi/niu/network/wan.lua @@ -1,11 +1,45 @@ local cursor = require "luci.model.uci".cursor() + +if not cursor:get("network", "wan") then + cursor:section("network", "interface", "wan", {proto = "none"}) + cursor:save("network") +end + +local function deviceroute(self) + cursor:unload("network") + local wd = cursor:get("network", "wan", "_wandev") or "" + + if wd == "none" then + cursor:set("network", "wan", "proto", "none") + end + + if wd:find("ethernet:") == 1 then + cursor:set("network", "wan", "defaultroute", "1") + cursor:set("network", "wan", "ifname", wd:sub(10)) + self:set_route("etherwan") + else + cursor:delete("network", "wan", "ifname") + end + + if wd:find("wlan:") == 1 then + + else + cursor:delete_all("wireless", "wifi-iface", {network = "wan"}) + end + + cursor:save("wireless") + cursor:save("network") +end + + local d = Delegator() d.allow_finish = true d.allow_back = true d.allow_cancel = true d:add("device", load("niu/network/wandevice")) -d:add("etherwan", load("niu/network/etherwan")) +d:add("deviceroute", deviceroute) +d:set("etherwan", load("niu/network/etherwan")) function d.on_cancel() cursor:revert("network")