2018-12-18 12:52:52 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function:
|
|
|
|
* checkoutMaster ()
|
|
|
|
*
|
|
|
|
* Checkout git master branch.
|
|
|
|
*/
|
|
|
|
function checkoutMaster ()
|
|
|
|
{
|
2018-12-19 14:08:29 +00:00
|
|
|
echo shell_exec ("/usr/bin/git -C ../registry/ o master --quiet 2>&1");
|
2018-12-18 12:52:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function:
|
|
|
|
* startsWith ($string, "word", $length)
|
|
|
|
*
|
|
|
|
* Find lines beginning with "word". Optionally
|
|
|
|
* give the length of the string you are looking for.
|
|
|
|
*/
|
|
|
|
function startsWith ($haystack, $needle, $length = "0")
|
|
|
|
{
|
|
|
|
if ($length <= 0 || $length > (strlen ($needle)))
|
|
|
|
$length = strlen ($needle);
|
|
|
|
|
|
|
|
return (substr ($haystack, 0, $length) === $needle);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function:
|
|
|
|
* endsWith ($string, "word")
|
|
|
|
*
|
|
|
|
* Find lines ending with "word".
|
|
|
|
*/
|
|
|
|
function endsWith ($haystack, $needle)
|
|
|
|
{
|
|
|
|
$length = strlen ($needle);
|
|
|
|
|
|
|
|
if ($length == 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return (substr( $haystack, -$length) === $needle);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function:
|
|
|
|
* trim_special_chars ($string)
|
|
|
|
*
|
|
|
|
* Remove special characters.
|
|
|
|
*/
|
|
|
|
function trim_special_chars ($string)
|
|
|
|
{
|
|
|
|
return (trim ($string, " \t\n\r\0\x0B"));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function:
|
|
|
|
* pushToRemotes ()
|
|
|
|
*
|
|
|
|
* Commit and push to all git remote repositories.
|
|
|
|
*/
|
|
|
|
function commitPushToRemotes ()
|
|
|
|
{
|
|
|
|
echo shell_exec ("./update.sh 2>&1");
|
|
|
|
}
|
|
|
|
|
2018-12-18 13:21:26 +00:00
|
|
|
function writeBirdConfig ($roas)
|
2018-12-18 12:52:52 +00:00
|
|
|
{
|
2018-12-18 13:21:26 +00:00
|
|
|
$json = json_encode($roas, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
|
|
|
|
|
2018-12-18 13:00:14 +00:00
|
|
|
$fq = fopen ('roa/bird_roa_dn42.conf', 'w');
|
|
|
|
$fq4 = fopen ('roa/bird4_roa_dn42.conf', 'w');
|
|
|
|
$fq6 = fopen ('roa/bird6_roa_dn42.conf', 'w');
|
|
|
|
|
2018-12-18 12:52:52 +00:00
|
|
|
fwrite ($fq, shell_exec ("/usr/bin/git -C ../registry/ show | sed 's/^/# /g'"));
|
|
|
|
fwrite ($fq4, shell_exec ("/usr/bin/git -C ../registry/ show | sed 's/^/# /g'"));
|
|
|
|
fwrite ($fq6, shell_exec ("/usr/bin/git -C ../registry/ show | sed 's/^/# /g'"));
|
|
|
|
|
|
|
|
foreach ($roas["roas"] as $roa)
|
|
|
|
{
|
|
|
|
$prfx = $roa["prefix"];
|
|
|
|
$mxLngth = $roa["maxLength"];
|
|
|
|
$sn = $roa["asn"];
|
|
|
|
|
|
|
|
$strng = "roa $prfx max $mxLngth as $sn;\n";
|
|
|
|
|
|
|
|
fwrite ($fq, $strng);
|
|
|
|
|
|
|
|
if (strpos ($prfx, ":") !== false)
|
|
|
|
fwrite ($fq6, $strng);
|
|
|
|
else
|
|
|
|
fwrite ($fq4, $strng);
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose ($fq);
|
|
|
|
fclose ($fq4);
|
|
|
|
fclose ($fq6);
|
|
|
|
}
|
|
|
|
|
2018-12-18 13:21:26 +00:00
|
|
|
function writeRoutinatorExceptionFile ($roas)
|
2018-12-18 12:52:52 +00:00
|
|
|
{
|
2018-12-18 13:21:26 +00:00
|
|
|
$json = json_encode($roas, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT|JSON_NUMERIC_CHECK);
|
|
|
|
|
2018-12-18 12:52:52 +00:00
|
|
|
$fp = fopen('roa/export_rfc8416_dn42.json', 'w');
|
|
|
|
|
2018-12-23 17:19:12 +00:00
|
|
|
fwrite ($fp, shell_exec ("/usr/bin/git -C ../registry/ show | sed 's/^/\/\/ /g'"));
|
2018-12-18 12:52:52 +00:00
|
|
|
fwrite($fp, $json);
|
|
|
|
|
|
|
|
fclose($fp);
|
|
|
|
}
|
|
|
|
|
2018-12-18 13:21:26 +00:00
|
|
|
function writeExportJSON ($roas)
|
2018-12-18 12:52:52 +00:00
|
|
|
{
|
2018-12-18 13:21:26 +00:00
|
|
|
$json = json_encode($roas, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
|
|
|
|
|
2018-12-18 12:52:52 +00:00
|
|
|
$fp = fopen ('roa/export_dn42.json', 'w');
|
|
|
|
|
|
|
|
fwrite ($fp, shell_exec ("/usr/bin/git -C ../registry/ show | sed 's/^/\/\/ /g'"));
|
|
|
|
fwrite ($fp, $json);
|
|
|
|
|
|
|
|
fclose ($fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|