22 lines
564 B
JavaScript
22 lines
564 B
JavaScript
import axios from "axios";
|
|
import fs from "fs";
|
|
import { fileURLToPath } from "url";
|
|
import path from "path";
|
|
|
|
export const gcp = async () => {
|
|
const { data } = await axios.get(
|
|
"https://www.gstatic.com/ipranges/cloud.json"
|
|
);
|
|
|
|
const ips = data.prefixes.map(
|
|
({ ipv4Prefix, ipv6Prefix }) => ipv4Prefix || ipv6Prefix
|
|
);
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
await fs.promises.writeFile(
|
|
path.join(__dirname, "../ip_ranges/GCP.json"),
|
|
JSON.stringify({
|
|
NN: ips.map((prefix) => ({ prefix })),
|
|
})
|
|
);
|
|
};
|