Skip to content
Permalink
Browse files

Closes #67: Fix coding errors.

* Fix mixture of destination and parameter.
* Fix undefined method.
  • Loading branch information...
markeganfuller authored and respawner committed May 3, 2019
1 parent 29a3b5e commit 939de561c9470366ef2c419c7accdc634480f819
Showing with 20 additions and 20 deletions.
  1. +2 −2 routers/cisco_iosxr.php
  2. +10 −10 routers/extreme_netiron.php
  3. +7 −7 routers/juniper.php
  4. +1 −1 routers/mikrotik.php
@@ -67,13 +67,13 @@ protected function build_ping($parameter) {
return array($cmd);
}
protected function build_traceroute($destination) {
protected function build_traceroute($parameter) {
if (!is_valid_destination($parameter)) {
throw new Exception('The parameter is not an IP address or a hostname.');
}
$cmd = new CommandBuilder('traceroute');
if (match_ipv6($destination) || match_ipv4($destination) ||
if (match_ipv6($parameter) || match_ipv4($parameter) ||
!$this->has_source_interface_id()) {
$cmd->add($parameter);
} else {
@@ -41,7 +41,7 @@ protected function build_bgp($parameter) {
$cmd->add('bgp routes');
if ($this->config['bgp_detail']) {
$this->add('detail');
$cmd->add('detail');
}
$cmd->add($parameter);
@@ -104,12 +104,12 @@ protected function build_ping($parameter) {
throw new Exception('No record found for '.$hostname);
}
if (match_ipv6($destination)) {
if (match_ipv6($parameter)) {
$cmd->add('ipv6');
}
$cmd->add(isset($hostname) ? $hostname : $parameter);
} else {
if (match_ipv6($destination)) {
if (match_ipv6($parameter)) {
$cmd->add('ipv6');
}
$cmd->add($parameter);
@@ -118,18 +118,18 @@ protected function build_ping($parameter) {
if ($this->has_source_interface_id()) {
$cmd->add('source');
if (match_ipv6($destination) && $this->get_source_interface_id('ipv6')) {
if (match_ipv6($parameter) && $this->get_source_interface_id('ipv6')) {
$cmd->add($this->get_source_interface_id('ipv6'));
}
if (match_ipv4($destination) && $this->get_source_interface_id('ipv4')) {
if (match_ipv4($parameter) && $this->get_source_interface_id('ipv4')) {
$cmd->add($this->get_source_interface_id('ipv4'));
}
}
return array($cmd);
}
protected function build_traceroute($destination) {
protected function build_traceroute($parameter) {
if (!is_valid_destination($parameter)) {
throw new Exception('The parameter is not an IP address or a hostname.');
}
@@ -143,12 +143,12 @@ protected function build_traceroute($destination) {
throw new Exception('No record found for '.$hostname);
}
if (match_ipv6($destination)) {
if (match_ipv6($parameter)) {
$cmd->add('ipv6');
}
$cmd->add(isset($hostname) ? $hostname : $parameter);
} else {
if (match_ipv6($destination)) {
if (match_ipv6($parameter)) {
$cmd->add('ipv6');
}
$cmd->add($parameter);
@@ -157,10 +157,10 @@ protected function build_traceroute($destination) {
if ($this->has_source_interface_id()) {
$cmd->add('source');
if (match_ipv6($destination) && $this->get_source_interface_id('ipv6')) {
if (match_ipv6($parameter) && $this->get_source_interface_id('ipv6')) {
$cmd->add($this->get_source_interface_id('ipv6'));
}
if (match_ipv4($destination) && $this->get_source_interface_id('ipv4')) {
if (match_ipv4($parameter) && $this->get_source_interface_id('ipv4')) {
$cmd->add($this->get_source_interface_id('ipv4'));
}
}
@@ -81,29 +81,29 @@ protected function build_as($parameter) {
return $this->build_aspath_regexp($parameter);
}
protected function build_ping($destination) {
if (!is_valid_destination($destination)) {
protected function build_ping($parameter) {
if (!is_valid_destination($parameter)) {
throw new Exception('The parameter is not an IP address or a hostname.');
}
$cmd = new CommandBuilder('ping count 10 rapid', $destination);
$cmd = new CommandBuilder('ping count 10 rapid', $parameter);
if ($this->has_source_interface_id()) {
$cmd->add('interface', $this->get_source_interface_id());
}
return array($cmd);
}
protected function build_traceroute($destination) {
if (!is_valid_destination($destination)) {
protected function build_traceroute($parameter) {
if (!is_valid_destination($parameter)) {
throw new Exception('The parameter is not an IP address or a hostname.');
}
$cmd = new CommandBuilder('traceroute');
if (match_ipv4($destination)) {
if (match_ipv4($parameter)) {
$cmd->add('as-number-lookup');
}
$cmd->add($destination);
$cmd->add($parameter);
if ($this->has_source_interface_id()) {
$cmd->add('interface', $this->get_source_interface_id());
@@ -120,7 +120,7 @@ protected function build_traceroute($parameter) {
}
$cmd = new CommandBuilder('tool traceroute count=1 use-dns=yes');
if (match_hostname($destination)) {
if (match_hostname($parameter)) {
$cmd->add('address=[:resolv '.quote($parameter).']');
} else {
$cmd->add('address='.quote($parameter));

0 comments on commit 939de56

Please sign in to comment.
You can’t perform that action at this time.