From c6119c771d8fdc4f4794e03afd9a4f84b5cdbebe Mon Sep 17 00:00:00 2001 From: Guillaume Mazoyer Date: Thu, 23 Jul 2015 17:59:59 +0200 Subject: 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. --- routers/quagga.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'routers/quagga.php') diff --git a/routers/quagga.php b/routers/quagga.php index 1944273..9ce6606 100644 --- a/routers/quagga.php +++ b/routers/quagga.php @@ -26,21 +26,21 @@ final class Quagga 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 Quagga 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.'); } -- cgit v1.2.3