diff options
author | Guillaume Mazoyer <gmazoyer@gravitons.in> | 2015-07-23 17:59:59 +0200 |
---|---|---|
committer | Guillaume Mazoyer <gmazoyer@gravitons.in> | 2015-07-23 17:59:59 +0200 |
commit | c6119c771d8fdc4f4794e03afd9a4f84b5cdbebe (patch) | |
tree | 6733adef9fe17a7c9a2e4dcaab559a0d886034f2 /routers/bird.php | |
parent | 6e9a4fb7765dda39656d1e95a743de1f79aab3b2 (diff) |
Rework hostname parameter check.
Rename FQDN to hostname which seems more appropriate.
Refactor match_fqdn / match_hostname function to use a more accurate way of
checking a potential hostname.
Diffstat (limited to 'routers/bird.php')
-rw-r--r-- | routers/bird.php | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/routers/bird.php b/routers/bird.php index fe9b197..b1a75b8 100644 --- a/routers/bird.php +++ b/routers/bird.php @@ -26,21 +26,21 @@ final class Bird extends Router { protected function build_ping($destination) { $ping = null; - if (match_fqdn($destination)) { - $fqdn = $destination; - $destination = fqdn_to_ip_address($fqdn); + if (match_hostname($destination)) { + $hostname = $destination; + $destination = hostname_to_ip_address($hostname); if (!$destination) { - throw new Exception('No A or AAAA record found for '.$fqdn); + throw new Exception('No A or AAAA record found for '.$hostname); } } if (match_ipv4($destination)) { $ping = 'ping '.$this->global_config['tools']['ping_options'].' '. - (isset($fqdn) ? $fqdn : $destination); + (isset($hostname) ? $hostname : $destination); } else if (match_ipv6($destination)) { $ping = 'ping6 '.$this->global_config['tools']['ping_options'].' '. - (isset($fqdn) ? $fqdn : $destination); + (isset($hostname) ? $hostname : $destination); } else { throw new Exception('The parameter does not resolve to an IPv4/IPv6 address.'); } @@ -63,23 +63,23 @@ final class Bird extends Router { protected function build_traceroute($destination) { $traceroute = null; - if (match_fqdn($destination)) { - $fqdn = $destination; - $destination = fqdn_to_ip_address($fqdn); + if (match_hostname($destination)) { + $hostname = $destination; + $destination = hostname_to_ip_address($hostname); if (!$destination) { - throw new Exception('No A or AAAA record found for '.$fqdn); + throw new Exception('No A or AAAA record found for '.$hostname); } } if (match_ipv4($destination)) { $traceroute = $this->global_config['tools']['traceroute4'].' '. $this->global_config['tools']['traceroute_options'].' '. - (isset($fqdn) ? $fqdn : $destination); + (isset($hostname) ? $hostname : $destination); } else if (match_ipv6($destination)) { $traceroute = $this->global_config['tools']['traceroute6'].' '. $this->global_config['tools']['traceroute_options'].' '. - (isset($fqdn) ? $fqdn : $destination); + (isset($hostname) ? $hostname : $destination); } else { throw new Exception('The parameter does not resolve to an IPv4/IPv6 address.'); } |