From 1631048bc50fd81b9b63056aebd11d8a7fab4e2a Mon Sep 17 00:00:00 2001 From: Christoffer Date: Mon, 10 Dec 2018 20:12:12 +0100 Subject: [PATCH] Updated roagen.php --- roagen.php | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/roagen.php b/roagen.php index 78c0f54..c183593 100755 --- a/roagen.php +++ b/roagen.php @@ -68,10 +68,11 @@ foreach($files as $file) $mask = $prefix[2]; } // extract var $maxLength + $maxLength = ''; // ensure var is null when starting new loop if (startsWith($line,'max-length')) { $maxLength = array(); preg_match('/([0-9]+)/',explode(':', $line)[1], $maxLength); - $maxLength = $maxLength[1]; + $maxLength = (empty($maxLength[1]) ? '' : $maxLength[1]); } // extract var $asn if (startsWith($line, 'origin')) { @@ -83,15 +84,13 @@ foreach($files as $file) $roas['roas'][$i]['asn'] = $asn[0]; $roas['roas'][$i]['prefix'] = $route; if (isset($ta)) { - if ($ta != ('ICVPN' || 'CHAOSVPN')) { + if ($ta == 'DN42') { $mask = ($mask <= 64 ? '64' : $mask); + if ($maxLength != '') $mask = $maxLength; } } else { $ta = 'NULL'; } - if ($ta == 'DN42' && isset($maxLength)) { - $mask = $maxLength; - } $roas['roas'][$i]['maxLength'] = $mask; $roas['roas'][$i]['ta'] = $ta; $i++; @@ -101,15 +100,13 @@ foreach($files as $file) $roas['roas'][$i]['asn'] = $asn[0]; $roas['roas'][$i]['prefix'] = $route; if (isset($ta)) { - if ($ta != ('ICVPN' || 'CHAOSVPN')) { + if ($ta == 'DN42') { $mask = ($mask <= 64 ? '64' : $mask); + if ($maxLength != '') $mask = $maxLength; } } else { $ta = 'NULL'; } - if ($ta == 'DN42' && isset($maxLength)) { - $mask = $maxLength; - } $roas['roas'][$i]['maxLength'] = $mask; $roas['roas'][$i]['ta'] = $ta; $i++; @@ -150,11 +147,12 @@ foreach($files as $file) $route = $prefix[0]; $mask = $prefix[5]; } - // extract var $maxLength + // extract var $maxLength + $maxLength = ''; // ensure var is null when starting new loop if (startsWith($line,'max-length')) { $maxLength = array(); preg_match('/([0-9]+)/',explode(':', $line)[1], $maxLength); - $maxLength = $maxLength[1]; + $maxLength = (empty($maxLength[1]) ? '' : $maxLength[1]); } // extract var $asn if (startsWith($line, 'origin')) { @@ -166,15 +164,13 @@ foreach($files as $file) $roas['roas'][$i]['asn'] = $asn[0]; $roas['roas'][$i]['prefix'] = $route; if (isset($ta)) { - if ($ta != ('ICVPN' || 'CHAOSVPN')) { + if ($ta == 'DN42') { $mask = ($mask <= 28 ? '28' : $mask); + if ($maxLength != '') $mask = $maxLength; } } else { $ta = 'NULL'; } - if ($ta == 'DN42' && isset($maxLength)) { - $mask = $maxLength; - } $roas['roas'][$i]['maxLength'] = $mask; $roas['roas'][$i]['ta'] = $ta; $i++; @@ -184,15 +180,13 @@ foreach($files as $file) $roas['roas'][$i]['asn'] = $asn[0]; $roas['roas'][$i]['prefix'] = $route; if (isset($ta)) { - if ($ta != ('ICVPN' || 'CHAOSVPN')) { + if ($ta == 'DN42') { $mask = ($mask <= 28 ? '28' : $mask); + if ($maxLength != '') $mask = $maxLength; } } else { $ta = 'NULL'; } - if ($ta == 'DN42' && isset($maxLength)) { - $mask = $maxLength; - } $roas['roas'][$i]['maxLength'] = $mask; $roas['roas'][$i]['ta'] = $ta; $i++;