diff options
author | Guillaume Mazoyer <respawneral@gmail.com> | 2014-06-20 23:44:35 +0200 |
---|---|---|
committer | Guillaume Mazoyer <respawneral@gmail.com> | 2014-06-20 23:44:35 +0200 |
commit | 1fe2859496a1d999f6a5926bff75ab6666fea156 (patch) | |
tree | e8ba83384a9b2d6d0e3c9d324f60625b13a5cc1c /utils.php | |
parent | b2c8f5e562e60eff4e544daa546eb67f8c41cda9 (diff) |
Add config to allow private AS numbers.
Diffstat (limited to 'utils.php')
-rw-r--r-- | utils.php | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -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) { |