composer require astrotomic/laravel-dns
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('[email protected]');
/** @var string|null $domain */
$domain = Domain::parse('[email protected]');