diff options
| author | Greg Roach <greg@subaqua.co.uk> | 2020-08-05 23:48:14 +0100 |
|---|---|---|
| committer | Greg Roach <greg@subaqua.co.uk> | 2020-08-05 23:48:14 +0100 |
| commit | d3744fc7614d3127c84109f68f7045777b04c62b (patch) | |
| tree | 49e88bea0bbf7e42768f4c45c00e961000ebb535 /vendor/mlocati | |
| parent | 32a9a96bd3e44c8adc659d014c069f7a9c1f70dc (diff) | |
| download | webtrees-d3744fc7614d3127c84109f68f7045777b04c62b.tar.gz webtrees-d3744fc7614d3127c84109f68f7045777b04c62b.tar.bz2 webtrees-d3744fc7614d3127c84109f68f7045777b04c62b.zip | |
Update vendor dependencies
Diffstat (limited to 'vendor/mlocati')
| -rw-r--r-- | vendor/mlocati/ip-lib/README.md | 34 | ||||
| -rw-r--r-- | vendor/mlocati/ip-lib/src/Address/AddressInterface.php | 10 | ||||
| -rw-r--r-- | vendor/mlocati/ip-lib/src/Address/IPv4.php | 13 | ||||
| -rw-r--r-- | vendor/mlocati/ip-lib/src/Address/IPv6.php | 13 |
4 files changed, 53 insertions, 17 deletions
diff --git a/vendor/mlocati/ip-lib/README.md b/vendor/mlocati/ip-lib/README.md index 64dd4eab39..ffb79fbfef 100644 --- a/vendor/mlocati/ip-lib/README.md +++ b/vendor/mlocati/ip-lib/README.md @@ -7,18 +7,15 @@ # IPLib - Handle IPv4, IPv6 and IP ranges - ## Introduction This library can handle IPv4, IPv6 addresses, as well as IP ranges, in CIDR formats (like `::1/128` or `127.0.0.1/32`) and in pattern format (like `::*:*` or `127.0.*.*`). - ## Requirements The only requirement is PHP 5.3.3. __No external dependencies__ and __no special PHP configuration__ are needed (yes, it will __always work__ even if PHP has not been built with IPv6 support!). - ## Manual installation [Download](https://github.com/mlocati/ip-lib/releases) the latest version, unzip it and add these lines in our PHP files: @@ -27,7 +24,6 @@ __No external dependencies__ and __no special PHP configuration__ are needed (ye require_once 'path/to/iplib/ip-lib.php'; ``` - ## Installation with Composer Simply run `composer require mlocati/ip-lib`, or add these lines to your `composer.json` file: @@ -38,10 +34,8 @@ Simply run `composer require mlocati/ip-lib`, or add these lines to your `compos } ``` - ## Sample usage - ### Parse an address To parse an IPv4 address: @@ -63,7 +57,6 @@ $address = \IPLib\Factory::addressFromString('::1'); $address = \IPLib\Factory::addressFromString('127.0.0.1'); ``` - ### Get the next/previous addresses ```php @@ -74,7 +67,6 @@ echo (string) $address->getNextAddress(); // prints ::2 ``` - ### Parse an IP address range To parse a subnet (CIDR) range: @@ -106,7 +98,6 @@ $range = \IPLib\Factory::rangeFromString('::1/128'); $range = \IPLib\Factory::rangeFromString('::'); ``` - ### Retrive a range from its boundaries ```php @@ -115,7 +106,6 @@ echo (string) $range; // prints 192.168.0.0/16 ``` - ### Retrive the boundaries of a range ```php @@ -126,7 +116,6 @@ echo (string) $range->getEndAddress(); // prints 127.0.0.255 ``` - ### Format addresses and ranges Both IP addresses and ranges have a `toString` method that you can use to retrieve a textual representation: @@ -161,7 +150,6 @@ echo \IPLib\Factory::rangeFromString('0:0::1/64')->toString(); // prints 0000:0000:0000:0000:0000:0000:0000:0001/64 ``` - ### Check if an address is contained in a range All the range types offer a `contains` method, and all the IP address types offer a `matches` method: you can call them to check if an address is contained in a range: @@ -177,7 +165,6 @@ $contained = $range->contains($address); Please remark that if the address is IPv4 and the range is IPv6 (or vice-versa), the result will always be `false`. - ### Check if a range contains another range All the range types offer a `containsRange` method: you can call them to check if an address range fully contains another range: @@ -188,7 +175,6 @@ $range2 = \IPLib\Factory::rangeFromString('0:0::1/65'); $contained = $range1->containsRange($range2); ``` - ### Getting the type of an IP address If you want to know if an address is within a private network, or if it's a public IP, or whatever you want, you can use the `getRangeType` method: @@ -207,7 +193,6 @@ The most notable values of the range type ID are: - `\IPLib\Range\Type::T_PRIVATENETWORK` if the address is in the local network (for instance `192.168.0.1` or `fc00::1`) - `\IPLib\Range\Type::T_PUBLIC` if the address is for public usage (for instance `104.25.25.33` or `2001:503:ba3e::2:30`) - ### Getting the type of an IP address range If you want to know the type of an address range, you can use the `getRangeType` method: @@ -230,7 +215,6 @@ echo \IPLib\Range\Type::getName($type); // 'Unknown type' ``` - ### Converting IP addresses This library supports converting IPv4 to/from IPv6 addresses using the [6to4 notation](https://tools.ietf.org/html/rfc3056) or the [IPv4-mapped notation](https://tools.ietf.org/html/rfc4291#section-2.5.5.2): @@ -253,7 +237,6 @@ echo (string) $ipv6; echo $ipv6_6to4->toIPv4(); ``` - ### Converting IP ranges This library supports IPv4/IPv6 ranges in pattern format (eg. `192.168.*.*`) and in CIDR/subnet format (eg. `192.168.0.0/16`), and it offers a way to convert between the two formats: @@ -284,6 +267,23 @@ echo \IPLib\Factory::rangeFromString('192.168.0.*')->getSubnetMask()->toString() echo \IPLib\Factory::rangeFromString('192.168.0.12/30')->getSubnetMask()->toString(); ``` +### Getting the reverse DNS lookup address + +In order to perform reverse DNS queries, you need to use a special format of the IP addresses. + +You can use the `getReverseDNSLookupName()` method of the IP address instances to easily retrieve it: + +```php + +$ipv4 = \IPLib\Factory::addressFromString('1.2.3.255'); +// This will print 255.3.2.1.in-addr.arpa +echo $ipv4->getReverseDNSLookupName(); + +$ipv6 = \IPLib\Factory::addressFromString('1234:abcd::cafe:babe'); +// This will print e.b.a.b.e.f.a.c.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.c.b.a.4.3.2.1.ip6.arpa +echo $ipv6->getReverseDNSLookupName(); +``` + ### Using a database This package offers a great feature: you can store address ranges in a database table, and check if an address is contained in one of the saved ranges with a simple query. diff --git a/vendor/mlocati/ip-lib/src/Address/AddressInterface.php b/vendor/mlocati/ip-lib/src/Address/AddressInterface.php index e4ee31daad..e42bc80a5b 100644 --- a/vendor/mlocati/ip-lib/src/Address/AddressInterface.php +++ b/vendor/mlocati/ip-lib/src/Address/AddressInterface.php @@ -93,4 +93,14 @@ interface AddressInterface * @return \IPLib\Address\AddressInterface|null */ public function getPreviousAddress(); + + /** + * Get the Reverse DNS Lookup Address of this IP address. + * + * @return string + * + * @example for IPv4 it returns something like x.x.x.x.in-addr.arpa + * @example for IPv6 it returns something like x.x.x.x..x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.ip6.arpa + */ + public function getReverseDNSLookupName(); } diff --git a/vendor/mlocati/ip-lib/src/Address/IPv4.php b/vendor/mlocati/ip-lib/src/Address/IPv4.php index d7f9fb0f7e..0933ad6d6c 100644 --- a/vendor/mlocati/ip-lib/src/Address/IPv4.php +++ b/vendor/mlocati/ip-lib/src/Address/IPv4.php @@ -424,4 +424,17 @@ class IPv4 implements AddressInterface return $overflow ? null : static::fromBytes($bytes); } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getReverseDNSLookupName() + */ + public function getReverseDNSLookupName() + { + return implode( + '.', + array_reverse($this->getBytes()) + ) . '.in-addr.arpa'; + } } diff --git a/vendor/mlocati/ip-lib/src/Address/IPv6.php b/vendor/mlocati/ip-lib/src/Address/IPv6.php index 605c2bb13f..63568f0605 100644 --- a/vendor/mlocati/ip-lib/src/Address/IPv6.php +++ b/vendor/mlocati/ip-lib/src/Address/IPv6.php @@ -527,4 +527,17 @@ class IPv6 implements AddressInterface return $overflow ? null : static::fromWords($words); } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getReverseDNSLookupName() + */ + public function getReverseDNSLookupName() + { + return implode( + '.', + array_reverse(str_split(str_replace(':', '', $this->toString(true)), 1)) + ) . '.ip6.arpa'; + } } |
