From 1fe2859496a1d999f6a5926bff75ab6666fea156 Mon Sep 17 00:00:00 2001 From: Guillaume Mazoyer Date: Fri, 20 Jun 2014 23:44:35 +0200 Subject: Add config to allow private AS numbers. --- config.php.example | 3 +++ utils.php | 20 +++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/config.php.example b/config.php.example index bc123e3..96599b6 100644 --- a/config.php.example +++ b/config.php.example @@ -23,6 +23,9 @@ $config['frontpage']['order'] = array('routers', 'commands', 'parameters', 'butt // 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'][0] = '/(client1|client2)/'; $config['filters'][1] = '/^NotToShow/'; diff --git a/utils.php b/utils.php index 6ead112..bf14096 100644 --- a/utils.php +++ b/utils.php @@ -41,6 +41,8 @@ function match_fqdn($fqdn) { } function match_as($as) { + global $config; + $options_wide_range = array( 'options' => array('min_range' => 1, 'max_range' => 4294967294) ); @@ -51,9 +53,21 @@ function match_as($as) { 'options' => array('min_range' => 4200000000, 'max_range' => 4294967294) ); - return (filter_var($as, FILTER_VALIDATE_INT, $options_wide_range) && - !filter_var($as, FILTER_VALIDATE_INT, $options_16bit_private) && - !filter_var($as, FILTER_VALIDATE_INT, $options_32bit_private)); + if (!filter_var($as, FILTER_VALIDATE_INT, $options_wide_range)) { + return false; + } + + if (filter_var($as, FILTER_VALIDATE_INT, $options_16bit_private)) { + return isset($config['misc']['allow_private_asn']) && + $config['misc']['allow_private_asn'] == true; + } + + if (filter_var($as, FILTER_VALIDATE_INT, $options_32bit_private)) { + return isset($config['misc']['allow_private_asn']) && + $config['misc']['allow_private_asn'] == true; + } + + return true; } function match_aspath_regex($aspath_regex) { -- cgit v1.2.3