gluon-config-mode-*, gluon-luci-portconfig: improve validation
Make bandwidth limits unsigned; trim numbers, the validator accepts trailing whitespace.
This commit is contained in:
parent
1e78665b12
commit
bb8d1783b3
@ -45,10 +45,10 @@ function M.handle(data)
|
|||||||
|
|
||||||
uci:set("gluon-node-info", sname, "share_location", data._location)
|
uci:set("gluon-node-info", sname, "share_location", data._location)
|
||||||
if data._location and data._latitude ~= nil and data._longitude ~= nil then
|
if data._location and data._latitude ~= nil and data._longitude ~= nil then
|
||||||
uci:set("gluon-node-info", sname, "latitude", data._latitude)
|
uci:set("gluon-node-info", sname, "latitude", data._latitude:trim())
|
||||||
uci:set("gluon-node-info", sname, "longitude", data._longitude)
|
uci:set("gluon-node-info", sname, "longitude", data._longitude:trim())
|
||||||
if data._altitude ~= nil then
|
if data._altitude ~= nil then
|
||||||
uci:set("gluon-node-info", sname, "altitude", data._altitude)
|
uci:set("gluon-node-info", sname, "altitude", data._altitude:trim())
|
||||||
else
|
else
|
||||||
uci:delete("gluon-node-info", sname, "altitude")
|
uci:delete("gluon-node-info", sname, "altitude")
|
||||||
end
|
end
|
||||||
|
@ -28,13 +28,13 @@ function M.section(form)
|
|||||||
o:depends("_limit_enabled", "1")
|
o:depends("_limit_enabled", "1")
|
||||||
o.value = uci:get("simple-tc", "mesh_vpn", "limit_ingress")
|
o.value = uci:get("simple-tc", "mesh_vpn", "limit_ingress")
|
||||||
o.rmempty = false
|
o.rmempty = false
|
||||||
o.datatype = "integer"
|
o.datatype = "uinteger"
|
||||||
|
|
||||||
o = s:option(cbi.Value, "_limit_egress", i18n.translate("Upstream (kbit/s)"))
|
o = s:option(cbi.Value, "_limit_egress", i18n.translate("Upstream (kbit/s)"))
|
||||||
o:depends("_limit_enabled", "1")
|
o:depends("_limit_enabled", "1")
|
||||||
o.value = uci:get("simple-tc", "mesh_vpn", "limit_egress")
|
o.value = uci:get("simple-tc", "mesh_vpn", "limit_egress")
|
||||||
o.rmempty = false
|
o.rmempty = false
|
||||||
o.datatype = "integer"
|
o.datatype = "uinteger"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.handle(data)
|
function M.handle(data)
|
||||||
@ -49,11 +49,11 @@ function M.handle(data)
|
|||||||
uci:set("simple-tc", "mesh_vpn", "ifname", "mesh-vpn")
|
uci:set("simple-tc", "mesh_vpn", "ifname", "mesh-vpn")
|
||||||
|
|
||||||
if data._limit_ingress ~= nil then
|
if data._limit_ingress ~= nil then
|
||||||
uci:set("simple-tc", "mesh_vpn", "limit_ingress", data._limit_ingress)
|
uci:set("simple-tc", "mesh_vpn", "limit_ingress", data._limit_ingress:trim())
|
||||||
end
|
end
|
||||||
|
|
||||||
if data._limit_egress ~= nil then
|
if data._limit_egress ~= nil then
|
||||||
uci:set("simple-tc", "mesh_vpn", "limit_egress", data._limit_egress)
|
uci:set("simple-tc", "mesh_vpn", "limit_egress", data._limit_egress:trim())
|
||||||
end
|
end
|
||||||
|
|
||||||
uci:commit("simple-tc")
|
uci:commit("simple-tc")
|
||||||
|
@ -99,9 +99,9 @@ function f.handle(self, state, data)
|
|||||||
if state == FORM_VALID then
|
if state == FORM_VALID then
|
||||||
uci:set("network", "wan", "proto", data.ipv4)
|
uci:set("network", "wan", "proto", data.ipv4)
|
||||||
if data.ipv4 == "static" then
|
if data.ipv4 == "static" then
|
||||||
uci:set("network", "wan", "ipaddr", data.ipv4_addr)
|
uci:set("network", "wan", "ipaddr", data.ipv4_addr:trim())
|
||||||
uci:set("network", "wan", "netmask", data.ipv4_netmask)
|
uci:set("network", "wan", "netmask", data.ipv4_netmask:trim())
|
||||||
uci:set("network", "wan", "gateway", data.ipv4_gateway)
|
uci:set("network", "wan", "gateway", data.ipv4_gateway:trim())
|
||||||
else
|
else
|
||||||
uci:delete("network", "wan", "ipaddr")
|
uci:delete("network", "wan", "ipaddr")
|
||||||
uci:delete("network", "wan", "netmask")
|
uci:delete("network", "wan", "netmask")
|
||||||
@ -110,8 +110,8 @@ function f.handle(self, state, data)
|
|||||||
|
|
||||||
uci:set("network", "wan6", "proto", data.ipv6)
|
uci:set("network", "wan6", "proto", data.ipv6)
|
||||||
if data.ipv6 == "static" then
|
if data.ipv6 == "static" then
|
||||||
uci:set("network", "wan6", "ip6addr", data.ipv6_addr)
|
uci:set("network", "wan6", "ip6addr", data.ipv6_addr:trim())
|
||||||
uci:set("network", "wan6", "ip6gw", data.ipv6_gateway)
|
uci:set("network", "wan6", "ip6gw", data.ipv6_gateway:trim())
|
||||||
else
|
else
|
||||||
uci:delete("network", "wan6", "ip6addr")
|
uci:delete("network", "wan6", "ip6addr")
|
||||||
uci:delete("network", "wan6", "ip6gw")
|
uci:delete("network", "wan6", "ip6gw")
|
||||||
|
Loading…
Reference in New Issue
Block a user