1 local cursor = require "luci.model.uci".cursor()
3 if not cursor:get("network", "wan") then
4 cursor:section("network", "interface", "wan", {proto = "none"})
8 local function deviceroute(self)
9 cursor:unload("network")
10 local wd = cursor:get("network", "wan", "_wandev") or ""
13 cursor:set("network", "wan", "proto", "none")
16 if wd:find("ethernet:") == 1 then
17 cursor:set("network", "wan", "defaultroute", "1")
18 cursor:set("network", "wan", "ifname", wd:sub(10))
19 self:set_route("etherwan")
21 cursor:delete("network", "wan", "ifname")
24 if wd:find("wlan:") == 1 then
27 cursor:delete_all("wireless", "wifi-iface", {network = "wan"})
30 cursor:save("wireless")
31 cursor:save("network")
40 d:add("device", load("niu/network/wandevice"))
41 d:add("deviceroute", deviceroute)
42 d:set("etherwan", load("niu/network/etherwan"))
44 function d.on_cancel()
45 cursor:revert("network")
46 cursor:revert("wireless")
50 cursor:commit("network")
51 cursor:commit("wireless")