Add a check for a failed dns query in get_astext() (#9020)

DO NOT DELETE THIS TEXT

#### Please note

> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.

- [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)

#### Testers

If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
This commit is contained in:
Tony Murray
2018-08-17 12:17:45 -05:00
committed by Neil Lathwood
parent 90665533b7
commit c57f60644d

View File

@ -968,21 +968,25 @@ function snmp2ipv6($ipv6_snmp)
function get_astext($asn) function get_astext($asn)
{ {
global $config,$cache; global $cache;
if (Config::has("astext.$asn")) {
return Config::get("astext.$asn");
}
if (isset($config['astext'][$asn])) {
return $config['astext'][$asn];
} else {
if (isset($cache['astext'][$asn])) { if (isset($cache['astext'][$asn])) {
return $cache['astext'][$asn]; return $cache['astext'][$asn];
} else { }
$result = dns_get_record("AS$asn.asn.cymru.com", DNS_TXT); $result = dns_get_record("AS$asn.asn.cymru.com", DNS_TXT);
if (!empty($result[0]['txt'])) {
$txt = explode('|', $result[0]['txt']); $txt = explode('|', $result[0]['txt']);
$result = trim(str_replace('"', '', $txt[4])); $result = trim($txt[4], ' "');
$cache['astext'][$asn] = $result; $cache['astext'][$asn] = $result;
return $result; return $result;
} }
}
return '';
} }
/** /**