Adds DoH capabilities

This commit is contained in:
Pierre Lannoy 2023-12-13 19:13:14 +01:00
commit 0dc6690281
Signed by: Pierre Lannoy
GPG key ID: D27231EF87D53F31

View file

@ -64,6 +64,7 @@ const parseTxtRecordData = (value) => {
*/ */
export async function findTxtRecord(host) { export async function findTxtRecord(host) {
const resolver = new DohResolver('https://doh.hosterra.tech/dns-query'); const resolver = new DohResolver('https://doh.hosterra.tech/dns-query');
const resolved = await resolver.query( '_.' + host );
/*resolver.query( host) /*resolver.query( host)
.then(response => { .then(response => {
response.answers.forEach(ans => { response.answers.forEach(ans => {
@ -82,11 +83,11 @@ export async function findTxtRecord(host) {
.catch(throw new Error(err));*/ .catch(throw new Error(err));*/
const resolved = await resolver.query( '_.' + host );
//console.log(resolved); //console.log(resolved);
throw new Error(JSON.stringify(resolved)); //throw new Error(JSON.stringify(resolved));
/*if (resolved.response.answers) { if (resolved.answers) {
for (const head of resolved.response.answers) { for (const head of resolved.answers) {
const txtData = parseTxtRecordData(head.data); const txtData = parseTxtRecordData(head.data);
if (!txtData[recordParamDestUrl]) continue; if (!txtData[recordParamDestUrl]) continue;
return { return {
@ -94,7 +95,7 @@ export async function findTxtRecord(host) {
httpStatus: txtData[recordParamHttpStatus], httpStatus: txtData[recordParamHttpStatus],
}; };
} }
}*/ }
/*resolver.query( host) /*resolver.query( host)
.then(response => { .then(response => {