astrotomic / laravel-dns
Fund package maintenance!
Gummibeer
SarahSibert
Issuehunt
forest.astrotomic.info
Installs: 6 026
Dependents: 0
Suggesters: 0
Security: 0
Stars: 31
Watchers: 4
Forks: 2
Open Issues: 0
Requires
- php: ^8.1
- illuminate/collections: ^9.0 || ^10.0
- illuminate/container: ^9.0 || ^10.0
- illuminate/contracts: ^9.0 || ^10.0
- illuminate/support: ^9.0 || ^10.0
- illuminate/translation: ^9.0 || ^10.0
- spatie/dns: ^2.0.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- orchestra/testbench: ^7.0 || ^8.0
- pestphp/pest: ^1.22
- pestphp/pest-plugin-laravel: ^1.3
README
Installation
composer require astrotomic/laravel-dns
Usage
use Astrotomic\Dns\Facades\Dns; /** @var \Illuminate\Support\Collection $records */ $records = Dns::records('astrotomic.info', DNS_A);
use Astrotomic\Dns\Rules\DnsRecordExists; use Spatie\Dns\Records\A; use Spatie\Dns\Records\TXT; return [ 'url' => [ 'required', 'string', 'url', // verify that domain of entered url // has any A, AAAA or CNAME record // and a TXT record with the users token DnsRecordExists::make() ->expect(DNS_A|DNS_AAAA|DNS_CNAME) ->expect(DNS_TXT, fn(TXT $record): bool => $record->txt() === 'token='.$this->user()->public_token), ], 'email' => [ 'required', 'string', 'email', // verify that domain of entered email // has any MX record // and SPF setup DnsRecordExists::make() ->expect(DNS_MX) ->expect(DNS_TXT, fn(TXT $record): bool => str_starts_with($record->txt(), 'v=spf1 ')), ], 'domain' => [ 'required', 'string', // verify that entered domain // has an A record // pointing to our IP-address DnsRecordExists::make() ->expect(DNS_A, fn(A $record): bool => $record->ip() === '127.0.0.1'), ], 'something' => [ 'required', 'string', // verify that value is something with DNS DnsRecordExists::make(), ], ];
use Astrotomic\Dns\Domain; protected $casts = [ 'domain' => Domain::class, ];
use Astrotomic\Dns\Domain; /** @var \Astrotomic\Dns\Domain $domain */ $domain = Domain::make('dns@astrotomic.info'); /** @var string|null $domain */ $domain = Domain::parse('dns@astrotomic.info');