Adds DoH capabilities

This commit is contained in:
Pierre Lannoy 2023-12-13 18:53:53 +01:00
commit d94fa033cb
Signed by: Pierre Lannoy
GPG key ID: D27231EF87D53F31

View file

@ -64,9 +64,26 @@ 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)
console.log(resolved); .then(response => {
throw new Error(resolved.response); response.answers.forEach(ans => {
console.log(ans.data)
const txtData = parseTxtRecordData(ans.data);
if (txtData[recordParamDestUrl]) {
return {
url: txtData[recordParamDestUrl],
httpStatus: txtData[recordParamHttpStatus],
};
}
});
})
.catch(throw new Error(err));
//const resolved = await resolver.query( host );
//console.log(resolved);
//throw new Error(resolved.response);
/*if (resolved.response.answers) { /*if (resolved.response.answers) {
for (const head of resolved.response.answers) { for (const head of resolved.response.answers) {
const txtData = parseTxtRecordData(head.data); const txtData = parseTxtRecordData(head.data);