From 9c3ca0405f01c5e414f64d553563836a7f635daf Mon Sep 17 00:00:00 2001 From: Netravnen Date: Tue, 21 Jul 2020 23:17:05 +0000 Subject: [PATCH 1/2] less commit info included and human readable info omitted for less file size --- lib/functions.php | 12 ------------ rfc8416.php | 18 ------------------ roagen.php | 14 -------------- update.sh | 35 +++++++++++++++++------------------ 4 files changed, 17 insertions(+), 62 deletions(-) diff --git a/lib/functions.php b/lib/functions.php index db3f174..42763c0 100755 --- a/lib/functions.php +++ b/lib/functions.php @@ -60,18 +60,6 @@ function writeBirdConfig ($roas) $bird2_fq4 = fopen ('roa/bird4_route_dn42.conf', 'w'); $bird2_fq6 = fopen ('roa/bird6_route_dn42.conf', 'w'); - /* - fwrite ($bird1_fq, shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --merges | sed 's/^/# /g'")); - fwrite ($bird1_fq4, shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --merges | sed 's/^/# /g'")); - fwrite ($bird1_fq6, shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --merges | sed 's/^/# /g'")); - */ - - /* - fwrite ($bird2_fq, shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --merges | sed 's/^/# /g'")); - fwrite ($bird2_fq4, shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --merges | sed 's/^/# /g'")); - fwrite ($bird2_fq6, shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --merges | sed 's/^/# /g'")); - */ - foreach ($roas["roas"] as $roa) { $prefix = $roa["prefix"]; diff --git a/rfc8416.php b/rfc8416.php index 9033085..03b8ddf 100755 --- a/rfc8416.php +++ b/rfc8416.php @@ -106,8 +106,6 @@ foreach ($raw_array as $sub_array) $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["asn"] = trim ($_asn[0], "AS"); $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["prefix"] = $_prefix; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["maxPrefixLength"] = ($_asn[0] != "AS0" ? $_maxlength : MAX_LEN_IPV6_AS0); - //$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["url"]["inetnum"] = "$web_registry_url/data/inet6num/$prefix[1]_$prefix[2]"; - //$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["url"]["route"] = "$web_registry_url/data/route6/$prefix[1]_$prefix[2]"; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["source"] = "$_ta"; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["mnt-by"] = "$_mnt"; @@ -208,8 +206,6 @@ foreach ($raw_array as $sub_array) $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["asn"] = trim ($_asn[0], "AS"); $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["prefix"] = $_prefix; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["maxPrefixLength"] = ($_asn[0] != "AS0" ? $_maxlength : MAX_LEN_IPV4_AS0); - //$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["url"]["inetnum"] = "$web_registry_url/data/inetnum/$prefix[1]_$prefix[2]"; - //$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["url"]["route"] = "$web_registry_url/data/route/$prefix[1]_$prefix[2]"; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["source"] = "$_ta"; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["mnt-by"] = "$_mnt"; @@ -217,14 +213,6 @@ foreach ($raw_array as $sub_array) } } -//$roas["metadata"]["human"]["commit"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%H'"); -//$roas["metadata"]["human"]["merge"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%p'"); -//$roas["metadata"]["human"]["author"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%an'"); -//$roas["metadata"]["human"]["date"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%aD'"); -//$roas["metadata"]["human"]["subject"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%s'"); -//$roas["metadata"]["human"]["url"] = "https://git.dn42.us/dn42/registry/commit/"; -//$roas["metadata"]["human"]["url"] .= $roas["metadata"]["human"]["commit"]; - /* * Function: Add metadata * @@ -239,12 +227,6 @@ foreach ($raw_array as $sub_array) //$roas["metadata"]["counts"] = (int)count($roas["locallyAddedAssertions"]["prefixAssertions"]); //$roas["metadata"]["generated"] = (int)(date_format(new \DateTime("now",new \DateTimeZone("UTC")),"U")); //$roas["metadata"]["valid"] = (int)(date_format(date_modify(new \DateTime("now",new \DateTimeZone("UTC")),"+3day"),"U")); -//$roas["metadata"]["signature"] = ""; -//$roas["metadata"]["signatureData"] = ""; - -// Additional human read-able DateTime format, example: 2013-04-12T15:52:01+00:00 -//$roas["metadata"]["human"]["generated"] = date_format(new \DateTime("now",new \DateTimeZone("UTC")),"c"); -//$roas["metadata"]["human"]["valid"] = date_format(date_modify(new \DateTime("now",new \DateTimeZone("UTC")),"+3day"),"c"); writeRoutinatorExceptionFile($roas); diff --git a/roagen.php b/roagen.php index a186843..282dcab 100755 --- a/roagen.php +++ b/roagen.php @@ -211,14 +211,6 @@ foreach ($raw_array as $sub_array) } } -$roas["metadata"]["human"]["commit"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%H'"); -$roas["metadata"]["human"]["merge"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%p'"); -$roas["metadata"]["human"]["author"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%an'"); -$roas["metadata"]["human"]["date"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%aD'"); -$roas["metadata"]["human"]["subject"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%s'"); -$roas["metadata"]["human"]["url"] = "https://git.dn42.us/dn42/registry/commit/"; -$roas["metadata"]["human"]["url"] .= $roas["metadata"]["human"]["commit"]; - /* * Function: Add metadata * @@ -233,12 +225,6 @@ $roas["metadata"]["human"]["url"] .= $roas["metadata"]["human"]["commit"]; $roas["metadata"]["counts"] = (int)count($roas["roas"]); $roas["metadata"]["generated"] = (int)(date_format(new \DateTime("now",new \DateTimeZone("UTC")),"U")); $roas["metadata"]["valid"] = (int)(date_format(date_modify(new \DateTime("now",new \DateTimeZone("UTC")),"+3day"),"U")); -//$roas["metadata"]["signature"] = ""; -//$roas["metadata"]["signatureData"] = ""; - -// Additional human read-able DateTime format, example: 2013-04-12T15:52:01+00:00 -$roas["metadata"]["human"]["generated"] = date_format(new \DateTime("now",new \DateTimeZone("UTC")),"c"); -$roas["metadata"]["human"]["valid"] = date_format(date_modify(new \DateTime("now",new \DateTimeZone("UTC")),"+3day"),"c"); writeExportJSON($roas); writeBirdConfig($roas); diff --git a/update.sh b/update.sh index fe1bfb5..1cdee2d 100755 --- a/update.sh +++ b/update.sh @@ -3,32 +3,29 @@ ISO_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") # Ensure registry repository is up-to-date -git -C ../registry/ pull upstream master:master --quiet 2>&1 +#git -C ../registry/ pull upstream master:master --quiet 2>&1 # Checkout master branch in dn42/repository git -C ../registry/ checkout master --quiet # Do a git pull beforehand to ensure our repository is up-to-date -git checkout master --quiet -git pull origin master:master --quiet --rebase +#git checkout master --quiet +#git pull origin master:master --quiet --rebase + +if ! [ -d roa ] ; then mkdir -p roa ; fi -if ! [ -d roa/ ] ; then mkdir -p roa ; fi for file in README.md {bird,bird4,bird6}_{route,roa}_dn42.conf export{_rfc8416,}_dn42.json ; do if ! [ -f roa/$file ] ; then touch roa/$file ; fi done # Do the same for sub-repo if exists -if [ -d roa/.git/ ] ; then +if [ -d roa/.git ] ; then git -C roa/ checkout master --quiet if [ $(git -C roa/ remote | grep origin) ] ; then git -C roa/ pull origin master:master --quiet --rebase fi fi -# Update with data from registry -php roagen.php -php rfc8416.php - # Ensure sub-repo is created to track roa file udpates if [ ! -d roa/ ] ; then mkdir roa ; fi if [ ! -f roa/.git/config ] ; then @@ -39,6 +36,10 @@ if [ ! -f roa/.git/config ] ; then git -C roa/ commit --allow-empty -m "Initial commit" git -C roa/ commit README.md -m "Add README.md" ; fi +# Update with data from registry +php roagen.php +php rfc8416.php + # Write out last commit to file echo "## Notes @@ -57,15 +58,12 @@ echo "## Notes Note the gortr source file is DateTime stamped only, it is not signed with any certificaty. So you will need to add \`-verify=false\` as a runtime parameter when loading the cache file. Alternatively, use gortr with a slurm file -instead (e.g. `-slurm export_rfc8416_dn42.json`) as a command-line parameter. +instead (e.g. \`-slurm export_rfc8416_dn42.json\`) as a command-line parameter. ## [Last merge commit][0] at [dn42 registry][1] \`\`\` -$(git -C ../registry/ log -n 1 --date=iso8601 --merges | - sed -E -e 's/^Author: ([a-zA-Z0-9]+) <.*>/Author: \1/' \ - -e 's/^commit ([a-f0-9]+) .*/commit \1/' \ - -e 's/[ ]+$//g' ) +$(git -C ../registry/ log -n 1 --date=iso8601 --merges | grep -v Reviewed- | grep -v Author | sed -E -e 's/^[Cc]ommit ([a-f0-9]+).*/Commit \1/' -e 's/[ ]+$//g') \`\`\` ## crontab @@ -104,7 +102,8 @@ git -C roa/ add README.md *.conf *.json *.sha256 git -C roa/ commit -m "Updated ROA files - $ISO_DATE" --quiet # Push ROA repository to every remote configured -for REMOTE in $(git -C roa/ remote | egrep -v upstream | paste -sd " " -) ; do git -C roa/ push $REMOTE master:master --quiet ; done - -# Push local roagen repository to every remote configured -for REMOTE in $(git remote | egrep -v upstream | paste -sd " " -) ; do git push $REMOTE master:master --quiet ; done +if [ $(git -C roa/ remote | grep -vi upstream | wc -l) > 0 ] ; then + for REMOTE in $(git -C roa/ remote | grep -vi upstream | paste -sd " " -) ; do + git -C roa/ push $REMOTE master:master --quiet + done +fi From 565f585fae09c3afacae80b80da712da91de7b41 Mon Sep 17 00:00:00 2001 From: Netravnen Date: Tue, 21 Jul 2020 23:18:48 +0000 Subject: [PATCH 2/2] increase roa file TTL 3 to 5 days --- rfc8416.php | 15 --------------- roagen.php | 2 +- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/rfc8416.php b/rfc8416.php index 03b8ddf..5ac47c7 100755 --- a/rfc8416.php +++ b/rfc8416.php @@ -213,21 +213,6 @@ foreach ($raw_array as $sub_array) } } -/* - * Function: Add metadata - * - * Add info - * 1. generation time (now), - * 2. expire time (now + 3 days), - * 3. number of routes - * - * Numbers must be unquoted integers, and timeformat must - * be epoch format. TImezone is set to Etc/UTC. - */ -//$roas["metadata"]["counts"] = (int)count($roas["locallyAddedAssertions"]["prefixAssertions"]); -//$roas["metadata"]["generated"] = (int)(date_format(new \DateTime("now",new \DateTimeZone("UTC")),"U")); -//$roas["metadata"]["valid"] = (int)(date_format(date_modify(new \DateTime("now",new \DateTimeZone("UTC")),"+3day"),"U")); - writeRoutinatorExceptionFile($roas); ?> diff --git a/roagen.php b/roagen.php index 282dcab..74df7f5 100755 --- a/roagen.php +++ b/roagen.php @@ -224,7 +224,7 @@ foreach ($raw_array as $sub_array) */ $roas["metadata"]["counts"] = (int)count($roas["roas"]); $roas["metadata"]["generated"] = (int)(date_format(new \DateTime("now",new \DateTimeZone("UTC")),"U")); -$roas["metadata"]["valid"] = (int)(date_format(date_modify(new \DateTime("now",new \DateTimeZone("UTC")),"+3day"),"U")); +$roas["metadata"]["valid"] = (int)(date_format(date_modify(new \DateTime("now",new \DateTimeZone("UTC")),"+5day"),"U")); writeExportJSON($roas); writeBirdConfig($roas);