chore: restart the repository with a clean history
CI / Docker image (push) Successful in 12s
CI / Server (push) Successful in 25s
CI / CLI (push) Successful in 13s
Development image / Development image (push) Successful in 21s
CI / CLI (windows) (push) Successful in 57s
CI / CLI (linux-arm64, static) (push) Successful in 1m37s
Release / Prepare release (push) Successful in 2s
Release / Server (linux-x64) (push) Successful in 53s
Release / CLI (linux-arm64, static) (push) Successful in 1m32s
Release / Docker image (push) Successful in 2m48s
Release / Server (windows-x64) (push) Successful in 6m20s
Release / CLI (windows-x64) (push) Successful in 6m48s
Release / CLI (linux-x64) (push) Successful in 7m8s
Release / Publish release (push) Successful in 1s
CI / Docker image (push) Successful in 12s
CI / Server (push) Successful in 25s
CI / CLI (push) Successful in 13s
Development image / Development image (push) Successful in 21s
CI / CLI (windows) (push) Successful in 57s
CI / CLI (linux-arm64, static) (push) Successful in 1m37s
Release / Prepare release (push) Successful in 2s
Release / Server (linux-x64) (push) Successful in 53s
Release / CLI (linux-arm64, static) (push) Successful in 1m32s
Release / Docker image (push) Successful in 2m48s
Release / Server (windows-x64) (push) Successful in 6m20s
Release / CLI (windows-x64) (push) Successful in 6m48s
Release / CLI (linux-x64) (push) Successful in 7m8s
Release / Publish release (push) Successful in 1s
Squash the tree into one commit, drop docs/architecture.html, reset the version line to 0.3.0, consolidate the changelog, enable Renovate automerge for non-major updates and add AGENTS.md.
This commit is contained in:
438 files changed
+45070
No files matched your search
@@ -0,0 +1,53 @@
|
||||
const API = "https://api.cloudflare.com/client/v4";
|
||||
|
||||
const call = async (token, path, options = {}) => {
|
||||
const response = await fetch(`${API}${path}`, {
|
||||
...options,
|
||||
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", ...options.headers },
|
||||
});
|
||||
const body = await response.json().catch(() => ({}));
|
||||
if (!response.ok || body.success === false) {
|
||||
const detail = body.errors?.map(error => error.message).join(", ") || response.statusText;
|
||||
throw new Error(`Cloudflare: ${detail}`);
|
||||
}
|
||||
return body.result;
|
||||
};
|
||||
|
||||
const zoneFor = async (token, hostname) => {
|
||||
const labels = hostname.split(".");
|
||||
for (let i = 0; i < labels.length - 1; i++) {
|
||||
const candidate = labels.slice(i).join(".");
|
||||
const zones = await call(token, `/zones?name=${encodeURIComponent(candidate)}`);
|
||||
if (zones?.length) return zones[0];
|
||||
}
|
||||
throw new Error(`Cloudflare: no zone found for ${hostname}. Check that the token can read this zone.`);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
id: "cloudflare",
|
||||
title: "Cloudflare",
|
||||
needsCredential: true,
|
||||
credentialLabel: "API token",
|
||||
|
||||
async verify(token, hostname) {
|
||||
const zone = await zoneFor(token, hostname);
|
||||
return { message: `Token works, zone ${zone.name} found` };
|
||||
},
|
||||
|
||||
async create(token, record, value) {
|
||||
const zone = await zoneFor(token, record);
|
||||
return call(token, `/zones/${zone.id}/dns_records`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ type: "TXT", name: record, content: value, ttl: 60 }),
|
||||
});
|
||||
},
|
||||
|
||||
async remove(token, record, value) {
|
||||
const zone = await zoneFor(token, record);
|
||||
const existing = await call(token, `/zones/${zone.id}/dns_records?type=TXT&name=${encodeURIComponent(record)}`);
|
||||
for (const entry of existing || []) {
|
||||
if (entry.content !== value) continue;
|
||||
await call(token, `/zones/${zone.id}/dns_records/${entry.id}`, { method: "DELETE" });
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
const cloudflare = require("./cloudflare");
|
||||
const manual = require("./manual");
|
||||
|
||||
const http = { id: "http", title: "No DNS provider", needsCredential: false, httpOnly: true };
|
||||
|
||||
const PROVIDERS = { cloudflare, manual, http };
|
||||
|
||||
const get = id => PROVIDERS[id] || null;
|
||||
|
||||
const describe = () => Object.values(PROVIDERS).map(provider => ({
|
||||
id: provider.id,
|
||||
title: provider.title,
|
||||
needsCredential: !!provider.needsCredential,
|
||||
credentialLabel: provider.credentialLabel || null,
|
||||
httpOnly: !!provider.httpOnly,
|
||||
}));
|
||||
|
||||
module.exports = { get, describe, PROVIDERS };
|
||||
@@ -0,0 +1,40 @@
|
||||
const WAIT_TIMEOUT = 15 * 60 * 1000;
|
||||
|
||||
const pending = new Map();
|
||||
|
||||
const settle = (key, error) => {
|
||||
const entry = pending.get(key);
|
||||
if (!entry) return;
|
||||
pending.delete(key);
|
||||
clearTimeout(entry.timer);
|
||||
if (error) entry.reject(error); else entry.resolve();
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
id: "manual",
|
||||
title: "Add the record yourself",
|
||||
needsCredential: false,
|
||||
|
||||
records: () => [...pending.values()].map(({ record, value }) => ({ record, value })),
|
||||
|
||||
create(_token, record, value) {
|
||||
const key = `${record}:${value}`;
|
||||
return new Promise((resolve, reject) => {
|
||||
const timer = setTimeout(() => settle(key, new Error("Timed out waiting for the TXT record to be added")), WAIT_TIMEOUT);
|
||||
timer.unref();
|
||||
pending.set(key, { record, value, timer, resolve, reject });
|
||||
});
|
||||
},
|
||||
|
||||
remove() {},
|
||||
|
||||
continue() {
|
||||
const keys = [...pending.keys()];
|
||||
for (const key of keys) settle(key);
|
||||
return keys.length > 0;
|
||||
},
|
||||
|
||||
reset() {
|
||||
for (const key of [...pending.keys()]) settle(key, new Error("Cancelled"));
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user