diff options
author | Guillaume Mazoyer <gmazoyer@gravitons.in> | 2016-06-13 00:00:32 +0200 |
---|---|---|
committer | Guillaume Mazoyer <gmazoyer@gravitons.in> | 2016-06-13 00:00:32 +0200 |
commit | 669fb2ebd03ac5e9b0806acb1c200e71e69b3d47 (patch) | |
tree | 39aa2352c0f14e3f94dcf4c0237e8fc81c9a0bd7 /routers/cisco.php | |
parent | 28bf462793fc9c15e70b73d3eb2223f6328abb84 (diff) |
Catch use of disable IP version before instanciating the router object.
Simplify the code and avoid unneeded computation.
Diffstat (limited to 'routers/cisco.php')
-rw-r--r-- | routers/cisco.php | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/routers/cisco.php b/routers/cisco.php index 0a7cb76..aee0b02 100644 --- a/routers/cisco.php +++ b/routers/cisco.php @@ -26,20 +26,9 @@ final class Cisco extends Router { protected function build_ping($destination) { $ping = null; - if (match_hostname($destination)) { + if (match_hostname($destination) || match_ipv6($destination) || + match_ipv4($destination)) { $ping = 'ping '.$destination.' repeat 10'; - } else if (match_ipv6($destination)) { - if ($this->global_config['misc']['disable_ipv6']) { - throw new Exception('IPv6 is disabled.'); - } else { - $ping = 'ping '.$destination.' repeat 10'; - } - } else if (match_ipv4($destination)) { - if ($this->global_config['misc']['disable_ipv4']) { - throw new Exception('IPv4 is disabled.'); - } else { - $ping = 'ping '.$destination.' repeat 10'; - } } else { throw new Exception('The parameter is not an IP address or a hostname.'); } @@ -90,17 +79,9 @@ final class Cisco extends Router { switch ($command) { case 'bgp': if (match_ipv6($parameter, false)) { - if ($this->global_config['misc']['disable_ipv6']) { - throw new Exception('IPv6 is disabled.'); - } else { - $commands[] = 'show bgp ipv6 unicast '.$parameter; - } + $commands[] = 'show bgp ipv6 unicast '.$parameter; } else if (match_ipv4($parameter, false)) { - if ($this->global_config['misc']['disable_ipv4']) { - throw new Exception('IPv4 is disabled.'); - } else { - $commands[] = 'show bgp ipv4 unicast '.$parameter; - } + $commands[] = 'show bgp ipv4 unicast '.$parameter; } else { throw new Exception('The parameter is not an IP address.'); } |