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,81 @@
|
||||
const { Router } = require("../utils/router");
|
||||
const store = require("../lib/tls/store");
|
||||
const providers = require("../lib/tls/providers");
|
||||
const logger = require("../utils/logger");
|
||||
|
||||
const app = Router();
|
||||
|
||||
const describeSettings = settings => ({
|
||||
email: settings.email,
|
||||
provider: settings.provider,
|
||||
hasCredential: !!settings.credential,
|
||||
});
|
||||
|
||||
app.get("/", async (req, res) => {
|
||||
const settings = await store.settings();
|
||||
res.json({
|
||||
mode: req.config.tlsMode,
|
||||
wildcard: req.config.wildcard,
|
||||
httpsPort: req.config.httpsPort,
|
||||
redirectPort: req.config.redirectPort,
|
||||
providers: providers.describe(),
|
||||
acme: describeSettings(settings),
|
||||
status: req.certificates.status(),
|
||||
});
|
||||
});
|
||||
|
||||
app.put("/", async (req, res) => {
|
||||
const { email, provider, credential } = req.body || {};
|
||||
const values = {};
|
||||
|
||||
if (email !== undefined) {
|
||||
const trimmed = String(email || "").trim();
|
||||
if (trimmed && !/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(trimmed)) {
|
||||
return res.status(400).json({ code: 400, message: "That does not look like an email address" });
|
||||
}
|
||||
values.email = trimmed || null;
|
||||
}
|
||||
if (provider !== undefined) {
|
||||
if (!providers.get(provider)) return res.status(400).json({ code: 400, message: `Unknown DNS provider "${provider}"` });
|
||||
values.provider = provider;
|
||||
}
|
||||
if (credential !== undefined) values.credential = String(credential || "").trim() || null;
|
||||
|
||||
if (!Object.keys(values).length) return res.status(400).json({ code: 400, message: "Nothing to change" });
|
||||
await store.saveSettings(values);
|
||||
logger.info(`${req.session.username} updated the certificate settings`, { provider: values.provider });
|
||||
res.json({ message: "Saved", acme: describeSettings(await store.settings()) });
|
||||
});
|
||||
|
||||
app.post("/verify", async (req, res) => {
|
||||
const settings = await store.settings();
|
||||
const provider = providers.get(settings.provider);
|
||||
if (!provider?.verify) return res.status(400).json({ code: 400, message: "This provider has nothing to verify" });
|
||||
if (!settings.credential) return res.status(400).json({ code: 400, message: `${provider.title} needs an API token` });
|
||||
|
||||
try {
|
||||
const result = await provider.verify(settings.credential, req.config.baseDomain);
|
||||
res.json(result);
|
||||
} catch (error) {
|
||||
res.status(502).json({ code: 502, message: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
app.post("/request", async (req, res) => {
|
||||
const result = await req.certificates.request();
|
||||
if (result.code) return res.status(result.code).json(result);
|
||||
res.json(result);
|
||||
});
|
||||
|
||||
app.post("/continue", (req, res) => {
|
||||
if (!req.certificates.continueManual()) {
|
||||
return res.status(409).json({ code: 409, message: "Nothing is waiting for a DNS record right now" });
|
||||
}
|
||||
res.json({ message: "Checking the record" });
|
||||
});
|
||||
|
||||
app.get("/status", (req, res) => {
|
||||
res.json({ status: req.certificates.status() });
|
||||
});
|
||||
|
||||
module.exports = app;
|
||||
Reference in new issue
Block a user