diff options
author | Jo-Philipp Wich <jo@mein.io> | 2017-08-22 21:22:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-22 21:22:45 +0200 |
commit | d86244ab3946cb4cf8b15443dd3e62e23db1079a (patch) | |
tree | a5621982e81cd0e954b690a6214710b11388dc69 /modules/luci-base/htdocs/luci-static/resources/cbi.js | |
parent | eff0b74ef9b1b4edbc0d3956431f2c8257a5aa48 (diff) | |
parent | 28b996d66f370517e5653b7ee5a4f3e5b3616520 (diff) |
Merge pull request #1323 from yousong/shadowsocks-libev
luci-app-shadowsocks-libev: support for option dst_forward_recentrst
Diffstat (limited to 'modules/luci-base/htdocs/luci-static/resources/cbi.js')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/cbi.js | 84 |
1 files changed, 62 insertions, 22 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index b819230cf3..884eb62f68 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -118,48 +118,88 @@ var cbi_validators = { return false; }, - 'ipmask': function() + 'ip4prefix': function() { - return cbi_validators.ipmask4.apply(this) || - cbi_validators.ipmask6.apply(this); + return !isNaN(this) && this >= 0 && this <= 32; }, - 'ipmask4': function() + 'ip6prefix': function() { - var ip = this, mask = 32; + return !isNaN(this) && this >= 0 && this <= 128; + }, - if (ip.match(/^(\S+)\/(\S+)$/)) + 'cidr': function() + { + return cbi_validators.cidr4.apply(this) || + cbi_validators.cidr6.apply(this); + }, + + 'cidr4': function() + { + if (this.match(/^(\S+)\/(\S+)$/)) { ip = RegExp.$1; mask = RegExp.$2; + return cbi_validators.ip4addr.apply(ip) && + cbi_validators.ip4prefix.apply(mask); } + return false; + }, - if (!isNaN(mask) && (mask < 0 || mask > 32)) - return false; - - if (isNaN(mask) && !cbi_validators.ip4addr.apply(mask)) - return false; - - return cbi_validators.ip4addr.apply(ip); + 'cidr6': function() + { + if (this.match(/^(\S+)\/(\S+)$/)) + { + ip = RegExp.$1; + mask = RegExp.$2; + return cbi_validators.ip6addr.apply(ip) && + cbi_validators.ip6prefix.apply(mask); + } + return false; }, - 'ipmask6': function() + 'ipnet4': function() { - var ip = this, mask = 128; + if (this.match(/^(\S+)\/(\S+)$/)) + { + ip = RegExp.$1; + net = RegExp.$2; + return cbi_validators.ip4addr.apply(ip) && + cbi_validators.ip4addr.apply(net); + } + return false; + }, - if (ip.match(/^(\S+)\/(\S+)$/)) + 'ipnet6': function() + { + if (this.match(/^(\S+)\/(\S+)$/)) { ip = RegExp.$1; - mask = RegExp.$2; + net = RegExp.$2; + return cbi_validators.ip6addr.apply(ip) && + cbi_validators.ip6addr.apply(net); } + return false; + }, - if (!isNaN(mask) && (mask < 0 || mask > 128)) - return false; + 'ipmask': function() + { + return cbi_validators.ipmask4.apply(this) || + cbi_validators.ipmask6.apply(this); + }, - if (isNaN(mask) && !cbi_validators.ip6addr.apply(mask)) - return false; + 'ipmask4': function() + { + return cbi_validators.cidr4.apply(this) || + cbi_validators.ipnet4.apply(this) || + cbi_validators.ip4addr.apply(this); + }, - return cbi_validators.ip6addr.apply(ip); + 'ipmask6': function() + { + return cbi_validators.cidr6.apply(this) || + cbi_validators.ipnet6.apply(this) || + cbi_validators.ip6addr.apply(this); }, 'port': function() |