From f85258ebcef65e0e27d62135086b04aad12985cb Mon Sep 17 00:00:00 2001 From: Chriztoffer Date: Fri, 7 Feb 2020 14:25:33 +0000 Subject: [PATCH] Update metadata headers --- rfc8416.php | 36 ++++++++++++++++++++++++++------- roagen.php | 58 ++++++++++++++++++++++++++--------------------------- 2 files changed, 57 insertions(+), 37 deletions(-) diff --git a/rfc8416.php b/rfc8416.php index b839c2a..28c6328 100755 --- a/rfc8416.php +++ b/rfc8416.php @@ -7,13 +7,35 @@ require ("lib/functions.php"); // Define array() we are going to populate with data. $roas["slurmVersion"] = 1; -$roas["_comments"]["modified"]["commit"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%H'"); -$roas["_comments"]["modified"]["merge"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%p'"); -$roas["_comments"]["modified"]["author"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%an'"); -$roas["_comments"]["modified"]["date"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%aD'"); -$roas["_comments"]["modified"]["subject"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%s'"); -$roas["_comments"]["modified"]["url"] = "https://git.dn42.us/dn42/registry/commit/"; -$roas["_comments"]["modified"]["url"] .= $roas["_comments"]["modified"]["commit"]; +$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 + * + * Addinfo + * 1.generationtime(now), + * 2.expiretime(now+3days), + * 3.numberofroutes + * + * Numbersmustbeunquotedintegers,andtimeformatmust + * beepochformat.TImezoneissettoEtc/UTC. + */ +$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"); + $roas["validationOutputFilters"]["prefixFilters"] = array(); $roas["validationOutputFilters"]["bgpsecFilters"] = array(); $roas["locallyAddedAssertions"]["bgpsecAssertions"] = array(); diff --git a/roagen.php b/roagen.php index 24ba254..b81ebe4 100755 --- a/roagen.php +++ b/roagen.php @@ -6,13 +6,34 @@ require ("lib/define.php"); require ("lib/functions.php"); // Define array() we are going to populate with data. -$roas["_comments"]["modified"]["commit"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%H'"); -$roas["_comments"]["modified"]["merge"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%p'"); -$roas["_comments"]["modified"]["author"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%an'"); -$roas["_comments"]["modified"]["date"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%aD'"); -$roas["_comments"]["modified"]["subject"] = shell_exec ("/usr/bin/git -C ../registry/ log -n 1 --date=iso8601 --merges --pretty='format:%s'"); -$roas["_comments"]["modified"]["url"] = "https://git.dn42.us/dn42/registry/commit/"; -$roas["_comments"]["modified"]["url"] .= $roas["_comments"]["modified"]["commit"]; +$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 + * + * Addinfo + * 1.generationtime(now), + * 2.expiretime(now+3days), + * 3.numberofroutes + * + * Numbersmustbeunquotedintegers,andtimeformatmust + * beepochformat.TImezoneissettoEtc/UTC. + */ +$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"); /* * @@ -220,29 +241,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["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")), "+3 day"), "U")); -/* -$roas["metadata"]["signature"] = ""; -$roas["metadata"]["signatureData"] = ""; -*/ - -// Additional human readbable 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")), "+3 day"), "c"); - writeExportJSON($roas); writeBirdConfig($roas);