1
0
mirror of https://github.com/danog/dns.git synced 2024-11-26 20:14:51 +01:00

Make required changes

This commit is contained in:
Daniil Gentili 2019-06-13 19:52:24 +02:00
parent 996a7819bc
commit 0528aa7491

View File

@ -94,21 +94,16 @@ final class Rfc1035StubResolver implements Resolver
}
return call(function () use ($name, $typeRestriction) {
if (!$this->configStatus) {
try {
if ($this->configStatus === self::CONFIG_NOT_LOADED) {
yield $this->reloadConfig();
} catch (ConfigException $e) {
trigger_error("Could not load DNS config, using synchronous fallback", E_USER_WARNING);
$this->configStatus = self::CONFIG_FAILED;
}
}
if ($this->configStatus === self::CONFIG_FAILED) {
if (!\in_array($typeRestriction, [Record::A, null])) {
return [];
throw new DnsException("All query attempts failed for {$name}: could not load DNS config, and fallback cannot load non-A queries");
}
$result = \gethostbynamel($name);
if ($result === false) {
return [];
throw new DnsException("All query attempts failed for {$name}: could not load DNS config, and no records were returned by fallback");
}
foreach ($result as &$record) {
$record = new Record($record, Record::A, null);
@ -215,8 +210,13 @@ final class Rfc1035StubResolver implements Resolver
}
$promise = call(function () {
try {
$this->config = yield $this->configLoader->loadConfig();
$this->configStatus = self::CONFIG_LOADED;
} catch (ConfigException $e) {
\trigger_error("Could not load DNS config, using synchronous fallback", E_USER_WARNING);
$this->configStatus = self::CONFIG_FAILED;
}
});
$this->pendingConfig = $promise;
@ -257,12 +257,8 @@ final class Rfc1035StubResolver implements Resolver
}
$promise = call(function () use ($name, $type) {
if (!$this->configStatus) {
try {
if ($this->configStatus === self::CONFIG_NOT_LOADED) {
yield $this->reloadConfig();
} catch (ConfigException $e) {
$this->configStatus = self::CONFIG_FAILED;
}
}
if ($this->configStatus === self::CONFIG_FAILED) {
if ($type !== Record::A) {