Updated roagen.php

This commit is contained in:
netravnen 2018-12-10 20:12:12 +01:00 committed by Christoffer
parent d846811613
commit 1631048bc5

View file

@ -68,10 +68,11 @@ foreach($files as $file)
$mask = $prefix[2]; $mask = $prefix[2];
} }
// extract var $maxLength // extract var $maxLength
$maxLength = ''; // ensure var is null when starting new loop
if (startsWith($line,'max-length')) { if (startsWith($line,'max-length')) {
$maxLength = array(); $maxLength = array();
preg_match('/([0-9]+)/',explode(':', $line)[1], $maxLength); preg_match('/([0-9]+)/',explode(':', $line)[1], $maxLength);
$maxLength = $maxLength[1]; $maxLength = (empty($maxLength[1]) ? '' : $maxLength[1]);
} }
// extract var $asn // extract var $asn
if (startsWith($line, 'origin')) { if (startsWith($line, 'origin')) {
@ -83,15 +84,13 @@ foreach($files as $file)
$roas['roas'][$i]['asn'] = $asn[0]; $roas['roas'][$i]['asn'] = $asn[0];
$roas['roas'][$i]['prefix'] = $route; $roas['roas'][$i]['prefix'] = $route;
if (isset($ta)) { if (isset($ta)) {
if ($ta != ('ICVPN' || 'CHAOSVPN')) { if ($ta == 'DN42') {
$mask = ($mask <= 64 ? '64' : $mask); $mask = ($mask <= 64 ? '64' : $mask);
if ($maxLength != '') $mask = $maxLength;
} }
} else { } else {
$ta = 'NULL'; $ta = 'NULL';
} }
if ($ta == 'DN42' && isset($maxLength)) {
$mask = $maxLength;
}
$roas['roas'][$i]['maxLength'] = $mask; $roas['roas'][$i]['maxLength'] = $mask;
$roas['roas'][$i]['ta'] = $ta; $roas['roas'][$i]['ta'] = $ta;
$i++; $i++;
@ -101,15 +100,13 @@ foreach($files as $file)
$roas['roas'][$i]['asn'] = $asn[0]; $roas['roas'][$i]['asn'] = $asn[0];
$roas['roas'][$i]['prefix'] = $route; $roas['roas'][$i]['prefix'] = $route;
if (isset($ta)) { if (isset($ta)) {
if ($ta != ('ICVPN' || 'CHAOSVPN')) { if ($ta == 'DN42') {
$mask = ($mask <= 64 ? '64' : $mask); $mask = ($mask <= 64 ? '64' : $mask);
if ($maxLength != '') $mask = $maxLength;
} }
} else { } else {
$ta = 'NULL'; $ta = 'NULL';
} }
if ($ta == 'DN42' && isset($maxLength)) {
$mask = $maxLength;
}
$roas['roas'][$i]['maxLength'] = $mask; $roas['roas'][$i]['maxLength'] = $mask;
$roas['roas'][$i]['ta'] = $ta; $roas['roas'][$i]['ta'] = $ta;
$i++; $i++;
@ -151,10 +148,11 @@ foreach($files as $file)
$mask = $prefix[5]; $mask = $prefix[5];
} }
// extract var $maxLength // extract var $maxLength
$maxLength = ''; // ensure var is null when starting new loop
if (startsWith($line,'max-length')) { if (startsWith($line,'max-length')) {
$maxLength = array(); $maxLength = array();
preg_match('/([0-9]+)/',explode(':', $line)[1], $maxLength); preg_match('/([0-9]+)/',explode(':', $line)[1], $maxLength);
$maxLength = $maxLength[1]; $maxLength = (empty($maxLength[1]) ? '' : $maxLength[1]);
} }
// extract var $asn // extract var $asn
if (startsWith($line, 'origin')) { if (startsWith($line, 'origin')) {
@ -166,15 +164,13 @@ foreach($files as $file)
$roas['roas'][$i]['asn'] = $asn[0]; $roas['roas'][$i]['asn'] = $asn[0];
$roas['roas'][$i]['prefix'] = $route; $roas['roas'][$i]['prefix'] = $route;
if (isset($ta)) { if (isset($ta)) {
if ($ta != ('ICVPN' || 'CHAOSVPN')) { if ($ta == 'DN42') {
$mask = ($mask <= 28 ? '28' : $mask); $mask = ($mask <= 28 ? '28' : $mask);
if ($maxLength != '') $mask = $maxLength;
} }
} else { } else {
$ta = 'NULL'; $ta = 'NULL';
} }
if ($ta == 'DN42' && isset($maxLength)) {
$mask = $maxLength;
}
$roas['roas'][$i]['maxLength'] = $mask; $roas['roas'][$i]['maxLength'] = $mask;
$roas['roas'][$i]['ta'] = $ta; $roas['roas'][$i]['ta'] = $ta;
$i++; $i++;
@ -184,15 +180,13 @@ foreach($files as $file)
$roas['roas'][$i]['asn'] = $asn[0]; $roas['roas'][$i]['asn'] = $asn[0];
$roas['roas'][$i]['prefix'] = $route; $roas['roas'][$i]['prefix'] = $route;
if (isset($ta)) { if (isset($ta)) {
if ($ta != ('ICVPN' || 'CHAOSVPN')) { if ($ta == 'DN42') {
$mask = ($mask <= 28 ? '28' : $mask); $mask = ($mask <= 28 ? '28' : $mask);
if ($maxLength != '') $mask = $maxLength;
} }
} else { } else {
$ta = 'NULL'; $ta = 'NULL';
} }
if ($ta == 'DN42' && isset($maxLength)) {
$mask = $maxLength;
}
$roas['roas'][$i]['maxLength'] = $mask; $roas['roas'][$i]['maxLength'] = $mask;
$roas['roas'][$i]['ta'] = $ta; $roas['roas'][$i]['ta'] = $ta;
$i++; $i++;