mirror of
https://github.com/danog/dns.git
synced 2024-11-30 04:29:06 +01:00
Add additional fallback
This commit is contained in:
parent
ecbeca2ae0
commit
eb0b0a26b5
@ -106,9 +106,23 @@ class BlockingFallbackResolver implements Resolver
|
||||
$encoder = $this->encoderFactory->create();
|
||||
$question = $encoder->encode($request);
|
||||
|
||||
$result = \dns_get_record(...$question);
|
||||
$result = @\dns_get_record(...$question);
|
||||
if ($result === false) {
|
||||
return new Failure(new DnsException("Query for '{$name}' failed, because loading the system's DNS configuration failed and blocking fallback via dns_get_record() failed, too."));
|
||||
if ($type !== Record::A) {
|
||||
return new Failure(new DnsException("Query for '{$name}' failed, because loading the system's DNS configuration failed and querying records other than A records isn't supported in blocking fallback mode."));
|
||||
}
|
||||
$result = \gethostbynamel($name);
|
||||
if ($result === false) {
|
||||
return new Failure(new DnsException("Query for '{$name}' failed, because loading the system's DNS configuration failed and blocking fallback via gethostbynamel() failed, too."));
|
||||
}
|
||||
if ($result === []) {
|
||||
return new Failure(new NoRecordException("No records returned for '{$name}' using blocking fallback mode."));
|
||||
}
|
||||
$records = [];
|
||||
foreach ($result as $record) {
|
||||
$records[] = new Record($record, Record::A, null);
|
||||
}
|
||||
return new Success($records);
|
||||
}
|
||||
|
||||
$decoder = $this->decoderFactory->create();
|
||||
|
Loading…
Reference in New Issue
Block a user