[BREAKING CHANGE] add _. for TXT
Just realized I can't put TXT on CNAME :/
This commit is contained in:
parent
7661a46132
commit
6b2a6e8186
4 changed files with 23 additions and 11 deletions
15
README.md
15
README.md
|
|
@ -26,9 +26,9 @@ How it is possible?
|
||||||
To forward from `www.old.com` to `old.com`, add these records to your DNS:
|
To forward from `www.old.com` to `old.com`, add these records to your DNS:
|
||||||
|
|
||||||
```
|
```
|
||||||
www.old.com IN CNAME r.forwarddomain.net
|
www.old.com IN CNAME r.forwarddomain.net
|
||||||
www.old.com IN TXT forward-domain=https://old.com/*
|
_.www.old.com IN TXT forward-domain=https://old.com/*
|
||||||
www.old.com IN TXT forward-domain-cert-maintainer=<your email address>
|
_.www.old.com IN TXT forward-domain-cert-maintainer=<your email address>
|
||||||
```
|
```
|
||||||
|
|
||||||
> IMPORTANT: replace `<your email address>` with your email address!
|
> IMPORTANT: replace `<your email address>` with your email address!
|
||||||
|
|
@ -37,13 +37,12 @@ Because CNAME can't be used in apex domains, you can use A/AAAA records.<br>
|
||||||
To forward from `old.com` to `new.net`, add these records to your DNS:
|
To forward from `old.com` to `new.net`, add these records to your DNS:
|
||||||
|
|
||||||
```
|
```
|
||||||
old.com IN A 206.189.61.89
|
old.com IN A 167.172.5.31
|
||||||
old.com IN AAAA 2a03:b0c0:3:d0::13a8:c001
|
_.old.com IN TXT forward-domain=https://new.net/*
|
||||||
old.com IN TXT forward-domain=https://new.net/*
|
_.old.com IN TXT forward-domain-cert-maintainer=<your email address>
|
||||||
old.com IN TXT forward-domain-cert-maintainer=<your email address>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
> BETA service notice: IP addresses can change anytime (with notice).
|
> BETA service notice: IP addresses may change anytime.
|
||||||
|
|
||||||
## FAQ
|
## FAQ
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,12 @@ const acme_prefix = '/.well-known/acme-challenge/';
|
||||||
const listener = async function (/** @type {import('http').IncomingMessage} */ req, /** @type {import('http').ServerResponse} */ res) {
|
const listener = async function (/** @type {import('http').IncomingMessage} */ req, /** @type {import('http').ServerResponse} */ res) {
|
||||||
try {
|
try {
|
||||||
if (req.url.startsWith(acme_prefix)) {
|
if (req.url.startsWith(acme_prefix)) {
|
||||||
if (client.challengeCallbacks) {
|
if (client.challengeCallbacks[req.headers.host]) {
|
||||||
res.writeHead(200, {
|
res.writeHead(200, {
|
||||||
// This is important :)
|
// This is important :)
|
||||||
'content-type': 'application/octet-stream'
|
'content-type': 'application/octet-stream'
|
||||||
});
|
});
|
||||||
res.write(client.challengeCallbacks());
|
res.write(client.challengeCallbacks[req.headers.host]());
|
||||||
} else {
|
} else {
|
||||||
res.writeHead(404)
|
res.writeHead(404)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,16 @@ function getCertCachePath(host) {
|
||||||
return path.join(certsDir, hash.substr(0, 2), hash.substr(2), host);
|
return path.join(certsDir, hash.substr(0, 2), hash.substr(2), host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} host
|
||||||
|
*/
|
||||||
async function findMaintainerEmail(host) {
|
async function findMaintainerEmail(host) {
|
||||||
return await findTxtRecord(host, record_email_prefix);
|
return await findTxtRecord(host, record_email_prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} host
|
||||||
|
*/
|
||||||
async function buildCache(host) {
|
async function buildCache(host) {
|
||||||
const dir = getCertCachePath(host);
|
const dir = getCertCachePath(host);
|
||||||
const keyP = path.join(dir, 'privateKey.pem');
|
const keyP = path.join(dir, 'privateKey.pem');
|
||||||
|
|
@ -64,6 +70,9 @@ async function buildCache(host) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} servername
|
||||||
|
*/
|
||||||
async function getKeyCert(servername) {
|
async function getKeyCert(servername) {
|
||||||
let cache = resolveCache[servername];
|
let cache = resolveCache[servername];
|
||||||
await ensureDir(certsDir);
|
await ensureDir(certsDir);
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,12 @@ async function ensureDir(dir) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} host
|
||||||
|
* @param {string} prefix
|
||||||
|
*/
|
||||||
async function findTxtRecord(host, prefix, required = true) {
|
async function findTxtRecord(host, prefix, required = true) {
|
||||||
const resolve = await axios(`https://dns.google/resolve?name=${encodeURIComponent(host)}&type=TXT`);
|
const resolve = await axios(`https://dns.google/resolve?name=_.${encodeURIComponent(host)}&type=TXT`);
|
||||||
if (resolve.data.Answer) {
|
if (resolve.data.Answer) {
|
||||||
for (const head of resolve.data.Answer) {
|
for (const head of resolve.data.Answer) {
|
||||||
if (!head.data.startsWith(prefix))
|
if (!head.data.startsWith(prefix))
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue