diff options
Diffstat (limited to 'routers/quagga.php')
-rw-r--r-- | routers/quagga.php | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/routers/quagga.php b/routers/quagga.php index 55f423f..bc91cdf 100644 --- a/routers/quagga.php +++ b/routers/quagga.php @@ -2,7 +2,7 @@ /* * Looking Glass - An easy to deploy Looking Glass - * Copyright (C) 2014-2015 Guillaume Mazoyer <gmazoyer@gravitons.in> + * Copyright (C) 2014-2016 Guillaume Mazoyer <gmazoyer@gravitons.in> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ final class Quagga extends Router { $destination = hostname_to_ip_address($hostname); if (!$destination) { - throw new Exception('No AAAA or A record found for '.$hostname); + throw new Exception('No record found for '.$hostname); } } @@ -42,7 +42,7 @@ final class Quagga extends Router { $ping = 'ping '.$this->global_config['tools']['ping_options'].' '. (isset($hostname) ? $hostname : $destination); } else { - throw new Exception('The parameter does not resolve to an IPv6/IPv4 address.'); + throw new Exception('The parameter does not resolve to an IP address.'); } if (($ping != null) && $this->has_source_interface_id()) { @@ -68,7 +68,7 @@ final class Quagga extends Router { $destination = hostname_to_ip_address($hostname); if (!$destination) { - throw new Exception('No AAAA or A record found for '.$hostname); + throw new Exception('No record found for '.$hostname); } } @@ -81,7 +81,7 @@ final class Quagga extends Router { $this->global_config['tools']['traceroute_options'].' '. (isset($hostname) ? $hostname : $destination); } else { - throw new Exception('The parameter does not resolve to an IPv6/IPv4 address.'); + throw new Exception('The parameter does not resolve to an IP address.'); } if (($traceroute != null) && $this->has_source_interface_id()) { @@ -109,18 +109,30 @@ final class Quagga extends Router { switch ($command) { case 'bgp': if (match_ipv6($parameter, false)) { - $commands[] = $vtysh.'show bgp ipv6 unicast '.$parameter.'"'; + if ($this->global_config['misc']['disable_ipv6']) { + throw new Exception('IPv6 is disabled.'); + } else { + $commands[] = $vtysh.'show bgp ipv6 unicast '.$parameter.'"'; + } } else if (match_ipv4($parameter, false)) { - $commands[] = $vtysh.'show bgp ipv4 unicast '.$parameter.'"'; + if ($this->global_config['misc']['disable_ipv4']) { + throw new Exception('IPv4 is disabled.'); + } else { + $commands[] = $vtysh.'show bgp ipv4 unicast '.$parameter.'"'; + } } else { - throw new Exception('The parameter is not an IPv4/IPv6 address.'); + throw new Exception('The parameter is not an IP address.'); } break; case 'as-path-regex': if (match_aspath_regex($parameter)) { - $commands[] = $vtysh.'show ipv6 bgp regexp '.$parameter.'"'; - $commands[] = $vtysh.'show ip bgp regexp '.$parameter.'"'; + if (!$this->global_config['misc']['disable_ipv6']) { + $commands[] = $vtysh.'show ipv6 bgp regexp '.$parameter.'"'; + } + if (!$this->global_config['misc']['disable_ipv4']) { + $commands[] = $vtysh.'show ip bgp regexp '.$parameter.'"'; + } } else { throw new Exception('The parameter is not an AS-Path regular expression.'); } @@ -128,8 +140,12 @@ final class Quagga extends Router { case 'as': if (match_as($parameter)) { - $commands[] = $vtysh.'show ipv6 bgp regexp ^'.$parameter.'_'.'"'; - $commands[] = $vtysh.'show ip bgp regexp ^'.$parameter.'_'.'"'; + if (!$this->global_config['misc']['disable_ipv6']) { + $commands[] = $vtysh.'show ipv6 bgp regexp ^'.$parameter.'_'.'"'; + } + if (!$this->global_config['misc']['disable_ipv4']) { + $commands[] = $vtysh.'show ip bgp regexp ^'.$parameter.'_'.'"'; + } } else { throw new Exception('The parameter is not an AS number.'); } |