mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
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
committed by
Neil Lathwood
parent
90665533b7
commit
c57f60644d
@ -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 '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user