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. --- utils.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'utils.php') 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