update
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
c42c20612f
commit
7b084039e9
50
src/index.ts
50
src/index.ts
|
@ -38,6 +38,7 @@ const main = async () => {
|
|||
members: number[];
|
||||
remarks: string[];
|
||||
include: string[];
|
||||
isChanged?: boolean;
|
||||
}[] = [];
|
||||
|
||||
console.log("INFO: start AS-SETS generation.");
|
||||
|
@ -45,13 +46,13 @@ const main = async () => {
|
|||
let i = 1;
|
||||
|
||||
for (let asSetName in config["AS-SETS"]) {
|
||||
let isChanged = true;
|
||||
console.log(
|
||||
`INFO: generating AS-SETS <${asSetName}>... (${i}/${
|
||||
Object.keys(config["AS-SETS"]).length
|
||||
`INFO: generating AS-SETS <${asSetName}>... (${i}/${Object.keys(config["AS-SETS"]).length
|
||||
})\n`
|
||||
);
|
||||
|
||||
let members = await Promise.all(
|
||||
let members = ([...new Set((await Promise.all(
|
||||
config.members.map(async (member) => {
|
||||
const setName = Object.keys(member)[0];
|
||||
const setGroup = Object.values(member)[0];
|
||||
|
@ -80,7 +81,13 @@ const main = async () => {
|
|||
|
||||
return asnList;
|
||||
})
|
||||
);
|
||||
)).flat(Infinity))].filter(Boolean) as any).sort((a: number, b: number) => a - b);
|
||||
|
||||
console.log(JSON.stringify(members), JSON.stringify(await bgpq4(asSetName)));
|
||||
if (JSON.stringify(members) === JSON.stringify(await bgpq4(asSetName))) {
|
||||
console.log(`[INFO] AS-SET <${asSetName}> is not changed.`);
|
||||
isChanged = false;
|
||||
}
|
||||
|
||||
config["AS-SETS"][asSetName].remarks.push(
|
||||
`Generated by git.186526.xyz/186526/net186-as-set.`
|
||||
|
@ -100,29 +107,32 @@ const main = async () => {
|
|||
remarks: config["AS-SETS"][asSetName].remarks,
|
||||
members: [...new Set(members.flat(Infinity))].filter(Boolean) as any,
|
||||
include: (config["AS-SETS"][asSetName].include ?? []).sort(),
|
||||
isChanged: isChanged,
|
||||
});
|
||||
i++;
|
||||
console.log("");
|
||||
}
|
||||
const answer = await Promise.all(
|
||||
asSets.map(
|
||||
async (k) =>
|
||||
async (k) => {
|
||||
if (!k.isChanged) return "";
|
||||
return `
|
||||
as-set: ${k["AS-SET"]}
|
||||
${k["MNT-BY"].map((k) => `mnt-by: ${k}`).join("\n")}
|
||||
${k["TECH-C"].map((k) => `tech-c: ${k}`).join("\n")}
|
||||
${k["ADMIN-C"].map((k) => `admin-c: ${k}`).join("\n")}
|
||||
${k.remarks.map((k) => `remarks: ${k}`).join("\n")}
|
||||
${(
|
||||
await Promise.all(
|
||||
k.members.map(
|
||||
async (k) =>
|
||||
`remarks: ${await getNetName(k)} from ${cache.get(k)}\nmembers: AS${k}`
|
||||
)
|
||||
)
|
||||
).join("\n")}${k.include.map((k) => `\nmembers: ${k}`)}
|
||||
source: RIPE\npassword: ${env["RIPE_PASSWORD"]}\n
|
||||
`
|
||||
as-set: ${k["AS-SET"]}
|
||||
${k["MNT-BY"].map((k) => `mnt-by: ${k}`).join("\n")}
|
||||
${k["TECH-C"].map((k) => `tech-c: ${k}`).join("\n")}
|
||||
${k["ADMIN-C"].map((k) => `admin-c: ${k}`).join("\n")}
|
||||
${k.remarks.map((k) => `remarks: ${k}`).join("\n")}
|
||||
${(
|
||||
await Promise.all(
|
||||
k.members.map(
|
||||
async (k) =>
|
||||
`remarks: ${await getNetName(k)} from ${cache.get(k)}\nmembers: AS${k}`
|
||||
)
|
||||
)
|
||||
).join("\n")}${k.include.map((k) => `\nmembers: ${k}`)}
|
||||
source: RIPE\npassword: ${env["RIPE_PASSWORD"]}\n
|
||||
`
|
||||
}
|
||||
)
|
||||
);
|
||||
console.log("INFO: sending update to RIPE Syncupdates...");
|
||||
|
|
Loading…
Reference in New Issue