summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--execute.php14
-rw-r--r--index.php2
-rw-r--r--routers/bird.php24
3 files changed, 14 insertions, 26 deletions
diff --git a/execute.php b/execute.php
index 6a5cd45..a6f0a15 100644
--- a/execute.php
+++ b/execute.php
@@ -35,12 +35,14 @@ function process_output($output) {
$valid = true;
- foreach ($config['filters'] as $filter) {
- // Line has been marked as invalid
- // Or filtered based on the configuration
- if (!$valid || (preg_match($filter, $line) === 1)) {
- $valid = false;
- break;
+ if (isset($config['filters'])) {
+ foreach ($config['filters'] as $filter) {
+ // Line has been marked as invalid
+ // Or filtered based on the configuration
+ if (!$valid || (preg_match($filter, $line) === 1)) {
+ $valid = false;
+ break;
+ }
}
}
diff --git a/index.php b/index.php
index 44c59d3..a2323b6 100644
--- a/index.php
+++ b/index.php
@@ -24,7 +24,6 @@ final class LookingGlass {
private $frontpage;
private $contact;
private $misc;
- private $filters;
private $routers;
function __construct() {
@@ -33,7 +32,6 @@ final class LookingGlass {
$this->frontpage = $config['frontpage'];
$this->contact = $config['contact'];
$this->misc = $config['misc'];
- $this->filters = $config['filters'];
$this->routers = $config['routers'];
}
diff --git a/routers/bird.php b/routers/bird.php
index 55f7ff9..16703c8 100644
--- a/routers/bird.php
+++ b/routers/bird.php
@@ -29,13 +29,9 @@ final class Bird extends Router {
switch ($command) {
case 'bgp':
if (match_ipv4($parameters)) {
- $commands[] = 'birdc';
- $commands[] = 'show route for '.$parameters;
- $commands[] = 'exit';
+ $commands[] = 'birdc show route for '.$parameters;
} else if (match_ipv6($parameters)) {
- $commands[] = 'birdc6';
- $commands[] = 'show route for '.$parameters;
- $commands[] = 'exit';
+ $commands[] = 'birdc6 show route for '.$parameters;
} else {
throw new Exception('The parameter is not an IPv4/IPv6 address.');
}
@@ -43,12 +39,8 @@ final class Bird extends Router {
case 'as-path-regex':
if (match_aspath_regex($parameters)) {
- $commands[] = 'birdc';
- $commands[] = 'show route where bgp_path ~ [= '.$parameters.' =]';
- $commands[] = 'exit';
- $commands[] = 'birdc6';
- $commands[] = 'show route where bgp_path ~ [= '.$parameters.' =]';
- $commands[] = 'exit';
+ $commands[] = 'birdc show route where bgp_path ~ [= '.$parameters.' =]';
+ $commands[] = 'birdc6 show route where bgp_path ~ [= '.$parameters.' =]';
} else {
throw new Exception('The parameter is not an AS-Path regular expression like ".*XXXX YYYY.*".');
}
@@ -56,12 +48,8 @@ final class Bird extends Router {
case 'as':
if (match_as($parameters)) {
- $commands[] = 'birdc';
- $commands[] = 'show route where bgp_path ~ [= '.$parameters.' =]';
- $commands[] = 'exit';
- $commands[] = 'birdc6';
- $commands[] = 'show route where bgp_path ~ [= '.$parameters.' =]';
- $commands[] = 'exit';
+ $commands[] = 'birdc show route where bgp_path ~ [= '.$parameters.' =]';
+ $commands[] = 'birdc6 show route where bgp_path ~ [= '.$parameters.' =]';
} else {
throw new Exception('The parameter is not an AS number.');
}