Skip to content

Commit

Permalink
fix: return authoritative answers from DNS server.
Browse files Browse the repository at this point in the history
  • Loading branch information
zicklag committed Nov 5, 2024
1 parent 3d8ff58 commit 4f5b647
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/lib/dns/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import * as network from 'dinodns/common/network';
import type { SupportedAnswer } from 'dinodns/types/dns';
import { DefaultStore } from 'dinodns/plugins/storage';
import { dev } from '$app/environment';
import { AUTHORITATIVE_ANSWER } from 'dns-packet';
import { z } from 'zod';
import { parse } from 'node:path';

const REDIS_USER_PREFIX = 'weird:users:';
const REDIS_DNS_RECORD_PREFIX = 'weird:dns:records:';
Expand Down Expand Up @@ -77,7 +77,13 @@ export async function startDnsServer() {
const results = (await Promise.all(
req.packet.questions.map(
(question) =>
new Promise(async (returnAnswers) => {
new Promise(async (ret) => {
const returnAnswers = (v: any) => {
if (v) {
res.packet.flags = res.packet.flags | AUTHORITATIVE_ANSWER;
}
ret(v);
};
const { type, name } = question;
const redisKey = REDIS_DNS_RECORD_PREFIX + type + ':' + name;
let record;
Expand Down Expand Up @@ -165,7 +171,11 @@ export async function startDnsServer() {
const results = (await Promise.all(
req.packet.questions.map(
(question) =>
new Promise(async (returnAnswers) => {
new Promise(async (ret) => {
const returnAnswers = (v: any) => {
res.packet.flags = res.packet.flags | AUTHORITATIVE_ANSWER;
ret(v);
};
const { type, name } = question;
switch (type) {
case 'TXT':
Expand Down

0 comments on commit 4f5b647

Please sign in to comment.