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[];
|
members: number[];
|
||||||
remarks: string[];
|
remarks: string[];
|
||||||
include: string[];
|
include: string[];
|
||||||
|
isChanged?: boolean;
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
|
||||||
console.log("INFO: start AS-SETS generation.");
|
console.log("INFO: start AS-SETS generation.");
|
||||||
|
@ -45,13 +46,13 @@ const main = async () => {
|
||||||
let i = 1;
|
let i = 1;
|
||||||
|
|
||||||
for (let asSetName in config["AS-SETS"]) {
|
for (let asSetName in config["AS-SETS"]) {
|
||||||
|
let isChanged = true;
|
||||||
console.log(
|
console.log(
|
||||||
`INFO: generating AS-SETS <${asSetName}>... (${i}/${
|
`INFO: generating AS-SETS <${asSetName}>... (${i}/${Object.keys(config["AS-SETS"]).length
|
||||||
Object.keys(config["AS-SETS"]).length
|
|
||||||
})\n`
|
})\n`
|
||||||
);
|
);
|
||||||
|
|
||||||
let members = await Promise.all(
|
let members = ([...new Set((await Promise.all(
|
||||||
config.members.map(async (member) => {
|
config.members.map(async (member) => {
|
||||||
const setName = Object.keys(member)[0];
|
const setName = Object.keys(member)[0];
|
||||||
const setGroup = Object.values(member)[0];
|
const setGroup = Object.values(member)[0];
|
||||||
|
@ -80,7 +81,13 @@ const main = async () => {
|
||||||
|
|
||||||
return asnList;
|
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(
|
config["AS-SETS"][asSetName].remarks.push(
|
||||||
`Generated by git.186526.xyz/186526/net186-as-set.`
|
`Generated by git.186526.xyz/186526/net186-as-set.`
|
||||||
|
@ -100,29 +107,32 @@ const main = async () => {
|
||||||
remarks: config["AS-SETS"][asSetName].remarks,
|
remarks: config["AS-SETS"][asSetName].remarks,
|
||||||
members: [...new Set(members.flat(Infinity))].filter(Boolean) as any,
|
members: [...new Set(members.flat(Infinity))].filter(Boolean) as any,
|
||||||
include: (config["AS-SETS"][asSetName].include ?? []).sort(),
|
include: (config["AS-SETS"][asSetName].include ?? []).sort(),
|
||||||
|
isChanged: isChanged,
|
||||||
});
|
});
|
||||||
i++;
|
i++;
|
||||||
console.log("");
|
console.log("");
|
||||||
}
|
}
|
||||||
const answer = await Promise.all(
|
const answer = await Promise.all(
|
||||||
asSets.map(
|
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...");
|
console.log("INFO: sending update to RIPE Syncupdates...");
|
||||||
|
|
Loading…
Reference in New Issue