summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Mazoyer <respawneral@gmail.com>2014-08-05 16:34:22 +0200
committerGuillaume Mazoyer <respawneral@gmail.com>2014-08-05 16:34:22 +0200
commit19d30190e20f1c0b2848ea4043aaf9c31e48e386 (patch)
tree64bd66efbab9f9b727b09aae046cd48008321e16
parent947303f3443a4379fc0000aad441bb156ef866b5 (diff)
Add config.defaults.php to set default configuration options.
The defaults can be overriden in the config.php file but some of them are fine as defaults. This will help in having a config.php file as short as we can. Also move utils.php to the includes directory.
-rw-r--r--config.php.example33
-rw-r--r--execute.php1
-rw-r--r--includes/config.defaults.php56
-rw-r--r--includes/utils.php (renamed from utils.php)0
-rw-r--r--index.php1
-rw-r--r--routers/bird.php2
-rw-r--r--routers/cisco.php2
-rw-r--r--routers/juniper.php2
-rw-r--r--routers/quagga.php2
-rw-r--r--routers/router.php3
10 files changed, 65 insertions, 37 deletions
diff --git a/config.php.example b/config.php.example
index fc093c1..13f7b33 100644
--- a/config.php.example
+++ b/config.php.example
@@ -6,48 +6,17 @@ $config['contact']['mail'] = 'support@example.com';
// Frontpage configuration
-// CSS to use
-$config['frontpage']['css'] = 'css/style.css';
// Title of the page
$config['frontpage']['title'] = 'Looking Glass';
-$config['frontpage']['show_title'] = true;
-// Logo to display
+// Logo to display (remove it to not display any logo)
$config['frontpage']['image'] = 'logo.png';
-// Show visitor IP address
-$config['frontpage']['show_visitor_ip'] = true;
// Disclaimer to inform people using the looking glass
$config['frontpage']['disclaimer'] = 'This is a disclaimer!';
-// Frontpage order you can use: routers, commands, parameters, buttons
-$config['frontpage']['order'] = array('routers', 'commands', 'parameters', 'buttons');
-
-// Logs file when commands will be written
-$config['misc']['logs'] = '/var/log/looking-glass.log';
-
-// Allow private ASN
-$config['misc']['allow_private_asn'] = false;
// Things to remove from the output (PHP compatible regex)
$config['filters'][] = '/(client1|client2)/';
$config['filters'][] = '/^NotToShow/';
-// Documentation for commands (must be HTML)
-
-// Documentation for the 'show route' query
-$config['doc']['bgp']['query'] = 'Show the best routes to a given destination.';
-$config['doc']['bgp']['parameter'] = 'The parameter must be a valid destination. Destination means an IPv4/IPv6 address or a subnet. Masks are also accepted as part of a valid IPv4/IPv6 address.<br />Please note that some routers always need a mask to be given when looking for an IPv6 address.<br /><br />Example of valid arguments:<br /><ul><li>10.1.1.1</li><li>172.16.0.0/12</li><li>2001:db8:1337::42</li><li>2001:db8::/32</li>';
-// Documentation for the 'as-path-regex' query
-$config['doc']['as-path-regex']['query'] = 'Show the routes matching the given AS path regular expression.';
-$config['doc']['as-path-regex']['parameter'] = 'The parameter must be a valid AS path regular expression.<br />Please note that these expression can change depending on the router and its software.<br /><br />Here are some examples:<ul><li><strong>Juniper</strong> - ^AS1 AS2 .*$</li><li><strong>Cisco</strong> - ^AS1_</li><li><strong>BIRD</strong> - AS1 AS2 AS3 &hellip; ASZ</li></ul><br />You may find some help with the following link:<br /><ul><li><a href="http://www.juniper.net/techpubs/en_US/junos13.3/topics/reference/command-summary/show-route-aspath-regex.html" title="Juniper Documentation">Juniper Documentation</a></li><li><a href="http://www.cisco.com/c/en/us/support/docs/ip/border-gateway-protocol-bgp/26634-bgp-toc.html#asregexp" title="Cisco Documentation">Cisco Documentation</a></li><li><a href="http://bird.network.cz/?get_doc&f=bird-5.html" title="BIRD Documentation">BIRD Documentation</a> (search for bgpmask)</li></ul>';
-// Documentation for the 'as' query
-$config['doc']['as']['query'] = 'Show the routes received from a given AS number.';
-$config['doc']['as']['parameter'] = 'The parameter must be a valid 16-bit or 32-bit autonomous system number.<br />Be careful, 32-bit ASN are not handled by old routers or old router softwares.<br />Unless specified, private ASN will be considered as invalid.<br /><br />Example of valid argument:<br /><ul><li>15169</li><li>29467</li></ul>';
-// Documentation for the 'ping' query
-$config['doc']['ping']['query'] = 'Send 10 pings to the given destination.';
-$config['doc']['ping']['parameter'] = 'The parameter must be an IPv4/IPv6 address (without mask) or a fully qualified domain name.<br /><br />Example of valid arguments:<br /><ul><li>10.1.1.1</li><li>2001:db8:1337::42</li><li>example.com</li></ul>';
-// Documentation for the 'traceroute' query
-$config['doc']['traceroute']['query'] = 'Display the path to a given destination.';
-$config['doc']['traceroute']['parameter'] = 'The parameter must be an IPv4/IPv6 address (without mask) or a fully qualified domain name.<br /><br />Example of valid arguments:<br /><ul><li>10.1.1.1</li><li>2001:db8:1337::42</li><li>example.com</li></ul>';
-
// Routers definitions
// Authentication based on SSH or Telnet with password
diff --git a/execute.php b/execute.php
index cd94ae6..330e070 100644
--- a/execute.php
+++ b/execute.php
@@ -19,6 +19,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+require_once 'includes/config.defaults.php';
require_once 'config.php';
require_once 'routers/router.php';
diff --git a/includes/config.defaults.php b/includes/config.defaults.php
new file mode 100644
index 0000000..895810b
--- /dev/null
+++ b/includes/config.defaults.php
@@ -0,0 +1,56 @@
+<?php
+
+$config = array (
+
+ // Frontpage configuration
+ 'frontpage' => array (
+ // CSS to use
+ 'css' => 'css/style.css',
+ // Title of the page
+ 'title' => 'Looking Glass',
+ 'show_title' => true,
+ // Show visitor IP address
+ 'show_visitor_ip' => true,
+ // Frontpage order you can use: routers, commands, parameters, buttons
+ 'order' => array('routers', 'commands', 'parameters', 'buttons')
+ ),
+
+ // Misc
+ 'misc' => array(
+ // Logs file when commands will be written
+ 'logs' => '/var/log/looking-glass.log',
+ // Allow private ASN
+ 'allow_private_asn' => false
+ ),
+
+ // Documentation (must be HTML)
+ 'doc' => array (
+ // Documentation for the 'show route' query
+ 'bgp' => array(
+ 'query' => 'Show the best routes to a given destination.',
+ 'parameter' => 'The parameter must be a valid destination. Destination means an IPv4/IPv6 address or a subnet. Masks are also accepted as part of a valid IPv4/IPv6 address.<br />Please note that some routers always need a mask to be given when looking for an IPv6 address.<br /><br />Example of valid arguments:<br /><ul><li>10.1.1.1</li><li>172.16.0.0/12</li><li>2001:db8:1337::42</li><li>2001:db8::/32</li>'
+ ),
+ // Documentation for the 'as-path-regex' query
+ 'as-path-regex' => array(
+ 'query' => 'Show the routes matching the given AS path regular expression.',
+ 'parameter' => 'The parameter must be a valid AS path regular expression.<br />Please note that these expression can change depending on the router and its software.<br /><br />Here are some examples:<ul><li><strong>Juniper</strong> - ^AS1 AS2 .*$</li><li><strong>Cisco</strong> - ^AS1_</li><li><strong>BIRD</strong> - AS1 AS2 AS3 &hellip; ASZ</li></ul><br />You may find some help with the following link:<br /><ul><li><a href="http://www.juniper.net/techpubs/en_US/junos13.3/topics/reference/command-summary/show-route-aspath-regex.html" title="Juniper Documentation">Juniper Documentation</a></li><li><a href="http://www.cisco.com/c/en/us/support/docs/ip/border-gateway-protocol-bgp/26634-bgp-toc.html#asregexp" title="Cisco Documentation">Cisco Documentation</a></li><li><a href="http://bird.network.cz/?get_doc&f=bird-5.html" title="BIRD Documentation">BIRD Documentation</a> (search for bgpmask)</li></ul>'
+ ),
+ // Documentation for the 'as' query
+ 'as' => array(
+ 'query' => 'Show the routes received from a given AS number.',
+ 'parameter' => 'The parameter must be a valid 16-bit or 32-bit autonomous system number.<br />Be careful, 32-bit ASN are not handled by old routers or old router softwares.<br />Unless specified, private ASN will be considered as invalid.<br /><br />Example of valid argument:<br /><ul><li>15169</li><li>29467</li></ul>'
+ ),
+ // Documentation for the 'ping' query
+ 'ping' => array(
+ 'query' => 'Send 10 pings to the given destination.',
+ 'parameter' => 'The parameter must be an IPv4/IPv6 address (without mask) or a fully qualified domain name.<br /><br />Example of valid arguments:<br /><ul><li>10.1.1.1</li><li>2001:db8:1337::42</li><li>example.com</li></ul>'
+ ),
+ // Documentation for the 'traceroute' query
+ 'traceroute' => array(
+ 'query' => 'Display the path to a given destination.',
+ 'parameter' => 'The parameter must be an IPv4/IPv6 address (without mask) or a fully qualified domain name.<br /><br />Example of valid arguments:<br /><ul><li>10.1.1.1</li><li>2001:db8:1337::42</li><li>example.com</li></ul>'
+ )
+ )
+);
+
+// End of config.defaults..php
diff --git a/utils.php b/includes/utils.php
index b6fc061..b6fc061 100644
--- a/utils.php
+++ b/includes/utils.php
diff --git a/index.php b/index.php
index b78699d..04d9904 100644
--- a/index.php
+++ b/index.php
@@ -18,6 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+require_once 'includes/config.defaults.php';
require_once 'config.php';
final class LookingGlass {
diff --git a/routers/bird.php b/routers/bird.php
index 4abd788..420cd42 100644
--- a/routers/bird.php
+++ b/routers/bird.php
@@ -20,7 +20,7 @@
*/
require_once 'router.php';
-require_once 'utils.php';
+require_once 'includes/utils.php';
final class Bird extends Router {
protected function build_commands($command, $parameters) {
diff --git a/routers/cisco.php b/routers/cisco.php
index fa010e1..593b293 100644
--- a/routers/cisco.php
+++ b/routers/cisco.php
@@ -20,7 +20,7 @@
*/
require_once 'router.php';
-require_once 'utils.php';
+require_once 'includes/utils.php';
final class Cisco extends Router {
protected function build_commands($command, $parameters) {
diff --git a/routers/juniper.php b/routers/juniper.php
index 30d783b..99da240 100644
--- a/routers/juniper.php
+++ b/routers/juniper.php
@@ -20,7 +20,7 @@
*/
require_once 'router.php';
-require_once 'utils.php';
+require_once 'includes/utils.php';
final class Juniper extends Router {
protected function build_commands($command, $parameters) {
diff --git a/routers/quagga.php b/routers/quagga.php
index c905a5e..9f6426d 100644
--- a/routers/quagga.php
+++ b/routers/quagga.php
@@ -20,7 +20,7 @@
*/
require_once 'router.php';
-require_once 'utils.php';
+require_once 'includes/utils.php';
final class Quagga extends Router {
protected function build_commands($command, $parameters) {
diff --git a/routers/router.php b/routers/router.php
index f1d2427..03336ac 100644
--- a/routers/router.php
+++ b/routers/router.php
@@ -19,12 +19,13 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+require_once 'includes/config.defaults.php';
require_once 'config.php';
require_once 'bird.php';
require_once 'cisco.php';
require_once 'juniper.php';
require_once 'quagga.php';
-require_once 'utils.php';
+require_once 'includes/utils.php';
require_once 'auth/authentication.php';
abstract class Router {