Static helper class providing some useful internet-protocol-related functions.
More...
|
static | get_ip_address (string $hostname) |
| Return IP address for given hostname, or null on failure.
|
|
static | is_domain_in_allowed_list ($domain, $alloweddomains) |
| Checks the domain name against a list of allowed domains.
|
|
static | is_domain_matching_pattern ($pattern) |
| Checks whether the input string is a valid wildcard domain matching pattern.
|
|
static | is_domain_name ($domainname) |
| Syntax checking for domain names, including fully qualified domain names.
|
|
static | is_ip_address ($address) |
| Syntax validation for IP addresses, supporting both IPv4 and Ipv6 formats.
|
|
static | is_ip_in_subnet_list ($ip, $list, $delim="\n") |
| Is an ip in a given list of subnets?
|
|
static | is_ipv4_address ($address) |
| Syntax validation for IPv4 addresses.
|
|
static | is_ipv4_range ($addressrange) |
| Syntax checking for IPv4 address ranges.
|
|
static | is_ipv6_address ($address) |
| Syntax validation for IPv6 addresses.
|
|
static | is_ipv6_range ($addressrange) |
| Syntax validation for IPv6 address ranges.
|
|
Static helper class providing some useful internet-protocol-related functions.
- Copyright
- 2016 Jake Dallimore
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- Author
- Jake Dallimore jrhda.nosp@m.llim.nosp@m.ore@g.nosp@m.mail.nosp@m..com
◆ get_ip_address()
static core\ip_utils::get_ip_address |
( |
string | $hostname | ) |
|
|
static |
Return IP address for given hostname, or null on failure.
- Parameters
-
- Return values
-
◆ is_domain_in_allowed_list()
static core\ip_utils::is_domain_in_allowed_list |
( |
| $domain, |
|
|
| $alloweddomains ) |
|
static |
Checks the domain name against a list of allowed domains.
The list of allowed domains may use wildcards that match {
- See also
- is_domain_matching_pattern()}. Domains are compared in a case-insensitive manner
- Parameters
-
string | $domain | Domain address |
array | $alloweddomains | An array of allowed domains. |
- Return values
-
boolean | True if the domain matches one of the entries in the allowed domains list. |
◆ is_domain_matching_pattern()
static core\ip_utils::is_domain_matching_pattern |
( |
| $pattern | ) |
|
|
static |
Checks whether the input string is a valid wildcard domain matching pattern.
A domain matching pattern is essentially a domain name with a single, leading wildcard (*) label, and at least one other label. The wildcard label is considered to match at least one label at or above (to the left of) its position in the string, but will not match the trailing domain (everything to its right).
The string must be dot-separated, and the whole pattern must follow the domain name syntax rules defined in RFC1034/1035. Namely, the character type (ascii), total-length (253) and label-length (63) restrictions. This function only confirms syntactic correctness. It does not check for the existence of the domain/subdomains.
For example, the string '*.example.com' is a pattern deemed to match any direct subdomain of example.com (such as test.example.com), any higher level subdomains (e.g. another.test.example.com) but will not match the 'example.com' domain itself.
- Parameters
-
string | $pattern | the string to check. |
- Return values
-
bool | true if the input string is a valid domain wildcard matching pattern, false otherwise. |
◆ is_domain_name()
static core\ip_utils::is_domain_name |
( |
| $domainname | ) |
|
|
static |
Syntax checking for domain names, including fully qualified domain names.
This function does not verify the existence of the domain name. It only verifies syntactic correctness. This is based on RFC1034/1035 and does not provide support for validation of internationalised domain names (IDNs). All IDNs must be prior-converted to their ascii-compatible encoding before being passed to this function.
- Parameters
-
string | $domainname | the input string to check. |
- Return values
-
bool | true if the string has valid syntax, false otherwise. |
◆ is_ip_address()
static core\ip_utils::is_ip_address |
( |
| $address | ) |
|
|
static |
Syntax validation for IP addresses, supporting both IPv4 and Ipv6 formats.
- Parameters
-
string | $address | the address to check. |
- Return values
-
bool | true if the address is a valid IPv4 of IPv6 address, false otherwise. |
◆ is_ip_in_subnet_list()
static core\ip_utils::is_ip_in_subnet_list |
( |
| $ip, |
|
|
| $list, |
|
|
| $delim = "\n" ) |
|
static |
Is an ip in a given list of subnets?
- Parameters
-
string | $ip | - the IP to test against the list |
string | $list | - the list of IP subnets |
string | $delim | a delimiter of the list |
- Return values
-
◆ is_ipv4_address()
static core\ip_utils::is_ipv4_address |
( |
| $address | ) |
|
|
static |
Syntax validation for IPv4 addresses.
- Parameters
-
string | $address | the address to check. |
- Return values
-
bool | true if the address is a valid IPv4 address, false otherwise. |
◆ is_ipv4_range()
static core\ip_utils::is_ipv4_range |
( |
| $addressrange | ) |
|
|
static |
Syntax checking for IPv4 address ranges.
Supports CIDR notation and last-group ranges. Eg. 127.0.0.0/24 or 127.0.0.80-255
- Parameters
-
string | $addressrange | the address range to check. |
- Return values
-
bool | true if the string is a valid range representation, false otherwise. |
◆ is_ipv6_address()
static core\ip_utils::is_ipv6_address |
( |
| $address | ) |
|
|
static |
Syntax validation for IPv6 addresses.
This function does not check whether the address is assigned, only its syntactical correctness.
- Parameters
-
string | $address | the address to check. |
- Return values
-
bool | true if the address is a valid IPv6 address, false otherwise. |
◆ is_ipv6_range()
static core\ip_utils::is_ipv6_range |
( |
| $addressrange | ) |
|
|
static |
Syntax validation for IPv6 address ranges.
Supports CIDR notation and last-group ranges. Eg. fe80\d98c/64 or fe80\d98c-ffee
- Parameters
-
string | $addressrange | the IPv6 address range to check. |
- Return values
-
bool | true if the string is a valid range representation, false otherwise. |
The documentation for this class was generated from the following file: