Set dns forward "marker"

This commit is contained in:
Pierre Lannoy 2023-12-13 19:48:50 +01:00
commit dc9c157488
Signed by: Pierre Lannoy
GPG key ID: D27231EF87D53F31

View file

@ -1,4 +1,3 @@
import request from "./certnode/lib/request.js";
import crypto from "crypto";
import fs from "fs";
import {fileURLToPath} from "url";
@ -48,8 +47,6 @@ export async function ensureDir(dir) {
* @param {string} value
*/
const parseTxtRecordData = (value) => {
value = String(value);
//throw new Error(value);
const result = {};
for (const part of value.split(';')) {
const [key, ...value] = part.split('=');
@ -66,10 +63,10 @@ const parseTxtRecordData = (value) => {
*/
export async function findTxtRecord(host) {
const resolver = new DohResolver('https://doh.hosterra.tech/dns-query');
const resolved = await resolver.query( '_.' + host );
const resolved = await resolver.query('_forward.' + host);
if (resolved.answers) {
for (const head of resolved.answers) {
const txtData = parseTxtRecordData(head.data);
const txtData = parseTxtRecordData(String(head.data));
if (!txtData[recordParamDestUrl]) continue;
return {
url: txtData[recordParamDestUrl],