X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;f=modules%2Fluci-base%2Fluasrc%2Fcbi%2Fdatatypes.lua;fp=modules%2Fluci-base%2Fluasrc%2Fcbi%2Fdatatypes.lua;h=95d19d88e0562aa2d1de71e5c24a868eb2fa068a;hb=bbcfad7953489ed87336e3a1981c9cb19e390cdb;hp=4c003be2a1bc50ad80301d84a6708f3125b2c96c;hpb=f25c4e07bc9642e0491d3a4ab3942a69545891e9;p=project%2Fluci.git diff --git a/modules/luci-base/luasrc/cbi/datatypes.lua b/modules/luci-base/luasrc/cbi/datatypes.lua index 4c003be2a..95d19d88e 100644 --- a/modules/luci-base/luasrc/cbi/datatypes.lua +++ b/modules/luci-base/luasrc/cbi/datatypes.lua @@ -189,9 +189,23 @@ function hostport(val) return not not (h and p and host(h) and port(p)) end -function ipaddrport(val) +function ip4addrport(val) local h, p = val:match("^([^:]+):([^:]+)$") - return not not (h and p and ipaddr(h) and port(p)) + return (h and p and ip4addr(h) and port(p)) +end + +function ipaddrport(val, bracket) + local h, p = val:match("^([^%[%]:]+):([^:]+)$") + if (h and p and ip4addr(h) and port(p)) then + return true + elseif (bracket == 1) then + h, p = val:match("^(%[.+%]):([^:]+)$") + if (h and p and ip6addr(h) and port(p)) then + return true + end + end + h, p = val:match("^([^%[%]]+):([^:]+)$") + return (h and p and ip6addr(h) and port(p)) end function wpakey(val)