std.anystr2ip()

Converts the string addr to an IP address (IPv4 or IPv6). If conversion fails, fallback will be returned.

This function accepts a wider range of formats than std.str2ip(): Each number may be specified in hexadecimal (0x...), octal (0...), or decimal format, and there may be fewer than four numbers, in which case the last number is responsible for the remaining bytes of the IP. For example, 0x8.010.2056 is equivalent to 8.8.8.8.

We recommend using a fallback IP address that's meaningful for your particular Fastly service.

Format

IP
std.anystr2ip(STRING addr, STRING fallback)

Examples

1
2
3
if (std.anystr2ip("0xc0.0.01001", "192.0.2.2") ~ my_acl) {
  ...
}