From 7e8927f375b240c1846072b3b5d1bbd2c7b427a6 Mon Sep 17 00:00:00 2001 From: Christoffer Date: Sat, 5 Jan 2019 23:58:13 +0000 Subject: [PATCH] BUG: fix bird ASNs from invalid string value to valid integer value --- lib/functions.php | 7 +++++++ roagen.php | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/functions.php b/lib/functions.php index 6d6bd99..f6730af 100755 --- a/lib/functions.php +++ b/lib/functions.php @@ -119,6 +119,13 @@ function writeRoutinatorExceptionFile ($roas) function writeExportJSON ($roas) { + $n = 0; + foreach ($roas['roas'] as $object) + { + $roas['roas'][$n]['asn'] = "AS" . $roas['roas'][$n]['asn']; + $n++; + } + $json = json_encode($roas, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT); $fp = fopen ('roa/export_dn42.json', 'w'); diff --git a/roagen.php b/roagen.php index cf90721..e680c2b 100755 --- a/roagen.php +++ b/roagen.php @@ -97,7 +97,7 @@ foreach ($raw_array as $sub_array) // Extract ASxxxxx from string. preg_match ("/AS[0-9]+/", explode (":", $asn)[1], $_asn); - $roas["roas"][$k]["asn"] = $_asn[0]; + $roas["roas"][$k]["asn"] = trim ($_asn[0], "AS"); $roas["roas"][$k]["prefix"] = $_prefix; $roas["roas"][$k]["maxLength"] = ($_asn[0] != "AS0" ? $_maxlength : MAX_LEN_IPV6_AS0); $roas["roas"][$k]["ta"] = $_ta; @@ -187,7 +187,7 @@ foreach ($raw_array as $sub_array) // Extract ASxxxxx from string. preg_match ("/AS[0-9]+/", explode (":", $asn)[1], $_asn); - $roas["roas"][$k]["asn"] = $_asn[0]; + $roas["roas"][$k]["asn"] = trim ($_asn[0], "AS"); $roas["roas"][$k]["prefix"] = $_prefix; $roas["roas"][$k]["maxLength"] = ($_asn[0] != "AS0" ? $_maxlength : MAX_LEN_IPV4_AS0); $roas["roas"][$k]["ta"] = $_ta;