Release 1.0.6: синхронизировать изменения из upstream и исправить баг фильтра URLTest/Priority
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
#!/usr/bin/env ucode
|
||||
|
||||
let common = require("core.common");
|
||||
let as_string = common.as_string;
|
||||
|
||||
|
||||
function as_string(value) {
|
||||
return value == null ? "" : "" + value;
|
||||
}
|
||||
|
||||
function decimal_text(value, strict) {
|
||||
value = as_string(value);
|
||||
@@ -17,11 +16,20 @@ function valid_ipv4(value, allow_trailing_dot, strict_decimal) {
|
||||
if (allow_trailing_dot && length(value) > 0 && substr(value, length(value) - 1, 1) == ".")
|
||||
value = substr(value, 0, length(value) - 1);
|
||||
|
||||
let regex = strict_decimal
|
||||
? /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/
|
||||
: /^((25[0-5]|2[0-4][0-9]|0*[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|0*[01]?[0-9][0-9]?)$/;
|
||||
|
||||
return match(value, regex) != null;
|
||||
let parts = split(value, ".");
|
||||
if (length(parts) != 4)
|
||||
return false;
|
||||
|
||||
for (let part in parts) {
|
||||
if (!decimal_text(part, strict_decimal))
|
||||
return false;
|
||||
|
||||
let octet = int(part);
|
||||
if (octet < 0 || octet > 255)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function valid_ipv4_cidr(value, strict_decimal) {
|
||||
@@ -141,4 +149,4 @@ return {
|
||||
nft_ip_or_cidr,
|
||||
ip_family,
|
||||
format_ipv6_tproxy_target
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user