Set dns forward "marker"
This commit is contained in:
parent
fd801274fd
commit
dc9c157488
1 changed files with 2 additions and 5 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
import request from "./certnode/lib/request.js";
|
|
||||||
import crypto from "crypto";
|
import crypto from "crypto";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import {fileURLToPath} from "url";
|
import {fileURLToPath} from "url";
|
||||||
|
|
@ -48,8 +47,6 @@ export async function ensureDir(dir) {
|
||||||
* @param {string} value
|
* @param {string} value
|
||||||
*/
|
*/
|
||||||
const parseTxtRecordData = (value) => {
|
const parseTxtRecordData = (value) => {
|
||||||
value = String(value);
|
|
||||||
//throw new Error(value);
|
|
||||||
const result = {};
|
const result = {};
|
||||||
for (const part of value.split(';')) {
|
for (const part of value.split(';')) {
|
||||||
const [key, ...value] = part.split('=');
|
const [key, ...value] = part.split('=');
|
||||||
|
|
@ -66,10 +63,10 @@ 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 );
|
const resolved = await resolver.query('_forward.' + host);
|
||||||
if (resolved.answers) {
|
if (resolved.answers) {
|
||||||
for (const head of resolved.answers) {
|
for (const head of resolved.answers) {
|
||||||
const txtData = parseTxtRecordData(head.data);
|
const txtData = parseTxtRecordData(String(head.data));
|
||||||
if (!txtData[recordParamDestUrl]) continue;
|
if (!txtData[recordParamDestUrl]) continue;
|
||||||
return {
|
return {
|
||||||
url: txtData[recordParamDestUrl],
|
url: txtData[recordParamDestUrl],
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue