update source
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
20433ae2d4
commit
956cd0df1d
29
src/index.ts
29
src/index.ts
|
@ -2,10 +2,16 @@ import bgpq4 from "./bgpq4";
|
|||
import fs from "node:fs";
|
||||
import YAML from "yaml";
|
||||
import { getNetName } from "./pdb";
|
||||
import LRUCache from "lru-cache";
|
||||
|
||||
import axios from "axios";
|
||||
import { env } from "node:process";
|
||||
|
||||
const cache = new LRUCache({
|
||||
max: 500,
|
||||
ttl: 1000 * 60 * 5,
|
||||
});
|
||||
|
||||
const main = async () => {
|
||||
const config: {
|
||||
"MNT-BY": string[];
|
||||
|
@ -44,6 +50,7 @@ const main = async () => {
|
|||
Object.keys(config["AS-SETS"]).length
|
||||
})\n`
|
||||
);
|
||||
|
||||
let members = await Promise.all(
|
||||
config.members.map(async (member) => {
|
||||
const setName = Object.keys(member)[0];
|
||||
|
@ -60,9 +67,18 @@ const main = async () => {
|
|||
|
||||
console.log("Add", setName, answer, "to", asSetName);
|
||||
|
||||
return answer.filter(
|
||||
(as) => !(config["AS-SETS"][asSetName].expect ?? [0]).includes(as)
|
||||
);
|
||||
const asnList = answer
|
||||
.filter(
|
||||
(as) => !(config["AS-SETS"][asSetName].expect ?? [0]).includes(as)
|
||||
)
|
||||
.filter(Boolean)
|
||||
.sort();
|
||||
|
||||
asnList.forEach((k) => {
|
||||
if (!cache.has(k)) cache.set(k, setName);
|
||||
});
|
||||
|
||||
return asnList;
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -79,9 +95,7 @@ const main = async () => {
|
|||
"TECH-C": config["TECH-C"],
|
||||
"ADMIN-C": config["ADMIN-C"],
|
||||
remarks: config["AS-SETS"][asSetName].remarks,
|
||||
members: Array.from(new Set(members.flat(Infinity)))
|
||||
.filter(Boolean)
|
||||
.sort() as number[],
|
||||
members: [...new Set(members.flat(Infinity))].filter(Boolean) as any,
|
||||
include: (config["AS-SETS"][asSetName].include ?? []).sort(),
|
||||
});
|
||||
i++;
|
||||
|
@ -99,7 +113,8 @@ ${k.remarks.map((k) => `remarks: ${k}`).join("\n")}
|
|||
${(
|
||||
await Promise.all(
|
||||
k.members.map(
|
||||
async (k) => `remarks: ${await getNetName(k)}\nmembers: AS${k}`
|
||||
async (k) =>
|
||||
`remarks: ${await getNetName(k)} from ${cache.get(k)}\nmembers: AS${k}`
|
||||
)
|
||||
)
|
||||
).join("\n")}${k.include.map((k) => `\nmembers: ${k}`)}
|
||||
|
|
Loading…
Reference in New Issue