X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Fluci-base%2Fluasrc%2Fcbi%2Fdatatypes.lua;h=52f90afee675488cf1eb19557264ed77a9716f5a;hp=c52ac4688abfadb11c5c0f8e7c51c5a3d7ca3eba;hb=3a58ef46c279ba4a72c21b81256877c16444b9fb;hpb=7a3493b1f7d75a3945279115324cf2ff4da26b7b diff --git a/modules/luci-base/luasrc/cbi/datatypes.lua b/modules/luci-base/luasrc/cbi/datatypes.lua index c52ac4688..52f90afee 100644 --- a/modules/luci-base/luasrc/cbi/datatypes.lua +++ b/modules/luci-base/luasrc/cbi/datatypes.lua @@ -1,4 +1,4 @@ --- Copyright 2010 Jo-Philipp Wich +-- Copyright 2010 Jo-Philipp Wich -- Licensed to the public under the Apache License 2.0. local fs = require "nixio.fs" @@ -184,6 +184,16 @@ function network(val) return uciname(val) or host(val) end +function hostport(val) + local h, p = val:match("^([^:]+):([^:]+)$") + return not not (h and p and host(h) and port(p)) +end + +function ipaddrport(val) + local h, p = val:match("^([^:]+):([^:]+)$") + return not not (h and p and ipaddr(h) and port(p)) +end + function wpakey(val) if #val == 64 then return (val:match("^[a-fA-F0-9]+$") ~= nil)