add pdb
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
3e5b318cbe
commit
20433ae2d4
|
@ -16,6 +16,8 @@ steps:
|
||||||
environment:
|
environment:
|
||||||
RIPE_PASSWORD:
|
RIPE_PASSWORD:
|
||||||
from_secret: ripe_password
|
from_secret: ripe_password
|
||||||
|
PDB_TOKEN:
|
||||||
|
from_secret: pdb_token
|
||||||
commands:
|
commands:
|
||||||
- apk add bgpq4 --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing
|
- apk add bgpq4 --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing
|
||||||
- yarn
|
- yarn
|
||||||
|
|
23
src/index.ts
23
src/index.ts
|
@ -1,6 +1,7 @@
|
||||||
import bgpq4 from "./bgpq4";
|
import bgpq4 from "./bgpq4";
|
||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import YAML from "yaml";
|
import YAML from "yaml";
|
||||||
|
import { getNetName } from "./pdb";
|
||||||
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { env } from "node:process";
|
import { env } from "node:process";
|
||||||
|
@ -86,18 +87,26 @@ const main = async () => {
|
||||||
i++;
|
i++;
|
||||||
console.log("");
|
console.log("");
|
||||||
}
|
}
|
||||||
const answer = asSets.map((k) => {
|
const answer = await Promise.all(
|
||||||
return `as-set: ${k["AS-SET"]}
|
asSets.map(
|
||||||
|
async (k) =>
|
||||||
|
`
|
||||||
|
as-set: ${k["AS-SET"]}
|
||||||
${k["MNT-BY"].map((k) => `mnt-by: ${k}`).join("\n")}
|
${k["MNT-BY"].map((k) => `mnt-by: ${k}`).join("\n")}
|
||||||
${k["TECH-C"].map((k) => `tech-c: ${k}`).join("\n")}
|
${k["TECH-C"].map((k) => `tech-c: ${k}`).join("\n")}
|
||||||
${k["ADMIN-C"].map((k) => `admin-c: ${k}`).join("\n")}
|
${k["ADMIN-C"].map((k) => `admin-c: ${k}`).join("\n")}
|
||||||
${k.remarks.map((k) => `remarks: ${k}`).join("\n")}
|
${k.remarks.map((k) => `remarks: ${k}`).join("\n")}
|
||||||
${k.members.map((k) => `members: AS${k}`).join("\n")}${k.include.map(
|
${(
|
||||||
(k) => `\nmembers: ${k}`
|
await Promise.all(
|
||||||
)}
|
k.members.map(
|
||||||
|
async (k) => `remarks: ${await getNetName(k)}\nmembers: AS${k}`
|
||||||
|
)
|
||||||
|
)
|
||||||
|
).join("\n")}${k.include.map((k) => `\nmembers: ${k}`)}
|
||||||
source: RIPE\npassword: ${env["RIPE_PASSWORD"]}\n
|
source: RIPE\npassword: ${env["RIPE_PASSWORD"]}\n
|
||||||
`;
|
`
|
||||||
});
|
)
|
||||||
|
);
|
||||||
console.log("INFO: sending update to RIPE Syncupdates...");
|
console.log("INFO: sending update to RIPE Syncupdates...");
|
||||||
const update = await axios.post(
|
const update = await axios.post(
|
||||||
"https://syncupdates.db.ripe.net",
|
"https://syncupdates.db.ripe.net",
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
import axios from "axios";
|
||||||
|
import { env } from "node:process";
|
||||||
|
|
||||||
|
const list = axios.get("https://www.peeringdb.com/api/net",{
|
||||||
|
headers: {
|
||||||
|
"User-Agent": "NET186-AS-SET/1.0.0",
|
||||||
|
"Authorization": `Api-Key ${env.PDB_TOKEN}`,
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const getNetName = async (ASN: number): Promise<string> => {
|
||||||
|
const answer = (await list).data;
|
||||||
|
return (answer.data.find((k: any) => k.asn === ASN) ?? { name: `AS${ASN}` })
|
||||||
|
.name;
|
||||||
|
};
|
Loading…
Reference in New Issue