synchro / ptrify
A utility class for generating DNS PTR records
Requires
- php: ^8.1.0
Requires (Dev)
- laravel/pint: ^1.10.1
- pestphp/pest: ^2.6.3
- phpstan/phpstan: ^1.10.18
- rector/rector: ^0.15.25
- symfony/var-dumper: ^6.3.0
README
Ptrify
This package provides a simple utility class for converting IP addresses to the format needed for DNS PTR records as defined in RFC1035 and RFC3596. While this can be done manually, it's a slightly tricky process that's easy to get wrong. This package aims to make it easier to generate PTR records for both IPv4 and IPv6 addresses.
This class does not attempt to handle subnets or wildcards, such as those discussed in RFC 4472; It is intended for use with single IP addresses only.
Requires PHP 8.1+
Installation
Install with Composer:
composer require synchro/ptrify
Usage
use Synchro\Ptrify\Ptrify; $ptr = Ptrify::ptrify('192.0.2.151'); //$ptr == '151.2.0.192.in-addr.arpa' $ptr6 = Ptrify::ptrify('2001:db8:f00::12:34ff:fe56:789a'); //$ptr6 == 'a.9.8.7.6.5.e.f.f.f.4.3.2.1.0.0.0.0.0.0.0.0.f.0.8.b.d.0.1.0.0.2.ip6.arpa'
Passing an invalid IP address (either v4 or v6) will throw an InvalidArgumentException
.
Contributing
See CONTRIBUTING.md for information, including coding standards and how to run tests.
Logo image based on this image of petrified wood by Petrifed ForestNPS under CC BY 2.0.
Package built from Skeleton PHP by Nuno Maduro under the MIT license.