X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=applications%2Fluci-app-mwan3%2Fluasrc%2Fmodel%2Fcbi%2Fmwan%2Fpolicy.lua;h=b7a90aa93ad0269c810a16d2a1aed4758a7eb97c;hp=44585d75efd228cb473ab77f3aaed8289ca37da2;hb=08a2b27df5e282a6b5221fbe72f700523c7b0913;hpb=b4350f21ff2f31b7dbcdbc5f034659ba580c059f diff --git a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/policy.lua b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/policy.lua index 44585d75e..b7a90aa93 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/policy.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/policy.lua @@ -1,5 +1,10 @@ -ds = require "luci.dispatcher" -sys = require "luci.sys" +-- Copyright 2014 Aedan Renner +-- Copyright 2018 Florian Eckert +-- Licensed to the public under the GNU General Public License v2. + +dsp = require "luci.dispatcher" +uci = require "uci" + function policyCheck() local policy_error = {} @@ -20,7 +25,7 @@ function policyError(policy_error) local warnings = "" for i, k in pairs(policy_error) do if policy_error[i] == true then - warnings = warnings .. string.format("%s
", + warnings = warnings .. string.format("%s
", translatef("WARNING: Policie %s has exceeding the maximum name of 15 characters", i) ) end @@ -32,51 +37,49 @@ end m5 = Map("mwan3", translate("MWAN - Policies"), policyError(policyCheck())) - mwan_policy = m5:section(TypedSection, "policy", nil, translate("Policies are profiles grouping one or more members controlling how MWAN distributes traffic
" .. "Member interfaces with lower metrics are used first. Interfaces with the same metric load-balance
" .. "Load-balanced member interfaces distribute more traffic out those with higher weights
" .. "Names may contain characters A-Z, a-z, 0-9, _ and no spaces. Names must be 15 characters or less
" .. "Policies may not share the same name as configured interfaces, members or rules")) - mwan_policy.addremove = true - mwan_policy.dynamic = false - mwan_policy.sectionhead = translate("Policy") - mwan_policy.sortable = true - mwan_policy.template = "cbi/tblsection" - mwan_policy.extedit = ds.build_url("admin", "network", "mwan", "policy", "%s") - function mwan_policy.create(self, section) - TypedSection.create(self, section) - m5.uci:save("mwan3") - luci.http.redirect(ds.build_url("admin", "network", "mwan", "policy", section)) - end - +mwan_policy.addremove = true +mwan_policy.dynamic = false +mwan_policy.sectionhead = translate("Policy") +mwan_policy.sortable = true +mwan_policy.template = "cbi/tblsection" +mwan_policy.extedit = dsp.build_url("admin", "network", "mwan", "policy", "%s") +function mwan_policy.create(self, section) + TypedSection.create(self, section) + m5.uci:save("mwan3") + luci.http.redirect(dsp.build_url("admin", "network", "mwan", "policy", section)) +end use_member = mwan_policy:option(DummyValue, "use_member", translate("Members assigned")) - use_member.rawhtml = true - function use_member.cfgvalue(self, s) - local memberConfig, memberList = self.map:get(s, "use_member"), "" - if memberConfig then - for k,v in pairs(memberConfig) do - memberList = memberList .. v .. "
" - end - return memberList - else - return "—" +use_member.rawhtml = true +function use_member.cfgvalue(self, s) + local memberConfig, memberList = self.map:get(s, "use_member"), "" + if memberConfig then + for k,v in pairs(memberConfig) do + memberList = memberList .. v .. "
" end + return memberList + else + return "—" end +end last_resort = mwan_policy:option(DummyValue, "last_resort", translate("Last resort")) - last_resort.rawhtml = true - function last_resort.cfgvalue(self, s) - local action = self.map:get(s, "last_resort") - if action == "blackhole" then - return translate("blackhole (drop)") - elseif action == "default" then - return translate("default (use main routing table)") - else - return translate("unreachable (reject)") - end +last_resort.rawhtml = true +function last_resort.cfgvalue(self, s) + local action = self.map:get(s, "last_resort") + if action == "blackhole" then + return translate("blackhole (drop)") + elseif action == "default" then + return translate("default (use main routing table)") + else + return translate("unreachable (reject)") end +end return m5