diff --git a/.github/workflows/update-rdap-dns.yml b/.github/workflows/update-rdap-dns.yml new file mode 100644 index 000000000..aa5384816 --- /dev/null +++ b/.github/workflows/update-rdap-dns.yml @@ -0,0 +1,45 @@ +name: Update RDAP DNS Data + +on: + schedule: + # Run on the 1st of every month at 00:00 UTC + - cron: '0 0 1 * *' + workflow_dispatch: + +permissions: + contents: write + +jobs: + update-rdap-dns: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Node.js + uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 + with: + node-version: 20 + + - name: Update RDAP DNS data + run: node extra/update-rdap-dns.mjs + + - name: Check for changes + id: changes + run: | + if git diff --quiet server/model/rdap-dns.json; then + echo "changed=false" >> $GITHUB_OUTPUT + else + echo "changed=true" >> $GITHUB_OUTPUT + fi + + - name: Commit and push changes + if: steps.changes.outputs.changed == 'true' + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add server/model/rdap-dns.json + git commit -m "chore: update RDAP DNS data from IANA [skip ci]" + git push diff --git a/extra/update-rdap-dns.mjs b/extra/update-rdap-dns.mjs new file mode 100644 index 000000000..b617d22bb --- /dev/null +++ b/extra/update-rdap-dns.mjs @@ -0,0 +1,45 @@ +#!/usr/bin/env node + +/** + * Update RDAP DNS data from IANA + * This script downloads the latest RDAP bootstrap file from IANA and updates the local file. + */ + +import { writeFileSync } from "fs"; +import { join, dirname } from "path"; +import { fileURLToPath } from "url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const RDAP_DNS_URL = "https://data.iana.org/rdap/dns.json"; +const OUTPUT_PATH = join(__dirname, "..", "server", "model", "rdap-dns.json"); + +console.log("Downloading RDAP DNS data from IANA..."); + +try { + const response = await fetch(RDAP_DNS_URL); + if (!response.ok) { + throw new Error(`HTTP ${response.status}: ${response.statusText}`); + } + + const data = await response.json(); + + // Validate that we have the expected structure + if (!data.services || !Array.isArray(data.services)) { + throw new Error("Invalid RDAP DNS data structure"); + } + + console.log(`Found ${data.services.length} RDAP services`); + console.log(`Publication date: ${data.publication}`); + + // Write the file with proper formatting + writeFileSync(OUTPUT_PATH, JSON.stringify(data, null, 2) + "\n", "utf8"); + + console.log(`✓ Successfully updated ${OUTPUT_PATH}`); + process.exit(0); +} catch (error) { + console.error("✗ Failed to update RDAP DNS data:"); + console.error(error.message); + process.exit(1); +} diff --git a/server/model/domain_expiry.js b/server/model/domain_expiry.js index 28abbf71f..20236f640 100644 --- a/server/model/domain_expiry.js +++ b/server/model/domain_expiry.js @@ -7,8 +7,8 @@ const { Notification } = require("../notification"); const TranslatableError = require("../translatable-error"); const dayjs = require("dayjs"); -// Load static RDAP DNS data from local file -const rdapDnsData = require("../data/rdap-dns.json"); +// Load static RDAP DNS data from local file (auto-updated by CI) +const rdapDnsData = require("./rdap-dns.json"); /** * Find the RDAP server for a given TLD diff --git a/server/data/rdap-dns.json b/server/model/rdap-dns.json similarity index 99% rename from server/data/rdap-dns.json rename to server/model/rdap-dns.json index 107b56c57..9b966e054 100644 --- a/server/data/rdap-dns.json +++ b/server/model/rdap-dns.json @@ -5363,4 +5363,4 @@ ] ], "version": "1.0" -} \ No newline at end of file +}